@mirrormedia/lilith-draft-editor 1.1.0-alpha.1 → 1.1.0-alpha.3
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 +0 -22
- package/lib/draft-js/buttons/audio.js +52 -0
- package/lib/draft-js/buttons/background-color.js +0 -26
- package/lib/draft-js/buttons/background-image.js +13 -32
- package/lib/draft-js/buttons/background-video.js +13 -32
- package/lib/draft-js/buttons/color-box.js +5 -21
- package/lib/draft-js/buttons/divider.js +3 -12
- package/lib/draft-js/buttons/embedded-code.js +5 -16
- package/lib/draft-js/buttons/enlarge.js +0 -3
- package/lib/draft-js/buttons/font-color.js +0 -26
- package/lib/draft-js/buttons/image.js +5 -16
- package/lib/draft-js/buttons/info-box.js +5 -21
- package/lib/draft-js/buttons/link.js +0 -19
- package/lib/draft-js/buttons/media.js +3 -16
- package/lib/draft-js/buttons/related-post.js +3 -14
- package/lib/draft-js/buttons/selector/align-selector.js +2 -11
- package/lib/draft-js/buttons/selector/audio-selector.js +252 -0
- package/lib/draft-js/buttons/selector/image-selector.js +6 -50
- package/lib/draft-js/buttons/selector/pagination.js +2 -6
- package/lib/draft-js/buttons/selector/post-selector.js +6 -39
- package/lib/draft-js/buttons/selector/search-box.js +0 -9
- package/lib/draft-js/buttons/selector/video-selector.js +4 -33
- package/lib/draft-js/buttons/side-index.js +15 -31
- package/lib/draft-js/buttons/slideshow.js +7 -16
- package/lib/draft-js/buttons/table.js +5 -11
- package/lib/draft-js/buttons/text-align.js +0 -14
- package/lib/draft-js/buttons/video.js +52 -0
- package/lib/draft-js/const.js +0 -2
- package/lib/draft-js/draft-converter/api-data-instance.js +0 -14
- package/lib/draft-js/draft-converter/atomic-block-processor.js +12 -41
- package/lib/draft-js/draft-converter/entities.js +1 -0
- package/lib/draft-js/draft-converter/index.js +10 -29
- package/lib/draft-js/draft-converter/inline-styles-processor.js +22 -55
- package/lib/draft-js/modifier.js +5 -13
- package/lib/index.js +0 -4
- package/lib/website/mirrormedia/block-renderer/background-image-block.js +2 -14
- package/lib/website/mirrormedia/block-renderer/background-video-block.js +2 -14
- package/lib/website/mirrormedia/block-renderer/color-box-block.js +2 -14
- package/lib/website/mirrormedia/block-renderer/embedded-code-block.js +3 -12
- package/lib/website/mirrormedia/block-renderer/info-box-block.js +2 -14
- package/lib/website/mirrormedia/block-renderer/side-index-block.js +2 -13
- package/lib/website/mirrormedia/block-renderer/slideshow-block.js +4 -11
- package/lib/website/mirrormedia/block-renderer/table-block.js +28 -62
- package/lib/website/mirrormedia/block-renderer-fn.js +11 -29
- package/lib/website/mirrormedia/draft-editor.js +31 -105
- package/lib/website/mirrormedia/entity-decorator.js +0 -4
- package/lib/website/mirrormedia/index.js +0 -3
- package/lib/website/mirrormedia/selector/align-selector.js +2 -11
- package/lib/website/mirrormedia/selector/audio-selector.js +252 -0
- package/lib/website/mirrormedia/selector/image-selector.js +10 -50
- package/lib/website/mirrormedia/selector/pagination.js +2 -6
- package/lib/website/mirrormedia/selector/post-selector.js +6 -39
- package/lib/website/mirrormedia/selector/search-box.js +0 -9
- package/lib/website/mirrormedia/selector/video-selector.js +8 -33
- package/lib/website/readr/block-renderer/background-image-block.js +2 -14
- package/lib/website/readr/block-renderer/background-video-block.js +2 -14
- package/lib/website/readr/block-renderer/color-box-block.js +2 -14
- package/lib/website/readr/block-renderer/info-box-block.js +2 -14
- package/lib/website/readr/block-renderer/side-index-block.js +2 -13
- package/lib/website/readr/block-renderer/table-block.js +28 -62
- package/lib/website/readr/block-renderer-fn.js +11 -27
- package/lib/website/readr/draft-editor.js +31 -105
- package/lib/website/readr/entity-decorator.js +0 -4
- package/lib/website/readr/index.js +0 -3
- package/lib/website/readr/selector/align-selector.js +2 -11
- package/lib/website/readr/selector/audio-selector.js +252 -0
- package/lib/website/readr/selector/image-selector.js +10 -50
- package/lib/website/readr/selector/pagination.js +2 -6
- package/lib/website/readr/selector/post-selector.js +6 -39
- package/lib/website/readr/selector/search-box.js +0 -9
- package/lib/website/readr/selector/video-selector.js +8 -33
- package/package.json +2 -2
|
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SlideshowEditBlock = SlideshowEditBlock;
|
|
7
7
|
exports.SlideshowEditBlockV2 = SlideshowEditBlockV2;
|
|
8
|
-
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
12
|
-
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
11
|
const Image = _styledComponents.default.img`
|
|
16
12
|
width: 100%;
|
|
17
13
|
`;
|
|
@@ -36,26 +32,24 @@ const Figure = _styledComponents.default.figure`
|
|
|
36
32
|
margin-block: unset;
|
|
37
33
|
margin-inline: unset;
|
|
38
34
|
margin: 0 10px;
|
|
39
|
-
`;
|
|
35
|
+
`;
|
|
40
36
|
|
|
37
|
+
// support old version of slideshow without delay propertiy
|
|
41
38
|
function SlideshowEditBlock(entity) {
|
|
42
39
|
var _images$, _images$$resized;
|
|
43
|
-
|
|
44
40
|
const images = entity.getData();
|
|
45
41
|
return /*#__PURE__*/_react.default.createElement(Figure, null, /*#__PURE__*/_react.default.createElement(Image, {
|
|
46
42
|
src: images === null || images === void 0 ? void 0 : (_images$ = images[0]) === null || _images$ === void 0 ? void 0 : (_images$$resized = _images$.resized) === null || _images$$resized === void 0 ? void 0 : _images$$resized.original,
|
|
47
43
|
onError: e => {
|
|
48
44
|
var _images$2, _images$2$imageFile;
|
|
49
|
-
|
|
50
45
|
return e.currentTarget.src = images === null || images === void 0 ? void 0 : (_images$2 = images[0]) === null || _images$2 === void 0 ? void 0 : (_images$2$imageFile = _images$2.imageFile) === null || _images$2$imageFile === void 0 ? void 0 : _images$2$imageFile.url;
|
|
51
46
|
}
|
|
52
47
|
}), /*#__PURE__*/_react.default.createElement(SlideshowCount, null, "+", images.length));
|
|
53
|
-
}
|
|
54
|
-
|
|
48
|
+
}
|
|
55
49
|
|
|
50
|
+
// 202206 latest version of slideshow, support delay property
|
|
56
51
|
function SlideshowEditBlockV2(entity) {
|
|
57
52
|
var _images$3, _images$3$resized;
|
|
58
|
-
|
|
59
53
|
const {
|
|
60
54
|
images,
|
|
61
55
|
delay
|
|
@@ -64,7 +58,6 @@ function SlideshowEditBlockV2(entity) {
|
|
|
64
58
|
src: images === null || images === void 0 ? void 0 : (_images$3 = images[0]) === null || _images$3 === void 0 ? void 0 : (_images$3$resized = _images$3.resized) === null || _images$3$resized === void 0 ? void 0 : _images$3$resized.original,
|
|
65
59
|
onError: e => {
|
|
66
60
|
var _images$4, _images$4$imageFile;
|
|
67
|
-
|
|
68
61
|
return e.currentTarget.src = images === null || images === void 0 ? void 0 : (_images$4 = images[0]) === null || _images$4 === void 0 ? void 0 : (_images$4$imageFile = _images$4.imageFile) === null || _images$4$imageFile === void 0 ? void 0 : _images$4$imageFile.url;
|
|
69
62
|
}
|
|
70
63
|
}), /*#__PURE__*/_react.default.createElement(SlideshowCount, null, /*#__PURE__*/_react.default.createElement("div", null, "+", images.length), delay && /*#__PURE__*/_react.default.createElement("div", null, `${delay}s`)));
|
|
@@ -4,49 +4,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TableEditorBlock = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _draftJs = require("draft-js");
|
|
13
|
-
|
|
14
10
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
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
13
|
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
14
|
const _ = {
|
|
23
15
|
cloneDeep: _cloneDeep.default
|
|
24
16
|
};
|
|
25
|
-
var ActionType
|
|
26
|
-
|
|
27
|
-
(function (ActionType) {
|
|
17
|
+
var ActionType = /*#__PURE__*/function (ActionType) {
|
|
28
18
|
ActionType["Insert"] = "insert";
|
|
29
19
|
ActionType["Delete"] = "delete";
|
|
30
20
|
ActionType["Update"] = "update";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var TableEnum
|
|
34
|
-
|
|
35
|
-
(function (TableEnum) {
|
|
21
|
+
return ActionType;
|
|
22
|
+
}(ActionType || {});
|
|
23
|
+
var TableEnum = /*#__PURE__*/function (TableEnum) {
|
|
36
24
|
TableEnum["Row"] = "row";
|
|
37
25
|
TableEnum["Column"] = "column";
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
return TableEnum;
|
|
27
|
+
}(TableEnum || {});
|
|
40
28
|
function createEmptyRow(colLen = 0, emptyValue) {
|
|
41
29
|
const rtn = [];
|
|
42
|
-
|
|
43
30
|
for (let i = 0; i < colLen; i++) {
|
|
44
31
|
rtn.push(emptyValue);
|
|
45
32
|
}
|
|
46
|
-
|
|
47
33
|
return rtn;
|
|
48
34
|
}
|
|
49
|
-
|
|
50
35
|
function resolveTableStyles(action, tableStyles) {
|
|
51
36
|
switch (action === null || action === void 0 ? void 0 : action.type) {
|
|
52
37
|
case ActionType.Insert:
|
|
@@ -56,12 +41,10 @@ function resolveTableStyles(action, tableStyles) {
|
|
|
56
41
|
return Object.assign({}, tableStyles, {
|
|
57
42
|
rows
|
|
58
43
|
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
}
|
|
45
|
+
// TODO: handle target === TableEnum.Column if needed
|
|
62
46
|
return tableStyles;
|
|
63
47
|
}
|
|
64
|
-
|
|
65
48
|
case ActionType.Delete:
|
|
66
49
|
{
|
|
67
50
|
if (action.target === TableEnum.Row) {
|
|
@@ -69,75 +52,61 @@ function resolveTableStyles(action, tableStyles) {
|
|
|
69
52
|
return Object.assign({}, tableStyles, {
|
|
70
53
|
rows
|
|
71
54
|
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
55
|
+
}
|
|
56
|
+
// TODO: handle target === TableEnum.Column if needed
|
|
75
57
|
return tableStyles;
|
|
76
58
|
}
|
|
77
59
|
// TODO: handle action.type === ActionType.Update if needed
|
|
78
|
-
|
|
79
60
|
default:
|
|
80
61
|
{
|
|
81
62
|
return tableStyles;
|
|
82
63
|
}
|
|
83
64
|
}
|
|
84
65
|
}
|
|
85
|
-
|
|
86
66
|
function resolveTableData(action, tableData) {
|
|
87
67
|
switch (action === null || action === void 0 ? void 0 : action.type) {
|
|
88
68
|
case ActionType.Insert:
|
|
89
69
|
{
|
|
90
70
|
var _tableData$;
|
|
91
|
-
|
|
92
71
|
if (typeof (action === null || action === void 0 ? void 0 : action.index) !== 'number') {
|
|
93
72
|
return tableData;
|
|
94
73
|
}
|
|
95
|
-
|
|
96
74
|
if ((action === null || action === void 0 ? void 0 : action.target) === TableEnum.Column) {
|
|
97
75
|
// add the new column at specific position in each row
|
|
98
76
|
return tableData.map(r => [...r.slice(0, action === null || action === void 0 ? void 0 : action.index), _draftJs.EditorState.createEmpty(), ...r.slice(action === null || action === void 0 ? void 0 : action.index)]);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
77
|
+
}
|
|
78
|
+
// add the new row
|
|
102
79
|
return [...tableData.slice(0, action === null || action === void 0 ? void 0 : action.index), createEmptyRow(tableData === null || tableData === void 0 ? void 0 : (_tableData$ = tableData[0]) === null || _tableData$ === void 0 ? void 0 : _tableData$.length, _draftJs.EditorState.createEmpty()), ...tableData.slice(action === null || action === void 0 ? void 0 : action.index)];
|
|
103
80
|
}
|
|
104
|
-
|
|
105
81
|
case ActionType.Delete:
|
|
106
82
|
{
|
|
107
83
|
if (typeof (action === null || action === void 0 ? void 0 : action.index) !== 'number') {
|
|
108
84
|
return tableData;
|
|
109
85
|
}
|
|
110
|
-
|
|
111
86
|
if ((action === null || action === void 0 ? void 0 : action.target) === 'column') {
|
|
112
87
|
// delete the column at specific position in each row
|
|
113
88
|
return tableData.map(r => [...r.slice(0, action.index), ...r.slice(action.index + 1)]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
89
|
+
}
|
|
90
|
+
// delete the column
|
|
117
91
|
return [...tableData.slice(0, action.index), ...tableData.slice(action.index + 1)];
|
|
118
92
|
}
|
|
119
|
-
|
|
120
93
|
case ActionType.Update:
|
|
121
94
|
{
|
|
122
95
|
// The reason we copy the array is to make sure
|
|
123
96
|
// that React component re-renders.
|
|
124
97
|
const copiedData = [...tableData];
|
|
125
|
-
|
|
126
98
|
if (typeof (action === null || action === void 0 ? void 0 : action.rIndex) !== 'number' || typeof (action === null || action === void 0 ? void 0 : action.cIndex) !== 'number') {
|
|
127
99
|
return copiedData;
|
|
128
100
|
}
|
|
129
|
-
|
|
130
101
|
copiedData[action.rIndex][action.cIndex] = action === null || action === void 0 ? void 0 : action.value;
|
|
131
102
|
return copiedData;
|
|
132
103
|
}
|
|
133
|
-
|
|
134
104
|
default:
|
|
135
105
|
{
|
|
136
106
|
return tableData;
|
|
137
107
|
}
|
|
138
108
|
}
|
|
139
109
|
}
|
|
140
|
-
|
|
141
110
|
function convertTableDataFromRaw(rawTableData) {
|
|
142
111
|
return rawTableData.map(rowData => {
|
|
143
112
|
return rowData.map(colData => {
|
|
@@ -146,7 +115,6 @@ function convertTableDataFromRaw(rawTableData) {
|
|
|
146
115
|
});
|
|
147
116
|
});
|
|
148
117
|
}
|
|
149
|
-
|
|
150
118
|
function convertTableDataToRaw(tableData) {
|
|
151
119
|
return tableData.map(rowData => {
|
|
152
120
|
return rowData.map(colData => {
|
|
@@ -154,7 +122,6 @@ function convertTableDataToRaw(tableData) {
|
|
|
154
122
|
});
|
|
155
123
|
});
|
|
156
124
|
}
|
|
157
|
-
|
|
158
125
|
const Table = _styledComponents.default.div`
|
|
159
126
|
display: table;
|
|
160
127
|
width: 95%;
|
|
@@ -255,10 +222,8 @@ const TableBlockContainer = _styledComponents.default.div`
|
|
|
255
222
|
overflow: scroll;
|
|
256
223
|
padding: 15px;
|
|
257
224
|
`;
|
|
258
|
-
|
|
259
225
|
const TableEditorBlock = props => {
|
|
260
226
|
var _tableData$2;
|
|
261
|
-
|
|
262
227
|
const {
|
|
263
228
|
block,
|
|
264
229
|
blockProps,
|
|
@@ -275,24 +240,26 @@ const TableEditorBlock = props => {
|
|
|
275
240
|
tableData: rawTableData,
|
|
276
241
|
tableStyles: _tableStyles
|
|
277
242
|
} = entity.getData();
|
|
278
|
-
const [tableData, setTableData] = (0, _react.useState)(convertTableDataFromRaw(rawTableData));
|
|
279
|
-
|
|
243
|
+
const [tableData, setTableData] = (0, _react.useState)(convertTableDataFromRaw(rawTableData));
|
|
244
|
+
// deep clone `_tableStyles` to prevent updating the entity data directly
|
|
280
245
|
const [tableStyles, setTableStyles] = (0, _react.useState)(_.cloneDeep(_tableStyles));
|
|
281
|
-
const tableRef = (0, _react.useRef)(null);
|
|
246
|
+
const tableRef = (0, _react.useRef)(null);
|
|
247
|
+
|
|
248
|
+
// `TableBlock` will render other inner/nested DraftJS Editors inside the main Editor.
|
|
282
249
|
// However, main Editor's `readOnly` needs to be mutually exclusive with nested Editors' `readOnly`.
|
|
283
250
|
// If the main Editor and nested Editor are editable (`readOnly={false}`) at the same time,
|
|
284
251
|
// there will be a DraftJS Edtior Selection bug.
|
|
252
|
+
const [cellEditorReadOnly, setCellEditorReadOnly] = (0, _react.useState)(!getMainEditorReadOnly());
|
|
285
253
|
|
|
286
|
-
|
|
287
|
-
|
|
254
|
+
// The user clicks the table for editing
|
|
288
255
|
const onTableClick = () => {
|
|
289
256
|
// call `onEditStart` function to tell the main DraftJS Editor
|
|
290
257
|
// that we are going to interact with the custom atomic block.
|
|
291
|
-
onEditStart();
|
|
258
|
+
onEditStart();
|
|
292
259
|
|
|
260
|
+
// make nested DraftJS Editors editable
|
|
293
261
|
setCellEditorReadOnly(false);
|
|
294
262
|
};
|
|
295
|
-
|
|
296
263
|
(0, _react.useEffect)(() => {
|
|
297
264
|
// The user clicks other places except the table,
|
|
298
265
|
// so we think he/she doesn't want to edit the table anymore.
|
|
@@ -304,9 +271,10 @@ const TableEditorBlock = props => {
|
|
|
304
271
|
// this `handleClickOutside` will only handle the just updated one.
|
|
305
272
|
if (tableRef.current && !tableRef.current.contains(event.target) && !cellEditorReadOnly) {
|
|
306
273
|
// make inner DraftJS Editors NOT editable
|
|
307
|
-
setCellEditorReadOnly(true);
|
|
308
|
-
// that we are finishing interacting with the custom atomic block.
|
|
274
|
+
setCellEditorReadOnly(true);
|
|
309
275
|
|
|
276
|
+
// call `onEditFinish` function tell the main DraftJS Editor
|
|
277
|
+
// that we are finishing interacting with the custom atomic block.
|
|
310
278
|
onEditFinish({
|
|
311
279
|
entityKey,
|
|
312
280
|
entityData: {
|
|
@@ -316,7 +284,6 @@ const TableEditorBlock = props => {
|
|
|
316
284
|
});
|
|
317
285
|
}
|
|
318
286
|
}
|
|
319
|
-
|
|
320
287
|
console.debug('(rich-text-editor/table): add click outside event listener');
|
|
321
288
|
document.addEventListener('mousedown', handleClickOutside);
|
|
322
289
|
return () => {
|
|
@@ -324,7 +291,8 @@ const TableEditorBlock = props => {
|
|
|
324
291
|
console.debug('(rich-text-editor/table): remove click outside event listener');
|
|
325
292
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
326
293
|
};
|
|
327
|
-
},
|
|
294
|
+
},
|
|
295
|
+
// Skip running effect if `tableData` and `cellEditorReadOnly` are not changed.
|
|
328
296
|
[tableData, cellEditorReadOnly]);
|
|
329
297
|
return /*#__PURE__*/_react.default.createElement(TableBlockContainer, null, /*#__PURE__*/_react.default.createElement(Table, {
|
|
330
298
|
key: entityKey,
|
|
@@ -356,7 +324,6 @@ const TableEditorBlock = props => {
|
|
|
356
324
|
}));
|
|
357
325
|
})), tableData.map((rowData, rIndex) => {
|
|
358
326
|
var _tableStyles$rows;
|
|
359
|
-
|
|
360
327
|
const colsJsx = rowData.map((colData, cIndex) => {
|
|
361
328
|
return /*#__PURE__*/_react.default.createElement(Td, {
|
|
362
329
|
key: `col_${cIndex}`
|
|
@@ -404,5 +371,4 @@ const TableEditorBlock = props => {
|
|
|
404
371
|
})), colsJsx));
|
|
405
372
|
})));
|
|
406
373
|
};
|
|
407
|
-
|
|
408
374
|
exports.TableEditorBlock = TableEditorBlock;
|
|
@@ -4,38 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.atomicBlockRenderer = atomicBlockRenderer;
|
|
7
|
-
|
|
8
7
|
var _infoBoxBlock = require("./block-renderer/info-box-block");
|
|
9
|
-
|
|
10
8
|
var _tableBlock = require("./block-renderer/table-block");
|
|
11
|
-
|
|
12
9
|
var _colorBoxBlock = require("./block-renderer/color-box-block");
|
|
13
|
-
|
|
14
10
|
var _backgroundImageBlock = require("./block-renderer/background-image-block");
|
|
15
|
-
|
|
16
11
|
var _backgroundVideoBlock = require("./block-renderer/background-video-block");
|
|
17
|
-
|
|
18
12
|
var _sideIndexBlock = require("./block-renderer/side-index-block");
|
|
19
|
-
|
|
20
13
|
var _embeddedCodeBlock = require("./block-renderer/embedded-code-block");
|
|
21
|
-
|
|
22
14
|
var _slideshowBlock = require("./block-renderer/slideshow-block");
|
|
23
|
-
|
|
24
15
|
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
const {
|
|
29
18
|
MediaBlock,
|
|
30
19
|
ImageBlock,
|
|
31
20
|
DividerBlock,
|
|
32
|
-
RelatedPostBlock
|
|
21
|
+
RelatedPostBlock,
|
|
22
|
+
VideoBlock,
|
|
23
|
+
AudioBlock
|
|
33
24
|
} = _mirrormedia.default.blockRenderers;
|
|
34
|
-
|
|
35
25
|
const AtomicBlock = props => {
|
|
36
26
|
const entity = props.contentState.getEntity(props.block.getEntityAt(0));
|
|
37
27
|
const entityType = entity.getType();
|
|
38
|
-
|
|
39
28
|
switch (entityType) {
|
|
40
29
|
case 'audioLink':
|
|
41
30
|
case 'imageLink':
|
|
@@ -43,71 +32,65 @@ const AtomicBlock = props => {
|
|
|
43
32
|
{
|
|
44
33
|
return MediaBlock(entity);
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
case 'image':
|
|
48
36
|
{
|
|
49
37
|
return ImageBlock(entity);
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
case 'slideshow':
|
|
53
40
|
{
|
|
54
41
|
return (0, _slideshowBlock.SlideshowEditBlock)(entity);
|
|
55
42
|
}
|
|
56
|
-
|
|
57
43
|
case 'slideshow-v2':
|
|
58
44
|
{
|
|
59
45
|
return (0, _slideshowBlock.SlideshowEditBlockV2)(entity);
|
|
60
46
|
}
|
|
61
|
-
|
|
62
47
|
case 'EMBEDDEDCODE':
|
|
63
48
|
{
|
|
64
49
|
return (0, _embeddedCodeBlock.EmbeddedCodeEditorBlock)(entity);
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
case 'INFOBOX':
|
|
68
52
|
{
|
|
69
53
|
return (0, _infoBoxBlock.InfoBoxEditorBlock)(props);
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
case 'DIVIDER':
|
|
73
56
|
{
|
|
74
57
|
return DividerBlock();
|
|
75
58
|
}
|
|
76
|
-
|
|
77
59
|
case 'TABLE':
|
|
78
60
|
{
|
|
79
61
|
return (0, _tableBlock.TableEditorBlock)(props);
|
|
80
62
|
}
|
|
81
|
-
|
|
82
63
|
case 'COLORBOX':
|
|
83
64
|
{
|
|
84
65
|
return (0, _colorBoxBlock.ColorBoxEditorBlock)(props);
|
|
85
66
|
}
|
|
86
|
-
|
|
87
67
|
case 'BACKGROUNDIMAGE':
|
|
88
68
|
{
|
|
89
69
|
return (0, _backgroundImageBlock.BGImageEditorBlock)(props);
|
|
90
70
|
}
|
|
91
|
-
|
|
92
71
|
case 'BACKGROUNDVIDEO':
|
|
93
72
|
{
|
|
94
73
|
return (0, _backgroundVideoBlock.BGVideoEditorBlock)(props);
|
|
95
74
|
}
|
|
96
|
-
|
|
97
75
|
case 'RELATEDPOST':
|
|
98
76
|
{
|
|
99
77
|
return RelatedPostBlock(entity);
|
|
100
78
|
}
|
|
101
|
-
|
|
102
79
|
case 'SIDEINDEX':
|
|
103
80
|
{
|
|
104
81
|
return (0, _sideIndexBlock.SideIndexEditorBlock)(props);
|
|
105
82
|
}
|
|
83
|
+
case 'VIDEO':
|
|
84
|
+
{
|
|
85
|
+
return VideoBlock(entity);
|
|
86
|
+
}
|
|
87
|
+
case 'AUDIO':
|
|
88
|
+
{
|
|
89
|
+
return AudioBlock(entity);
|
|
90
|
+
}
|
|
106
91
|
}
|
|
107
|
-
|
|
108
92
|
return null;
|
|
109
93
|
};
|
|
110
|
-
|
|
111
94
|
function atomicBlockRenderer(block) {
|
|
112
95
|
if (block.getType() === 'atomic') {
|
|
113
96
|
return {
|
|
@@ -115,6 +98,5 @@ function atomicBlockRenderer(block) {
|
|
|
115
98
|
editable: false
|
|
116
99
|
};
|
|
117
100
|
}
|
|
118
|
-
|
|
119
101
|
return null;
|
|
120
102
|
}
|