@mirrormedia/lilith-draft-editor 1.1.0-alpha.8 → 1.2.0
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/audio.js +3 -2
- package/lib/draft-js/buttons/image.js +3 -3
- package/lib/draft-js/buttons/link.js +49 -22
- package/lib/draft-js/buttons/selector/audio-selector.js +5 -0
- package/lib/draft-js/buttons/selector/image-selector.js +14 -10
- package/lib/draft-js/buttons/video.js +3 -2
- package/lib/draft-js/buttons/youtube.js +147 -0
- package/lib/draft-js/draft-converter/atomic-block-processor.js +15 -34
- package/lib/draft-js/draft-converter/entities.js +6 -0
- package/lib/draft-js/util.js +32 -0
- package/lib/website/mirrormedia/block-renderer/embedded-code-block.js +3 -0
- package/lib/website/mirrormedia/block-renderer/image-block.js +108 -0
- package/lib/website/mirrormedia/block-renderer/slideshow-block.js +85 -6
- package/lib/website/mirrormedia/block-renderer-fn.js +24 -5
- package/lib/website/mirrormedia/draft-editor.js +26 -2
- package/lib/website/mirrormedia/entity-decorator.js +8 -1
- package/lib/website/mirrormedia/selector/audio-selector.js +4 -3
- package/lib/website/mirrormedia/selector/image-selector.js +26 -12
- package/lib/website/mirrormedia/selector/post-selector.js +1 -0
- package/lib/website/mirrormedia/selector/video-selector.js +4 -3
- package/lib/website/mirrormedia/shared-style/index.js +17 -0
- package/lib/website/readr/block-renderer/background-image-block.js +53 -5
- package/lib/website/readr/block-renderer/background-video-block.js +63 -5
- package/lib/website/readr/block-renderer/image-block.js +106 -0
- package/lib/website/readr/block-renderer-fn.js +3 -2
- package/lib/website/readr/selector/audio-selector.js +1 -0
- package/lib/website/readr/selector/image-selector.js +13 -10
- package/lib/website/readr/selector/post-selector.js +3 -9
- package/lib/website/readr/selector/video-selector.js +1 -0
- package/lib/website/readr/theme/index.js +11 -0
- package/package.json +9 -9
|
@@ -38,8 +38,9 @@ function AudioButton(props) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const contentState = editorState.getCurrentContent();
|
|
42
|
-
|
|
41
|
+
const contentState = editorState.getCurrentContent(); // since 202310, only AUDIO-V2 will be created
|
|
42
|
+
|
|
43
|
+
const contentStateWithEntity = contentState.createEntity('AUDIO-V2', 'IMMUTABLE', {
|
|
43
44
|
audio
|
|
44
45
|
});
|
|
45
46
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
@@ -37,9 +37,9 @@ function ImageButton(props) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const contentState = editorState.getCurrentContent();
|
|
40
|
-
const contentStateWithEntity = contentState.createEntity('image', 'IMMUTABLE', { ...
|
|
41
|
-
desc: selected
|
|
42
|
-
url: selected
|
|
40
|
+
const contentStateWithEntity = contentState.createEntity('image', 'IMMUTABLE', { ...selected.image,
|
|
41
|
+
desc: selected.desc,
|
|
42
|
+
url: selected.url,
|
|
43
43
|
alignment: align
|
|
44
44
|
});
|
|
45
45
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
@@ -7,32 +7,40 @@ exports.LinkButton = LinkButton;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
10
12
|
var _modals = require("@keystone-ui/modals");
|
|
11
13
|
|
|
12
14
|
var _draftJs = require("draft-js");
|
|
13
15
|
|
|
14
16
|
var _fields = require("@keystone-ui/fields");
|
|
15
17
|
|
|
18
|
+
var _util = require("../util");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
16
22
|
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); }
|
|
17
23
|
|
|
18
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
25
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
};
|
|
26
|
+
const StyledTextInput = (0, _styledComponents.default)(_fields.TextInput)`
|
|
27
|
+
fontfamily: Georgia, serif;
|
|
28
|
+
marginright: 10;
|
|
29
|
+
padding: 10;
|
|
30
|
+
`;
|
|
27
31
|
|
|
28
32
|
function LinkButton(props) {
|
|
29
33
|
const {
|
|
30
|
-
isActive,
|
|
31
34
|
editorState,
|
|
32
35
|
onChange
|
|
33
36
|
} = props;
|
|
37
|
+
const entityData = (0, _util.getSelectionEntityData)(editorState);
|
|
38
|
+
const url = (entityData === null || entityData === void 0 ? void 0 : entityData.url) || '';
|
|
39
|
+
(0, _react.useEffect)(() => {
|
|
40
|
+
setLinkUrl(url);
|
|
41
|
+
}, [url]);
|
|
34
42
|
const [toShowUrlInput, setToShowUrlInput] = (0, _react.useState)(false);
|
|
35
|
-
const [
|
|
43
|
+
const [linkUrl, setLinkUrl] = (0, _react.useState)(url || '');
|
|
36
44
|
|
|
37
45
|
const promptForLink = e => {
|
|
38
46
|
e.preventDefault();
|
|
@@ -46,7 +54,7 @@ function LinkButton(props) {
|
|
|
46
54
|
const confirmLink = () => {
|
|
47
55
|
const contentState = editorState.getCurrentContent();
|
|
48
56
|
const contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', {
|
|
49
|
-
url:
|
|
57
|
+
url: linkUrl
|
|
50
58
|
});
|
|
51
59
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
52
60
|
|
|
@@ -54,9 +62,11 @@ function LinkButton(props) {
|
|
|
54
62
|
currentContent: contentStateWithEntity
|
|
55
63
|
});
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
const selection = newEditorState.getSelection(); // RichUtils.toggleLink will reset selection back to first block and cause
|
|
66
|
+
// the editor scroll to top. Use `forceSelection` to hold the selection.
|
|
67
|
+
|
|
68
|
+
onChange(_draftJs.EditorState.forceSelection(_draftJs.RichUtils.toggleLink(newEditorState, selection, entityKey), selection));
|
|
58
69
|
setToShowUrlInput(false);
|
|
59
|
-
setUrlValue('');
|
|
60
70
|
};
|
|
61
71
|
|
|
62
72
|
const onLinkInputKeyDown = e => {
|
|
@@ -70,16 +80,28 @@ function LinkButton(props) {
|
|
|
70
80
|
const selection = editorState.getSelection();
|
|
71
81
|
|
|
72
82
|
if (!selection.isCollapsed()) {
|
|
73
|
-
|
|
83
|
+
// RichUtils.toggleLink will reset selection back to first block and cause
|
|
84
|
+
// the editor scroll to top. Use `forceSelection` to hold the selection.
|
|
85
|
+
onChange(_draftJs.EditorState.forceSelection(_draftJs.RichUtils.toggleLink(editorState, selection, null), selection));
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
setToShowUrlInput(false);
|
|
77
|
-
setUrlValue('');
|
|
78
89
|
};
|
|
79
90
|
|
|
80
|
-
const
|
|
81
|
-
title:
|
|
82
|
-
|
|
91
|
+
const alertProps = linkUrl ? {
|
|
92
|
+
title: 'Update Link',
|
|
93
|
+
actions: {
|
|
94
|
+
cancel: {
|
|
95
|
+
label: 'Remove',
|
|
96
|
+
action: removeLink
|
|
97
|
+
},
|
|
98
|
+
confirm: {
|
|
99
|
+
label: 'Update',
|
|
100
|
+
action: confirmLink
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} : {
|
|
104
|
+
title: 'Insert Link',
|
|
83
105
|
actions: {
|
|
84
106
|
cancel: {
|
|
85
107
|
label: 'Cancel',
|
|
@@ -90,17 +112,22 @@ function LinkButton(props) {
|
|
|
90
112
|
action: confirmLink
|
|
91
113
|
}
|
|
92
114
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const urlInput = /*#__PURE__*/_react.default.createElement(_modals.AlertDialog, {
|
|
118
|
+
title: alertProps.title,
|
|
119
|
+
isOpen: toShowUrlInput,
|
|
120
|
+
actions: alertProps.actions
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement(StyledTextInput, {
|
|
122
|
+
onChange: e => setLinkUrl(e.target.value),
|
|
123
|
+
value: linkUrl,
|
|
96
124
|
type: "text",
|
|
97
|
-
value: urlValue,
|
|
98
125
|
onKeyDown: onLinkInputKeyDown
|
|
99
126
|
}));
|
|
100
127
|
|
|
101
128
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, urlInput, /*#__PURE__*/_react.default.createElement("div", {
|
|
102
129
|
className: props.className,
|
|
103
|
-
onMouseDown:
|
|
130
|
+
onMouseDown: promptForLink
|
|
104
131
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
105
132
|
className: "fas fa-link"
|
|
106
133
|
})));
|
|
@@ -103,6 +103,8 @@ function AudioGrid(props) {
|
|
|
103
103
|
controls: true
|
|
104
104
|
}, /*#__PURE__*/_react.default.createElement("source", {
|
|
105
105
|
src: audio === null || audio === void 0 ? void 0 : audio.urlOriginal
|
|
106
|
+
}), /*#__PURE__*/_react.default.createElement("source", {
|
|
107
|
+
src: audio === null || audio === void 0 ? void 0 : audio.audioSrc
|
|
106
108
|
}), /*#__PURE__*/_react.default.createElement("source", {
|
|
107
109
|
src: audio === null || audio === void 0 ? void 0 : (_audio$file = audio.file) === null || _audio$file === void 0 ? void 0 : _audio$file.url
|
|
108
110
|
})), /*#__PURE__*/_react.default.createElement(AudioName, null, audio === null || audio === void 0 ? void 0 : audio.name));
|
|
@@ -135,6 +137,8 @@ function AudioMetaGrid(props) {
|
|
|
135
137
|
controls: true
|
|
136
138
|
}, /*#__PURE__*/_react.default.createElement("source", {
|
|
137
139
|
src: audio === null || audio === void 0 ? void 0 : audio.urlOriginal
|
|
140
|
+
}), /*#__PURE__*/_react.default.createElement("source", {
|
|
141
|
+
src: audio === null || audio === void 0 ? void 0 : audio.audioSrc
|
|
138
142
|
}), /*#__PURE__*/_react.default.createElement("source", {
|
|
139
143
|
src: audio === null || audio === void 0 ? void 0 : (_audio$file2 = audio.file) === null || _audio$file2 === void 0 ? void 0 : _audio$file2.url
|
|
140
144
|
})), /*#__PURE__*/_react.default.createElement(AudioName, null, audio === null || audio === void 0 ? void 0 : audio.name));
|
|
@@ -151,6 +155,7 @@ const AudiosQuery = (0, _apollo.gql)`
|
|
|
151
155
|
id
|
|
152
156
|
name
|
|
153
157
|
urlOriginal
|
|
158
|
+
audioSrc
|
|
154
159
|
file {
|
|
155
160
|
url
|
|
156
161
|
}
|
|
@@ -226,6 +226,8 @@ const imagesQuery = (0, _apollo.gql)`
|
|
|
226
226
|
name
|
|
227
227
|
imageFile {
|
|
228
228
|
url
|
|
229
|
+
width
|
|
230
|
+
height
|
|
229
231
|
}
|
|
230
232
|
resized {
|
|
231
233
|
original
|
|
@@ -240,6 +242,16 @@ const imagesQuery = (0, _apollo.gql)`
|
|
|
240
242
|
`;
|
|
241
243
|
|
|
242
244
|
function ImageSelector(props) {
|
|
245
|
+
const {
|
|
246
|
+
enableMultiSelect = false,
|
|
247
|
+
enableCaption = false,
|
|
248
|
+
enableUrl = false,
|
|
249
|
+
enableAlignment = false,
|
|
250
|
+
enableDelay = false,
|
|
251
|
+
onChange,
|
|
252
|
+
initialSelected = [],
|
|
253
|
+
initialAlign
|
|
254
|
+
} = props;
|
|
243
255
|
const [queryImages, {
|
|
244
256
|
loading,
|
|
245
257
|
error,
|
|
@@ -253,9 +265,9 @@ function ImageSelector(props) {
|
|
|
253
265
|
const [currentPage, setCurrentPage] = (0, _react.useState)(0); // page starts with 1, 0 is used to detect initialization
|
|
254
266
|
|
|
255
267
|
const [searchText, setSearchText] = (0, _react.useState)('');
|
|
256
|
-
const [selected, setSelected] = (0, _react.useState)(
|
|
268
|
+
const [selected, setSelected] = (0, _react.useState)(initialSelected);
|
|
257
269
|
const [delay, setDelay] = (0, _react.useState)('5');
|
|
258
|
-
const [align, setAlign] = (0, _react.useState)(
|
|
270
|
+
const [align, setAlign] = (0, _react.useState)(initialAlign);
|
|
259
271
|
const contentWrapperRef = (0, _react.useRef)();
|
|
260
272
|
const pageSize = 6;
|
|
261
273
|
const options = [{
|
|
@@ -271,14 +283,6 @@ function ImageSelector(props) {
|
|
|
271
283
|
label: 'right',
|
|
272
284
|
isDisabled: false
|
|
273
285
|
}];
|
|
274
|
-
const {
|
|
275
|
-
enableMultiSelect = false,
|
|
276
|
-
enableCaption = false,
|
|
277
|
-
enableUrl = false,
|
|
278
|
-
enableAlignment = false,
|
|
279
|
-
enableDelay = false,
|
|
280
|
-
onChange
|
|
281
|
-
} = props;
|
|
282
286
|
|
|
283
287
|
const onSave = () => {
|
|
284
288
|
let adjustedDelay = +delay;
|
|
@@ -38,8 +38,9 @@ function VideoButton(props) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const contentState = editorState.getCurrentContent();
|
|
42
|
-
|
|
41
|
+
const contentState = editorState.getCurrentContent(); // since 202310, only VIDEO-V2 will be created
|
|
42
|
+
|
|
43
|
+
const contentStateWithEntity = contentState.createEntity('VIDEO-V2', 'IMMUTABLE', {
|
|
43
44
|
video
|
|
44
45
|
});
|
|
45
46
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.YoutubeButton = YoutubeButton;
|
|
7
|
+
exports.YoutubeInput = YoutubeInput;
|
|
8
|
+
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
var _draftJs = require("draft-js");
|
|
12
|
+
|
|
13
|
+
var _modals = require("@keystone-ui/modals");
|
|
14
|
+
|
|
15
|
+
var _fields = require("@keystone-ui/fields");
|
|
16
|
+
|
|
17
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
18
|
+
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
|
|
21
|
+
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); }
|
|
22
|
+
|
|
23
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
+
|
|
25
|
+
const Label = _styledComponents.default.label`
|
|
26
|
+
display: block;
|
|
27
|
+
font-weight: 600;
|
|
28
|
+
margin: 10px 0;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
function YoutubeInput(props) {
|
|
32
|
+
const {
|
|
33
|
+
isOpen,
|
|
34
|
+
onChange,
|
|
35
|
+
onCancel
|
|
36
|
+
} = props;
|
|
37
|
+
const initialInputValue = {
|
|
38
|
+
description: '',
|
|
39
|
+
youtubeId: ''
|
|
40
|
+
};
|
|
41
|
+
const [inputValue, setInputValue] = (0, _react.useState)(initialInputValue);
|
|
42
|
+
|
|
43
|
+
const clearInputValue = () => {
|
|
44
|
+
setInputValue(initialInputValue);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
|
|
48
|
+
isOpen: isOpen
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
|
|
50
|
+
title: `Insert Youtube video`,
|
|
51
|
+
actions: {
|
|
52
|
+
cancel: {
|
|
53
|
+
label: 'Cancel',
|
|
54
|
+
action: () => {
|
|
55
|
+
clearInputValue();
|
|
56
|
+
onCancel();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
confirm: {
|
|
60
|
+
label: 'Confirm',
|
|
61
|
+
action: () => {
|
|
62
|
+
onChange({
|
|
63
|
+
description: inputValue.description,
|
|
64
|
+
youtubeId: inputValue.youtubeId
|
|
65
|
+
});
|
|
66
|
+
clearInputValue();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(Label, {
|
|
71
|
+
htmlFor: "description"
|
|
72
|
+
}, "Youtube Description"), /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
|
|
73
|
+
onChange: e => setInputValue({
|
|
74
|
+
description: e.target.value,
|
|
75
|
+
youtubeId: inputValue.youtubeId
|
|
76
|
+
}),
|
|
77
|
+
type: "text",
|
|
78
|
+
placeholder: "description",
|
|
79
|
+
id: "description",
|
|
80
|
+
value: inputValue.description
|
|
81
|
+
}), /*#__PURE__*/_react.default.createElement(Label, {
|
|
82
|
+
htmlFor: "youtubeId"
|
|
83
|
+
}, "Youtube Videi Id"), /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
|
|
84
|
+
onChange: e => setInputValue({
|
|
85
|
+
description: inputValue.description,
|
|
86
|
+
youtubeId: e.target.value
|
|
87
|
+
}),
|
|
88
|
+
type: "text",
|
|
89
|
+
placeholder: "youtubeId",
|
|
90
|
+
id: "youtubeId",
|
|
91
|
+
value: inputValue.youtubeId
|
|
92
|
+
})));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function YoutubeButton(props) {
|
|
96
|
+
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
97
|
+
const {
|
|
98
|
+
className,
|
|
99
|
+
editorState,
|
|
100
|
+
onChange: onEditorStateChange
|
|
101
|
+
} = props;
|
|
102
|
+
|
|
103
|
+
const onChange = ({
|
|
104
|
+
description,
|
|
105
|
+
youtubeId
|
|
106
|
+
}) => {
|
|
107
|
+
const contentState = editorState.getCurrentContent(); // create an InfoBox entity
|
|
108
|
+
|
|
109
|
+
const contentStateWithEntity = contentState.createEntity('YOUTUBE', 'IMMUTABLE', {
|
|
110
|
+
description,
|
|
111
|
+
youtubeId
|
|
112
|
+
});
|
|
113
|
+
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
114
|
+
|
|
115
|
+
const newEditorState = _draftJs.EditorState.set(editorState, {
|
|
116
|
+
currentContent: contentStateWithEntity
|
|
117
|
+
}); //The third parameter here is a space string, not an empty string
|
|
118
|
+
//If you set an empty string, you will get an error: Unknown DraftEntity key: null
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
onEditorStateChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
|
|
122
|
+
setToShowInput(false);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(YoutubeInput, {
|
|
126
|
+
onChange: onChange,
|
|
127
|
+
onCancel: () => {
|
|
128
|
+
setToShowInput(false);
|
|
129
|
+
},
|
|
130
|
+
isOpen: toShowInput
|
|
131
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
132
|
+
className: className,
|
|
133
|
+
onClick: () => {
|
|
134
|
+
setToShowInput(true);
|
|
135
|
+
}
|
|
136
|
+
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
137
|
+
height: "16px",
|
|
138
|
+
width: "14px",
|
|
139
|
+
version: "1.1",
|
|
140
|
+
id: "Layer_1",
|
|
141
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
142
|
+
viewBox: "0 0 461.001 461.001"
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
144
|
+
fill: "#6b7280",
|
|
145
|
+
d: "M365.257,67.393H95.744C42.866,67.393,0,110.259,0,163.137v134.728 c0,52.878,42.866,95.744,95.744,95.744h269.513c52.878,0,95.744-42.866,95.744-95.744V163.137 C461.001,110.259,418.135,67.393,365.257,67.393z M300.506,237.056l-126.06,60.123c-3.359,1.602-7.239-0.847-7.239-4.568V168.607 c0-3.774,3.982-6.22,7.348-4.514l126.06,63.881C304.363,229.873,304.298,235.248,300.506,237.056z"
|
|
146
|
+
})), /*#__PURE__*/_react.default.createElement("span", null, "Youtube")));
|
|
147
|
+
}
|
|
@@ -11,8 +11,6 @@ var _apiDataInstance = _interopRequireDefault(require("./api-data-instance"));
|
|
|
11
11
|
|
|
12
12
|
var _entities = _interopRequireDefault(require("./entities"));
|
|
13
13
|
|
|
14
|
-
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
15
|
-
|
|
16
14
|
var _draftJs = require("draft-js");
|
|
17
15
|
|
|
18
16
|
var _draftConvert = require("draft-convert");
|
|
@@ -78,44 +76,25 @@ const processor = {
|
|
|
78
76
|
|
|
79
77
|
case _entities.default.TABLE.type:
|
|
80
78
|
{
|
|
81
|
-
var _content
|
|
79
|
+
var _content;
|
|
82
80
|
|
|
83
81
|
// About TABLE atomic block entity data structure,
|
|
84
82
|
// see `../views/editor/table.tsx` for more information.
|
|
85
83
|
content = entity === null || entity === void 0 ? void 0 : entity.data;
|
|
86
|
-
/** @type DraftEditor.TableEntity.TableStyles */
|
|
87
|
-
|
|
88
|
-
const tableStyles = (_content = content) === null || _content === void 0 ? void 0 : _content.tableStyles;
|
|
89
84
|
/** @type DraftEditor.TableEntity.TableData */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const cellStyle = tableStyles === null || tableStyles === void 0 ? void 0 : (_tableStyles$cells = tableStyles.cells) === null || _tableStyles$cells === void 0 ? void 0 : (_tableStyles$cells$rI = _tableStyles$cells[rIndex]) === null || _tableStyles$cells$rI === void 0 ? void 0 : _tableStyles$cells$rI[cIndex];
|
|
100
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
101
|
-
key: `col_${cIndex}`,
|
|
102
|
-
style: Object.assign({}, colStyle, cellStyle),
|
|
103
|
-
dangerouslySetInnerHTML: {
|
|
104
|
-
__html: (0, _draftConvert.convertToHTML)((0, _draftJs.convertFromRaw)(col))
|
|
105
|
-
}
|
|
106
|
-
});
|
|
85
|
+
// since apiData is now only for app,
|
|
86
|
+
// keep the rows data structure for app to style the table
|
|
87
|
+
|
|
88
|
+
const tableData = (_content = content) === null || _content === void 0 ? void 0 : _content.tableData;
|
|
89
|
+
const rows = tableData === null || tableData === void 0 ? void 0 : tableData.map(row => {
|
|
90
|
+
const cols = row === null || row === void 0 ? void 0 : row.map(col => {
|
|
91
|
+
return {
|
|
92
|
+
html: (0, _draftConvert.convertToHTML)((0, _draftJs.convertFromRaw)(col))
|
|
93
|
+
};
|
|
107
94
|
});
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, colsJsx);
|
|
112
|
-
}); // Use `React.renderToStsaticMarkup` to generate plain HTML string
|
|
113
|
-
|
|
114
|
-
const html = _server.default.renderToStaticMarkup( /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, rowsJsx)));
|
|
115
|
-
|
|
116
|
-
content = [{
|
|
117
|
-
html
|
|
118
|
-
}];
|
|
95
|
+
return cols;
|
|
96
|
+
});
|
|
97
|
+
content = rows;
|
|
119
98
|
break;
|
|
120
99
|
}
|
|
121
100
|
|
|
@@ -133,11 +112,13 @@ const processor = {
|
|
|
133
112
|
break;
|
|
134
113
|
|
|
135
114
|
case _entities.default.AUDIO.type:
|
|
115
|
+
case _entities.default['AUDIO-V2'].type:
|
|
136
116
|
case _entities.default.IMAGE.type:
|
|
137
117
|
case _entities.default.IMAGEDIFF.type:
|
|
138
118
|
case _entities.default.SLIDESHOW.type:
|
|
139
119
|
case _entities.default['SLIDESHOW-V2'].type:
|
|
140
120
|
case _entities.default.VIDEO.type:
|
|
121
|
+
case _entities.default['VIDEO-V2'].type:
|
|
141
122
|
case _entities.default.YOUTUBE.type:
|
|
142
123
|
case _entities.default.BACKGROUNDIMAGE.type:
|
|
143
124
|
case _entities.default.BACKGROUNDVIDEO.type:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSelectionEntityData = void 0;
|
|
7
|
+
|
|
8
|
+
const getSelectionEntityData = editorState => {
|
|
9
|
+
const selection = editorState.getSelection();
|
|
10
|
+
const startOffset = selection.getStartOffset();
|
|
11
|
+
const startBlock = editorState.getCurrentContent().getBlockForKey(selection.getStartKey());
|
|
12
|
+
let data;
|
|
13
|
+
let entityInstance;
|
|
14
|
+
let entityKey;
|
|
15
|
+
|
|
16
|
+
if (!selection.isCollapsed()) {
|
|
17
|
+
entityKey = startBlock.getEntityAt(startOffset);
|
|
18
|
+
} else {
|
|
19
|
+
entityKey = startBlock.getEntityAt(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const contentState = editorState.getCurrentContent();
|
|
23
|
+
|
|
24
|
+
if (entityKey !== null) {
|
|
25
|
+
entityInstance = contentState.getEntity(entityKey);
|
|
26
|
+
data = entityInstance.getData();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getSelectionEntityData = getSelectionEntityData;
|
|
@@ -17,6 +17,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
17
17
|
|
|
18
18
|
const Block = _styledComponents.default.div`
|
|
19
19
|
position: relative;
|
|
20
|
+
/* fix CLS issue while re-rendering trigger by composition input */
|
|
21
|
+
height: 25vh;
|
|
22
|
+
overflow-y: scroll;
|
|
20
23
|
/* styles for image link */
|
|
21
24
|
img.img-responsive {
|
|
22
25
|
margin: 0 auto;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ImageEditorBlock = ImageEditorBlock;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
13
|
+
|
|
14
|
+
var _imageSelector = require("../selector/image-selector");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
ImageBlock
|
|
24
|
+
} = _mirrormedia.default.blockRenderers;
|
|
25
|
+
const ImageBlockWrapper = _styledComponents.default.div`
|
|
26
|
+
img {
|
|
27
|
+
min-width: 300px;
|
|
28
|
+
max-width: 600px;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const ImageEditButton = _styledComponents.default.span`
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
background-color: white;
|
|
34
|
+
padding: 6px;
|
|
35
|
+
border-radius: 6px;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
function ImageEditorBlock(props) {
|
|
39
|
+
const [toShowImageSelector, setToShowImageSelector] = (0, _react.useState)(false);
|
|
40
|
+
const {
|
|
41
|
+
block,
|
|
42
|
+
blockProps,
|
|
43
|
+
contentState
|
|
44
|
+
} = props;
|
|
45
|
+
const {
|
|
46
|
+
onEditStart,
|
|
47
|
+
onEditFinish
|
|
48
|
+
} = blockProps;
|
|
49
|
+
const entityKey = block.getEntityAt(0);
|
|
50
|
+
const entity = contentState.getEntity(entityKey);
|
|
51
|
+
const {
|
|
52
|
+
id,
|
|
53
|
+
name,
|
|
54
|
+
imageFile,
|
|
55
|
+
resized,
|
|
56
|
+
resizedWebp,
|
|
57
|
+
desc,
|
|
58
|
+
url,
|
|
59
|
+
alignment
|
|
60
|
+
} = entity.getData();
|
|
61
|
+
const imageWithMeta = {
|
|
62
|
+
image: {
|
|
63
|
+
id,
|
|
64
|
+
name,
|
|
65
|
+
imageFile,
|
|
66
|
+
resized,
|
|
67
|
+
resizedWebp
|
|
68
|
+
},
|
|
69
|
+
desc,
|
|
70
|
+
url
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onImageSelectorChange = (params, align) => {
|
|
74
|
+
if (params.length === 0) {
|
|
75
|
+
onEditFinish({});
|
|
76
|
+
} else {
|
|
77
|
+
const imageEntity = params[0];
|
|
78
|
+
onEditFinish({
|
|
79
|
+
entityKey,
|
|
80
|
+
entityData: { ...imageEntity.image,
|
|
81
|
+
desc: imageEntity.desc,
|
|
82
|
+
url: imageEntity.url,
|
|
83
|
+
alignment: align
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setToShowImageSelector(false);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowImageSelector && /*#__PURE__*/_react.default.createElement(_imageSelector.ImageSelector, {
|
|
92
|
+
onChange: onImageSelectorChange,
|
|
93
|
+
enableCaption: true,
|
|
94
|
+
enableUrl: true,
|
|
95
|
+
enableAlignment: true,
|
|
96
|
+
initialAlign: alignment,
|
|
97
|
+
initialSelected: [imageWithMeta]
|
|
98
|
+
}), /*#__PURE__*/_react.default.createElement(ImageBlockWrapper, null, /*#__PURE__*/_react.default.createElement(ImageBlock, props)), /*#__PURE__*/_react.default.createElement(ImageEditButton, {
|
|
99
|
+
onClick: () => {
|
|
100
|
+
// call `onEditStart` prop as we are trying to update the BGImage entity
|
|
101
|
+
onEditStart(); // open `BGImageInput`
|
|
102
|
+
|
|
103
|
+
setToShowImageSelector(true);
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
106
|
+
className: "fa-solid fa-pen"
|
|
107
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, "Modify")));
|
|
108
|
+
}
|