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 c301261
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 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,
initialValue,
disabled,
minHeight,
onBlur,
onChange,
onFocus,
editorConfig,
inputValue,
onEditorChange,
} = this.props;
const config = {
branding: false,
menubar: false,
Expand All @@ -39,23 +50,27 @@ export class RichEditor extends Component {

return (
<Editor
initialValue={value}
initialValue={initialValue}
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,
initialValue: 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 @@ -64,10 +79,12 @@ RichEditor.propTypes = {

RichEditor.defaultProps = {
minHeight: 250,
value: "",
inputValue: "",
initialValue: "",
id: undefined,
disabled: undefined,
onChange: undefined,
onEditorChange: undefined,
onBlur: undefined,
onFocus: undefined,
editorConfig: undefined,
Expand Down

0 comments on commit c301261

Please sign in to comment.