Skip to content

Commit

Permalink
editor: fix jumping cursor to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
Samk13 committed Jul 3, 2024
1 parent 6cde34d commit 3ea0772
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/lib/forms/RichEditor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is part of React-Invenio-Forms
// Copyright (C) 2022 CERN.
// Copyright (C) 2020 Northwestern University.
// Copyright (C) 2024 KTH Royal Institute of Technology.
//
// React-Invenio-Forms is free software; you can redistribute it and/or modify it
// under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -19,8 +20,18 @@ import PropTypes from "prop-types";

export class RichEditor extends Component {
render() {
const { id, value, disabled, minHeight, onBlur, onChange, onFocus, editorConfig } =
this.props;
const {
id,
value,
disabled,
minHeight,
onBlur,
onChange,
onFocus,
editorConfig,
inputValue,
onEditorChange,
} = this.props;
const config = {
branding: false,
menubar: false,
Expand All @@ -40,22 +51,26 @@ export class RichEditor extends Component {
return (
<Editor
initialValue={value}
value={inputValue}
init={config}
id={id}
disabled={disabled}
onChange={onChange}
onBlur={onBlur}
onFocus={onFocus}
onChange={onChange}
onEditorChange={onEditorChange}
/>
);
}
}

RichEditor.propTypes = {
value: PropTypes.string,
inputValue: PropTypes.string,
id: PropTypes.string,
disabled: PropTypes.bool,
onChange: PropTypes.func,
onEditorChange: PropTypes.func,
onBlur: PropTypes.func,
onFocus: PropTypes.func,
minHeight: PropTypes.number,
Expand All @@ -65,9 +80,11 @@ RichEditor.propTypes = {
RichEditor.defaultProps = {
minHeight: 250,
value: "",
inputValue: "",
id: undefined,
disabled: undefined,
onChange: undefined,
onEditorChange: undefined,
onBlur: undefined,
onFocus: undefined,
editorConfig: undefined,
Expand Down

0 comments on commit 3ea0772

Please sign in to comment.