@kids-reporter/draft-editor 1.0.6 → 1.0.8

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.
@@ -32,9 +32,7 @@ function EditableInfoBox(props) {
32
32
  } = props;
33
33
  const {
34
34
  onEditStart,
35
- onEditFinish,
36
- RichTextEditorComponent: Editor,
37
- decorator
35
+ onEditFinish
38
36
  } = blockProps;
39
37
  const entityKey = block.getEntityAt(0);
40
38
  const entity = contentState.getEntity(entityKey);
@@ -54,9 +52,7 @@ function EditableInfoBox(props) {
54
52
  onEditFinish();
55
53
  },
56
54
  onConfirm: onInputChange,
57
- inputValue: data,
58
- Editor: Editor,
59
- decorator: decorator
55
+ inputValue: data
60
56
  }), /*#__PURE__*/_react.default.createElement(EditableBlock, {
61
57
  component: /*#__PURE__*/_react.default.createElement(StyledInfoBox, {
62
58
  data: data
@@ -3,95 +3,61 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createAnnotationButton = createAnnotationButton;
6
+ exports.AnnotationButton = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _btNames = _interopRequireDefault(require("./bt-names"));
9
8
  var _draftJs = require("draft-js");
10
- var _modals = require("@keystone-ui/modals");
11
9
  var _draftRenderer = require("@kids-reporter/draft-renderer");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var _annotation = require("../entity-decorators/annotation");
13
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- const disabledButtons = [_btNames.default.h2, _btNames.default.h3, _btNames.default.code, _btNames.default.codeBlock, _btNames.default.blockquote, _btNames.default.annotation, _btNames.default.embed, _btNames.default.image, _btNames.default.infoBox, _btNames.default.slideshow, _btNames.default.newsReading, _btNames.default.tocAnchor, _btNames.default.anchor];
16
- function createAnnotationButton({
17
- InnerEditor,
18
- decorator
19
- }) {
20
- return function AnnotationButton(props) {
21
- const toggleEntity = _draftJs.RichUtils.toggleLink;
22
- const {
23
- isActive,
24
- editorState: editorStateOfOuterEditor,
25
- onChange
26
- } = props;
27
- const [toShowInput, setToShowInput] = (0, _react.useState)(false);
28
- const [inputValue, setInputValue] = (0, _react.useState)({
29
- editorStateOfInnerEditor: _draftJs.EditorState.createEmpty(decorator)
13
+ const AnnotationButton = props => {
14
+ const toggleEntity = _draftJs.RichUtils.toggleLink;
15
+ const {
16
+ isActive,
17
+ editorState: editorStateOfOuterEditor,
18
+ onChange
19
+ } = props;
20
+ const [toShowInput, setToShowInput] = (0, _react.useState)(false);
21
+ const promptForAnnotation = e => {
22
+ e.preventDefault();
23
+ const selection = editorStateOfOuterEditor.getSelection();
24
+ if (!selection.isCollapsed()) {
25
+ props.onEditStart();
26
+ setToShowInput(true);
27
+ }
28
+ };
29
+ const confirmAnnotation = editorState => {
30
+ const contentState = editorStateOfOuterEditor.getCurrentContent();
31
+ const rawContentState = (0, _draftJs.convertToRaw)(editorState.getCurrentContent());
32
+ const contentStateWithEntity = contentState.createEntity(_draftRenderer.ENTITY.Annotation, 'MUTABLE', {
33
+ rawContentState
34
+ });
35
+ const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
36
+ const newEditorState = _draftJs.EditorState.set(editorStateOfOuterEditor, {
37
+ currentContent: contentStateWithEntity
30
38
  });
31
- const promptForAnnotation = e => {
32
- e.preventDefault();
33
- const selection = editorStateOfOuterEditor.getSelection();
34
- if (!selection.isCollapsed()) {
35
- props.onEditStart();
36
- setToShowInput(true);
37
- }
38
- };
39
- const confirmAnnotation = () => {
40
- const contentState = editorStateOfOuterEditor.getCurrentContent();
41
- const rawContentState = (0, _draftJs.convertToRaw)(inputValue.editorStateOfInnerEditor.getCurrentContent());
42
- const contentStateWithEntity = contentState.createEntity(_draftRenderer.ENTITY.Annotation, 'MUTABLE', {
43
- rawContentState
44
- });
45
- const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
46
- const newEditorState = _draftJs.EditorState.set(editorStateOfOuterEditor, {
47
- currentContent: contentStateWithEntity
48
- });
49
- onChange(toggleEntity(newEditorState, newEditorState.getSelection(), entityKey));
50
- setToShowInput(false);
51
- setInputValue({
52
- editorStateOfInnerEditor: _draftJs.EditorState.createEmpty(decorator)
53
- });
54
- props.onEditFinish();
55
- };
56
- const removeAnnotation = () => {
57
- const selection = editorStateOfOuterEditor.getSelection();
58
- if (!selection.isCollapsed()) {
59
- onChange(toggleEntity(editorStateOfOuterEditor, selection, null));
60
- }
61
- setToShowInput(false);
62
- setInputValue({
63
- editorStateOfInnerEditor: _draftJs.EditorState.createEmpty(decorator)
64
- });
65
- props.onEditFinish();
66
- };
67
- const input = /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
68
- isOpen: toShowInput
69
- }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
70
- title: "\u8A3B\u89E3",
71
- actions: {
72
- cancel: {
73
- label: 'Cancel',
74
- action: removeAnnotation
75
- },
76
- confirm: {
77
- label: 'Confirm',
78
- action: confirmAnnotation
79
- }
80
- }
81
- }, /*#__PURE__*/_react.default.createElement(InnerEditor, {
82
- disabledButtons: disabledButtons,
83
- editorState: inputValue.editorStateOfInnerEditor,
84
- onChange: editorState => {
85
- setInputValue({
86
- editorStateOfInnerEditor: editorState
87
- });
88
- }
89
- })));
90
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, input, /*#__PURE__*/_react.default.createElement("div", {
91
- className: props.className,
92
- onMouseDown: isActive ? removeAnnotation : promptForAnnotation
93
- }, /*#__PURE__*/_react.default.createElement("i", {
94
- className: "far"
95
- }), /*#__PURE__*/_react.default.createElement("span", null, "Annotation")));
39
+ onChange(toggleEntity(newEditorState, newEditorState.getSelection(), entityKey));
40
+ setToShowInput(false);
41
+ props.onEditFinish();
42
+ };
43
+ const removeAnnotation = () => {
44
+ const selection = editorStateOfOuterEditor.getSelection();
45
+ if (!selection.isCollapsed()) {
46
+ onChange(toggleEntity(editorStateOfOuterEditor, selection, null));
47
+ }
48
+ setToShowInput(false);
49
+ props.onEditFinish();
96
50
  };
97
- }
51
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowInput && /*#__PURE__*/_react.default.createElement(_annotation.AnnotationEditor, {
52
+ isOpen: toShowInput,
53
+ editorStateValue: _draftJs.EditorState.createEmpty(),
54
+ onConfirm: confirmAnnotation,
55
+ onCancel: removeAnnotation
56
+ }), /*#__PURE__*/_react.default.createElement("div", {
57
+ className: props.className,
58
+ onMouseDown: isActive ? removeAnnotation : promptForAnnotation
59
+ }, /*#__PURE__*/_react.default.createElement("i", {
60
+ className: "far"
61
+ }), /*#__PURE__*/_react.default.createElement("span", null, "Annotation")));
62
+ };
63
+ exports.AnnotationButton = AnnotationButton;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.withStyle = exports.InlineStyleControls = exports.CustomTOCAnchorButton = exports.CustomSlideshowButton = exports.CustomNewsReadingButton = exports.CustomLinkButton = exports.CustomImageButton = exports.CustomFontColorButton = exports.CustomEnlargeButton = exports.CustomEmbeddedCodeButton = exports.CustomDividerButton = exports.CustomBlockquoteButton = exports.CustomBackgroundColorButton = exports.CustomAnchorButton = exports.BlockStyleControls = void 0;
6
+ exports.withStyle = exports.InlineStyleControls = exports.CustomTOCAnchorButton = exports.CustomSlideshowButton = exports.CustomNewsReadingButton = exports.CustomLinkButton = exports.CustomInfoBoxButton = exports.CustomImageButton = exports.CustomFontColorButton = exports.CustomEnlargeButton = exports.CustomEmbeddedCodeButton = exports.CustomDividerButton = exports.CustomBlockquoteButton = exports.CustomBackgroundColorButton = exports.CustomAnnotationButton = exports.CustomAnchorButton = exports.BlockStyleControls = void 0;
7
7
  var _styledComponents = _interopRequireDefault(require("styled-components"));
8
8
  var _controlButtons = require("./control-buttons");
9
9
  var _bgColor = require("./bg-color");
@@ -16,8 +16,10 @@ var _image = require("./image");
16
16
  var _tocAnchor = require("./toc-anchor");
17
17
  var _anchor = require("./anchor");
18
18
  var _link = require("./link");
19
+ var _annotation = require("./annotation");
19
20
  var _slideshow = require("./slideshow");
20
21
  var _newsReading = require("./news-reading");
22
+ var _infoBox = require("./info-box");
21
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
24
  const withStyle = Button => {
23
25
  return (0, _styledComponents.default)(Button)`
@@ -31,6 +33,7 @@ const CustomBlockquoteButton = exports.CustomBlockquoteButton = withStyle(_block
31
33
  const CustomTOCAnchorButton = exports.CustomTOCAnchorButton = withStyle(_tocAnchor.TOCAnchorButton);
32
34
  const CustomAnchorButton = exports.CustomAnchorButton = withStyle(_anchor.AnchorButton);
33
35
  const CustomLinkButton = exports.CustomLinkButton = withStyle(_link.LinkButton);
36
+ const CustomAnnotationButton = exports.CustomAnnotationButton = withStyle(_annotation.AnnotationButton);
34
37
  const CustomEnlargeButton = exports.CustomEnlargeButton = (0, _styledComponents.default)(withStyle(_enlarge.EnlargeButton))`
35
38
  color: #999;
36
39
  `;
@@ -40,4 +43,5 @@ const CustomEmbeddedCodeButton = exports.CustomEmbeddedCodeButton = withStyle(_e
40
43
  const CustomNewsReadingButton = exports.CustomNewsReadingButton = withStyle(_newsReading.NewsReadingButton);
41
44
  const CustomBackgroundColorButton = exports.CustomBackgroundColorButton = withStyle(_bgColor.BackgroundColorButton);
42
45
  const CustomFontColorButton = exports.CustomFontColorButton = withStyle(_fontColor.FontColorButton);
43
- const CustomDividerButton = exports.CustomDividerButton = withStyle(_divider.DividerButton);
46
+ const CustomDividerButton = exports.CustomDividerButton = withStyle(_divider.DividerButton);
47
+ const CustomInfoBoxButton = exports.CustomInfoBoxButton = withStyle(_infoBox.InfoBoxButton);
@@ -3,13 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.InfoBoxButton = void 0;
6
7
  exports.InfoBoxInput = InfoBoxInput;
7
- exports.createInfoBoxButton = createInfoBoxButton;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _btNames = _interopRequireDefault(require("./bt-names"));
10
10
  var _draftJs = require("draft-js");
11
11
  var _modals = require("@keystone-ui/modals");
12
+ var _richTextEditor = require("../rich-text-editor");
12
13
  var _select = require("./form/select");
14
+ var _annotation = require("../entity-decorators/annotation");
15
+ var _link = require("../entity-decorators/link");
13
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -31,14 +34,12 @@ function InfoBoxInput(props) {
31
34
  isOpen,
32
35
  onConfirm,
33
36
  onCancel,
34
- Editor,
35
- decorator,
36
37
  inputValue
37
38
  } = props;
38
39
  const contentState = (0, _draftJs.convertFromRaw)(inputValue.rawContentState);
39
40
  const [inputValueState, setInputValueState] = (0, _react.useState)({
40
41
  type: inputValue.type,
41
- editorState: _draftJs.EditorState.createWithContent(contentState, decorator)
42
+ editorState: _draftJs.EditorState.createWithContent(contentState)
42
43
  });
43
44
  return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
44
45
  isOpen: isOpen
@@ -80,7 +81,8 @@ function InfoBoxInput(props) {
80
81
  editorState: inputValueState.editorState
81
82
  });
82
83
  }
83
- }), /*#__PURE__*/_react.default.createElement(Editor, {
84
+ }), /*#__PURE__*/_react.default.createElement(_richTextEditor.RichTextEditor, {
85
+ decorators: [_annotation.editableAnnotationDecorator, _link.editableLinkDecorator],
84
86
  disabledButtons: disabledButtons,
85
87
  editorState: inputValueState.editorState,
86
88
  onChange: editorState => {
@@ -91,60 +93,54 @@ function InfoBoxInput(props) {
91
93
  }
92
94
  })));
93
95
  }
94
- function createInfoBoxButton({
95
- InnerEditor,
96
- decorator
97
- }) {
98
- return function InfoBoxButton(props) {
99
- const [toShowInput, setToShowInput] = (0, _react.useState)(false);
100
- const {
101
- className,
102
- editorState,
103
- onChange: onEditorStateChange
104
- } = props;
105
- const onChange = ({
96
+ const InfoBoxButton = props => {
97
+ const [toShowInput, setToShowInput] = (0, _react.useState)(false);
98
+ const {
99
+ className,
100
+ editorState,
101
+ onChange: onEditorStateChange
102
+ } = props;
103
+ const onChange = ({
104
+ type,
105
+ rawContentState
106
+ }) => {
107
+ const contentState = editorState.getCurrentContent();
108
+
109
+ // create an InfoBox entity
110
+ const contentStateWithEntity = contentState.createEntity('INFOBOX', 'IMMUTABLE', {
106
111
  type,
107
112
  rawContentState
108
- }) => {
109
- const contentState = editorState.getCurrentContent();
113
+ });
114
+ const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
115
+ const newEditorState = _draftJs.EditorState.set(editorState, {
116
+ currentContent: contentStateWithEntity
117
+ });
110
118
 
111
- // create an InfoBox entity
112
- const contentStateWithEntity = contentState.createEntity('INFOBOX', 'IMMUTABLE', {
113
- type,
114
- rawContentState
115
- });
116
- const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
117
- const newEditorState = _draftJs.EditorState.set(editorState, {
118
- currentContent: contentStateWithEntity
119
- });
120
-
121
- //The third parameter here is a space string, not an empty string
122
- //If you set an empty string, you will get an error: Unknown DraftEntity key: null
123
- onEditorStateChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
119
+ //The third parameter here is a space string, not an empty string
120
+ //If you set an empty string, you will get an error: Unknown DraftEntity key: null
121
+ onEditorStateChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
122
+ setToShowInput(false);
123
+ };
124
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowInput && /*#__PURE__*/_react.default.createElement(InfoBoxInput, {
125
+ onConfirm: onChange,
126
+ onCancel: () => {
124
127
  setToShowInput(false);
125
- };
126
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowInput && /*#__PURE__*/_react.default.createElement(InfoBoxInput, {
127
- Editor: InnerEditor,
128
- decorator: decorator,
129
- onConfirm: onChange,
130
- onCancel: () => {
131
- setToShowInput(false);
132
- },
133
- isOpen: toShowInput,
134
- inputValue: {
135
- type: InfoBoxTypeEnum.newsChargeStation,
136
- rawContentState: {
137
- blocks: [],
138
- entityMap: {}
139
- }
140
- }
141
- }), /*#__PURE__*/_react.default.createElement("div", {
142
- className: className,
143
- onClick: () => {
144
- setToShowInput(true);
128
+ },
129
+ isOpen: toShowInput,
130
+ inputValue: {
131
+ type: InfoBoxTypeEnum.newsChargeStation,
132
+ rawContentState: {
133
+ blocks: [],
134
+ entityMap: {}
145
135
  }
146
- }, /*#__PURE__*/_react.default.createElement("i", {
147
- className: "far"
148
- }), /*#__PURE__*/_react.default.createElement("span", null, "InfoBox")));
149
- };
150
- }
136
+ }
137
+ }), /*#__PURE__*/_react.default.createElement("div", {
138
+ className: className,
139
+ onClick: () => {
140
+ setToShowInput(true);
141
+ }
142
+ }, /*#__PURE__*/_react.default.createElement("i", {
143
+ className: "far"
144
+ }), /*#__PURE__*/_react.default.createElement("span", null, "InfoBox")));
145
+ };
146
+ exports.InfoBoxButton = InfoBoxButton;
@@ -5,19 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.LinkButton = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _modals = require("@keystone-ui/modals");
9
8
  var _draftJs = require("draft-js");
10
- var _fields = require("@keystone-ui/fields");
11
9
  var _draftRenderer = require("@kids-reporter/draft-renderer");
10
+ var _link = require("../entity-decorators/link");
12
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- const styles = {
15
- urlInput: {
16
- fontFamily: "'Georgia', serif",
17
- marginRight: 10,
18
- padding: 10
19
- }
20
- };
21
13
  const LinkButton = props => {
22
14
  const {
23
15
  isActive,
@@ -25,7 +17,6 @@ const LinkButton = props => {
25
17
  onChange
26
18
  } = props;
27
19
  const [toShowUrlInput, setToShowUrlInput] = (0, _react.useState)(false);
28
- const [urlValue, setUrlValue] = (0, _react.useState)('');
29
20
  const promptForLink = e => {
30
21
  e.preventDefault();
31
22
  const selection = editorState.getSelection();
@@ -34,7 +25,7 @@ const LinkButton = props => {
34
25
  setToShowUrlInput(true);
35
26
  }
36
27
  };
37
- const confirmLink = () => {
28
+ const confirmLink = urlValue => {
38
29
  const contentState = editorState.getCurrentContent();
39
30
  const contentStateWithEntity = contentState.createEntity(_draftRenderer.ENTITY.Link, 'MUTABLE', {
40
31
  url: urlValue
@@ -45,45 +36,22 @@ const LinkButton = props => {
45
36
  });
46
37
  onChange(_draftJs.RichUtils.toggleLink(newEditorState, newEditorState.getSelection(), entityKey));
47
38
  setToShowUrlInput(false);
48
- setUrlValue('');
49
39
  props.onEditFinish();
50
40
  };
51
- const onLinkInputKeyDown = e => {
52
- if (e.which === 13) {
53
- e.preventDefault();
54
- confirmLink();
55
- }
56
- };
57
41
  const removeLink = () => {
58
42
  const selection = editorState.getSelection();
59
43
  if (!selection.isCollapsed()) {
60
44
  onChange(_draftJs.RichUtils.toggleLink(editorState, selection, null));
61
45
  }
62
46
  setToShowUrlInput(false);
63
- setUrlValue('');
64
47
  props.onEditFinish();
65
48
  };
66
- const urlInput = /*#__PURE__*/_react.default.createElement(_modals.AlertDialog, {
67
- title: "\u7DE8\u8F2F\u5916\u90E8\u9023\u7D50\u6216\u5167\u90E8\u9328\u9EDE(ID)",
49
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowUrlInput && /*#__PURE__*/_react.default.createElement(_link.LinkEditor, {
68
50
  isOpen: toShowUrlInput,
69
- actions: {
70
- cancel: {
71
- label: 'Cancel',
72
- action: removeLink
73
- },
74
- confirm: {
75
- label: 'Confirm',
76
- action: confirmLink
77
- }
78
- }
79
- }, /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("br", null), "\u5916\u90E8\u9023\u7D50\u7BC4\u4F8B:", /*#__PURE__*/_react.default.createElement("br", null), "https://kids.twreporter.org/article/article1#part1", /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("br", null), "\u5167\u90E8\u9328\u9EDE\u7BC4\u4F8B:", /*#__PURE__*/_react.default.createElement("br", null), "#part1"), /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
80
- onChange: e => setUrlValue(e.target.value),
81
- style: styles.urlInput,
82
- type: "text",
83
- value: urlValue,
84
- onKeyDown: onLinkInputKeyDown
85
- }));
86
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, urlInput, /*#__PURE__*/_react.default.createElement("div", {
51
+ urlValue: '',
52
+ onConfirm: confirmLink,
53
+ onCancel: removeLink
54
+ }), /*#__PURE__*/_react.default.createElement("div", {
87
55
  className: props.className,
88
56
  onMouseDown: isActive ? removeLink : promptForLink
89
57
  }, /*#__PURE__*/_react.default.createElement("i", {
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.editableAnnotationDecorator = exports.AnnotationEditor = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _draftJs = require("draft-js");
9
+ var _modals = require("@keystone-ui/modals");
10
+ var _draftRenderer = require("@kids-reporter/draft-renderer");
11
+ var _btNames = _interopRequireDefault(require("../buttons/bt-names"));
12
+ var _richTextEditor = require("../rich-text-editor");
13
+ var _wrapper = require("./wrapper");
14
+ var _link = require("./link");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ const disabledButtons = [_btNames.default.h2, _btNames.default.h3, _btNames.default.code, _btNames.default.codeBlock, _btNames.default.blockquote, _btNames.default.annotation, _btNames.default.embed, _btNames.default.image, _btNames.default.infoBox, _btNames.default.slideshow, _btNames.default.newsReading, _btNames.default.tocAnchor, _btNames.default.anchor];
19
+ const AnnotationEditor = props => {
20
+ const {
21
+ isOpen,
22
+ editorStateValue,
23
+ onConfirm,
24
+ onCancel
25
+ } = props;
26
+ const [editorState, setEditorState] = (0, _react.useState)({
27
+ value: editorStateValue
28
+ });
29
+ return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
30
+ isOpen: isOpen
31
+ }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
32
+ title: "\u8A3B\u89E3",
33
+ actions: {
34
+ cancel: {
35
+ label: 'Cancel',
36
+ action: () => onCancel()
37
+ },
38
+ confirm: {
39
+ label: 'Confirm',
40
+ action: () => onConfirm(editorState.value)
41
+ }
42
+ }
43
+ }, /*#__PURE__*/_react.default.createElement(_richTextEditor.RichTextEditor, {
44
+ decorators: [_link.editableLinkDecorator],
45
+ disabledButtons: disabledButtons,
46
+ editorState: editorState.value,
47
+ onChange: editorState => {
48
+ setEditorState({
49
+ value: editorState
50
+ });
51
+ }
52
+ })));
53
+ };
54
+ exports.AnnotationEditor = AnnotationEditor;
55
+ const EditableAnnotation = props => {
56
+ var _contentState$getEnti;
57
+ const {
58
+ children,
59
+ contentState,
60
+ entityKey
61
+ } = props;
62
+ const [isModalOpen, setIsModalOpen] = (0, _react.useState)(false);
63
+ const [editorState, setEditorState] = (0, _react.useState)({
64
+ value: _draftJs.EditorState.createWithContent((0, _draftJs.convertFromRaw)(contentState === null || contentState === void 0 || (_contentState$getEnti = contentState.getEntity(entityKey).getData()) === null || _contentState$getEnti === void 0 ? void 0 : _contentState$getEnti.rawContentState))
65
+ });
66
+ (0, _react.useEffect)(() => {
67
+ var _contentState$getEnti2;
68
+ setEditorState({
69
+ value: _draftJs.EditorState.createWithContent((0, _draftJs.convertFromRaw)(contentState === null || contentState === void 0 || (_contentState$getEnti2 = contentState.getEntity(entityKey).getData()) === null || _contentState$getEnti2 === void 0 ? void 0 : _contentState$getEnti2.rawContentState))
70
+ });
71
+ }, [contentState, entityKey]);
72
+ const onEditorStateChange = editorState => {
73
+ setIsModalOpen(false);
74
+ setEditorState({
75
+ value: editorState
76
+ });
77
+ props.onEditFinish({
78
+ entityKey,
79
+ entityData: {
80
+ rawContentState: editorState ? (0, _draftJs.convertToRaw)(editorState.getCurrentContent()) : undefined
81
+ }
82
+ });
83
+ };
84
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isModalOpen && /*#__PURE__*/_react.default.createElement(AnnotationEditor, {
85
+ isOpen: isModalOpen,
86
+ editorStateValue: editorState.value,
87
+ onConfirm: onEditorStateChange,
88
+ onCancel: () => {
89
+ setIsModalOpen(false);
90
+ props.onEditFinish();
91
+ }
92
+ }), /*#__PURE__*/_react.default.createElement(_wrapper.EditableWrapper, {
93
+ component: /*#__PURE__*/_react.default.createElement(_draftRenderer.annotationDecorator.component, {
94
+ children,
95
+ contentState,
96
+ entityKey
97
+ }),
98
+ onClick: e => {
99
+ e.preventDefault();
100
+ setIsModalOpen(true);
101
+ props.onEditStart();
102
+ }
103
+ }));
104
+ };
105
+ const editableAnnotationDecorator = exports.editableAnnotationDecorator = {
106
+ strategy: _draftRenderer.annotationDecorator.strategy,
107
+ component: EditableAnnotation
108
+ };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.editableLinkDecorator = exports.LinkEditor = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _modals = require("@keystone-ui/modals");
9
+ var _fields = require("@keystone-ui/fields");
10
+ var _draftRenderer = require("@kids-reporter/draft-renderer");
11
+ var _wrapper = require("./wrapper");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const LinkEditor = props => {
15
+ const {
16
+ isOpen,
17
+ urlValue,
18
+ onConfirm,
19
+ onCancel
20
+ } = props;
21
+ const [url, setURL] = (0, _react.useState)(urlValue);
22
+ return /*#__PURE__*/_react.default.createElement(_modals.AlertDialog, {
23
+ title: "\u7DE8\u8F2F\u5916\u90E8\u9023\u7D50\u6216\u5167\u90E8\u9328\u9EDE(ID)",
24
+ isOpen: isOpen,
25
+ actions: {
26
+ cancel: {
27
+ label: 'Cancel',
28
+ action: () => onCancel()
29
+ },
30
+ confirm: {
31
+ label: 'Confirm',
32
+ action: () => onConfirm(url)
33
+ }
34
+ }
35
+ }, /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("br", null), "\u5916\u90E8\u9023\u7D50\u7BC4\u4F8B:", /*#__PURE__*/_react.default.createElement("br", null), "https://kids.twreporter.org/article/article1#part1", /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("br", null), "\u5167\u90E8\u9328\u9EDE\u7BC4\u4F8B:", /*#__PURE__*/_react.default.createElement("br", null), "#part1"), /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
36
+ placeholder: "\u9023\u7D50",
37
+ type: "text",
38
+ value: url,
39
+ onChange: e => setURL(e.target.value)
40
+ }));
41
+ };
42
+ exports.LinkEditor = LinkEditor;
43
+ const EditableLink = props => {
44
+ var _contentState$getEnti;
45
+ const {
46
+ children,
47
+ contentState,
48
+ entityKey
49
+ } = props;
50
+ const [isModalOpen, setIsModalOpen] = (0, _react.useState)(false);
51
+ const [url, setURL] = (0, _react.useState)(contentState === null || contentState === void 0 || (_contentState$getEnti = contentState.getEntity(entityKey)) === null || _contentState$getEnti === void 0 || (_contentState$getEnti = _contentState$getEnti.getData()) === null || _contentState$getEnti === void 0 ? void 0 : _contentState$getEnti.url);
52
+ (0, _react.useEffect)(() => {
53
+ var _contentState$getEnti2;
54
+ setURL(contentState === null || contentState === void 0 || (_contentState$getEnti2 = contentState.getEntity(entityKey).getData()) === null || _contentState$getEnti2 === void 0 ? void 0 : _contentState$getEnti2.url);
55
+ });
56
+ const onURLChange = url => {
57
+ setIsModalOpen(false);
58
+ setURL(url);
59
+ props.onEditFinish({
60
+ entityKey,
61
+ entityData: {
62
+ url: url
63
+ }
64
+ });
65
+ };
66
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isModalOpen && /*#__PURE__*/_react.default.createElement(LinkEditor, {
67
+ isOpen: isModalOpen,
68
+ urlValue: url,
69
+ onConfirm: onURLChange,
70
+ onCancel: () => {
71
+ setIsModalOpen(false);
72
+ props.onEditFinish();
73
+ }
74
+ }), /*#__PURE__*/_react.default.createElement(_wrapper.EditableWrapper, {
75
+ component: /*#__PURE__*/_react.default.createElement(_draftRenderer.linkDecorator.component, {
76
+ children,
77
+ contentState,
78
+ entityKey
79
+ }),
80
+ onClick: e => {
81
+ e.preventDefault();
82
+ setIsModalOpen(true);
83
+ props.onEditStart();
84
+ }
85
+ }));
86
+ };
87
+ const editableLinkDecorator = exports.editableLinkDecorator = {
88
+ strategy: _draftRenderer.linkDecorator.strategy,
89
+ component: EditableLink
90
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EditableWrapper = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const Wrapper = _styledComponents.default.span`
11
+ display: inline;
12
+ color: #8e8e8e;
13
+ `;
14
+ const EditButton = _styledComponents.default.div`
15
+ display: inline;
16
+ cursor: pointer;
17
+ padding-left: 2px;
18
+ padding-right: 2px;
19
+ `;
20
+ const EditableWrapper = props => {
21
+ return /*#__PURE__*/_react.default.createElement(Wrapper, null, props.component, /*#__PURE__*/_react.default.createElement(EditButton, {
22
+ onClick: props.onClick
23
+ }, /*#__PURE__*/_react.default.createElement("i", {
24
+ className: "fas fa-pen"
25
+ })));
26
+ };
27
+ exports.EditableWrapper = EditableWrapper;
package/lib/index.js CHANGED
@@ -3,30 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "RichTextEditor", {
7
- enumerable: true,
8
- get: function () {
9
- return _draftEditor.RichTextEditor;
10
- }
11
- });
6
+ exports.RichTextEditor = void 0;
12
7
  Object.defineProperty(exports, "buttonNames", {
13
8
  enumerable: true,
14
9
  get: function () {
15
10
  return _btNames.default;
16
11
  }
17
12
  });
18
- Object.defineProperty(exports, "decorator", {
19
- enumerable: true,
20
- get: function () {
21
- return _draftEditor.decorator;
22
- }
23
- });
24
13
  exports.default = void 0;
25
- var _draftEditor = require("./draft-editor");
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _richTextEditor = require("./rich-text-editor");
26
16
  var _btNames = _interopRequireDefault(require("./buttons/bt-names"));
17
+ var _annotation = require("./entity-decorators/annotation");
18
+ var _link = require("./entity-decorators/link");
19
+ var _tocAnchor = require("./entity-decorators/toc-anchor");
20
+ var _anchor = require("./entity-decorators/anchor");
27
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
+ const RichTextEditor = props => {
24
+ return /*#__PURE__*/_react.default.createElement(_richTextEditor.RichTextEditor, _extends({
25
+ decorators: [_annotation.editableAnnotationDecorator, _link.editableLinkDecorator, _tocAnchor.editableTOCAnchorDecorator, _anchor.editableAnchorDecorator]
26
+ }, props));
27
+ };
28
+ exports.RichTextEditor = RichTextEditor;
28
29
  var _default = exports.default = {
29
- RichTextEditor: _draftEditor.RichTextEditor,
30
- buttonNames: _btNames.default,
31
- decorator: _draftEditor.decorator
30
+ RichTextEditor,
31
+ buttonNames: _btNames.default
32
32
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.decorator = exports.RichTextEditor = void 0;
6
+ exports.default = exports.RichTextEditor = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _draftJs = require("draft-js");
9
9
  var _draftRenderer = require("@kids-reporter/draft-renderer");
@@ -12,12 +12,8 @@ var _blockRendererFn = require("./block-renderer-fn");
12
12
  var _styled = require("./styled");
13
13
  var _buttons = require("./buttons");
14
14
  var _imageSelector = require("./buttons/selector/image-selector");
15
- var _annotation = require("./buttons/annotation");
16
- var _infoBox = require("./buttons/info-box");
17
15
  var _bgColor = require("./buttons/bg-color");
18
16
  var _fontColor = require("./buttons/font-color");
19
- var _tocAnchor = require("./entity-decorators/toc-anchor");
20
- var _anchor = require("./entity-decorators/anchor");
21
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
18
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
19
  const styleSource = ['https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css', 'https://storage.googleapis.com/static-readr-tw-dev/cdn/draft-js/rich-editor.css', 'https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'].map((src, index) => /*#__PURE__*/_react.default.createElement("link", {
@@ -26,28 +22,35 @@ const styleSource = ['https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/
26
22
  rel: "stylesheet",
27
23
  type: "text/css"
28
24
  }));
29
- const decorator = exports.decorator = new _draftJs.CompositeDecorator([_draftRenderer.annotationDecorator, _draftRenderer.linkDecorator]);
30
25
  class RichTextEditor extends _react.default.Component {
31
26
  editorRef = null;
32
27
  constructor(props) {
28
+ var _props$decorators;
33
29
  super(props);
30
+ // Assign edit props to decorators
31
+ const editableDecorators = new _draftJs.CompositeDecorator((_props$decorators = props.decorators) === null || _props$decorators === void 0 ? void 0 : _props$decorators.map(editableDecorator => {
32
+ return {
33
+ ...editableDecorator,
34
+ props: {
35
+ ...this.customEditProps
36
+ }
37
+ };
38
+ }));
39
+ const {
40
+ editorState
41
+ } = props;
34
42
  this.state = {
35
43
  isEnlarged: false,
36
- readOnly: false
44
+ readOnly: false,
45
+ editorState: !(editorState instanceof _draftJs.EditorState) ? _draftJs.EditorState.createEmpty(editableDecorators) : _draftJs.EditorState.set(editorState, {
46
+ decorator: editableDecorators
47
+ })
37
48
  };
38
- this.editorDecorator = new _draftJs.CompositeDecorator([_draftRenderer.annotationDecorator, _draftRenderer.linkDecorator, {
39
- ..._tocAnchor.editableTOCAnchorDecorator,
40
- props: {
41
- ...this.customEditProps
42
- }
43
- }, {
44
- ..._anchor.editableAnchorDecorator,
45
- props: {
46
- ...this.customEditProps
47
- }
48
- }]);
49
49
  }
50
50
  onChange = editorState => {
51
+ this.setState({
52
+ editorState: editorState
53
+ });
51
54
  this.props.onChange(editorState);
52
55
  };
53
56
  handleKeyCommand = (command, editorState) => {
@@ -60,19 +63,15 @@ class RichTextEditor extends _react.default.Component {
60
63
  };
61
64
  handleReturn = event => {
62
65
  if (_draftJs.KeyBindingUtil.isSoftNewlineEvent(event)) {
63
- const {
64
- onChange,
65
- editorState
66
- } = this.props;
67
- onChange(_draftJs.RichUtils.insertSoftNewline(editorState));
66
+ this.onChange(_draftJs.RichUtils.insertSoftNewline(this.state.editorState));
68
67
  return 'handled';
69
68
  }
70
69
  return 'not-handled';
71
70
  };
72
71
  mapKeyToEditorCommand = e => {
73
72
  if (e.keyCode === 9 /* TAB */) {
74
- const newEditorState = _draftJs.RichUtils.onTab(e, this.props.editorState, 4 /* maxDepth */);
75
- if (newEditorState !== this.props.editorState) {
73
+ const newEditorState = _draftJs.RichUtils.onTab(e, this.state.editorState, 4 /* maxDepth */);
74
+ if (newEditorState !== this.state.editorState) {
76
75
  this.onChange(newEditorState);
77
76
  }
78
77
  return null;
@@ -80,10 +79,10 @@ class RichTextEditor extends _react.default.Component {
80
79
  return (0, _draftJs.getDefaultKeyBinding)(e);
81
80
  };
82
81
  toggleBlockType = blockType => {
83
- this.onChange(_draftJs.RichUtils.toggleBlockType(this.props.editorState, blockType));
82
+ this.onChange(_draftJs.RichUtils.toggleBlockType(this.state.editorState, blockType));
84
83
  };
85
84
  toggleInlineStyle = inlineStyle => {
86
- this.onChange(_draftJs.RichUtils.toggleInlineStyle(this.props.editorState, inlineStyle));
85
+ this.onChange(_draftJs.RichUtils.toggleInlineStyle(this.state.editorState, inlineStyle));
87
86
  };
88
87
  getEntityType = editorState => {
89
88
  const contentState = editorState.getCurrentContent();
@@ -140,9 +139,9 @@ class RichTextEditor extends _react.default.Component {
140
139
  entityData
141
140
  } = {}) => {
142
141
  if (entityKey && entityData) {
143
- const oldContentState = this.props.editorState.getCurrentContent();
142
+ const oldContentState = this.state.editorState.getCurrentContent();
144
143
  const newContentState = oldContentState.replaceEntityData(entityKey, entityData);
145
- this.onChange(_draftJs.EditorState.set(this.props.editorState, {
144
+ this.onChange(_draftJs.EditorState.set(this.state.editorState, {
146
145
  currentContent: newContentState
147
146
  }));
148
147
  }
@@ -158,8 +157,6 @@ class RichTextEditor extends _react.default.Component {
158
157
  // and `props.blockProps.onEditFinish` in the custom block components.
159
158
  atomicBlockObj['props'] = {
160
159
  ...this.customEditProps,
161
- RichTextEditorComponent: RichTextEditor,
162
- decorator,
163
160
  getMainEditorReadOnly: () => this.state.readOnly
164
161
  };
165
162
  }
@@ -169,25 +166,16 @@ class RichTextEditor extends _react.default.Component {
169
166
  const {
170
167
  disabledButtons = []
171
168
  } = this.props;
172
- let {
173
- editorState
174
- } = this.props;
175
- if (!(editorState instanceof _draftJs.EditorState)) {
176
- editorState = _draftJs.EditorState.createEmpty(this.editorDecorator);
177
- } else {
178
- editorState = _draftJs.EditorState.set(editorState, {
179
- decorator: this.editorDecorator
180
- });
181
- }
182
169
  const {
183
170
  isEnlarged,
184
- readOnly
171
+ readOnly,
172
+ editorState
185
173
  } = this.state;
186
174
  const entityType = this.getEntityType(editorState);
187
175
  const commonProps = {
188
176
  editorState: editorState,
189
177
  onChange: this.onChange,
190
- readOnly: this.state.readOnly
178
+ readOnly: readOnly
191
179
  };
192
180
  return /*#__PURE__*/_react.default.createElement(_styled.DraftEditorContainer, {
193
181
  isEnlarged: isEnlarged
@@ -195,12 +183,12 @@ class RichTextEditor extends _react.default.Component {
195
183
  disabledButtons: disabledButtons,
196
184
  editorState: editorState,
197
185
  onToggle: this.toggleBlockType,
198
- readOnly: this.state.readOnly
186
+ readOnly: readOnly
199
187
  }), /*#__PURE__*/_react.default.createElement(_buttons.InlineStyleControls, {
200
188
  disabledButtons: disabledButtons,
201
189
  editorState: editorState,
202
190
  onToggle: this.toggleInlineStyle,
203
- readOnly: this.state.readOnly
191
+ readOnly: readOnly
204
192
  }), /*#__PURE__*/_react.default.createElement(_styled.EnlargeButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_buttons.CustomEnlargeButton, {
205
193
  onToggle: this.toggleEnlarge,
206
194
  isEnlarged: isEnlarged
@@ -221,7 +209,7 @@ class RichTextEditor extends _react.default.Component {
221
209
  isActive: editorState.getCurrentInlineStyle().find(styleName => typeof styleName === 'string' && styleName.startsWith(_fontColor.customStylePrefix)) !== undefined
222
210
  }, commonProps, this.commonEditProps)), /*#__PURE__*/_react.default.createElement(_buttons.CustomBlockquoteButton, _extends({
223
211
  isDisabled: disabledButtons.includes(_btNames.default.blockquote)
224
- }, commonProps)), /*#__PURE__*/_react.default.createElement(CustomAnnotationButton, _extends({
212
+ }, commonProps)), /*#__PURE__*/_react.default.createElement(_buttons.CustomAnnotationButton, _extends({
225
213
  isDisabled: disabledButtons.includes(_btNames.default.annotation),
226
214
  isActive: entityType === _draftRenderer.ENTITY.Annotation
227
215
  }, commonProps, this.commonEditProps)), /*#__PURE__*/_react.default.createElement(_buttons.CustomImageButton, _extends({
@@ -230,7 +218,7 @@ class RichTextEditor extends _react.default.Component {
230
218
  }, commonProps)), /*#__PURE__*/_react.default.createElement(_buttons.CustomSlideshowButton, _extends({
231
219
  isDisabled: disabledButtons.includes(_btNames.default.slideshow),
232
220
  ImageSelector: _imageSelector.ImageSelector
233
- }, commonProps)), /*#__PURE__*/_react.default.createElement(CustomInfoBoxButton, _extends({
221
+ }, commonProps)), /*#__PURE__*/_react.default.createElement(_buttons.CustomInfoBoxButton, _extends({
234
222
  isDisabled: disabledButtons.includes(_btNames.default.infoBox)
235
223
  }, commonProps)), /*#__PURE__*/_react.default.createElement(_buttons.CustomEmbeddedCodeButton, _extends({
236
224
  isDisabled: disabledButtons.includes(_btNames.default.embed)
@@ -263,17 +251,6 @@ class RichTextEditor extends _react.default.Component {
263
251
  }
264
252
  }
265
253
  exports.RichTextEditor = RichTextEditor;
266
- const AnnotationButton = (0, _annotation.createAnnotationButton)({
267
- InnerEditor: RichTextEditor,
268
- decorator
269
- });
270
- const InfoBoxButton = (0, _infoBox.createInfoBoxButton)({
271
- InnerEditor: RichTextEditor,
272
- decorator
273
- });
274
- const CustomAnnotationButton = (0, _buttons.withStyle)(AnnotationButton);
275
- const CustomInfoBoxButton = (0, _buttons.withStyle)(InfoBoxButton);
276
254
  var _default = exports.default = {
277
- RichTextEditor,
278
- decorator
255
+ RichTextEditor
279
256
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kids-reporter/draft-editor",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@kids-reporter/draft-renderer": "1.0.5",
26
+ "@kids-reporter/draft-renderer": "1.0.6",
27
27
  "@twreporter/errors": "^1.1.2",
28
28
  "draft-js": "^0.11.7"
29
29
  },
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });