Skip to content

Commit

Permalink
Fixed #1851 - Removed inital focus
Browse files Browse the repository at this point in the history
  • Loading branch information
mcandu committed Apr 14, 2021
1 parent 1dedc65 commit d1d90e6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/components/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Editor extends Component {
theme: 'snow',
headerTemplate: null,
onTextChange: null,
onSelectionChange: null
onSelectionChange: null
};

static propTypes = {
Expand All @@ -31,7 +31,7 @@ export class Editor extends Component {
theme: PropTypes.string,
headerTemplate: PropTypes.any,
onTextChange: PropTypes.func,
onSelectionChange: PropTypes.func
onSelectionChange: PropTypes.func
};

componentDidMount() {
Expand All @@ -49,7 +49,7 @@ export class Editor extends Component {
});

if (this.props.value) {
this.quill.pasteHTML(this.props.value);
this.quill.setContents(this.quill.clipboard.convert(this.props.value));
}

this.quill.on('text-change', (delta, source) => {
Expand All @@ -70,7 +70,7 @@ export class Editor extends Component {
});

this.quill.on('selection-change', (range, oldRange, source) => {
if(this.props.onSelectionChange) {
if (this.props.onSelectionChange) {
this.props.onSelectionChange({
range: range,
oldRange: oldRange,
Expand All @@ -84,9 +84,8 @@ export class Editor extends Component {

componentDidUpdate(prevProps) {
if (this.props.value !== prevProps.value && this.quill && !this.quill.hasFocus()) {
if(this.props.value)
this.quill.pasteHTML(this.props.value);
else
if (this.props.value)
this.quill.setContents(this.quill.clipboard.convert(this.props.value)); else
this.quill.setText('');
}
}
Expand All @@ -107,9 +106,9 @@ export class Editor extends Component {
<div ref={el => this.toolbarElement = el} className="p-editor-toolbar">
<span className="ql-formats">
<select className="ql-header" defaultValue="0">
<option value="1">Heading</option>
<option value="2">Subheading</option>
<option value="0">Normal</option>
<option value="1">Heading</option>
<option value="2">Subheading</option>
<option value="0">Normal</option>
</select>
<select className="ql-font">
<option ></option>
Expand Down

0 comments on commit d1d90e6

Please sign in to comment.