@kids-reporter/draft-editor 0.1.0 → 0.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/buttons/annotation.js +1 -14
- package/lib/buttons/image.js +0 -3
- package/lib/buttons/info-box.js +1 -4
- package/lib/buttons/selector/image-selector.js +3 -1
- package/lib/buttons/slideshow.js +2 -3
- package/lib/draft-editor.js +61 -363
- package/package.json +12 -7
- package/lib/block-renderer/background-image-block.js +0 -141
- package/lib/block-renderer/background-video-block.js +0 -151
- package/lib/block-renderer/color-box-block.js +0 -86
- package/lib/block-renderer/info-box-block.js +0 -86
- package/lib/block-renderer/side-index-block.js +0 -90
- package/lib/block-renderer/table-block.js +0 -408
- package/lib/block-renderer-fn.js +0 -131
- package/lib/buttons/audio.js +0 -65
- package/lib/buttons/background-color.js +0 -122
- package/lib/buttons/background-image.js +0 -223
- package/lib/buttons/background-video.js +0 -223
- package/lib/buttons/color-box.js +0 -173
- package/lib/buttons/divider.js +0 -63
- package/lib/buttons/font-color.js +0 -115
- package/lib/buttons/media.js +0 -121
- package/lib/buttons/related-post.js +0 -71
- package/lib/buttons/selector/audio-selector.js +0 -279
- package/lib/buttons/selector/post-selector.js +0 -317
- package/lib/buttons/selector/video-selector.js +0 -281
- package/lib/buttons/side-index.js +0 -200
- package/lib/buttons/table.js +0 -67
- package/lib/buttons/text-align.js +0 -88
- package/lib/buttons/video.js +0 -65
- package/lib/buttons/youtube.js +0 -147
- package/lib/const.js +0 -18
- package/lib/draft-converter/api-data-instance.js +0 -58
- package/lib/draft-converter/atomic-block-processor.js +0 -233
- package/lib/draft-converter/entities.js +0 -76
- package/lib/draft-converter/index.js +0 -201
- package/lib/draft-converter/inline-styles-processor.js +0 -236
- package/lib/entity-decorator.js +0 -20
- package/lib/modifier.js +0 -68
- package/lib/theme/index.js +0 -39
package/lib/buttons/video.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.VideoButton = VideoButton;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _draftJs = require("draft-js");
|
|
11
|
-
|
|
12
|
-
var _videoSelector = require("./selector/video-selector");
|
|
13
|
-
|
|
14
|
-
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
|
-
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
|
-
function VideoButton(props) {
|
|
19
|
-
const {
|
|
20
|
-
editorState,
|
|
21
|
-
onChange,
|
|
22
|
-
className,
|
|
23
|
-
VideoSelector = _videoSelector.VideoSelector
|
|
24
|
-
} = props;
|
|
25
|
-
const [toShowVideoSelector, setToShowVideoSelector] = (0, _react.useState)(false);
|
|
26
|
-
|
|
27
|
-
const promptForVideoSelector = () => {
|
|
28
|
-
setToShowVideoSelector(true);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const onVideoSelectorChange = selectedVideosWithMeta => {
|
|
32
|
-
var _selectedVideosWithMe;
|
|
33
|
-
|
|
34
|
-
const video = selectedVideosWithMeta === null || selectedVideosWithMeta === void 0 ? void 0 : (_selectedVideosWithMe = selectedVideosWithMeta[0]) === null || _selectedVideosWithMe === void 0 ? void 0 : _selectedVideosWithMe.video;
|
|
35
|
-
|
|
36
|
-
if (!video) {
|
|
37
|
-
setToShowVideoSelector(false);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const contentState = editorState.getCurrentContent();
|
|
42
|
-
const contentStateWithEntity = contentState.createEntity('VIDEO', 'IMMUTABLE', {
|
|
43
|
-
video
|
|
44
|
-
});
|
|
45
|
-
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
46
|
-
|
|
47
|
-
const newEditorState = _draftJs.EditorState.set(editorState, {
|
|
48
|
-
currentContent: contentStateWithEntity
|
|
49
|
-
}); // The third parameter here is a space string, not an empty string
|
|
50
|
-
// If you set an empty string, you will get an error: Unknown DraftEntity key: null
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onChange(_draftJs.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '));
|
|
54
|
-
setToShowVideoSelector(false);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toShowVideoSelector && /*#__PURE__*/_react.default.createElement(VideoSelector, {
|
|
58
|
-
onChange: onVideoSelectorChange
|
|
59
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
-
className: className,
|
|
61
|
-
onClick: promptForVideoSelector
|
|
62
|
-
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
63
|
-
className: "fa fa-video-camera"
|
|
64
|
-
}), /*#__PURE__*/_react.default.createElement("span", null, " Video")));
|
|
65
|
-
}
|
package/lib/buttons/youtube.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
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
|
-
}
|
package/lib/const.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _const = require("@kids-reporter/draft-renderer/lib/const");
|
|
8
|
-
|
|
9
|
-
Object.keys(_const).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _const[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _const[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _immutable = require("immutable");
|
|
9
|
-
|
|
10
|
-
var _shortid = _interopRequireDefault(require("shortid"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const ApiDataInstanceRecord = (0, _immutable.Record)({
|
|
15
|
-
id: _shortid.default.generate(),
|
|
16
|
-
type: 'paragraph',
|
|
17
|
-
alignment: 'center',
|
|
18
|
-
content: [],
|
|
19
|
-
styles: {},
|
|
20
|
-
textAlign: undefined
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
class ApiDataInstance extends ApiDataInstanceRecord {
|
|
24
|
-
constructor(props) {
|
|
25
|
-
let id = props && props.id || _shortid.default.generate();
|
|
26
|
-
|
|
27
|
-
props.id = id;
|
|
28
|
-
super(props);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getId() {
|
|
32
|
-
return this.get('id');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getType() {
|
|
36
|
-
return this.get('type');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getAlignment() {
|
|
40
|
-
return this.get('alignment');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
getContent() {
|
|
44
|
-
return this.get('content');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getStyles() {
|
|
48
|
-
return this.get('styles');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getTextAlign() {
|
|
52
|
-
return this.get('textAlign');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var _default = ApiDataInstance;
|
|
58
|
-
exports.default = _default;
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
|
|
10
|
-
var _apiDataInstance = _interopRequireDefault(require("./api-data-instance"));
|
|
11
|
-
|
|
12
|
-
var _entities = _interopRequireDefault(require("./entities"));
|
|
13
|
-
|
|
14
|
-
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
15
|
-
|
|
16
|
-
var _draftJs = require("draft-js");
|
|
17
|
-
|
|
18
|
-
var _draftConvert = require("draft-convert");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
23
|
-
// import sizeOf from 'image-size';
|
|
24
|
-
// eslint-disable-line
|
|
25
|
-
// import htmlparser2 from 'htmlparser2'
|
|
26
|
-
// eslint-disable-next-line no-undef
|
|
27
|
-
const htmlparser2 = require('htmlparser2');
|
|
28
|
-
/**
|
|
29
|
-
* @typedef {Object} DraftEditor.TableEntity.TableStyles
|
|
30
|
-
* @property {Record<string, string>[]} rows
|
|
31
|
-
* @property {Record<string, string>[]} columns
|
|
32
|
-
* @property {Record<string, string>[][]} cells
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {RawDraftContentState[][]} DraftEditor.TableEntity.TableData
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const processor = {
|
|
41
|
-
convertBlock(entityMap, block) {
|
|
42
|
-
let alignment = 'center';
|
|
43
|
-
let content;
|
|
44
|
-
let entityRange = block.entityRanges[0];
|
|
45
|
-
let styles = {}; // current block's entity data
|
|
46
|
-
// ex:
|
|
47
|
-
// entity.type = IMAGE, entity.data={id,name,url...}
|
|
48
|
-
|
|
49
|
-
const entity = entityMap[entityRange.key];
|
|
50
|
-
|
|
51
|
-
let type = _lodash.default.get(entity, 'type', ''); // backward compatible. Old entity type might be lower case
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
switch (type && type.toUpperCase()) {
|
|
55
|
-
case _entities.default.INFOBOX.type:
|
|
56
|
-
{
|
|
57
|
-
var _entity$data, _entity$data2;
|
|
58
|
-
|
|
59
|
-
// About INFOBOX atomic block entity data structure,
|
|
60
|
-
// see `../views/editor/info-box.tsx` for more information.
|
|
61
|
-
content = [{
|
|
62
|
-
title: entity === null || entity === void 0 ? void 0 : (_entity$data = entity.data) === null || _entity$data === void 0 ? void 0 : _entity$data.title,
|
|
63
|
-
body: entity === null || entity === void 0 ? void 0 : (_entity$data2 = entity.data) === null || _entity$data2 === void 0 ? void 0 : _entity$data2.body
|
|
64
|
-
}];
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
case _entities.default.COLORBOX.type:
|
|
69
|
-
{
|
|
70
|
-
var _entity$data3, _entity$data4;
|
|
71
|
-
|
|
72
|
-
content = [{
|
|
73
|
-
color: entity === null || entity === void 0 ? void 0 : (_entity$data3 = entity.data) === null || _entity$data3 === void 0 ? void 0 : _entity$data3.color,
|
|
74
|
-
body: entity === null || entity === void 0 ? void 0 : (_entity$data4 = entity.data) === null || _entity$data4 === void 0 ? void 0 : _entity$data4.body
|
|
75
|
-
}];
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
case _entities.default.TABLE.type:
|
|
80
|
-
{
|
|
81
|
-
var _content, _content2;
|
|
82
|
-
|
|
83
|
-
// About TABLE atomic block entity data structure,
|
|
84
|
-
// see `../views/editor/table.tsx` for more information.
|
|
85
|
-
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
|
-
/** @type DraftEditor.TableEntity.TableData */
|
|
90
|
-
|
|
91
|
-
const tableData = (_content2 = content) === null || _content2 === void 0 ? void 0 : _content2.tableData;
|
|
92
|
-
const rowsJsx = tableData === null || tableData === void 0 ? void 0 : tableData.map((row, rIndex) => {
|
|
93
|
-
var _tableStyles$rows;
|
|
94
|
-
|
|
95
|
-
const colsJsx = row === null || row === void 0 ? void 0 : row.map((col, cIndex) => {
|
|
96
|
-
var _tableStyles$columns, _tableStyles$cells, _tableStyles$cells$rI;
|
|
97
|
-
|
|
98
|
-
const colStyle = tableStyles === null || tableStyles === void 0 ? void 0 : (_tableStyles$columns = tableStyles.columns) === null || _tableStyles$columns === void 0 ? void 0 : _tableStyles$columns[cIndex];
|
|
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
|
-
});
|
|
107
|
-
});
|
|
108
|
-
return /*#__PURE__*/React.createElement("tr", {
|
|
109
|
-
key: `row_${rIndex}`,
|
|
110
|
-
style: tableStyles === null || tableStyles === void 0 ? void 0 : (_tableStyles$rows = tableStyles.rows) === null || _tableStyles$rows === void 0 ? void 0 : _tableStyles$rows[rIndex]
|
|
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
|
-
}];
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
case _entities.default.DIVIDER.type:
|
|
123
|
-
content = ['<hr>'];
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case _entities.default.BLOCKQUOTE.type:
|
|
127
|
-
// this is different from default blockquote of draftjs
|
|
128
|
-
// so we name our specific blockquote as 'quoteby'
|
|
129
|
-
type = 'quoteby';
|
|
130
|
-
alignment = entity.data && entity.data.alignment || alignment;
|
|
131
|
-
content = _lodash.default.get(entity, 'data');
|
|
132
|
-
content = Array.isArray(content) ? content : [content];
|
|
133
|
-
break;
|
|
134
|
-
|
|
135
|
-
case _entities.default.AUDIO.type:
|
|
136
|
-
case _entities.default.IMAGE.type:
|
|
137
|
-
case _entities.default.IMAGEDIFF.type:
|
|
138
|
-
case _entities.default.SLIDESHOW.type:
|
|
139
|
-
case _entities.default['SLIDESHOW-V2'].type:
|
|
140
|
-
case _entities.default.VIDEO.type:
|
|
141
|
-
case _entities.default.YOUTUBE.type:
|
|
142
|
-
case _entities.default.BACKGROUNDIMAGE.type:
|
|
143
|
-
case _entities.default.BACKGROUNDVIDEO.type:
|
|
144
|
-
case _entities.default.RELATEDPOST.type:
|
|
145
|
-
case _entities.default.SIDEINDEX.type:
|
|
146
|
-
alignment = entity.data && entity.data.alignment || alignment;
|
|
147
|
-
content = _lodash.default.get(entity, 'data');
|
|
148
|
-
content = Array.isArray(content) ? content : [content];
|
|
149
|
-
break;
|
|
150
|
-
|
|
151
|
-
case _entities.default.IMAGELINK.type:
|
|
152
|
-
{
|
|
153
|
-
// use Embedded component to dangerouslySetInnerHTML
|
|
154
|
-
type = _entities.default.EMBEDDEDCODE.type;
|
|
155
|
-
alignment = entity.data && entity.data.alignment || alignment;
|
|
156
|
-
|
|
157
|
-
let description = _lodash.default.get(entity, ['data', 'description'], '');
|
|
158
|
-
|
|
159
|
-
let url = _lodash.default.get(entity, ['data', 'url'], '');
|
|
160
|
-
|
|
161
|
-
content = [{
|
|
162
|
-
caption: description,
|
|
163
|
-
embeddedCodeWithoutScript: `<img alt="${description}" src="${url}" class="img-responsive"/>`,
|
|
164
|
-
url: url
|
|
165
|
-
}];
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
case _entities.default.EMBEDDEDCODE.type:
|
|
170
|
-
{
|
|
171
|
-
alignment = entity.data && entity.data.alignment || alignment;
|
|
172
|
-
|
|
173
|
-
let caption = _lodash.default.get(entity, ['data', 'caption'], '');
|
|
174
|
-
|
|
175
|
-
let embeddedCode = _lodash.default.get(entity, ['data', 'embeddedCode'], '');
|
|
176
|
-
|
|
177
|
-
let script = {};
|
|
178
|
-
let scripts = [];
|
|
179
|
-
let scriptTagStart = false;
|
|
180
|
-
let height;
|
|
181
|
-
let width;
|
|
182
|
-
let parser = new htmlparser2.Parser({
|
|
183
|
-
onopentag: (name, attribs) => {
|
|
184
|
-
if (name === 'script') {
|
|
185
|
-
scriptTagStart = true;
|
|
186
|
-
script.attribs = attribs;
|
|
187
|
-
} else if (name === 'iframe') {
|
|
188
|
-
height = _lodash.default.get(attribs, 'height', 0);
|
|
189
|
-
width = _lodash.default.get(attribs, 'width', 0);
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
ontext: text => {
|
|
193
|
-
if (scriptTagStart) {
|
|
194
|
-
script.text = text;
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
onclosetag: tagname => {
|
|
198
|
-
if (tagname === 'script' && scriptTagStart) {
|
|
199
|
-
scriptTagStart = false;
|
|
200
|
-
scripts.push(script);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
parser.write(embeddedCode);
|
|
205
|
-
parser.end();
|
|
206
|
-
content = [{
|
|
207
|
-
caption,
|
|
208
|
-
embeddedCode,
|
|
209
|
-
embeddedCodeWithoutScript: embeddedCode.replace(/<script(.+?)\/script>/g, ''),
|
|
210
|
-
height,
|
|
211
|
-
scripts,
|
|
212
|
-
width
|
|
213
|
-
}];
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
default:
|
|
218
|
-
return;
|
|
219
|
-
} // block type of api data should be lower case
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return new _apiDataInstance.default({
|
|
223
|
-
id: block.key,
|
|
224
|
-
alignment,
|
|
225
|
-
type: type && type.toLowerCase(),
|
|
226
|
-
content,
|
|
227
|
-
styles
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
var _default = processor;
|
|
233
|
-
exports.default = _default;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
// 'use strict';
|
|
8
|
-
const ENTITY = {
|
|
9
|
-
DIVIDER: {
|
|
10
|
-
type: 'DIVIDER'
|
|
11
|
-
},
|
|
12
|
-
ANNOTATION: {
|
|
13
|
-
type: 'ANNOTATION'
|
|
14
|
-
},
|
|
15
|
-
BLOCKQUOTE: {
|
|
16
|
-
type: 'BLOCKQUOTE'
|
|
17
|
-
},
|
|
18
|
-
LINK: {
|
|
19
|
-
type: 'LINK'
|
|
20
|
-
},
|
|
21
|
-
INFOBOX: {
|
|
22
|
-
type: 'INFOBOX'
|
|
23
|
-
},
|
|
24
|
-
COLORBOX: {
|
|
25
|
-
type: 'COLORBOX'
|
|
26
|
-
},
|
|
27
|
-
EMBEDDEDCODE: {
|
|
28
|
-
type: 'EMBEDDEDCODE'
|
|
29
|
-
},
|
|
30
|
-
AUDIO: {
|
|
31
|
-
type: 'AUDIO'
|
|
32
|
-
},
|
|
33
|
-
VIDEO: {
|
|
34
|
-
type: 'VIDEO'
|
|
35
|
-
},
|
|
36
|
-
IMAGE: {
|
|
37
|
-
type: 'IMAGE'
|
|
38
|
-
},
|
|
39
|
-
STOREDIMAGE: {
|
|
40
|
-
type: 'STOREDIMAGE'
|
|
41
|
-
},
|
|
42
|
-
IMAGEDIFF: {
|
|
43
|
-
type: 'IMAGEDIFF'
|
|
44
|
-
},
|
|
45
|
-
IMAGELINK: {
|
|
46
|
-
type: 'IMAGELINK'
|
|
47
|
-
},
|
|
48
|
-
SLIDESHOW: {
|
|
49
|
-
type: 'SLIDESHOW',
|
|
50
|
-
slideshowSelectionLimit: 30
|
|
51
|
-
},
|
|
52
|
-
['SLIDESHOW-V2']: {
|
|
53
|
-
type: 'SLIDESHOW-V2',
|
|
54
|
-
slideshowSelectionLimit: 30
|
|
55
|
-
},
|
|
56
|
-
YOUTUBE: {
|
|
57
|
-
type: 'YOUTUBE'
|
|
58
|
-
},
|
|
59
|
-
TABLE: {
|
|
60
|
-
type: 'TABLE'
|
|
61
|
-
},
|
|
62
|
-
BACKGROUNDIMAGE: {
|
|
63
|
-
type: 'BACKGROUNDIMAGE'
|
|
64
|
-
},
|
|
65
|
-
BACKGROUNDVIDEO: {
|
|
66
|
-
type: 'BACKGROUNDVIDEO'
|
|
67
|
-
},
|
|
68
|
-
RELATEDPOST: {
|
|
69
|
-
type: 'RELATEDPOST'
|
|
70
|
-
},
|
|
71
|
-
SIDEINDEX: {
|
|
72
|
-
type: 'SIDEINDEX'
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var _default = ENTITY;
|
|
76
|
-
exports.default = _default;
|