@kids-reporter/draft-editor 0.4.15 → 0.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,7 @@ function createAnnotationButton({
29
29
  });
30
30
  const promptForAnnotation = e => {
31
31
  e.preventDefault();
32
+ props.onEditStart();
32
33
  const selection = editorStateOfOuterEditor.getSelection();
33
34
  if (!selection.isCollapsed()) {
34
35
  setToShowInput(true);
@@ -49,6 +50,7 @@ function createAnnotationButton({
49
50
  setInputValue({
50
51
  editorStateOfInnerEditor: _draftJs.EditorState.createEmpty(decorator)
51
52
  });
53
+ props.onEditFinish();
52
54
  };
53
55
  const removeAnnotation = () => {
54
56
  const selection = editorStateOfOuterEditor.getSelection();
@@ -59,6 +61,7 @@ function createAnnotationButton({
59
61
  setInputValue({
60
62
  editorStateOfInnerEditor: _draftJs.EditorState.createEmpty(decorator)
61
63
  });
64
+ props.onEditFinish();
62
65
  };
63
66
  const input = /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
64
67
  isOpen: toShowInput
@@ -27,6 +27,7 @@ function LinkButton(props) {
27
27
  const [urlValue, setUrlValue] = (0, _react.useState)('');
28
28
  const promptForLink = e => {
29
29
  e.preventDefault();
30
+ props.onEditStart();
30
31
  const selection = editorState.getSelection();
31
32
  if (!selection.isCollapsed()) {
32
33
  setToShowUrlInput(true);
@@ -44,6 +45,7 @@ function LinkButton(props) {
44
45
  onChange(_draftJs.RichUtils.toggleLink(newEditorState, newEditorState.getSelection(), entityKey));
45
46
  setToShowUrlInput(false);
46
47
  setUrlValue('');
48
+ props.onEditFinish();
47
49
  };
48
50
  const onLinkInputKeyDown = e => {
49
51
  if (e.which === 13) {
@@ -58,6 +60,7 @@ function LinkButton(props) {
58
60
  }
59
61
  setToShowUrlInput(false);
60
62
  setUrlValue('');
63
+ props.onEditFinish();
61
64
  };
62
65
  const urlInput = /*#__PURE__*/_react.default.createElement(_modals.AlertDialog, {
63
66
  title: "Insert LINK",
@@ -370,7 +370,17 @@ class RichTextEditor extends _react.default.Component {
370
370
  isActive: entityType === 'LINK',
371
371
  editorState: editorState,
372
372
  onChange: this.onChange,
373
- readOnly: this.state.readOnly
373
+ readOnly: this.state.readOnly,
374
+ onEditStart: () => {
375
+ this.setState({
376
+ readOnly: true
377
+ });
378
+ },
379
+ onEditFinish: () => {
380
+ this.setState({
381
+ readOnly: false
382
+ });
383
+ }
374
384
  }), /*#__PURE__*/_react.default.createElement(CustomBlockquoteButton, {
375
385
  isDisabled: disabledButtons.includes(_btNames.default.blockquote),
376
386
  editorState: editorState,
@@ -380,8 +390,20 @@ class RichTextEditor extends _react.default.Component {
380
390
  isDisabled: disabledButtons.includes(_btNames.default.annotation),
381
391
  isActive: entityType === 'ANNOTATION',
382
392
  editorState: editorState,
383
- onChange: this.onChange,
384
- readOnly: this.state.readOnly
393
+ onChange: editorState => {
394
+ this.onChange(editorState);
395
+ },
396
+ readOnly: this.state.readOnly,
397
+ onEditStart: () => {
398
+ this.setState({
399
+ readOnly: true
400
+ });
401
+ },
402
+ onEditFinish: () => {
403
+ this.setState({
404
+ readOnly: false
405
+ });
406
+ }
385
407
  }), /*#__PURE__*/_react.default.createElement(CustomImageButton, {
386
408
  isDisabled: disabledButtons.includes(_btNames.default.image),
387
409
  editorState: editorState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kids-reporter/draft-editor",
3
- "version": "0.4.15",
3
+ "version": "0.4.16",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {