@kids-reporter/draft-editor 1.0.17 → 1.0.19
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.
- package/lib/block-renderer-fn.js +1 -1
- package/lib/block-renderers/blockquote.js +23 -21
- package/lib/block-renderers/embedded-code.js +33 -28
- package/lib/block-renderers/image-link.js +80 -74
- package/lib/block-renderers/image.js +24 -22
- package/lib/block-renderers/info-box.js +25 -22
- package/lib/block-renderers/slideshow.js +24 -22
- package/lib/block-renderers/styled.js +13 -9
- package/lib/buttons/anchor.js +18 -14
- package/lib/buttons/annotation.js +19 -15
- package/lib/buttons/bg-color.js +33 -26
- package/lib/buttons/blockquote.js +69 -64
- package/lib/buttons/control-buttons.js +33 -28
- package/lib/buttons/divider.js +30 -22
- package/lib/buttons/embedded-code.js +86 -79
- package/lib/buttons/enlarge.js +8 -6
- package/lib/buttons/font-color.js +23 -19
- package/lib/buttons/form/checkbox.js +42 -0
- package/lib/buttons/form/select.js +15 -11
- package/lib/buttons/image-link.js +26 -22
- package/lib/buttons/image.js +19 -14
- package/lib/buttons/index.js +7 -7
- package/lib/buttons/info-box.js +102 -81
- package/lib/buttons/link.js +17 -15
- package/lib/buttons/news-reading.js +66 -58
- package/lib/buttons/selector/align-selector.js +22 -19
- package/lib/buttons/selector/image-selector.js +120 -90
- package/lib/buttons/selector/pagination.js +46 -34
- package/lib/buttons/selector/search-box.js +20 -19
- package/lib/buttons/slideshow.js +19 -14
- package/lib/buttons/toc-anchor.js +10 -6
- package/lib/entity-decorators/anchor.js +48 -36
- package/lib/entity-decorators/annotation.js +54 -53
- package/lib/entity-decorators/link.js +38 -36
- package/lib/entity-decorators/toc-anchor.js +43 -38
- package/lib/entity-decorators/wrapper.js +10 -7
- package/lib/index.js +8 -7
- package/lib/local-types/kids-reporter__draft-renderer.d.js +1 -0
- package/lib/rich-text-editor.js +111 -85
- package/lib/styled.js +15 -5
- package/package.json +26 -13
- package/lib/buttons/form/array-field.js +0 -30
package/lib/buttons/anchor.js
CHANGED
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AnchorButton = 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 _anchor = require("../entity-decorators/anchor");
|
|
11
|
-
|
|
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 AnchorButton = props => {
|
|
14
13
|
const toggleEntity = _draftJs.RichUtils.toggleLink;
|
|
15
14
|
const {
|
|
@@ -47,15 +46,20 @@ const AnchorButton = props => {
|
|
|
47
46
|
setIsEditorOpen(false);
|
|
48
47
|
props.onEditFinish();
|
|
49
48
|
};
|
|
50
|
-
return /*#__PURE__*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
50
|
+
children: [isEditorOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_anchor.AnchorIDEditor, {
|
|
51
|
+
isOpen: isEditorOpen,
|
|
52
|
+
anchorIDValue: '',
|
|
53
|
+
onConfirm: confirmAnchor,
|
|
54
|
+
onCancel: removeAnchor
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
56
|
+
className: props.className,
|
|
57
|
+
onMouseDown: isActive ? removeAnchor : promptForAnchor,
|
|
58
|
+
title: "\u9328\u9EDE",
|
|
59
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
60
|
+
children: "\u9328"
|
|
61
|
+
})
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
60
64
|
};
|
|
61
65
|
exports.AnchorButton = AnchorButton;
|
|
@@ -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
|
-
|
|
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__*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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;
|
package/lib/buttons/bg-color.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.BackgroundColorButton = BackgroundColorButton;
|
|
7
7
|
exports.customStylePrefix = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _fields = require("@keystone-ui/fields");
|
|
9
9
|
var _modals = require("@keystone-ui/modals");
|
|
10
10
|
var _draftJs = require("draft-js");
|
|
11
|
-
var
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
16
|
const customStylePrefix = exports.customStylePrefix = 'BACKGROUND_COLOR_';
|
|
17
17
|
const ColorHexInput = (0, _styledComponents.default)(_fields.TextInput)`
|
|
18
18
|
margin-right: 10px;
|
|
@@ -69,7 +69,7 @@ function BackgroundColorButton(props) {
|
|
|
69
69
|
setColorValue('');
|
|
70
70
|
props.onEditFinish();
|
|
71
71
|
};
|
|
72
|
-
const colorInput = /*#__PURE__*/
|
|
72
|
+
const colorInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.AlertDialog, {
|
|
73
73
|
title: "Hex Color Code (#ffffff)",
|
|
74
74
|
isOpen: toShowColorInput,
|
|
75
75
|
actions: {
|
|
@@ -81,24 +81,31 @@ function BackgroundColorButton(props) {
|
|
|
81
81
|
label: 'Confirm',
|
|
82
82
|
action: confirmColor
|
|
83
83
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
},
|
|
85
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorHexInput, {
|
|
86
|
+
onChange: e => setColorValue(e.target.value),
|
|
87
|
+
type: "text",
|
|
88
|
+
value: colorValue,
|
|
89
|
+
onKeyDown: onColorInputKeyDown
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
93
|
+
children: [colorInput, /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
94
|
+
className: props.className,
|
|
95
|
+
onMouseDown: isActive ? removeColor : promptForColor,
|
|
96
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
97
|
+
width: "16",
|
|
98
|
+
height: "14",
|
|
99
|
+
viewBox: "0 0 16 14",
|
|
100
|
+
fill: "none",
|
|
101
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
102
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
103
|
+
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",
|
|
104
|
+
fill: isActive ? '#ED8B00' : '#6b7280'
|
|
105
|
+
})
|
|
106
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
107
|
+
children: " Highlight"
|
|
108
|
+
})]
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
104
111
|
}
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.BlockquoteButton = BlockquoteButton;
|
|
7
7
|
exports.BlockquoteInput = BlockquoteInput;
|
|
8
|
-
var
|
|
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
|
|
13
|
-
function
|
|
14
|
-
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; }
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
15
|
var BlockquoteTypeEnum = /*#__PURE__*/function (BlockquoteTypeEnum) {
|
|
16
16
|
BlockquoteTypeEnum["borderLeft"] = "border_left";
|
|
17
17
|
BlockquoteTypeEnum["quoteLeft"] = "quote_left";
|
|
@@ -32,50 +32,52 @@ function BlockquoteInput({
|
|
|
32
32
|
const confirmInput = () => {
|
|
33
33
|
onConfirm(inputValueState);
|
|
34
34
|
};
|
|
35
|
-
return /*#__PURE__*/
|
|
36
|
-
isOpen: isOpen
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
|
|
36
|
+
isOpen: isOpen,
|
|
37
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_modals.Drawer, {
|
|
38
|
+
title: "\u5F15\u8A00"
|
|
39
|
+
//isOpen={toShowInput}
|
|
40
|
+
,
|
|
41
|
+
actions: {
|
|
42
|
+
cancel: {
|
|
43
|
+
label: 'Cancel',
|
|
44
|
+
action: onCancel
|
|
45
|
+
},
|
|
46
|
+
confirm: {
|
|
47
|
+
label: 'Confirm',
|
|
48
|
+
action: confirmInput
|
|
49
|
+
}
|
|
45
50
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
marginBottom: '30px'
|
|
77
|
-
}
|
|
78
|
-
})));
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_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__*/(0, _jsxRuntime.jsx)(_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
|
+
})]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
79
81
|
}
|
|
80
82
|
function BlockquoteButton(props) {
|
|
81
83
|
const {
|
|
@@ -103,20 +105,23 @@ function BlockquoteButton(props) {
|
|
|
103
105
|
const onInputCancel = () => {
|
|
104
106
|
setIsInputOpen(false);
|
|
105
107
|
};
|
|
106
|
-
return /*#__PURE__*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
109
|
+
children: [isInputOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockquoteInput, {
|
|
110
|
+
isOpen: isInputOpen,
|
|
111
|
+
onConfirm: onInputChange,
|
|
112
|
+
onCancel: onInputCancel,
|
|
113
|
+
inputValue: {
|
|
114
|
+
type: BlockquoteTypeEnum.borderLeft,
|
|
115
|
+
text: ''
|
|
116
|
+
}
|
|
117
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
118
|
+
onClick: () => {
|
|
119
|
+
promptForInput();
|
|
120
|
+
},
|
|
121
|
+
className: className,
|
|
122
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
123
|
+
className: "fas fa-quote-left"
|
|
124
|
+
})
|
|
125
|
+
})]
|
|
126
|
+
});
|
|
122
127
|
}
|
|
@@ -6,9 +6,9 @@ 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
|
-
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
11
|
-
function _interopRequireDefault(
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
const buttonStyle = exports.buttonStyle = (0, _styledComponents.css)`
|
|
13
13
|
cursor: pointer;
|
|
14
14
|
border-radius: 6px;
|
|
@@ -68,14 +68,17 @@ class StyleButton extends _react.default.Component {
|
|
|
68
68
|
this.props.onToggle(this.props.style);
|
|
69
69
|
};
|
|
70
70
|
render() {
|
|
71
|
-
return /*#__PURE__*/
|
|
71
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomButton, {
|
|
72
72
|
isDisabled: this.props.isDisabled,
|
|
73
73
|
isActive: this.props.active,
|
|
74
74
|
onMouseDown: this.onToggle,
|
|
75
|
-
readOnly: this.props.readOnly
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
readOnly: this.props.readOnly,
|
|
76
|
+
children: [this.props.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
77
|
+
className: this.props.icon
|
|
78
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
79
|
+
children: !this.props.icon ? this.props.label : ''
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
const blockStyles = [{
|
|
@@ -114,16 +117,17 @@ const BlockStyleControls = props => {
|
|
|
114
117
|
} = props;
|
|
115
118
|
const selection = editorState.getSelection();
|
|
116
119
|
const blockType = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
|
|
117
|
-
return /*#__PURE__*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
121
|
+
children: blockStyles.map(type => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyleButton, {
|
|
122
|
+
isDisabled: disabledButtons.includes(type.style),
|
|
123
|
+
active: type.style === blockType,
|
|
124
|
+
label: type.label,
|
|
125
|
+
onToggle: props.onToggle,
|
|
126
|
+
style: type.style,
|
|
127
|
+
icon: type.icon,
|
|
128
|
+
readOnly: props.readOnly
|
|
129
|
+
}, type.label))
|
|
130
|
+
});
|
|
127
131
|
};
|
|
128
132
|
exports.BlockStyleControls = BlockStyleControls;
|
|
129
133
|
const inlineStyles = [{
|
|
@@ -145,15 +149,16 @@ const inlineStyles = [{
|
|
|
145
149
|
}];
|
|
146
150
|
const InlineStyleControls = props => {
|
|
147
151
|
const currentStyle = props.editorState.getCurrentInlineStyle();
|
|
148
|
-
return /*#__PURE__*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
153
|
+
children: inlineStyles.map(type => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyleButton, {
|
|
154
|
+
isDisabled: props.disabledButtons.includes(type.style.toLowerCase()),
|
|
155
|
+
active: currentStyle.has(type.style),
|
|
156
|
+
label: type.label,
|
|
157
|
+
onToggle: props.onToggle,
|
|
158
|
+
style: type.style,
|
|
159
|
+
icon: type.icon,
|
|
160
|
+
readOnly: props.readOnly
|
|
161
|
+
}, type.label))
|
|
162
|
+
});
|
|
158
163
|
};
|
|
159
164
|
exports.InlineStyleControls = InlineStyleControls;
|
package/lib/buttons/divider.js
CHANGED
|
@@ -4,10 +4,11 @@ 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
|
-
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
const IconWrapper = _styledComponents.default.span`
|
|
12
13
|
display: inline-block;
|
|
13
14
|
position: relative;
|
|
@@ -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__*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
}
|