@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
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ImageAlignment = exports.ImageAlignOptions = void 0;
|
|
7
7
|
exports.ImageSelector = ImageSelector;
|
|
8
|
-
var
|
|
8
|
+
var _apollo = require("@keystone-6/core/admin-ui/apollo");
|
|
9
|
+
var _modals = require("@keystone-ui/modals");
|
|
9
10
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
var _modals = require("@keystone-ui/modals");
|
|
12
|
-
var _apollo = require("@keystone-6/core/admin-ui/apollo");
|
|
13
13
|
var _alignSelector = require("./align-selector");
|
|
14
|
-
var _searchBox = require("./search-box");
|
|
15
14
|
var _pagination = require("./pagination");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
15
|
+
var _searchBox = require("./search-box");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
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); }
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
let ImageAlignment = exports.ImageAlignment = /*#__PURE__*/function (ImageAlignment) {
|
|
20
20
|
ImageAlignment["DEFAULT"] = "default";
|
|
21
21
|
ImageAlignment["PARAGRAPH"] = "paragraph-width";
|
|
@@ -87,15 +87,16 @@ function ImageGrids(props) {
|
|
|
87
87
|
images,
|
|
88
88
|
onSelect
|
|
89
89
|
} = props;
|
|
90
|
-
return /*#__PURE__*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridsBlock, {
|
|
91
|
+
children: images.map(image => {
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridBlock, {
|
|
93
|
+
onClick: () => onSelect(image),
|
|
94
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Img, {
|
|
95
|
+
src: image?.imageFile?.url
|
|
96
|
+
})
|
|
97
|
+
}, image.id);
|
|
98
|
+
})
|
|
99
|
+
});
|
|
99
100
|
}
|
|
100
101
|
function ImageMetaGrids(props) {
|
|
101
102
|
const {
|
|
@@ -104,35 +105,39 @@ function ImageMetaGrids(props) {
|
|
|
104
105
|
enableCaption,
|
|
105
106
|
enableDelete
|
|
106
107
|
} = props;
|
|
107
|
-
return /*#__PURE__*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridsBlock, {
|
|
109
|
+
children: imageMetas.map((imageMeta, idx) => {
|
|
110
|
+
const {
|
|
111
|
+
desc,
|
|
112
|
+
url
|
|
113
|
+
} = imageMeta;
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridBlock, {
|
|
115
|
+
children: [enableDelete && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
116
|
+
onClick: () => {
|
|
117
|
+
onChange(imageMeta, 'delete');
|
|
118
|
+
},
|
|
119
|
+
className: "fas fa-check-circle"
|
|
120
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Img, {
|
|
121
|
+
src: imageMeta?.imageFile?.url
|
|
122
|
+
}), enableCaption && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
123
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
|
|
124
|
+
htmlFor: "caption",
|
|
125
|
+
children: "Image Caption:"
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
|
|
127
|
+
id: "caption",
|
|
128
|
+
placeholder: imageMeta?.name,
|
|
129
|
+
defaultValue: desc,
|
|
130
|
+
onChange: _.debounce(e => {
|
|
131
|
+
onChange(Object.assign({}, imageMeta, {
|
|
132
|
+
desc: e.target.value,
|
|
133
|
+
url
|
|
134
|
+
}), 'modify');
|
|
135
|
+
})
|
|
136
|
+
})]
|
|
137
|
+
})]
|
|
138
|
+
}, idx);
|
|
139
|
+
})
|
|
140
|
+
});
|
|
136
141
|
}
|
|
137
142
|
const imagesQuery = (0, _apollo.gql)`
|
|
138
143
|
query Photos($searchText: String!, $take: Int, $skip: Int) {
|
|
@@ -197,10 +202,9 @@ function ImageSelector(props) {
|
|
|
197
202
|
setAlign(align);
|
|
198
203
|
};
|
|
199
204
|
const onAlignSelectOpen = () => {
|
|
200
|
-
|
|
201
|
-
const scrollWrapper = (_contentWrapperRef$cu = contentWrapperRef.current) === null || _contentWrapperRef$cu === void 0 ? void 0 : _contentWrapperRef$cu.parentElement;
|
|
205
|
+
const scrollWrapper = contentWrapperRef.current?.parentElement;
|
|
202
206
|
if (scrollWrapper) {
|
|
203
|
-
scrollWrapper.scrollTop = scrollWrapper
|
|
207
|
+
scrollWrapper.scrollTop = scrollWrapper?.scrollHeight;
|
|
204
208
|
}
|
|
205
209
|
};
|
|
206
210
|
const changeSelectedImage = (imageEntityWithMeta, actionType) => {
|
|
@@ -245,51 +249,77 @@ function ImageSelector(props) {
|
|
|
245
249
|
});
|
|
246
250
|
}
|
|
247
251
|
}, [currentPage, searchText]);
|
|
248
|
-
let searchResult = /*#__PURE__*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
252
|
+
let searchResult = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
253
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ImageGrids, {
|
|
254
|
+
images: images,
|
|
255
|
+
onSelect: selectImage
|
|
256
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_pagination.Pagination, {
|
|
257
|
+
currentPage: currentPage,
|
|
258
|
+
total: imagesCount,
|
|
259
|
+
pageSize: pageSize,
|
|
260
|
+
onChange: pageIndex => {
|
|
261
|
+
setCurrentPage(pageIndex);
|
|
262
|
+
}
|
|
263
|
+
})]
|
|
264
|
+
});
|
|
259
265
|
if (loading) {
|
|
260
|
-
searchResult = /*#__PURE__*/
|
|
266
|
+
searchResult = /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
267
|
+
children: "searching..."
|
|
268
|
+
});
|
|
261
269
|
}
|
|
262
270
|
if (error) {
|
|
263
|
-
|
|
264
|
-
|
|
271
|
+
searchResult = /*#__PURE__*/(0, _jsxRuntime.jsxs)(ErrorWrapper, {
|
|
272
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
|
|
273
|
+
children: "Errors occurs in the `images` query"
|
|
274
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
275
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
276
|
+
children: "Message:"
|
|
277
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
278
|
+
children: error.message
|
|
279
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
280
|
+
children: "Stack:"
|
|
281
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
282
|
+
children: error.stack
|
|
283
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
284
|
+
children: "Query:"
|
|
285
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
|
|
286
|
+
children: imagesQuery.loc?.source.body
|
|
287
|
+
})]
|
|
288
|
+
})]
|
|
289
|
+
});
|
|
265
290
|
}
|
|
266
|
-
return /*#__PURE__*/
|
|
267
|
-
isOpen: true
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
291
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
|
|
292
|
+
isOpen: true,
|
|
293
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.Drawer, {
|
|
294
|
+
title: "Select image",
|
|
295
|
+
actions: {
|
|
296
|
+
cancel: {
|
|
297
|
+
label: 'Cancel',
|
|
298
|
+
action: onCancel
|
|
299
|
+
},
|
|
300
|
+
confirm: {
|
|
301
|
+
label: 'Confirm',
|
|
302
|
+
action: onSave
|
|
303
|
+
}
|
|
274
304
|
},
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
})
|
|
305
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
306
|
+
ref: contentWrapperRef,
|
|
307
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SearchBox, {
|
|
308
|
+
onChange: onSearchBoxChange
|
|
309
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(MainBlock, {
|
|
310
|
+
children: [searchResult, selected.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(SeparationLine, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageMetaGrids, {
|
|
311
|
+
imageMetas: selected,
|
|
312
|
+
onChange: changeSelectedImage,
|
|
313
|
+
enableCaption: enableCaption,
|
|
314
|
+
enableDelete: enableMultiSelect
|
|
315
|
+
})]
|
|
316
|
+
}), enableAlignment && /*#__PURE__*/(0, _jsxRuntime.jsx)(_alignSelector.AlignSelector, {
|
|
317
|
+
align: align,
|
|
318
|
+
options: ImageAlignOptions,
|
|
319
|
+
onChange: onAlignSelectChange,
|
|
320
|
+
onOpen: onAlignSelectOpen
|
|
321
|
+
})]
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
});
|
|
295
325
|
}
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Pagination = Pagination;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
const PaginationWrapper = _styledComponents.default.div`
|
|
11
12
|
display: flex;
|
|
12
13
|
justify-content: end;
|
|
@@ -27,6 +28,7 @@ const ArrowButtonWrapper = _styledComponents.default.a`
|
|
|
27
28
|
cursor: unset;
|
|
28
29
|
`;
|
|
29
30
|
}
|
|
31
|
+
return '';
|
|
30
32
|
}}
|
|
31
33
|
`;
|
|
32
34
|
function Pagination({
|
|
@@ -42,37 +44,47 @@ function Pagination({
|
|
|
42
44
|
|
|
43
45
|
// Don't render the pagiantion component if the pageSize is greater than the total number of items in the list.
|
|
44
46
|
if (total <= pageSize) return null;
|
|
45
|
-
return /*#__PURE__*/
|
|
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
|
-
|
|
77
|
-
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PaginationWrapper, {
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
49
|
+
children: [currentPage, " of ", limit, " pages"]
|
|
50
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Arrows, {
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ArrowButtonWrapper, {
|
|
52
|
+
onClick: () => {
|
|
53
|
+
onChange(prevPage);
|
|
54
|
+
},
|
|
55
|
+
disable: prevPage < minPage,
|
|
56
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
focusable: "false",
|
|
59
|
+
height: "24px",
|
|
60
|
+
width: "24px",
|
|
61
|
+
role: "img",
|
|
62
|
+
viewBox: "0 0 24 24",
|
|
63
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
64
|
+
className: "css-bztyua",
|
|
65
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
|
|
66
|
+
points: "15 18 9 12 15 6"
|
|
67
|
+
}), ' ']
|
|
68
|
+
})
|
|
69
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ArrowButtonWrapper, {
|
|
70
|
+
onClick: () => {
|
|
71
|
+
onChange(nextPage);
|
|
72
|
+
},
|
|
73
|
+
disable: nextPage > limit,
|
|
74
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
focusable: "false",
|
|
77
|
+
height: "24px",
|
|
78
|
+
width: "24px",
|
|
79
|
+
role: "img",
|
|
80
|
+
viewBox: "0 0 24 24",
|
|
81
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
82
|
+
className: "css-bztyua",
|
|
83
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
|
|
84
|
+
points: "9 18 15 12 9 6"
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
})]
|
|
89
|
+
});
|
|
78
90
|
}
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SearchBox = SearchBox;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
7
|
var _button = require("@keystone-ui/button");
|
|
10
8
|
var _fields = require("@keystone-ui/fields");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
const SearchBoxWrapper = _styledComponents.default.div`
|
|
15
14
|
display: flex;
|
|
16
15
|
`;
|
|
@@ -20,18 +19,20 @@ function SearchBox(props) {
|
|
|
20
19
|
className
|
|
21
20
|
} = props;
|
|
22
21
|
const [searchInput, setSearchInput] = (0, _react.useState)('');
|
|
23
|
-
return /*#__PURE__*/
|
|
24
|
-
className: className
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(SearchBoxWrapper, {
|
|
23
|
+
className: className,
|
|
24
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextInput, {
|
|
25
|
+
type: "text",
|
|
26
|
+
placeholder: "\u8ACB\u8F38\u5165\u95DC\u9375\u5B57\u641C\u5C0B",
|
|
27
|
+
value: searchInput,
|
|
28
|
+
onChange: e => {
|
|
29
|
+
setSearchInput(e.target.value);
|
|
30
|
+
}
|
|
31
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
32
|
+
onClick: () => {
|
|
33
|
+
onChange(searchInput);
|
|
34
|
+
},
|
|
35
|
+
children: "Search"
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
37
38
|
}
|
package/lib/buttons/slideshow.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SlideshowButton = SlideshowButton;
|
|
7
|
+
var _draftJs = require("draft-js");
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _imageSelector = require("./selector/image-selector");
|
|
9
|
-
var
|
|
10
|
-
function
|
|
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; }
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
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); }
|
|
12
12
|
function SlideshowButton(props) {
|
|
13
13
|
const {
|
|
14
14
|
editorState,
|
|
@@ -41,15 +41,20 @@ function SlideshowButton(props) {
|
|
|
41
41
|
onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
|
|
42
42
|
setToShowImageSelector(false);
|
|
43
43
|
};
|
|
44
|
-
return /*#__PURE__*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
45
|
+
children: [toShowImageSelector && /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageSelector, {
|
|
46
|
+
onChange: onImageSelectorChange,
|
|
47
|
+
enableCaption: true,
|
|
48
|
+
enableMultiSelect: true,
|
|
49
|
+
enableAlignment: false
|
|
50
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
51
|
+
className: className,
|
|
52
|
+
onClick: promptForImageSelector,
|
|
53
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
54
|
+
className: "far fa-images"
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
56
|
+
children: " Slideshow"
|
|
57
|
+
})]
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
55
60
|
}
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TOCAnchorButton = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _draftJs = require("draft-js");
|
|
9
7
|
var _draftRenderer = require("@kids-reporter/draft-renderer");
|
|
10
|
-
|
|
8
|
+
var _draftJs = require("draft-js");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
const TOCAnchorButton = props => {
|
|
12
13
|
const toggleEntity = _draftJs.RichUtils.toggleLink;
|
|
13
14
|
const {
|
|
@@ -42,10 +43,13 @@ const TOCAnchorButton = props => {
|
|
|
42
43
|
onChange(toggleEntity(editorState, selection, null));
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
return /*#__PURE__*/
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
46
47
|
className: props.className,
|
|
47
48
|
onMouseDown: isActive ? removeAnchor : promptForAnchor,
|
|
48
|
-
title: "\u7D22\u5F15"
|
|
49
|
-
|
|
49
|
+
title: "\u7D22\u5F15",
|
|
50
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
51
|
+
children: "\u7D22"
|
|
52
|
+
})
|
|
53
|
+
});
|
|
50
54
|
};
|
|
51
55
|
exports.TOCAnchorButton = TOCAnchorButton;
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.editableAnchorDecorator = exports.AnchorIDEditor = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _modals = require("@keystone-ui/modals");
|
|
10
7
|
var _fields = require("@keystone-ui/fields");
|
|
8
|
+
var _modals = require("@keystone-ui/modals");
|
|
11
9
|
var _draftRenderer = require("@kids-reporter/draft-renderer");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
const AnchorWrapper = _styledComponents.default.span`
|
|
16
16
|
display: inline;
|
|
17
17
|
color: #8e8e8e;
|
|
@@ -51,7 +51,7 @@ const AnchorIDEditor = props => {
|
|
|
51
51
|
const idRex = /^[A-Za-z][\w-]*$/;
|
|
52
52
|
return idRex.test(id);
|
|
53
53
|
};
|
|
54
|
-
return /*#__PURE__*/
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_modals.AlertDialog, {
|
|
55
55
|
title: "\u7DE8\u8F2F\u9328\u9EDE\u6587\u5B57(ID)",
|
|
56
56
|
isOpen: isOpen,
|
|
57
57
|
actions: {
|
|
@@ -69,17 +69,23 @@ const AnchorIDEditor = props => {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
},
|
|
73
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Warning, {
|
|
74
|
+
children: "\u6CE8\u610F\uFF01\u540C\u7BC7\u6587\u7AE0ID\u4E0D\u53EF\u91CD\u8907\uFF01ID\u9700\u4F7F\u7528\u534A\u578B\u82F1\u6587\u5B57\u6BCD(\u5927/\u5C0F\u5BEB)\u958B\u982D\uFF0C\u63A5\u7E8C \u82F1\u6587\u5B57\u6BCD/\u6578\u5B57/-/_"
|
|
75
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
76
|
+
children: "\u7BC4\u4F8B: part1, Section-234, table_5"
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledTextInput, {
|
|
78
|
+
placeholder: "\u9328\u9EDE\u6587\u5B57(ID)",
|
|
79
|
+
type: "text",
|
|
80
|
+
value: anchorID,
|
|
81
|
+
onChange: e => setAnchorID(e.target.value)
|
|
82
|
+
}), msg && /*#__PURE__*/(0, _jsxRuntime.jsx)(Warning, {
|
|
83
|
+
children: msg
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
79
86
|
};
|
|
80
87
|
exports.AnchorIDEditor = AnchorIDEditor;
|
|
81
88
|
const EditableAnchor = props => {
|
|
82
|
-
var _contentState$getEnti;
|
|
83
89
|
const {
|
|
84
90
|
children,
|
|
85
91
|
contentState,
|
|
@@ -87,10 +93,9 @@ const EditableAnchor = props => {
|
|
|
87
93
|
} = props;
|
|
88
94
|
const tocContent = props.decoratedText;
|
|
89
95
|
const [isModalOpen, setIsModalOpen] = (0, _react.useState)(false);
|
|
90
|
-
const [anchorID, setAnchorID] = (0, _react.useState)(contentState
|
|
96
|
+
const [anchorID, setAnchorID] = (0, _react.useState)(contentState?.getEntity(entityKey)?.getData()?.anchorID);
|
|
91
97
|
(0, _react.useEffect)(() => {
|
|
92
|
-
|
|
93
|
-
setAnchorID((_contentState$getEnti2 = contentState.getEntity(entityKey).getData()) === null || _contentState$getEnti2 === void 0 ? void 0 : _contentState$getEnti2.anchorID);
|
|
98
|
+
setAnchorID(contentState.getEntity(entityKey).getData()?.anchorID);
|
|
94
99
|
});
|
|
95
100
|
const onAnchorIDChange = anchorID => {
|
|
96
101
|
setIsModalOpen(false);
|
|
@@ -102,24 +107,31 @@ const EditableAnchor = props => {
|
|
|
102
107
|
}
|
|
103
108
|
});
|
|
104
109
|
};
|
|
105
|
-
return /*#__PURE__*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
111
|
+
children: [isModalOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(AnchorIDEditor, {
|
|
112
|
+
isOpen: isModalOpen,
|
|
113
|
+
anchorIDValue: anchorID,
|
|
114
|
+
onConfirm: onAnchorIDChange,
|
|
115
|
+
onCancel: () => {
|
|
116
|
+
setIsModalOpen(false);
|
|
117
|
+
props.onEditFinish();
|
|
118
|
+
}
|
|
119
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(AnchorWrapper, {
|
|
120
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AnchorEditButton, {
|
|
121
|
+
anchorLabel: anchorID !== tocContent ? anchorID : undefined,
|
|
122
|
+
onClick: e => {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
setIsModalOpen(true);
|
|
125
|
+
props.onEditStart();
|
|
126
|
+
},
|
|
127
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
128
|
+
className: "fas fa-pen"
|
|
129
|
+
})
|
|
130
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
131
|
+
children: children
|
|
132
|
+
})]
|
|
133
|
+
})]
|
|
134
|
+
});
|
|
123
135
|
};
|
|
124
136
|
const editableAnchorDecorator = exports.editableAnchorDecorator = {
|
|
125
137
|
strategy: (0, _draftRenderer.findEntitiesByType)(_draftRenderer.ENTITY.Anchor),
|