@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/info-box.js
CHANGED
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.InfoBoxButton = void 0;
|
|
7
7
|
exports.InfoBoxInput = InfoBoxInput;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _btNames = _interopRequireDefault(require("./bt-names"));
|
|
10
|
-
var _draftJs = require("draft-js");
|
|
11
8
|
var _modals = require("@keystone-ui/modals");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
9
|
+
var _draftJs = require("draft-js");
|
|
10
|
+
var _react = require("react");
|
|
14
11
|
var _annotation = require("../entity-decorators/annotation");
|
|
15
12
|
var _link = require("../entity-decorators/link");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
var _richTextEditor = require("../rich-text-editor");
|
|
14
|
+
var _btNames = _interopRequireDefault(require("./bt-names"));
|
|
15
|
+
var _checkbox = require("./form/checkbox");
|
|
16
|
+
var _select = require("./form/select");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
const disabledButtons = [_btNames.default.h2, _btNames.default.h3, _btNames.default.code, _btNames.default.codeBlock, _btNames.default.blockquote, _btNames.default.infoBox, _btNames.default.slideshow, _btNames.default.newsReading, _btNames.default.tocAnchor, _btNames.default.anchor];
|
|
20
20
|
var InfoBoxTypeEnum = /*#__PURE__*/function (InfoBoxTypeEnum) {
|
|
21
21
|
InfoBoxTypeEnum["newsChargeStation"] = "news-charge-station";
|
|
@@ -25,8 +25,8 @@ var InfoBoxTypeEnum = /*#__PURE__*/function (InfoBoxTypeEnum) {
|
|
|
25
25
|
}(InfoBoxTypeEnum || {});
|
|
26
26
|
var InfoBoxLabelEnum = /*#__PURE__*/function (InfoBoxLabelEnum) {
|
|
27
27
|
InfoBoxLabelEnum["newsChargeStation"] = "\u65B0\u805E\u5145\u96FB\u5668";
|
|
28
|
-
InfoBoxLabelEnum["headerBorder"] = "\
|
|
29
|
-
InfoBoxLabelEnum["boxBorder"] = "\
|
|
28
|
+
InfoBoxLabelEnum["headerBorder"] = "\u85CD\u5E95\u7248\uFF08\u6709\u6A19\u984C\u8A2D\u8A08\uFF09";
|
|
29
|
+
InfoBoxLabelEnum["boxBorder"] = "\u7070\u5E95\u7248";
|
|
30
30
|
return InfoBoxLabelEnum;
|
|
31
31
|
}(InfoBoxLabelEnum || {});
|
|
32
32
|
function InfoBoxInput(props) {
|
|
@@ -39,59 +39,72 @@ function InfoBoxInput(props) {
|
|
|
39
39
|
const contentState = (0, _draftJs.convertFromRaw)(inputValue.rawContentState);
|
|
40
40
|
const [inputValueState, setInputValueState] = (0, _react.useState)({
|
|
41
41
|
type: inputValue.type,
|
|
42
|
-
editorState: _draftJs.EditorState.createWithContent(contentState)
|
|
42
|
+
editorState: _draftJs.EditorState.createWithContent(contentState),
|
|
43
|
+
showBaodaozai: inputValue.showBaodaozai
|
|
43
44
|
});
|
|
44
|
-
return /*#__PURE__*/
|
|
45
|
-
isOpen: isOpen
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
|
|
46
|
+
isOpen: isOpen,
|
|
47
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_modals.Drawer, {
|
|
48
|
+
title: `Info Box`,
|
|
49
|
+
actions: {
|
|
50
|
+
cancel: {
|
|
51
|
+
label: 'Cancel',
|
|
52
|
+
action: () => {
|
|
53
|
+
onCancel();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
confirm: {
|
|
57
|
+
label: 'Confirm',
|
|
58
|
+
action: () => {
|
|
59
|
+
onConfirm({
|
|
60
|
+
type: inputValueState.type,
|
|
61
|
+
rawContentState: (0, _draftJs.convertToRaw)(inputValueState.editorState.getCurrentContent()),
|
|
62
|
+
showBaodaozai: inputValueState.showBaodaozai
|
|
63
|
+
});
|
|
64
|
+
}
|
|
53
65
|
}
|
|
54
66
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_select.Select, {
|
|
68
|
+
title: "\u7248\u578B",
|
|
69
|
+
value: inputValueState.type,
|
|
70
|
+
options: [{
|
|
71
|
+
label: InfoBoxLabelEnum.newsChargeStation,
|
|
72
|
+
value: InfoBoxTypeEnum.newsChargeStation
|
|
73
|
+
}, {
|
|
74
|
+
label: InfoBoxLabelEnum.headerBorder,
|
|
75
|
+
value: InfoBoxTypeEnum.headerBorder
|
|
76
|
+
}, {
|
|
77
|
+
label: InfoBoxLabelEnum.boxBorder,
|
|
78
|
+
value: InfoBoxTypeEnum.boxBorder
|
|
79
|
+
}],
|
|
80
|
+
onChange: infoBoxType => {
|
|
81
|
+
setInputValueState(prev => ({
|
|
82
|
+
...prev,
|
|
83
|
+
type: infoBoxType
|
|
84
|
+
}));
|
|
62
85
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
decorators: [_annotation.editableAnnotationDecorator, _link.editableLinkDecorator],
|
|
86
|
-
disabledButtons: disabledButtons,
|
|
87
|
-
editorState: inputValueState.editorState,
|
|
88
|
-
onChange: editorState => {
|
|
89
|
-
setInputValueState({
|
|
90
|
-
type: inputValueState.type,
|
|
91
|
-
editorState
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
})));
|
|
86
|
+
}), inputValueState.type !== InfoBoxTypeEnum.newsChargeStation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkbox.Checkbox, {
|
|
87
|
+
label: "\u662F\u5426\u986F\u793A\u5831\u5C0E\u4ED4\u5716\u7247",
|
|
88
|
+
checked: inputValueState.showBaodaozai ?? false,
|
|
89
|
+
onChange: checked => {
|
|
90
|
+
setInputValueState(prev => ({
|
|
91
|
+
...prev,
|
|
92
|
+
showBaodaozai: checked
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_richTextEditor.RichTextEditor, {
|
|
96
|
+
decorators: [_annotation.editableAnnotationDecorator, _link.editableLinkDecorator],
|
|
97
|
+
disabledButtons: disabledButtons,
|
|
98
|
+
editorState: inputValueState.editorState,
|
|
99
|
+
onChange: editorState => {
|
|
100
|
+
setInputValueState(prev => ({
|
|
101
|
+
...prev,
|
|
102
|
+
editorState
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
})]
|
|
106
|
+
})
|
|
107
|
+
});
|
|
95
108
|
}
|
|
96
109
|
const InfoBoxButton = props => {
|
|
97
110
|
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
@@ -102,14 +115,16 @@ const InfoBoxButton = props => {
|
|
|
102
115
|
} = props;
|
|
103
116
|
const onChange = ({
|
|
104
117
|
type,
|
|
105
|
-
rawContentState
|
|
118
|
+
rawContentState,
|
|
119
|
+
showBaodaozai
|
|
106
120
|
}) => {
|
|
107
121
|
const contentState = editorState.getCurrentContent();
|
|
108
122
|
|
|
109
123
|
// create an InfoBox entity
|
|
110
124
|
const contentStateWithEntity = contentState.createEntity('INFOBOX', 'IMMUTABLE', {
|
|
111
125
|
type,
|
|
112
|
-
rawContentState
|
|
126
|
+
rawContentState,
|
|
127
|
+
showBaodaozai
|
|
113
128
|
});
|
|
114
129
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
115
130
|
const newEditorState = _draftJs.EditorState.set(editorState, {
|
|
@@ -121,26 +136,32 @@ const InfoBoxButton = props => {
|
|
|
121
136
|
onEditorStateChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
|
|
122
137
|
setToShowInput(false);
|
|
123
138
|
};
|
|
124
|
-
return /*#__PURE__*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
140
|
+
children: [toShowInput && /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoBoxInput, {
|
|
141
|
+
onConfirm: onChange,
|
|
142
|
+
onCancel: () => {
|
|
143
|
+
setToShowInput(false);
|
|
144
|
+
},
|
|
145
|
+
isOpen: toShowInput,
|
|
146
|
+
inputValue: {
|
|
147
|
+
type: InfoBoxTypeEnum.newsChargeStation,
|
|
148
|
+
rawContentState: {
|
|
149
|
+
blocks: [],
|
|
150
|
+
entityMap: {}
|
|
151
|
+
},
|
|
152
|
+
showBaodaozai: true
|
|
135
153
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
155
|
+
className: className,
|
|
156
|
+
onClick: () => {
|
|
157
|
+
setToShowInput(true);
|
|
158
|
+
},
|
|
159
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
160
|
+
className: "far"
|
|
161
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
162
|
+
children: "InfoBox"
|
|
163
|
+
})]
|
|
164
|
+
})]
|
|
165
|
+
});
|
|
145
166
|
};
|
|
146
167
|
exports.InfoBoxButton = InfoBoxButton;
|
package/lib/buttons/link.js
CHANGED
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.LinkButton = 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 _link = require("../entity-decorators/link");
|
|
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 LinkButton = props => {
|
|
14
13
|
const {
|
|
15
14
|
isActive,
|
|
@@ -46,16 +45,19 @@ const LinkButton = props => {
|
|
|
46
45
|
setToShowUrlInput(false);
|
|
47
46
|
props.onEditFinish();
|
|
48
47
|
};
|
|
49
|
-
return /*#__PURE__*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
49
|
+
children: [toShowUrlInput && /*#__PURE__*/(0, _jsxRuntime.jsx)(_link.LinkEditor, {
|
|
50
|
+
isOpen: toShowUrlInput,
|
|
51
|
+
urlValue: '',
|
|
52
|
+
onConfirm: confirmLink,
|
|
53
|
+
onCancel: removeLink
|
|
54
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
55
|
+
className: props.className,
|
|
56
|
+
onMouseDown: isActive ? removeLink : promptForLink,
|
|
57
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
58
|
+
className: "fas fa-link"
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
60
62
|
};
|
|
61
63
|
exports.LinkButton = LinkButton;
|
|
@@ -5,19 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.NewsReadingButton = NewsReadingButton;
|
|
7
7
|
exports.NewsReadingInput = NewsReadingInput;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var _fields = require("@keystone-ui/fields");
|
|
9
|
+
var _modals = require("@keystone-ui/modals");
|
|
10
10
|
var _errors = _interopRequireDefault(require("@twreporter/errors"));
|
|
11
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
11
12
|
var _draftJs = require("draft-js");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
function
|
|
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; }
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
// @ts-ignore pkg does not have definition
|
|
18
18
|
|
|
19
19
|
async function fetchNewsReadingGroup(itemId) {
|
|
20
|
-
var _res$data, _res$data2;
|
|
21
20
|
const query = `
|
|
22
21
|
query GetNewsReadingGroup($itemId: ID!){
|
|
23
22
|
newsReadingGroup(where: {id: $itemId}) {
|
|
@@ -40,13 +39,13 @@ query GetNewsReadingGroup($itemId: ID!){
|
|
|
40
39
|
const annotatedErr = _errors.default.helpers.annotateAxiosError(err);
|
|
41
40
|
throw annotatedErr;
|
|
42
41
|
}
|
|
43
|
-
if (
|
|
42
|
+
if (res.data?.errors) {
|
|
44
43
|
const annotatingError = _errors.default.helpers.wrap(new Error('Errors occured while executing `GetNewsReadingGroup` query'), 'GraphQLError', '`errors` returned in the GQL query response', {
|
|
45
44
|
errors: res.data.errors
|
|
46
45
|
});
|
|
47
46
|
throw annotatingError;
|
|
48
47
|
}
|
|
49
|
-
return
|
|
48
|
+
return res.data?.data?.newsReadingGroup;
|
|
50
49
|
}
|
|
51
50
|
function NewsReadingInput({
|
|
52
51
|
isOpen,
|
|
@@ -58,9 +57,8 @@ function NewsReadingInput({
|
|
|
58
57
|
const [warning, setWarning] = (0, _react.useState)('');
|
|
59
58
|
const confirmInput = async () => {
|
|
60
59
|
try {
|
|
61
|
-
var _newsReadingGroup$ite;
|
|
62
60
|
const newsReadingGroup = await fetchNewsReadingGroup(inputValueState);
|
|
63
|
-
if (newsReadingGroup === null ||
|
|
61
|
+
if (newsReadingGroup === null || newsReadingGroup?.items?.length === 0) {
|
|
64
62
|
throw new Error(`input ${inputValueState} has no data.`);
|
|
65
63
|
}
|
|
66
64
|
onConfirm({
|
|
@@ -77,7 +75,7 @@ function NewsReadingInput({
|
|
|
77
75
|
};
|
|
78
76
|
let warningJsx = null;
|
|
79
77
|
if (warning) {
|
|
80
|
-
warningJsx = /*#__PURE__*/
|
|
78
|
+
warningJsx = /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.AlertDialog, {
|
|
81
79
|
isOpen: warning !== '',
|
|
82
80
|
title: `Something went wrong`,
|
|
83
81
|
actions: {
|
|
@@ -87,37 +85,43 @@ function NewsReadingInput({
|
|
|
87
85
|
},
|
|
88
86
|
label: 'Done'
|
|
89
87
|
}
|
|
90
|
-
}
|
|
91
|
-
}, /*#__PURE__*/_react.default.createElement(_fields.TextArea, {
|
|
92
|
-
readOnly: true
|
|
93
|
-
}, warning));
|
|
94
|
-
}
|
|
95
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, warningJsx, /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
|
|
96
|
-
isOpen: isOpen
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
|
|
98
|
-
title: "\u8B80\u5831\u4E3B\u984C",
|
|
99
|
-
actions: {
|
|
100
|
-
cancel: {
|
|
101
|
-
label: 'Cancel',
|
|
102
|
-
action: onCancel
|
|
103
88
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
89
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextArea, {
|
|
90
|
+
readOnly: true,
|
|
91
|
+
children: warning
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
96
|
+
children: [warningJsx, /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
|
|
97
|
+
isOpen: isOpen,
|
|
98
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.Drawer, {
|
|
99
|
+
title: "\u8B80\u5831\u4E3B\u984C",
|
|
100
|
+
actions: {
|
|
101
|
+
cancel: {
|
|
102
|
+
label: 'Cancel',
|
|
103
|
+
action: onCancel
|
|
104
|
+
},
|
|
105
|
+
confirm: {
|
|
106
|
+
label: 'Confirm',
|
|
107
|
+
action: confirmInput
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextInput, {
|
|
111
|
+
onChange: e => {
|
|
112
|
+
setInputValueState(e.target.value);
|
|
113
|
+
},
|
|
114
|
+
placeholder: "News-readings-groups Item ID",
|
|
115
|
+
type: "text",
|
|
116
|
+
value: inputValueState,
|
|
117
|
+
style: {
|
|
118
|
+
marginBottom: '10px',
|
|
119
|
+
marginTop: '30px'
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
124
|
+
});
|
|
121
125
|
}
|
|
122
126
|
function NewsReadingButton(props) {
|
|
123
127
|
const {
|
|
@@ -130,11 +134,10 @@ function NewsReadingButton(props) {
|
|
|
130
134
|
setIsInputOpen(true);
|
|
131
135
|
};
|
|
132
136
|
const onInputChange = inputValue => {
|
|
133
|
-
var _inputValue$newsReadi;
|
|
134
137
|
const contentState = editorState.getCurrentContent();
|
|
135
138
|
const contentStateWithEntity = contentState.createEntity('NEWS_READING', 'IMMUTABLE', {
|
|
136
139
|
newsReadingGroupId: inputValue.newsReadingGroupId,
|
|
137
|
-
readings:
|
|
140
|
+
readings: inputValue?.newsReadingGroup?.items || []
|
|
138
141
|
});
|
|
139
142
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
140
143
|
const newEditorState = _draftJs.EditorState.set(editorState, {
|
|
@@ -149,17 +152,22 @@ function NewsReadingButton(props) {
|
|
|
149
152
|
const onInputCancel = () => {
|
|
150
153
|
setIsInputOpen(false);
|
|
151
154
|
};
|
|
152
|
-
return /*#__PURE__*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
156
|
+
children: [isInputOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(NewsReadingInput, {
|
|
157
|
+
isOpen: isInputOpen,
|
|
158
|
+
onConfirm: onInputChange,
|
|
159
|
+
onCancel: onInputCancel,
|
|
160
|
+
inputValue: ""
|
|
161
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
162
|
+
onClick: () => {
|
|
163
|
+
promptForInput();
|
|
164
|
+
},
|
|
165
|
+
className: className,
|
|
166
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
167
|
+
className: "far"
|
|
168
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
169
|
+
children: "\u8B80\u5831"
|
|
170
|
+
})]
|
|
171
|
+
})]
|
|
172
|
+
});
|
|
165
173
|
}
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AlignSelector = AlignSelector;
|
|
7
|
+
var _fields = require("@keystone-ui/fields");
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var
|
|
10
|
-
function _interopRequireDefault(
|
|
11
|
-
function
|
|
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; }
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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); }
|
|
13
13
|
const Label = _styledComponents.default.label`
|
|
14
14
|
display: block;
|
|
15
15
|
margin: 10px 0;
|
|
@@ -44,19 +44,22 @@ function AlignSelector(props) {
|
|
|
44
44
|
onOpen();
|
|
45
45
|
}
|
|
46
46
|
}, [isOpen]);
|
|
47
|
-
return /*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
|
|
49
|
+
htmlFor: "alignment",
|
|
50
|
+
children: "\u5C0D\u9F4A"
|
|
51
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(AlignSelect, {
|
|
52
|
+
id: "alignment"
|
|
53
|
+
// default align === undefined
|
|
54
|
+
,
|
|
55
|
+
value: options.find(option => option.value === align) || null,
|
|
56
|
+
options: options,
|
|
57
|
+
onChange: option => {
|
|
58
|
+
onChange(option.value);
|
|
59
|
+
},
|
|
60
|
+
onMenuOpen: () => setIsOpen(true),
|
|
61
|
+
onMenuClose: () => setIsOpen(false),
|
|
62
|
+
menuHeight: menuHeight
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
62
65
|
}
|