@mirrormedia/lilith-draft-editor 3.0.7 → 3.0.8
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/draft-js/buttons/annotation.js +3 -1
- package/lib/draft-js/buttons/embedded-code.js +3 -1
- package/lib/draft-js/buttons/image.js +18 -20
- package/lib/draft-js/buttons/info-box.js +3 -1
- package/lib/website/mirrordaily/selector/image-selector.js +5 -26
- package/lib/website/mirrordaily/selector/video-selector.js +7 -30
- package/lib/website/mirrormedia/draft-editor.js +312 -338
- package/package.json +1 -2
- package/lib/website/mirrordaily/selector/image-uploader.js +0 -247
- package/lib/website/mirrordaily/selector/video-uploader.js +0 -188
- package/lib/website/mirrordaily/utils/file-convert.js +0 -86
|
@@ -112,5 +112,7 @@ function AnnotationButton(props) {
|
|
|
112
112
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, urlInput, /*#__PURE__*/_react.default.createElement("div", {
|
|
113
113
|
className: className,
|
|
114
114
|
onMouseDown: isActive ? removeAnnotation : promptForAnnotation
|
|
115
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
116
|
+
className: "far"
|
|
117
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, "Annotation")));
|
|
116
118
|
}
|
|
@@ -103,5 +103,7 @@ function EmbeddedCodeButton(props) {
|
|
|
103
103
|
promptForInput();
|
|
104
104
|
},
|
|
105
105
|
className: className
|
|
106
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
107
|
+
className: "far"
|
|
108
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, "Embed")));
|
|
107
109
|
}
|
|
@@ -28,30 +28,29 @@ function ImageButton(props) {
|
|
|
28
28
|
setToShowImageSelector(true);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const onImageSelectorChange = (
|
|
32
|
-
|
|
31
|
+
const onImageSelectorChange = (selectedImagesWithMeta, align) => {
|
|
32
|
+
const selected = selectedImagesWithMeta === null || selectedImagesWithMeta === void 0 ? void 0 : selectedImagesWithMeta[0];
|
|
33
|
+
|
|
34
|
+
if (!selected) {
|
|
33
35
|
setToShowImageSelector(false);
|
|
36
|
+
return;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
const contentState = editorState.getCurrentContent();
|
|
40
|
+
const contentStateWithEntity = contentState.createEntity('image', 'IMMUTABLE', { ...selected.image,
|
|
41
|
+
desc: selected.desc,
|
|
42
|
+
url: selected.url,
|
|
43
|
+
alignment: align
|
|
44
|
+
});
|
|
45
|
+
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
url: selectedImage.url,
|
|
43
|
-
alignment: align
|
|
44
|
-
});
|
|
45
|
-
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
46
|
-
newEditorState = _draftJs.EditorState.set(newEditorState, {
|
|
47
|
-
currentContent: contentStateWithEntity
|
|
48
|
-
}); // The third parameter here is a space string, not an empty string
|
|
49
|
-
// If you set an empty string, you will get an error: Unknown DraftEntity key: null
|
|
47
|
+
const newEditorState = _draftJs.EditorState.set(editorState, {
|
|
48
|
+
currentContent: contentStateWithEntity
|
|
49
|
+
}); // The third parameter here is a space string, not an empty string
|
|
50
|
+
// If you set an empty string, you will get an error: Unknown DraftEntity key: null
|
|
50
51
|
|
|
51
|
-
newEditorState = _draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' ');
|
|
52
|
-
}
|
|
53
52
|
|
|
54
|
-
onChange(newEditorState);
|
|
53
|
+
onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
|
|
55
54
|
setToShowImageSelector(false);
|
|
56
55
|
};
|
|
57
56
|
|
|
@@ -59,8 +58,7 @@ function ImageButton(props) {
|
|
|
59
58
|
onChange: onImageSelectorChange,
|
|
60
59
|
enableCaption: true,
|
|
61
60
|
enableUrl: true,
|
|
62
|
-
enableAlignment: true
|
|
63
|
-
enableMultiSelect: true
|
|
61
|
+
enableAlignment: true
|
|
64
62
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
65
63
|
className: className,
|
|
66
64
|
onClick: promptForImageSelector
|
|
@@ -142,5 +142,7 @@ function InfoBoxButton(props) {
|
|
|
142
142
|
onClick: () => {
|
|
143
143
|
setToShowInput(true);
|
|
144
144
|
}
|
|
145
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
145
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
146
|
+
className: "far"
|
|
147
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, "InfoBox")));
|
|
146
148
|
}
|
|
@@ -23,10 +23,6 @@ var _searchBox = require("./search-box");
|
|
|
23
23
|
|
|
24
24
|
var _pagination = require("./pagination");
|
|
25
25
|
|
|
26
|
-
var _button = require("@keystone-ui/button");
|
|
27
|
-
|
|
28
|
-
var _imageUploader = require("./image-uploader");
|
|
29
|
-
|
|
30
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
27
|
|
|
32
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -81,9 +77,6 @@ const GlobalStyle = (0, _styledComponents.createGlobalStyle)`
|
|
|
81
77
|
const ImageSearchBox = (0, _styledComponents.default)(_searchBox.SearchBox)`
|
|
82
78
|
margin-top: 10px;
|
|
83
79
|
`;
|
|
84
|
-
const CustomButton = (0, _styledComponents.default)(_button.Button)`
|
|
85
|
-
margin-top: 10px;
|
|
86
|
-
`;
|
|
87
80
|
const ImageSelectionWrapper = _styledComponents.default.div`
|
|
88
81
|
overflow: auto;
|
|
89
82
|
margin-top: 10px;
|
|
@@ -96,7 +89,7 @@ const ImageGridsWrapper = _styledComponents.default.div`
|
|
|
96
89
|
margin-top: 5px;
|
|
97
90
|
`;
|
|
98
91
|
const ImageGridWrapper = _styledComponents.default.div`
|
|
99
|
-
|
|
92
|
+
flex: 0 0 33.3333%;
|
|
100
93
|
cursor: pointer;
|
|
101
94
|
padding: 0 10px 10px;
|
|
102
95
|
`;
|
|
@@ -106,7 +99,7 @@ const ImageMetaGridsWrapper = _styledComponents.default.div`
|
|
|
106
99
|
overflow: auto;
|
|
107
100
|
`;
|
|
108
101
|
const ImageMetaGridWrapper = _styledComponents.default.div`
|
|
109
|
-
|
|
102
|
+
flex: 0 0 33.3333%;
|
|
110
103
|
cursor: pointer;
|
|
111
104
|
padding: 0 10px 10px;
|
|
112
105
|
`;
|
|
@@ -114,7 +107,7 @@ const Image = _styledComponents.default.img`
|
|
|
114
107
|
display: block;
|
|
115
108
|
width: 100%;
|
|
116
109
|
aspect-ratio: 2;
|
|
117
|
-
object-fit:
|
|
110
|
+
object-fit: cover;
|
|
118
111
|
`;
|
|
119
112
|
const Label = _styledComponents.default.label`
|
|
120
113
|
display: block;
|
|
@@ -294,7 +287,6 @@ function ImageSelector(props) {
|
|
|
294
287
|
const [selected, setSelected] = (0, _react.useState)(initialSelected);
|
|
295
288
|
const [delay, setDelay] = (0, _react.useState)(initialDelay ?? '5');
|
|
296
289
|
const [align, setAlign] = (0, _react.useState)(initialAlign);
|
|
297
|
-
const [showImageUploader, setShowImageUploader] = (0, _react.useState)(false);
|
|
298
290
|
const contentWrapperRef = (0, _react.useRef)(null);
|
|
299
291
|
const pageSize = 18;
|
|
300
292
|
const options = [{
|
|
@@ -344,15 +336,6 @@ function ImageSelector(props) {
|
|
|
344
336
|
}
|
|
345
337
|
};
|
|
346
338
|
|
|
347
|
-
const onImageUploaderChange = images => {
|
|
348
|
-
setSelected(prev => prev.concat(images.map(image => ({
|
|
349
|
-
image,
|
|
350
|
-
desc: '',
|
|
351
|
-
url: ''
|
|
352
|
-
}))));
|
|
353
|
-
setShowImageUploader(false);
|
|
354
|
-
};
|
|
355
|
-
|
|
356
339
|
const onImageMetaChange = imageEntityWithMeta => {
|
|
357
340
|
if (enableMultiSelect) {
|
|
358
341
|
const foundIndex = selected.findIndex(ele => {
|
|
@@ -455,9 +438,7 @@ function ImageSelector(props) {
|
|
|
455
438
|
width: "narrow"
|
|
456
439
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
457
440
|
ref: contentWrapperRef
|
|
458
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
459
|
-
onClick: () => setShowImageUploader(true)
|
|
460
|
-
}, "\u4E0A\u50B3\u5716\u7247"), /*#__PURE__*/_react.default.createElement(ImageSearchBox, {
|
|
441
|
+
}, /*#__PURE__*/_react.default.createElement(ImageSearchBox, {
|
|
461
442
|
onChange: onSearchBoxChange
|
|
462
443
|
}), /*#__PURE__*/_react.default.createElement(ImageSelectionWrapper, null, /*#__PURE__*/_react.default.createElement("div", null, searchResult), !!selected.length && /*#__PURE__*/_react.default.createElement(SeparationLine, null), /*#__PURE__*/_react.default.createElement(ImageMetaGrids, {
|
|
463
444
|
imageMetas: selected,
|
|
@@ -474,7 +455,5 @@ function ImageSelector(props) {
|
|
|
474
455
|
options: options,
|
|
475
456
|
onChange: onAlignSelectChange,
|
|
476
457
|
onOpen: onAlignSelectOpen
|
|
477
|
-
})))))
|
|
478
|
-
onChange: onImageUploaderChange
|
|
479
|
-
}));
|
|
458
|
+
}))))));
|
|
480
459
|
}
|
|
@@ -21,10 +21,6 @@ var _pagination = require("./pagination");
|
|
|
21
21
|
|
|
22
22
|
var _fields = require("@keystone-ui/fields");
|
|
23
23
|
|
|
24
|
-
var _videoUploader = require("./video-uploader");
|
|
25
|
-
|
|
26
|
-
var _button = require("@keystone-ui/button");
|
|
27
|
-
|
|
28
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
25
|
|
|
30
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -33,11 +29,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
33
29
|
|
|
34
30
|
const videosQuery = (0, _apollo.gql)`
|
|
35
31
|
query Videos($searchText: String!, $take: Int, $skip: Int) {
|
|
36
|
-
videosCount(
|
|
37
|
-
where: { name: { contains: $searchText }, state: { equals: "published" } }
|
|
38
|
-
)
|
|
32
|
+
videosCount(where: { name: { contains: $searchText } })
|
|
39
33
|
videos(
|
|
40
|
-
where: { name: { contains: $searchText }
|
|
34
|
+
where: { name: { contains: $searchText } }
|
|
41
35
|
orderBy: { id: desc }
|
|
42
36
|
take: $take
|
|
43
37
|
skip: $skip
|
|
@@ -45,7 +39,6 @@ const videosQuery = (0, _apollo.gql)`
|
|
|
45
39
|
id
|
|
46
40
|
name
|
|
47
41
|
videoSrc
|
|
48
|
-
youtubeUrl
|
|
49
42
|
file {
|
|
50
43
|
filename
|
|
51
44
|
filesize
|
|
@@ -77,9 +70,6 @@ const GlobalStyle = (0, _styledComponents.createGlobalStyle)`
|
|
|
77
70
|
const VideoSearchBox = (0, _styledComponents.default)(_searchBox.SearchBox)`
|
|
78
71
|
margin-top: 10px;
|
|
79
72
|
`;
|
|
80
|
-
const CustomButton = (0, _styledComponents.default)(_button.Button)`
|
|
81
|
-
margin-top: 10px;
|
|
82
|
-
`;
|
|
83
73
|
const VideoSelectionWrapper = _styledComponents.default.div`
|
|
84
74
|
overflow: auto;
|
|
85
75
|
margin-top: 10px;
|
|
@@ -90,7 +80,7 @@ const VideoGridsWrapper = _styledComponents.default.div`
|
|
|
90
80
|
overflow: auto;
|
|
91
81
|
`;
|
|
92
82
|
const VideoGridWrapper = _styledComponents.default.div`
|
|
93
|
-
|
|
83
|
+
flex: 0 0 33.3333%;
|
|
94
84
|
cursor: pointer;
|
|
95
85
|
padding: 0 10px 10px;
|
|
96
86
|
`;
|
|
@@ -100,7 +90,7 @@ const VideoMetaGridsWrapper = _styledComponents.default.div`
|
|
|
100
90
|
overflow: auto;
|
|
101
91
|
`;
|
|
102
92
|
const VideoMetaGridWrapper = _styledComponents.default.div`
|
|
103
|
-
|
|
93
|
+
flex: 0 0 33.3333%;
|
|
104
94
|
cursor: pointer;
|
|
105
95
|
padding: 0 10px 10px;
|
|
106
96
|
`;
|
|
@@ -108,7 +98,7 @@ const Video = _styledComponents.default.video`
|
|
|
108
98
|
display: block;
|
|
109
99
|
width: 100%;
|
|
110
100
|
aspect-ratio: 2;
|
|
111
|
-
object-fit:
|
|
101
|
+
object-fit: cover;
|
|
112
102
|
`;
|
|
113
103
|
const SeparationLine = _styledComponents.default.div`
|
|
114
104
|
border: #e1e5e9 1px solid;
|
|
@@ -240,7 +230,6 @@ function VideoSelector(props) {
|
|
|
240
230
|
|
|
241
231
|
const [searchText, setSearchText] = (0, _react.useState)('');
|
|
242
232
|
const [selected, setSelected] = (0, _react.useState)([]);
|
|
243
|
-
const [showVideoUploader, setShowVideoUploader] = (0, _react.useState)(false);
|
|
244
233
|
const pageSize = 6;
|
|
245
234
|
const {
|
|
246
235
|
onChange
|
|
@@ -259,14 +248,6 @@ function VideoSelector(props) {
|
|
|
259
248
|
setCurrentPage(1);
|
|
260
249
|
};
|
|
261
250
|
|
|
262
|
-
const onVideoUploaderChange = video => {
|
|
263
|
-
if (video) setSelected(prev => [...prev, {
|
|
264
|
-
video,
|
|
265
|
-
desc: ''
|
|
266
|
-
}]);
|
|
267
|
-
setShowVideoUploader(false);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
251
|
const onVideoMetaChange = videoEntityWithMeta => {
|
|
271
252
|
setSelected([videoEntityWithMeta]);
|
|
272
253
|
};
|
|
@@ -344,14 +325,10 @@ function VideoSelector(props) {
|
|
|
344
325
|
}
|
|
345
326
|
},
|
|
346
327
|
width: "narrow"
|
|
347
|
-
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(
|
|
348
|
-
onClick: () => setShowVideoUploader(true)
|
|
349
|
-
}, "\u4E0A\u50B3\u5F71\u7247"), /*#__PURE__*/_react.default.createElement(VideoSearchBox, {
|
|
328
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(VideoSearchBox, {
|
|
350
329
|
onChange: onSearchBoxChange
|
|
351
330
|
}), /*#__PURE__*/_react.default.createElement(VideoSelectionWrapper, null, /*#__PURE__*/_react.default.createElement("div", null, searchResult), !!selected.length && /*#__PURE__*/_react.default.createElement(SeparationLine, null), /*#__PURE__*/_react.default.createElement(VideoMetaGrids, {
|
|
352
331
|
videoMetas: selected,
|
|
353
332
|
onChange: onVideoMetaChange
|
|
354
|
-
})))))
|
|
355
|
-
onChange: onVideoUploaderChange
|
|
356
|
-
}));
|
|
333
|
+
}))))));
|
|
357
334
|
}
|