@mirrormedia/lilith-draft-editor 1.1.0-alpha.2 → 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 +3 -16
- 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 +4 -33
- 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 +3 -16
- 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 +0 -30
- package/lib/website/mirrormedia/draft-editor.js +10 -106
- 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 +4 -33
- package/lib/website/mirrormedia/selector/image-selector.js +6 -49
- 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 +4 -32
- 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 +4 -27
- package/lib/website/readr/draft-editor.js +10 -106
- 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 +4 -33
- package/lib/website/readr/selector/image-selector.js +6 -49
- 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 +4 -32
- package/package.json +2 -2
|
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BGImageEditorBlock = BGImageEditorBlock;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _draftConverter = _interopRequireDefault(require("../../../draft-js/draft-converter"));
|
|
13
|
-
|
|
14
10
|
var _backgroundImage = require("../../../draft-js/buttons/background-image");
|
|
15
|
-
|
|
16
11
|
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
const {
|
|
25
16
|
BGImageBlock
|
|
26
17
|
} = _mirrormedia.default.blockRenderers;
|
|
@@ -30,7 +21,6 @@ const BGImageRenderButton = _styledComponents.default.span`
|
|
|
30
21
|
padding: 6px;
|
|
31
22
|
border-radius: 6px;
|
|
32
23
|
`;
|
|
33
|
-
|
|
34
24
|
function BGImageEditorBlock(props) {
|
|
35
25
|
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
36
26
|
const {
|
|
@@ -50,7 +40,6 @@ function BGImageEditorBlock(props) {
|
|
|
50
40
|
image,
|
|
51
41
|
rawContentState
|
|
52
42
|
} = entity.getData();
|
|
53
|
-
|
|
54
43
|
const onChange = ({
|
|
55
44
|
textBlockAlign: newTextBlockAlign,
|
|
56
45
|
image: newImage,
|
|
@@ -68,7 +57,6 @@ function BGImageEditorBlock(props) {
|
|
|
68
57
|
}
|
|
69
58
|
});
|
|
70
59
|
};
|
|
71
|
-
|
|
72
60
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_backgroundImage.BGImageInput, {
|
|
73
61
|
renderBasicEditor: renderBasicEditor,
|
|
74
62
|
textBlockAlign: textBlockAlign,
|
|
@@ -83,8 +71,8 @@ function BGImageEditorBlock(props) {
|
|
|
83
71
|
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(BGImageBlock, props), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(BGImageRenderButton, {
|
|
84
72
|
onClick: () => {
|
|
85
73
|
// call `onEditStart` prop as we are trying to update the BGImage entity
|
|
86
|
-
onEditStart();
|
|
87
|
-
|
|
74
|
+
onEditStart();
|
|
75
|
+
// open `BGImageInput`
|
|
88
76
|
setToShowInput(true);
|
|
89
77
|
}
|
|
90
78
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BGVideoEditorBlock = BGVideoEditorBlock;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _draftConverter = _interopRequireDefault(require("../../../draft-js/draft-converter"));
|
|
13
|
-
|
|
14
10
|
var _backgroundVideo = require("../../../draft-js/buttons/background-video");
|
|
15
|
-
|
|
16
11
|
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
const {
|
|
25
16
|
BGVideoBlock
|
|
26
17
|
} = _mirrormedia.default.blockRenderers;
|
|
@@ -30,7 +21,6 @@ const BGVideoRenderButton = _styledComponents.default.span`
|
|
|
30
21
|
padding: 6px;
|
|
31
22
|
border-radius: 6px;
|
|
32
23
|
`;
|
|
33
|
-
|
|
34
24
|
function BGVideoEditorBlock(props) {
|
|
35
25
|
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
36
26
|
const {
|
|
@@ -50,7 +40,6 @@ function BGVideoEditorBlock(props) {
|
|
|
50
40
|
video,
|
|
51
41
|
rawContentState
|
|
52
42
|
} = entity.getData();
|
|
53
|
-
|
|
54
43
|
const onChange = ({
|
|
55
44
|
textBlockAlign: newTextBlockAlign,
|
|
56
45
|
video: newVideo,
|
|
@@ -68,7 +57,6 @@ function BGVideoEditorBlock(props) {
|
|
|
68
57
|
}
|
|
69
58
|
});
|
|
70
59
|
};
|
|
71
|
-
|
|
72
60
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_backgroundVideo.BGVideoInput, {
|
|
73
61
|
renderBasicEditor: renderBasicEditor,
|
|
74
62
|
textBlockAlign: textBlockAlign,
|
|
@@ -83,8 +71,8 @@ function BGVideoEditorBlock(props) {
|
|
|
83
71
|
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(BGVideoBlock, props), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(BGVideoRenderButton, {
|
|
84
72
|
onClick: () => {
|
|
85
73
|
// call `onEditStart` prop as we are trying to update the BGVideo entity
|
|
86
|
-
onEditStart();
|
|
87
|
-
|
|
74
|
+
onEditStart();
|
|
75
|
+
// open `BGVideoInput`
|
|
88
76
|
setToShowInput(true);
|
|
89
77
|
}
|
|
90
78
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
@@ -4,30 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ColorBoxEditorBlock = ColorBoxEditorBlock;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _draftConverter = _interopRequireDefault(require("../../../draft-js/draft-converter"));
|
|
13
|
-
|
|
14
10
|
var _colorBox = require("../../../draft-js/buttons/color-box");
|
|
15
|
-
|
|
16
11
|
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
const {
|
|
25
16
|
ColorBoxBlock
|
|
26
17
|
} = _mirrormedia.default.blockRenderers;
|
|
27
18
|
const ColorBoxRenderButton = _styledComponents.default.div`
|
|
28
19
|
cursor: pointer;
|
|
29
20
|
`;
|
|
30
|
-
|
|
31
21
|
function ColorBoxEditorBlock(props) {
|
|
32
22
|
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
33
23
|
const {
|
|
@@ -46,7 +36,6 @@ function ColorBoxEditorBlock(props) {
|
|
|
46
36
|
color,
|
|
47
37
|
rawContentState
|
|
48
38
|
} = entity.getData();
|
|
49
|
-
|
|
50
39
|
const onChange = ({
|
|
51
40
|
color: newColor,
|
|
52
41
|
rawContentState: newRawContentState
|
|
@@ -62,7 +51,6 @@ function ColorBoxEditorBlock(props) {
|
|
|
62
51
|
}
|
|
63
52
|
});
|
|
64
53
|
};
|
|
65
|
-
|
|
66
54
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_colorBox.ColorBoxInput, {
|
|
67
55
|
renderBasicEditor: renderBasicEditor,
|
|
68
56
|
color: color,
|
|
@@ -76,8 +64,8 @@ function ColorBoxEditorBlock(props) {
|
|
|
76
64
|
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(ColorBoxBlock, props), /*#__PURE__*/_react.default.createElement(ColorBoxRenderButton, {
|
|
77
65
|
onClick: () => {
|
|
78
66
|
// call `onEditStart` prop as we are trying to update the ColorBox entity
|
|
79
|
-
onEditStart();
|
|
80
|
-
|
|
67
|
+
onEditStart();
|
|
68
|
+
// open `ColorBoxInput`
|
|
81
69
|
setToShowInput(true);
|
|
82
70
|
}
|
|
83
71
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EmbeddedCodeEditorBlock = exports.Caption = exports.Block = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
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); }
|
|
15
|
-
|
|
16
11
|
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; }
|
|
17
|
-
|
|
18
12
|
const Block = _styledComponents.default.div`
|
|
19
13
|
position: relative;
|
|
20
14
|
/* styles for image link */
|
|
@@ -34,7 +28,6 @@ const Caption = _styledComponents.default.div`
|
|
|
34
28
|
padding: 15px 15px 0 15px;
|
|
35
29
|
`;
|
|
36
30
|
exports.Caption = Caption;
|
|
37
|
-
|
|
38
31
|
const EmbeddedCodeEditorBlock = entity => {
|
|
39
32
|
const {
|
|
40
33
|
caption,
|
|
@@ -44,7 +37,9 @@ const EmbeddedCodeEditorBlock = entity => {
|
|
|
44
37
|
(0, _react.useEffect)(() => {
|
|
45
38
|
if (!embedded.current) return;
|
|
46
39
|
const node = embedded.current;
|
|
47
|
-
const fragment = document.createDocumentFragment();
|
|
40
|
+
const fragment = document.createDocumentFragment();
|
|
41
|
+
|
|
42
|
+
// `embeddedCode` is a string, which may includes
|
|
48
43
|
// multiple '<script>' tags and other html tags.
|
|
49
44
|
// For executing '<script>' tags on the browser,
|
|
50
45
|
// we need to extract '<script>' tags from `embeddedCode` string first.
|
|
@@ -53,7 +48,6 @@ const EmbeddedCodeEditorBlock = entity => {
|
|
|
53
48
|
// and we could use DOM element built-in functions,
|
|
54
49
|
// such as `querySelectorAll` method, to query '<script>' elements,
|
|
55
50
|
// and other non '<script>' elements.
|
|
56
|
-
|
|
57
51
|
const parser = new DOMParser();
|
|
58
52
|
const ele = parser.parseFromString(`<div id="draft-embed">${embeddedCode}</div>`, 'text/html');
|
|
59
53
|
const scripts = ele.querySelectorAll('script');
|
|
@@ -64,11 +58,9 @@ const EmbeddedCodeEditorBlock = entity => {
|
|
|
64
58
|
scripts.forEach(s => {
|
|
65
59
|
const scriptEle = document.createElement('script');
|
|
66
60
|
const attrs = s.attributes;
|
|
67
|
-
|
|
68
61
|
for (let i = 0; i < attrs.length; i++) {
|
|
69
62
|
scriptEle.setAttribute(attrs[i].name, attrs[i].value);
|
|
70
63
|
}
|
|
71
|
-
|
|
72
64
|
scriptEle.text = s.text || '';
|
|
73
65
|
fragment.appendChild(scriptEle);
|
|
74
66
|
});
|
|
@@ -81,5 +73,4 @@ const EmbeddedCodeEditorBlock = entity => {
|
|
|
81
73
|
ref: embedded
|
|
82
74
|
}), caption ? /*#__PURE__*/_react.default.createElement(Caption, null, caption) : null);
|
|
83
75
|
};
|
|
84
|
-
|
|
85
76
|
exports.EmbeddedCodeEditorBlock = EmbeddedCodeEditorBlock;
|
|
@@ -4,30 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.InfoBoxEditorBlock = InfoBoxEditorBlock;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _draftConverter = _interopRequireDefault(require("../../../draft-js/draft-converter"));
|
|
13
|
-
|
|
14
10
|
var _infoBox = require("../../../draft-js/buttons/info-box");
|
|
15
|
-
|
|
16
11
|
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
const {
|
|
25
16
|
InfoBoxBlock
|
|
26
17
|
} = _mirrormedia.default.blockRenderers;
|
|
27
18
|
const InfoBoxRenderButton = _styledComponents.default.div`
|
|
28
19
|
cursor: pointer;
|
|
29
20
|
`;
|
|
30
|
-
|
|
31
21
|
function InfoBoxEditorBlock(props) {
|
|
32
22
|
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
33
23
|
const {
|
|
@@ -46,7 +36,6 @@ function InfoBoxEditorBlock(props) {
|
|
|
46
36
|
title,
|
|
47
37
|
rawContentState
|
|
48
38
|
} = entity.getData();
|
|
49
|
-
|
|
50
39
|
const onChange = ({
|
|
51
40
|
title: newTitle,
|
|
52
41
|
rawContentState: newRawContentState
|
|
@@ -62,7 +51,6 @@ function InfoBoxEditorBlock(props) {
|
|
|
62
51
|
}
|
|
63
52
|
});
|
|
64
53
|
};
|
|
65
|
-
|
|
66
54
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_infoBox.InfoBoxInput, {
|
|
67
55
|
renderBasicEditor: renderBasicEditor,
|
|
68
56
|
title: title,
|
|
@@ -76,8 +64,8 @@ function InfoBoxEditorBlock(props) {
|
|
|
76
64
|
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(InfoBoxBlock, props), /*#__PURE__*/_react.default.createElement(InfoBoxRenderButton, {
|
|
77
65
|
onClick: () => {
|
|
78
66
|
// call `onEditStart` prop as we are trying to update the InfoBox entity
|
|
79
|
-
onEditStart();
|
|
80
|
-
|
|
67
|
+
onEditStart();
|
|
68
|
+
// open `InfoBoxInput`
|
|
81
69
|
setToShowInput(true);
|
|
82
70
|
}
|
|
83
71
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SideIndexEditorBlock = SideIndexEditorBlock;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _sideIndex = require("../../../draft-js/buttons/side-index");
|
|
13
|
-
|
|
14
10
|
var _mirrormedia = _interopRequireDefault(require("@mirrormedia/lilith-draft-renderer/lib/website/mirrormedia"));
|
|
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
|
SideIndexBlock
|
|
24
16
|
} = _mirrormedia.default.blockRenderers;
|
|
@@ -26,7 +18,6 @@ const SideIndexBlockButton = _styledComponents.default.div`
|
|
|
26
18
|
cursor: pointer;
|
|
27
19
|
margin-left: 20px;
|
|
28
20
|
`;
|
|
29
|
-
|
|
30
21
|
function SideIndexEditorBlock(props) {
|
|
31
22
|
const [toShowInput, setToShowInput] = (0, _react.useState)(false);
|
|
32
23
|
const {
|
|
@@ -46,7 +37,6 @@ function SideIndexEditorBlock(props) {
|
|
|
46
37
|
sideIndexUrl,
|
|
47
38
|
sideIndexImage
|
|
48
39
|
} = entity.getData();
|
|
49
|
-
|
|
50
40
|
const onChange = ({
|
|
51
41
|
h2Text,
|
|
52
42
|
sideIndexText,
|
|
@@ -65,7 +55,6 @@ function SideIndexEditorBlock(props) {
|
|
|
65
55
|
}
|
|
66
56
|
});
|
|
67
57
|
};
|
|
68
|
-
|
|
69
58
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_sideIndex.SideIndexInput, {
|
|
70
59
|
h2Text: h2Text,
|
|
71
60
|
sideIndexText: sideIndexText,
|
|
@@ -80,8 +69,8 @@ function SideIndexEditorBlock(props) {
|
|
|
80
69
|
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(SideIndexBlock, props), /*#__PURE__*/_react.default.createElement(SideIndexBlockButton, {
|
|
81
70
|
onClick: () => {
|
|
82
71
|
// call `onEditStart` prop as we are trying to update the SideIndex entity
|
|
83
|
-
onEditStart();
|
|
84
|
-
|
|
72
|
+
onEditStart();
|
|
73
|
+
// open `SideIndexInput`
|
|
85
74
|
setToShowInput(true);
|
|
86
75
|
}
|
|
87
76
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
@@ -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;
|