@kids-reporter/draft-editor 1.0.16 → 1.0.18

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.
Files changed (41) hide show
  1. package/lib/block-renderer-fn.js +1 -1
  2. package/lib/block-renderers/blockquote.js +21 -18
  3. package/lib/block-renderers/embedded-code.js +31 -25
  4. package/lib/block-renderers/image-link.js +78 -73
  5. package/lib/block-renderers/image.js +23 -21
  6. package/lib/block-renderers/info-box.js +22 -19
  7. package/lib/block-renderers/slideshow.js +22 -19
  8. package/lib/block-renderers/styled.js +12 -8
  9. package/lib/buttons/anchor.js +18 -14
  10. package/lib/buttons/annotation.js +19 -15
  11. package/lib/buttons/bg-color.js +31 -23
  12. package/lib/buttons/blockquote.js +68 -62
  13. package/lib/buttons/control-buttons.js +31 -25
  14. package/lib/buttons/divider.js +29 -21
  15. package/lib/buttons/embedded-code.js +84 -76
  16. package/lib/buttons/enlarge.js +7 -5
  17. package/lib/buttons/font-color.js +21 -16
  18. package/lib/buttons/form/select.js +14 -10
  19. package/lib/buttons/image-link.js +26 -22
  20. package/lib/buttons/image.js +18 -12
  21. package/lib/buttons/index.js +6 -6
  22. package/lib/buttons/info-box.js +79 -73
  23. package/lib/buttons/link.js +17 -15
  24. package/lib/buttons/news-reading.js +65 -56
  25. package/lib/buttons/selector/align-selector.js +20 -16
  26. package/lib/buttons/selector/image-selector.js +119 -88
  27. package/lib/buttons/selector/pagination.js +45 -33
  28. package/lib/buttons/selector/search-box.js +19 -18
  29. package/lib/buttons/slideshow.js +18 -12
  30. package/lib/buttons/toc-anchor.js +9 -5
  31. package/lib/entity-decorators/anchor.js +46 -33
  32. package/lib/entity-decorators/annotation.js +53 -52
  33. package/lib/entity-decorators/link.js +38 -36
  34. package/lib/entity-decorators/toc-anchor.js +41 -35
  35. package/lib/entity-decorators/wrapper.js +9 -6
  36. package/lib/index.js +7 -6
  37. package/lib/local-types/kids-reporter__draft-renderer.d.js +1 -0
  38. package/lib/rich-text-editor.js +110 -84
  39. package/lib/styled.js +14 -3
  40. package/package.json +12 -10
  41. package/lib/buttons/form/array-field.js +0 -30
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AnnotationButton = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _draftJs = require("draft-js");
9
7
  var _draftRenderer = require("@kids-reporter/draft-renderer");
8
+ var _draftJs = require("draft-js");
9
+ var _react = require("react");
10
10
  var _annotation = require("../entity-decorators/annotation");
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); }
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; }
11
+ var _jsxRuntime = require("react/jsx-runtime");
13
12
  const AnnotationButton = props => {
14
13
  const toggleEntity = _draftJs.RichUtils.toggleLink;
15
14
  const {
@@ -48,16 +47,21 @@ const AnnotationButton = props => {
48
47
  setToShowInput(false);
49
48
  props.onEditFinish();
50
49
  };
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")));
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
51
+ children: [toShowInput && /*#__PURE__*/(0, _jsxRuntime.jsx)(_annotation.AnnotationEditor, {
52
+ isOpen: toShowInput,
53
+ editorStateValue: _draftJs.EditorState.createEmpty(),
54
+ onConfirm: confirmAnnotation,
55
+ onCancel: removeAnnotation
56
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
57
+ className: props.className,
58
+ onMouseDown: isActive ? removeAnnotation : promptForAnnotation,
59
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
60
+ className: "far"
61
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
62
+ children: "Annotation"
63
+ })]
64
+ })]
65
+ });
62
66
  };
63
67
  exports.AnnotationButton = AnnotationButton;
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BackgroundColorButton = BackgroundColorButton;
7
7
  exports.customStylePrefix = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _fields = require("@keystone-ui/fields");
9
9
  var _modals = require("@keystone-ui/modals");
10
10
  var _draftJs = require("draft-js");
11
- var _fields = require("@keystone-ui/fields");
11
+ var _react = _interopRequireWildcard(require("react"));
12
12
  var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+ var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  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
16
  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; }
@@ -69,7 +70,7 @@ function BackgroundColorButton(props) {
69
70
  setColorValue('');
70
71
  props.onEditFinish();
71
72
  };
72
- const colorInput = /*#__PURE__*/_react.default.createElement(_modals.AlertDialog, {
73
+ const colorInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.AlertDialog, {
73
74
  title: "Hex Color Code (#ffffff)",
74
75
  isOpen: toShowColorInput,
75
76
  actions: {
@@ -81,24 +82,31 @@ function BackgroundColorButton(props) {
81
82
  label: 'Confirm',
82
83
  action: confirmColor
83
84
  }
84
- }
85
- }, /*#__PURE__*/_react.default.createElement(ColorHexInput, {
86
- onChange: e => setColorValue(e.target.value),
87
- type: "text",
88
- value: colorValue,
89
- onKeyDown: onColorInputKeyDown
90
- }));
91
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, colorInput, /*#__PURE__*/_react.default.createElement("div", {
92
- className: props.className,
93
- onMouseDown: isActive ? removeColor : promptForColor
94
- }, /*#__PURE__*/_react.default.createElement("svg", {
95
- width: "16",
96
- height: "14",
97
- viewBox: "0 0 16 14",
98
- fill: "none",
99
- xmlns: "http://www.w3.org/2000/svg"
100
- }, /*#__PURE__*/_react.default.createElement("path", {
101
- d: "M3.74443 8.75V6.78945C3.74443 6.37109 3.98306 5.98008 4.34542 5.73125L12.3911 0.229633C12.6091 0.0804726 12.8477 0 13.1453 0C13.4811 0 13.8022 0.124113 14.0409 0.345078L15.6553 1.84242C15.8939 2.06336 16 2.36305 16 2.67531C16 2.92578 15.9411 3.14727 15.779 3.37422L9.85159 10.8418C9.5835 11.1781 9.1357 11.375 8.71147 11.375H6.57264L5.85086 12.0695C5.4826 12.4113 4.8875 12.4113 4.51924 12.0695L3.02265 10.6805C2.65439 10.3387 2.65439 9.78633 3.02265 9.44453L3.74443 8.75ZM13.9466 2.73219L13.0834 1.9302L6.74646 6.26172L9.25354 8.58867L13.9466 2.73219ZM0.207107 12.7504L2.064 11.0277L4.14509 12.9582L3.23182 13.784C3.09925 13.9316 2.91954 14 2.73099 14H0.707052C0.3167 14 0 13.7074 0 13.3438V13.2152C0 13.0184 0.0745351 12.8734 0.207107 12.7504Z",
102
- fill: isActive ? '#ED8B00' : '#6b7280'
103
- })), /*#__PURE__*/_react.default.createElement("span", null, " Highlight")));
85
+ },
86
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorHexInput, {
87
+ onChange: e => setColorValue(e.target.value),
88
+ type: "text",
89
+ value: colorValue,
90
+ onKeyDown: onColorInputKeyDown
91
+ })
92
+ });
93
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
94
+ children: [colorInput, /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
95
+ className: props.className,
96
+ onMouseDown: isActive ? removeColor : promptForColor,
97
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
98
+ width: "16",
99
+ height: "14",
100
+ viewBox: "0 0 16 14",
101
+ fill: "none",
102
+ xmlns: "http://www.w3.org/2000/svg",
103
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
104
+ d: "M3.74443 8.75V6.78945C3.74443 6.37109 3.98306 5.98008 4.34542 5.73125L12.3911 0.229633C12.6091 0.0804726 12.8477 0 13.1453 0C13.4811 0 13.8022 0.124113 14.0409 0.345078L15.6553 1.84242C15.8939 2.06336 16 2.36305 16 2.67531C16 2.92578 15.9411 3.14727 15.779 3.37422L9.85159 10.8418C9.5835 11.1781 9.1357 11.375 8.71147 11.375H6.57264L5.85086 12.0695C5.4826 12.4113 4.8875 12.4113 4.51924 12.0695L3.02265 10.6805C2.65439 10.3387 2.65439 9.78633 3.02265 9.44453L3.74443 8.75ZM13.9466 2.73219L13.0834 1.9302L6.74646 6.26172L9.25354 8.58867L13.9466 2.73219ZM0.207107 12.7504L2.064 11.0277L4.14509 12.9582L3.23182 13.784C3.09925 13.9316 2.91954 14 2.73099 14H0.707052C0.3167 14 0 13.7074 0 13.3438V13.2152C0 13.0184 0.0745351 12.8734 0.207107 12.7504Z",
105
+ fill: isActive ? '#ED8B00' : '#6b7280'
106
+ })
107
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
108
+ children: " Highlight"
109
+ })]
110
+ })]
111
+ });
104
112
  }
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BlockquoteButton = BlockquoteButton;
7
7
  exports.BlockquoteInput = BlockquoteInput;
8
- var _react = _interopRequireWildcard(require("react"));
9
- var _draftJs = require("draft-js");
8
+ var _fields = require("@keystone-ui/fields");
10
9
  var _modals = require("@keystone-ui/modals");
10
+ var _draftJs = require("draft-js");
11
+ var _react = _interopRequireWildcard(require("react"));
11
12
  var _select = require("./form/select");
12
- var _fields = require("@keystone-ui/fields");
13
+ var _jsxRuntime = require("react/jsx-runtime");
13
14
  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
15
  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
16
  var BlockquoteTypeEnum = /*#__PURE__*/function (BlockquoteTypeEnum) {
@@ -32,50 +33,52 @@ function BlockquoteInput({
32
33
  const confirmInput = () => {
33
34
  onConfirm(inputValueState);
34
35
  };
35
- return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
36
- isOpen: isOpen
37
- }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
38
- title: "\u5F15\u8A00"
39
- //isOpen={toShowInput}
40
- ,
41
- actions: {
42
- cancel: {
43
- label: 'Cancel',
44
- action: onCancel
36
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
37
+ isOpen: isOpen,
38
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_modals.Drawer, {
39
+ title: "\u5F15\u8A00"
40
+ //isOpen={toShowInput}
41
+ ,
42
+ actions: {
43
+ cancel: {
44
+ label: 'Cancel',
45
+ action: onCancel
46
+ },
47
+ confirm: {
48
+ label: 'Confirm',
49
+ action: confirmInput
50
+ }
45
51
  },
46
- confirm: {
47
- label: 'Confirm',
48
- action: confirmInput
49
- }
50
- }
51
- }, /*#__PURE__*/_react.default.createElement(_select.Select, {
52
- title: "\u7248\u578B",
53
- value: inputValueState.type,
54
- options: [{
55
- label: BlockquoteLabelEnum.borderLeft,
56
- value: BlockquoteTypeEnum.borderLeft
57
- }, {
58
- label: BlockquoteLabelEnum.quoteLeft,
59
- value: BlockquoteTypeEnum.quoteLeft
60
- }],
61
- onChange: blockquoteType => {
62
- setInputValueState({
63
- type: blockquoteType,
64
- text: inputValueState.text
65
- });
66
- }
67
- }), /*#__PURE__*/_react.default.createElement(_fields.TextArea, {
68
- onChange: e => setInputValueState({
69
- type: inputValueState.type,
70
- text: e.target.value
71
- }),
72
- placeholder: "\u5F15\u8A00\u6587\u5B57",
73
- type: "text",
74
- value: inputValueState.text,
75
- style: {
76
- marginBottom: '30px'
77
- }
78
- })));
52
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_select.Select, {
53
+ title: "\u7248\u578B",
54
+ value: inputValueState.type,
55
+ options: [{
56
+ label: BlockquoteLabelEnum.borderLeft,
57
+ value: BlockquoteTypeEnum.borderLeft
58
+ }, {
59
+ label: BlockquoteLabelEnum.quoteLeft,
60
+ value: BlockquoteTypeEnum.quoteLeft
61
+ }],
62
+ onChange: blockquoteType => {
63
+ setInputValueState({
64
+ type: blockquoteType,
65
+ text: inputValueState.text
66
+ });
67
+ }
68
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextArea, {
69
+ onChange: e => setInputValueState({
70
+ type: inputValueState.type,
71
+ text: e.target.value
72
+ }),
73
+ placeholder: "\u5F15\u8A00\u6587\u5B57",
74
+ type: "text",
75
+ value: inputValueState.text,
76
+ style: {
77
+ marginBottom: '30px'
78
+ }
79
+ })]
80
+ })
81
+ });
79
82
  }
80
83
  function BlockquoteButton(props) {
81
84
  const {
@@ -103,20 +106,23 @@ function BlockquoteButton(props) {
103
106
  const onInputCancel = () => {
104
107
  setIsInputOpen(false);
105
108
  };
106
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isInputOpen && /*#__PURE__*/_react.default.createElement(BlockquoteInput, {
107
- isOpen: isInputOpen,
108
- onConfirm: onInputChange,
109
- onCancel: onInputCancel,
110
- inputValue: {
111
- type: BlockquoteTypeEnum.borderLeft,
112
- text: ''
113
- }
114
- }), /*#__PURE__*/_react.default.createElement("div", {
115
- onClick: () => {
116
- promptForInput();
117
- },
118
- className: className
119
- }, /*#__PURE__*/_react.default.createElement("i", {
120
- className: "fas fa-quote-left"
121
- })));
109
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
110
+ children: [isInputOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockquoteInput, {
111
+ isOpen: isInputOpen,
112
+ onConfirm: onInputChange,
113
+ onCancel: onInputCancel,
114
+ inputValue: {
115
+ type: BlockquoteTypeEnum.borderLeft,
116
+ text: ''
117
+ }
118
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
119
+ onClick: () => {
120
+ promptForInput();
121
+ },
122
+ className: className,
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
124
+ className: "fas fa-quote-left"
125
+ })
126
+ })]
127
+ });
122
128
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.buttonStyle = exports.InlineStyleControls = exports.BlockStyleControls = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
9
10
  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); }
10
11
  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; }
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -68,14 +69,17 @@ class StyleButton extends _react.default.Component {
68
69
  this.props.onToggle(this.props.style);
69
70
  };
70
71
  render() {
71
- return /*#__PURE__*/_react.default.createElement(CustomButton, {
72
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomButton, {
72
73
  isDisabled: this.props.isDisabled,
73
74
  isActive: this.props.active,
74
75
  onMouseDown: this.onToggle,
75
- readOnly: this.props.readOnly
76
- }, this.props.icon && /*#__PURE__*/_react.default.createElement("i", {
77
- className: this.props.icon
78
- }), /*#__PURE__*/_react.default.createElement("span", null, !this.props.icon ? this.props.label : ''));
76
+ readOnly: this.props.readOnly,
77
+ children: [this.props.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
78
+ className: this.props.icon
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
80
+ children: !this.props.icon ? this.props.label : ''
81
+ })]
82
+ });
79
83
  }
80
84
  }
81
85
  const blockStyles = [{
@@ -114,16 +118,17 @@ const BlockStyleControls = props => {
114
118
  } = props;
115
119
  const selection = editorState.getSelection();
116
120
  const blockType = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
117
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, blockStyles.map(type => /*#__PURE__*/_react.default.createElement(StyleButton, {
118
- isDisabled: disabledButtons.includes(type.style),
119
- key: type.label,
120
- active: type.style === blockType,
121
- label: type.label,
122
- onToggle: props.onToggle,
123
- style: type.style,
124
- icon: type.icon,
125
- readOnly: props.readOnly
126
- })));
121
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
122
+ children: blockStyles.map(type => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyleButton, {
123
+ isDisabled: disabledButtons.includes(type.style),
124
+ active: type.style === blockType,
125
+ label: type.label,
126
+ onToggle: props.onToggle,
127
+ style: type.style,
128
+ icon: type.icon,
129
+ readOnly: props.readOnly
130
+ }, type.label))
131
+ });
127
132
  };
128
133
  exports.BlockStyleControls = BlockStyleControls;
129
134
  const inlineStyles = [{
@@ -145,15 +150,16 @@ const inlineStyles = [{
145
150
  }];
146
151
  const InlineStyleControls = props => {
147
152
  const currentStyle = props.editorState.getCurrentInlineStyle();
148
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, inlineStyles.map(type => /*#__PURE__*/_react.default.createElement(StyleButton, {
149
- isDisabled: props.disabledButtons.includes(type.style.toLowerCase()),
150
- key: type.label,
151
- active: currentStyle.has(type.style),
152
- label: type.label,
153
- onToggle: props.onToggle,
154
- style: type.style,
155
- icon: type.icon,
156
- readOnly: props.readOnly
157
- })));
153
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
154
+ children: inlineStyles.map(type => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyleButton, {
155
+ isDisabled: props.disabledButtons.includes(type.style.toLowerCase()),
156
+ active: currentStyle.has(type.style),
157
+ label: type.label,
158
+ onToggle: props.onToggle,
159
+ style: type.style,
160
+ icon: type.icon,
161
+ readOnly: props.readOnly
162
+ }, type.label))
163
+ });
158
164
  };
159
165
  exports.InlineStyleControls = InlineStyleControls;
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DividerButton = DividerButton;
7
- var _react = _interopRequireDefault(require("react"));
8
7
  var _draftJs = require("draft-js");
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  const IconWrapper = _styledComponents.default.span`
12
13
  display: inline-block;
@@ -31,24 +32,31 @@ function DividerButton(props) {
31
32
  // If you set an empty string, you will get an error: Unknown DraftEntity key: null
32
33
  onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
33
34
  };
34
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
35
- onClick: onClick,
36
- className: className
37
- }, /*#__PURE__*/_react.default.createElement(IconWrapper, null, /*#__PURE__*/_react.default.createElement("svg", {
38
- xmlns: "http://www.w3.org/2000/svg",
39
- height: "16",
40
- viewBox: "0 0 16 16",
41
- width: "16"
42
- }, /*#__PURE__*/_react.default.createElement("g", {
43
- fill: "none",
44
- fillRule: "evenodd"
45
- }, /*#__PURE__*/_react.default.createElement("path", {
46
- d: "M0 0h16v16H0z"
47
- }), /*#__PURE__*/_react.default.createElement("path", {
48
- d: "M15 10.501a0.5 0.5 0 0 1 0.496 0.442l0.004 0.059v2.031a2.468 2.468 0 0 1 -2.361 2.466l-0.107 0.003H2.967a2.467 2.467 0 0 1 -2.465 -2.36L0.5 13.032v-2.03a0.5 0.5 0 0 1 0.997 -0.058l0.004 0.059v2.03a1.468 1.468 0 0 0 1.381 1.464l0.086 0.003h10.065a1.468 1.468 0 0 0 1.466 -1.382l0.003 -0.086v-2.031a0.5 0.5 0 0 1 0.5 -0.5zM15.5 7.5a0.5 0.5 0 0 1 0 1H0.5a0.5 0.5 0 0 1 0 -1zM13.029 0.5a2.471 2.471 0 0 1 2.469 2.364l0.003 0.107v2.031a0.5 0.5 0 0 1 -0.997 0.058L14.5 5.003V2.971a1.471 1.471 0 0 0 -1.385 -1.468L13.029 1.5H2.97a1.47 1.47 0 0 0 -1.467 1.383L1.5 2.97V5a0.5 0.5 0 0 1 -0.997 0.058L0.5 5V2.97a2.47 2.47 0 0 1 2.362 -2.467L2.97 0.5z",
49
- fill: "#6b7280",
50
- fillRule: "nonzero",
51
- stroke: "#6b7280",
52
- strokeWidth: "0.5"
53
- }))))));
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
36
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
37
+ onClick: onClick,
38
+ className: className,
39
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconWrapper, {
40
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
41
+ xmlns: "http://www.w3.org/2000/svg",
42
+ height: "16",
43
+ viewBox: "0 0 16 16",
44
+ width: "16",
45
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
46
+ fill: "none",
47
+ fillRule: "evenodd",
48
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
49
+ d: "M0 0h16v16H0z"
50
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
51
+ d: "M15 10.501a0.5 0.5 0 0 1 0.496 0.442l0.004 0.059v2.031a2.468 2.468 0 0 1 -2.361 2.466l-0.107 0.003H2.967a2.467 2.467 0 0 1 -2.465 -2.36L0.5 13.032v-2.03a0.5 0.5 0 0 1 0.997 -0.058l0.004 0.059v2.03a1.468 1.468 0 0 0 1.381 1.464l0.086 0.003h10.065a1.468 1.468 0 0 0 1.466 -1.382l0.003 -0.086v-2.031a0.5 0.5 0 0 1 0.5 -0.5zM15.5 7.5a0.5 0.5 0 0 1 0 1H0.5a0.5 0.5 0 0 1 0 -1zM13.029 0.5a2.471 2.471 0 0 1 2.469 2.364l0.003 0.107v2.031a0.5 0.5 0 0 1 -0.997 0.058L14.5 5.003V2.971a1.471 1.471 0 0 0 -1.385 -1.468L13.029 1.5H2.97a1.47 1.47 0 0 0 -1.467 1.383L1.5 2.97V5a0.5 0.5 0 0 1 -0.997 0.058L0.5 5V2.97a2.47 2.47 0 0 1 2.362 -2.467L2.97 0.5z",
52
+ fill: "#6b7280",
53
+ fillRule: "nonzero",
54
+ stroke: "#6b7280",
55
+ strokeWidth: "0.5"
56
+ })]
57
+ })
58
+ })
59
+ })
60
+ })
61
+ });
54
62
  }
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.EmbeddedCodeButton = EmbeddedCodeButton;
7
7
  exports.EmbeddedCodeInput = EmbeddedCodeInput;
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _fields = require("@keystone-ui/fields");
9
+ var _modals = require("@keystone-ui/modals");
9
10
  var _draftJs = require("draft-js");
11
+ var _react = _interopRequireWildcard(require("react"));
10
12
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
- var _modals = require("@keystone-ui/modals");
12
- var _fields = require("@keystone-ui/fields");
13
13
  var _alignSelector = require("./selector/align-selector");
14
+ var _jsxRuntime = require("react/jsx-runtime");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
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); }
16
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; }
@@ -42,67 +43,69 @@ function EmbeddedCodeInput({
42
43
  onConfirm(inputValueState);
43
44
  };
44
45
  const onAlignSelectOpen = () => {
45
- var _contentWrapperRef$cu;
46
- const scrollWrapper = (_contentWrapperRef$cu = contentWrapperRef.current) === null || _contentWrapperRef$cu === void 0 ? void 0 : _contentWrapperRef$cu.parentElement;
46
+ const scrollWrapper = contentWrapperRef.current?.parentElement;
47
47
  if (scrollWrapper) {
48
- scrollWrapper.scrollTop = scrollWrapper === null || scrollWrapper === void 0 ? void 0 : scrollWrapper.scrollHeight;
48
+ scrollWrapper.scrollTop = scrollWrapper?.scrollHeight;
49
49
  }
50
50
  };
51
- return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
52
- isOpen: isOpen
53
- }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
54
- title: "\u9472\u5D4C\u7A0B\u5F0F\u78BC\uFF08Embedded Code\uFF09"
55
- //isOpen={toShowInput}
56
- ,
57
- actions: {
58
- cancel: {
59
- label: 'Cancel',
60
- action: onCancel
51
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
52
+ isOpen: isOpen,
53
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.Drawer, {
54
+ title: "\u9472\u5D4C\u7A0B\u5F0F\u78BC\uFF08Embedded Code\uFF09"
55
+ //isOpen={toShowInput}
56
+ ,
57
+ actions: {
58
+ cancel: {
59
+ label: 'Cancel',
60
+ action: onCancel
61
+ },
62
+ confirm: {
63
+ label: 'Confirm',
64
+ action: confirmInput
65
+ }
61
66
  },
62
- confirm: {
63
- label: 'Confirm',
64
- action: confirmInput
65
- }
66
- }
67
- }, /*#__PURE__*/_react.default.createElement(Container, {
68
- ref: contentWrapperRef
69
- }, /*#__PURE__*/_react.default.createElement(_fields.TextArea, {
70
- onChange: e => setInputValue({
71
- caption: inputValueState.caption,
72
- align: inputValueState.align,
73
- embeddedCode: e.target.value
74
- }),
75
- placeholder: "Embedded Code",
76
- type: "text",
77
- value: inputValueState.embeddedCode,
78
- style: {
79
- marginBottom: '30px'
80
- }
81
- }), /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
82
- onChange: e => setInputValue({
83
- caption: e.target.value,
84
- align: inputValueState.align,
85
- embeddedCode: inputValueState.embeddedCode
86
- }),
87
- type: "text",
88
- placeholder: "Caption",
89
- value: inputValueState.caption,
90
- style: {
91
- marginBottom: '10px',
92
- marginTop: '30px'
93
- }
94
- }), /*#__PURE__*/_react.default.createElement(_alignSelector.AlignSelector, {
95
- align: inputValueState.align,
96
- options: options,
97
- onChange: align => {
98
- setInputValue({
99
- caption: inputValueState.caption,
100
- align: align,
101
- embeddedCode: inputValueState.embeddedCode
102
- });
103
- },
104
- onOpen: onAlignSelectOpen
105
- }))));
67
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
68
+ ref: contentWrapperRef,
69
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextArea, {
70
+ onChange: e => setInputValue({
71
+ caption: inputValueState.caption,
72
+ align: inputValueState.align,
73
+ embeddedCode: e.target.value
74
+ }),
75
+ placeholder: "Embedded Code",
76
+ type: "text",
77
+ value: inputValueState.embeddedCode,
78
+ style: {
79
+ marginBottom: '30px'
80
+ }
81
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextInput, {
82
+ onChange: e => setInputValue({
83
+ caption: e.target.value,
84
+ align: inputValueState.align,
85
+ embeddedCode: inputValueState.embeddedCode
86
+ }),
87
+ type: "text",
88
+ placeholder: "Caption",
89
+ value: inputValueState.caption,
90
+ style: {
91
+ marginBottom: '10px',
92
+ marginTop: '30px'
93
+ }
94
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_alignSelector.AlignSelector, {
95
+ align: inputValueState.align,
96
+ options: options,
97
+ onChange: align => {
98
+ setInputValue({
99
+ caption: inputValueState.caption,
100
+ align: align,
101
+ embeddedCode: inputValueState.embeddedCode
102
+ });
103
+ },
104
+ onOpen: onAlignSelectOpen
105
+ })]
106
+ })
107
+ })
108
+ });
106
109
  }
107
110
  function EmbeddedCodeButton(props) {
108
111
  const {
@@ -130,20 +133,25 @@ function EmbeddedCodeButton(props) {
130
133
  const onInputCancel = () => {
131
134
  setIsInputOpen(false);
132
135
  };
133
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isInputOpen && /*#__PURE__*/_react.default.createElement(EmbeddedCodeInput, {
134
- isOpen: isInputOpen,
135
- onConfirm: onInputChange,
136
- onCancel: onInputCancel,
137
- inputValue: {
138
- caption: '',
139
- embeddedCode: ''
140
- }
141
- }), /*#__PURE__*/_react.default.createElement("div", {
142
- onClick: () => {
143
- promptForInput();
144
- },
145
- className: className
146
- }, /*#__PURE__*/_react.default.createElement("i", {
147
- className: "far"
148
- }), /*#__PURE__*/_react.default.createElement("span", null, "Embed")));
136
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
137
+ children: [isInputOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(EmbeddedCodeInput, {
138
+ isOpen: isInputOpen,
139
+ onConfirm: onInputChange,
140
+ onCancel: onInputCancel,
141
+ inputValue: {
142
+ caption: '',
143
+ embeddedCode: ''
144
+ }
145
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
146
+ onClick: () => {
147
+ promptForInput();
148
+ },
149
+ className: className,
150
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
151
+ className: "far"
152
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
153
+ children: "Embed"
154
+ })]
155
+ })]
156
+ });
149
157
  }