@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.
- package/lib/block-renderer-fn.js +1 -1
- package/lib/block-renderers/blockquote.js +21 -18
- package/lib/block-renderers/embedded-code.js +31 -25
- package/lib/block-renderers/image-link.js +78 -73
- package/lib/block-renderers/image.js +23 -21
- package/lib/block-renderers/info-box.js +22 -19
- package/lib/block-renderers/slideshow.js +22 -19
- package/lib/block-renderers/styled.js +12 -8
- package/lib/buttons/anchor.js +18 -14
- package/lib/buttons/annotation.js +19 -15
- package/lib/buttons/bg-color.js +31 -23
- package/lib/buttons/blockquote.js +68 -62
- package/lib/buttons/control-buttons.js +31 -25
- package/lib/buttons/divider.js +29 -21
- package/lib/buttons/embedded-code.js +84 -76
- package/lib/buttons/enlarge.js +7 -5
- package/lib/buttons/font-color.js +21 -16
- package/lib/buttons/form/select.js +14 -10
- package/lib/buttons/image-link.js +26 -22
- package/lib/buttons/image.js +18 -12
- package/lib/buttons/index.js +6 -6
- package/lib/buttons/info-box.js +79 -73
- package/lib/buttons/link.js +17 -15
- package/lib/buttons/news-reading.js +65 -56
- package/lib/buttons/selector/align-selector.js +20 -16
- package/lib/buttons/selector/image-selector.js +119 -88
- package/lib/buttons/selector/pagination.js +45 -33
- package/lib/buttons/selector/search-box.js +19 -18
- package/lib/buttons/slideshow.js +18 -12
- package/lib/buttons/toc-anchor.js +9 -5
- package/lib/entity-decorators/anchor.js +46 -33
- package/lib/entity-decorators/annotation.js +53 -52
- package/lib/entity-decorators/link.js +38 -36
- package/lib/entity-decorators/toc-anchor.js +41 -35
- package/lib/entity-decorators/wrapper.js +9 -6
- package/lib/index.js +7 -6
- package/lib/local-types/kids-reporter__draft-renderer.d.js +1 -0
- package/lib/rich-text-editor.js +110 -84
- package/lib/styled.js +14 -3
- package/package.json +12 -10
- 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
|
-
|
|
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,11 +5,12 @@ 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
|
+
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__*/
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
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
|
+
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__*/
|
|
36
|
-
isOpen: isOpen
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
})));
|
|
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__*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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__*/
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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__*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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__*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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;
|
package/lib/buttons/divider.js
CHANGED
|
@@ -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__*/
|
|
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
|
}
|
|
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EmbeddedCodeButton = EmbeddedCodeButton;
|
|
7
7
|
exports.EmbeddedCodeInput = EmbeddedCodeInput;
|
|
8
|
-
var
|
|
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
|
-
|
|
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
|
|
48
|
+
scrollWrapper.scrollTop = scrollWrapper?.scrollHeight;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
return /*#__PURE__*/
|
|
52
|
-
isOpen: isOpen
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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__*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
}
|