@pie-lib/editable-html 10.0.0-beta.7 → 10.0.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/CHANGELOG.json +1 -1
- package/CHANGELOG.md +81 -0
- package/LICENSE.md +5 -0
- package/lib/editor.js +410 -543
- package/lib/editor.js.map +1 -1
- package/lib/index.js +200 -101
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js +5 -6
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +12 -2
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +71 -19
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/html/icons/index.js +38 -0
- package/lib/plugins/html/icons/index.js.map +1 -0
- package/lib/plugins/html/index.js +75 -0
- package/lib/plugins/html/index.js.map +1 -0
- package/lib/plugins/image/alt-dialog.js +26 -0
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +124 -90
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +45 -7
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +91 -113
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +54 -72
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +71 -31
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +129 -58
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +152 -118
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +185 -168
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +197 -110
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +24 -4
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +65 -23
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +50 -10
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +22 -9
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +9 -4
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +18 -1
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +133 -122
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +10 -4
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +33 -15
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +7 -0
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +279 -390
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +47 -14
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +63 -51
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +9 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +140 -83
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +5 -0
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +39 -8
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +261 -225
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +16 -19
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +70 -11
- package/lib/serialization.js.map +1 -1
- package/lib/theme.js.map +1 -1
- package/package.json +18 -17
- package/src/editor.jsx +139 -434
- package/src/index.jsx +96 -62
- package/src/plugins/characters/index.jsx +17 -12
- package/src/plugins/html/icons/index.jsx +19 -0
- package/src/plugins/html/index.jsx +68 -0
- package/src/plugins/image/component.jsx +38 -60
- package/src/plugins/image/index.jsx +42 -95
- package/src/plugins/image/insert-image-handler.js +27 -62
- package/src/plugins/index.jsx +39 -21
- package/src/plugins/list/index.jsx +90 -62
- package/src/plugins/math/index.jsx +70 -93
- package/src/plugins/media/index.jsx +117 -146
- package/src/plugins/media/media-dialog.js +9 -10
- package/src/plugins/media/media-wrapper.jsx +27 -29
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +4 -5
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +1 -2
- package/src/plugins/respArea/index.jsx +84 -114
- package/src/plugins/respArea/inline-dropdown/index.jsx +2 -3
- package/src/plugins/respArea/utils.jsx +28 -23
- package/src/plugins/table/index.jsx +214 -334
- package/src/plugins/table/table-toolbar.jsx +4 -3
- package/src/plugins/toolbar/default-toolbar.jsx +30 -48
- package/src/plugins/toolbar/editor-and-toolbar.jsx +114 -114
- package/src/plugins/toolbar/toolbar.jsx +224 -254
- package/src/plugins/utils.js +0 -16
- package/src/serialization.jsx +1 -1
- package/lib/components.js +0 -92
- package/lib/components.js.map +0 -1
- package/lib/new-serialization.js +0 -280
- package/lib/new-serialization.js.map +0 -1
- package/lib/plugins/hotKeys/index.js +0 -60
- package/lib/plugins/hotKeys/index.js.map +0 -1
- package/lib/test-serializer.js +0 -138
- package/lib/test-serializer.js.map +0 -1
- package/src/components.js +0 -135
- package/src/new-serialization.jsx +0 -310
- package/src/plugins/hotKeys/index.js +0 -54
- package/src/test-serializer.js +0 -132
|
@@ -1,450 +1,245 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
|
-
exports.serialization = exports.reactAttributes = exports.parseStyleString = exports["default"] = void 0;
|
|
8
|
+
exports.serialization = exports.reactAttributes = exports.parseStyleString = exports.moveFocusToBeginningOfTable = exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
11
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _slateEditTable = _interopRequireDefault(require("slate-edit-table"));
|
|
17
|
+
|
|
13
18
|
var _slate = require("slate");
|
|
19
|
+
|
|
14
20
|
var _debug = _interopRequireDefault(require("debug"));
|
|
21
|
+
|
|
15
22
|
var _GridOn = _interopRequireDefault(require("@material-ui/icons/GridOn"));
|
|
23
|
+
|
|
16
24
|
var _tableToolbar = _interopRequireDefault(require("./table-toolbar"));
|
|
25
|
+
|
|
17
26
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
-
|
|
19
|
-
var
|
|
27
|
+
|
|
28
|
+
var _slatePropTypes = _interopRequireDefault(require("slate-prop-types"));
|
|
29
|
+
|
|
30
|
+
var _styles = require("@material-ui/core/styles");
|
|
31
|
+
|
|
20
32
|
var _reactAttrConverter = _interopRequireDefault(require("react-attr-converter"));
|
|
33
|
+
|
|
21
34
|
var _toStyle = require("to-style");
|
|
22
|
-
|
|
23
|
-
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
24
|
-
var _reduce = _interopRequireDefault(require("lodash/reduce"));
|
|
35
|
+
|
|
25
36
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
37
|
+
|
|
26
38
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
-
|
|
28
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
39
|
+
|
|
30
40
|
var log = (0, _debug["default"])('@pie-lib:editable-html:plugins:table');
|
|
31
|
-
var Table =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
var Table = (0, _styles.withStyles)(function () {
|
|
42
|
+
return {
|
|
43
|
+
table: {}
|
|
44
|
+
};
|
|
45
|
+
})(function (props) {
|
|
46
|
+
var nodeAttributes = dataToAttributes(props.node.data);
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement("table", (0, _extends2["default"])({
|
|
48
|
+
className: props.classes.table
|
|
49
|
+
}, props.attributes, nodeAttributes, {
|
|
35
50
|
onFocus: props.onFocus,
|
|
36
51
|
onBlur: props.onBlur
|
|
37
|
-
}), props.children);
|
|
52
|
+
}), /*#__PURE__*/_react["default"].createElement("tbody", null, props.children));
|
|
38
53
|
});
|
|
39
54
|
Table.propTypes = {
|
|
40
55
|
attributes: _propTypes["default"].object,
|
|
41
|
-
element: _propTypes["default"].object,
|
|
42
56
|
onFocus: _propTypes["default"].func,
|
|
43
57
|
onBlur: _propTypes["default"].func,
|
|
44
|
-
node:
|
|
45
|
-
type: _propTypes["default"].string,
|
|
46
|
-
children: _propTypes["default"].array,
|
|
47
|
-
data: _propTypes["default"].object
|
|
48
|
-
}),
|
|
58
|
+
node: _slatePropTypes["default"].node,
|
|
49
59
|
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
|
|
50
60
|
};
|
|
51
|
-
|
|
61
|
+
|
|
62
|
+
var TableRow = function TableRow(props) {
|
|
52
63
|
return /*#__PURE__*/_react["default"].createElement("tr", props.attributes, props.children);
|
|
53
|
-
});
|
|
54
|
-
TableRow.propTypes = {
|
|
55
|
-
attributes: _propTypes["default"].object,
|
|
56
|
-
onFocus: _propTypes["default"].func,
|
|
57
|
-
onBlur: _propTypes["default"].func,
|
|
58
|
-
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
|
|
59
64
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
TableBody.propTypes = {
|
|
65
|
+
|
|
66
|
+
TableRow.propTypes = {
|
|
64
67
|
attributes: _propTypes["default"].object,
|
|
65
68
|
onFocus: _propTypes["default"].func,
|
|
66
69
|
onBlur: _propTypes["default"].func,
|
|
67
70
|
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
|
|
68
71
|
};
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var nodeAttributes = dataToAttributes(props.element.data);
|
|
72
|
+
var TableCell = (0, _styles.withStyles)(function () {
|
|
73
|
+
return {
|
|
74
|
+
td: {
|
|
75
|
+
minWidth: '25px'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
})(function (props) {
|
|
79
|
+
var Tag = props.node.data.get('header') ? 'th' : 'td';
|
|
80
|
+
var nodeAttributes = dataToAttributes(props.node.data);
|
|
79
81
|
delete nodeAttributes.header;
|
|
80
82
|
return /*#__PURE__*/_react["default"].createElement(Tag, (0, _extends2["default"])({}, props.attributes, nodeAttributes, {
|
|
81
|
-
colSpan:
|
|
82
|
-
className: classes[Tag],
|
|
83
|
+
colSpan: props.node.data.get('colspan'),
|
|
84
|
+
className: props.classes[Tag],
|
|
83
85
|
onFocus: props.onFocus,
|
|
84
86
|
onBlur: props.onBlur
|
|
85
87
|
}), props.children);
|
|
86
88
|
});
|
|
87
89
|
TableCell.propTypes = {
|
|
88
|
-
node: _propTypes["default"].object,
|
|
89
|
-
element: _propTypes["default"].object,
|
|
90
90
|
attributes: _propTypes["default"].object,
|
|
91
91
|
onFocus: _propTypes["default"].func,
|
|
92
92
|
onBlur: _propTypes["default"].func,
|
|
93
93
|
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var ancestors = _slate.Node.ancestors(editor, _slate.Editor.path(editor, editor.selection), {
|
|
100
|
-
reverse: true
|
|
95
|
+
|
|
96
|
+
var moveFocusToBeginningOfTable = function moveFocusToBeginningOfTable(change) {
|
|
97
|
+
var addedTable = change.value.document.findDescendant(function (d) {
|
|
98
|
+
return !!d.data && !!d.data.get('newTable');
|
|
101
99
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
106
|
-
var _step$value = (0, _slicedToArray2["default"])(_step.value, 2),
|
|
107
|
-
ancestor = _step$value[0],
|
|
108
|
-
ancestorPath = _step$value[1];
|
|
109
|
-
if (ancestor.type === type) {
|
|
110
|
-
return [ancestor, ancestorPath];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
} catch (err) {
|
|
114
|
-
_iterator.e(err);
|
|
115
|
-
} finally {
|
|
116
|
-
_iterator.f();
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
};
|
|
120
|
-
var moveToBeginningOfTable = function moveToBeginningOfTable(editor) {
|
|
121
|
-
var _getAncestorByType = getAncestorByType(editor, 'table'),
|
|
122
|
-
_getAncestorByType2 = (0, _slicedToArray2["default"])(_getAncestorByType, 2),
|
|
123
|
-
tableBlock = _getAncestorByType2[0],
|
|
124
|
-
tablePath = _getAncestorByType2[1];
|
|
125
|
-
var firstTdPath;
|
|
126
|
-
var _iterator2 = _createForOfIteratorHelper(_slate.Node.descendants(tableBlock, {
|
|
127
|
-
reverse: true
|
|
128
|
-
})),
|
|
129
|
-
_step2;
|
|
130
|
-
try {
|
|
131
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
132
|
-
var _step2$value = (0, _slicedToArray2["default"])(_step2.value, 2),
|
|
133
|
-
descendant = _step2$value[0],
|
|
134
|
-
descendantPath = _step2$value[1];
|
|
135
|
-
if (descendant.type === 'td') {
|
|
136
|
-
firstTdPath = descendantPath;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
} catch (err) {
|
|
140
|
-
_iterator2.e(err);
|
|
141
|
-
} finally {
|
|
142
|
-
_iterator2.f();
|
|
100
|
+
|
|
101
|
+
if (!addedTable) {
|
|
102
|
+
return;
|
|
143
103
|
}
|
|
144
|
-
|
|
104
|
+
|
|
105
|
+
change.collapseToStartOf(addedTable);
|
|
106
|
+
var update = addedTable.data.remove('newTable');
|
|
107
|
+
change.setNodeByKey(addedTable.key, {
|
|
108
|
+
data: update
|
|
109
|
+
});
|
|
145
110
|
};
|
|
146
|
-
var TABLE_TYPES = ['tbody', 'tr', 'td', 'table'];
|
|
147
|
-
var _default = function _default(opts, toolbarPlugins /* : {toolbar: {}}[] */) {
|
|
148
|
-
var core = {
|
|
149
|
-
utils: {},
|
|
150
|
-
rules: function rules(editor) {
|
|
151
|
-
var normalizeNode = editor.normalizeNode;
|
|
152
|
-
editor.normalizeNode = function (entry) {
|
|
153
|
-
var _entry = (0, _slicedToArray2["default"])(entry, 2),
|
|
154
|
-
tableNode = _entry[0],
|
|
155
|
-
tablePath = _entry[1];
|
|
156
|
-
var tableParent = _slate.Node.get(editor, tablePath.slice(0, -1));
|
|
157
|
-
|
|
158
|
-
// If the element is a paragraph, ensure its children are valid.
|
|
159
|
-
if (_slate.Element.isElement(tableNode) && tableNode.type === 'table') {
|
|
160
|
-
var emptyBlock = {
|
|
161
|
-
type: 'paragraph',
|
|
162
|
-
children: [{
|
|
163
|
-
text: ''
|
|
164
|
-
}]
|
|
165
|
-
};
|
|
166
|
-
var tableIndex = tablePath.slice(-1)[0];
|
|
167
|
-
|
|
168
|
-
// if table is the first element, we need to add a space before
|
|
169
|
-
// so users can focus before the table
|
|
170
|
-
if (tableIndex === 0) {
|
|
171
|
-
var beforeTablePath = [].concat((0, _toConsumableArray2["default"])(tablePath.slice(0, -1)), [0]);
|
|
172
|
-
editor.apply({
|
|
173
|
-
type: 'insert_node',
|
|
174
|
-
path: beforeTablePath,
|
|
175
|
-
node: emptyBlock
|
|
176
|
-
});
|
|
177
|
-
editor.continueNormalization();
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
111
|
|
|
181
|
-
|
|
182
|
-
if (tableParent.children.length - 1 === tableIndex) {
|
|
183
|
-
var afterTablePath = [].concat((0, _toConsumableArray2["default"])(tablePath.slice(0, -1)), [tableIndex + 1]);
|
|
184
|
-
editor.apply({
|
|
185
|
-
type: 'insert_node',
|
|
186
|
-
path: afterTablePath,
|
|
187
|
-
node: emptyBlock
|
|
188
|
-
});
|
|
189
|
-
editor.continueNormalization();
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
112
|
+
exports.moveFocusToBeginningOfTable = moveFocusToBeginningOfTable;
|
|
192
113
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
editor.continueNormalization();
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
114
|
+
var _default = function _default(opts, toolbarPlugins
|
|
115
|
+
/* : {toolbar: {}}[] */
|
|
116
|
+
) {
|
|
117
|
+
var core = (0, _slateEditTable["default"])({
|
|
118
|
+
typeContent: 'div'
|
|
119
|
+
}); // fix outdated schema
|
|
120
|
+
|
|
121
|
+
if (core.schema && core.schema.blocks) {
|
|
122
|
+
Object.keys(core.schema.blocks).forEach(function (key) {
|
|
123
|
+
var block = core.schema.blocks[key];
|
|
124
|
+
|
|
125
|
+
if (block.parent) {
|
|
126
|
+
if (block.nodes[0].types) {
|
|
127
|
+
block.nodes[0] = {
|
|
128
|
+
type: block.nodes[0].types[0]
|
|
129
|
+
};
|
|
214
130
|
}
|
|
215
131
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
var tableRow = {
|
|
230
|
-
type: 'tr',
|
|
231
|
-
children: []
|
|
232
|
-
};
|
|
233
|
-
for (var j = 0; j < columnsLength; j++) {
|
|
234
|
-
tableRow.children.push({
|
|
235
|
-
type: 'td',
|
|
236
|
-
children: [{
|
|
237
|
-
text: ''
|
|
238
|
-
}]
|
|
239
|
-
});
|
|
132
|
+
if (block.nodes[0].objects) {
|
|
133
|
+
block.nodes[0] = {
|
|
134
|
+
object: block.nodes[0].objects[0]
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
block.parent = {
|
|
139
|
+
type: block.parent.types[0]
|
|
140
|
+
};
|
|
141
|
+
} else {
|
|
142
|
+
block.nodes[0] = {
|
|
143
|
+
type: block.nodes[0].types[0]
|
|
144
|
+
};
|
|
240
145
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
core.utils.getTableBlock = function (editor) {
|
|
252
|
-
return getAncestorByType(editor, 'table');
|
|
253
|
-
};
|
|
254
|
-
core.utils.isSelectionInTable = function (editor) {
|
|
255
|
-
return !!core.utils.getTableBlock(editor);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
core.utils.getTableBlock = function (containerNode, key) {
|
|
150
|
+
var node = containerNode.getDescendant(key);
|
|
151
|
+
var ancestors = containerNode.getAncestors(key).push(node);
|
|
152
|
+
return ancestors.findLast(function (p) {
|
|
153
|
+
return p.type === 'table';
|
|
154
|
+
});
|
|
256
155
|
};
|
|
156
|
+
|
|
257
157
|
core.utils.createTableWithOptions = function (row, columns, extra) {
|
|
258
158
|
var createdTable = core.utils.createTable(row, columns);
|
|
259
|
-
|
|
159
|
+
|
|
160
|
+
var newTable = _slate.Block.create(_objectSpread(_objectSpread({}, createdTable.toJSON()), extra));
|
|
161
|
+
|
|
260
162
|
return newTable;
|
|
261
163
|
};
|
|
164
|
+
|
|
262
165
|
core.toolbar = {
|
|
263
166
|
icon: /*#__PURE__*/_react["default"].createElement(_GridOn["default"], null),
|
|
264
|
-
onClick: function onClick(
|
|
167
|
+
onClick: function onClick(value, onChange) {
|
|
265
168
|
log('insert table');
|
|
169
|
+
var change = value.change();
|
|
266
170
|
var newTable = core.utils.createTableWithOptions(2, 2, {
|
|
267
171
|
data: {
|
|
268
172
|
border: '1',
|
|
269
173
|
newTable: true
|
|
270
174
|
}
|
|
271
175
|
});
|
|
272
|
-
|
|
273
|
-
|
|
176
|
+
change.insertBlock(newTable);
|
|
177
|
+
moveFocusToBeginningOfTable(change);
|
|
178
|
+
onChange(change);
|
|
274
179
|
},
|
|
180
|
+
supports: function supports(node, value) {
|
|
181
|
+
return node && node.object === 'block' && core.utils.isSelectionInTable(value);
|
|
182
|
+
},
|
|
183
|
+
|
|
275
184
|
/**
|
|
276
185
|
* Note - the node may not be a table node - it may be a node inside a table.
|
|
277
186
|
*/
|
|
278
|
-
customToolbar: function customToolbar(node,
|
|
187
|
+
customToolbar: function customToolbar(node, value, onToolbarDone) {
|
|
279
188
|
log('[customToolbar] node.data: ', node.data);
|
|
280
|
-
var
|
|
281
|
-
_core$utils$getTableB2 = (0, _slicedToArray2["default"])(_core$utils$getTableB, 1),
|
|
282
|
-
tableBlock = _core$utils$getTableB2[0];
|
|
189
|
+
var tableBlock = core.utils.getTableBlock(value.document, node === null || node === void 0 ? void 0 : node.key);
|
|
283
190
|
log('[customToolbar] tableBlock: ', tableBlock);
|
|
191
|
+
|
|
284
192
|
var hasBorder = function hasBorder() {
|
|
285
|
-
return (
|
|
193
|
+
return tableBlock.data.get('border') && tableBlock.data.get('border') !== '0';
|
|
286
194
|
};
|
|
195
|
+
|
|
287
196
|
var addRow = function addRow() {
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
trNode = _getAncestorByType4[0],
|
|
291
|
-
trPath = _getAncestorByType4[1];
|
|
292
|
-
log('[addRow]');
|
|
293
|
-
if (trNode) {
|
|
294
|
-
var newTr = {
|
|
295
|
-
type: 'tr',
|
|
296
|
-
children: []
|
|
297
|
-
};
|
|
298
|
-
var columnsLength = trNode.children.length;
|
|
299
|
-
for (var i = 0; i < columnsLength; i++) {
|
|
300
|
-
newTr.children.push({
|
|
301
|
-
type: 'td',
|
|
302
|
-
children: [{
|
|
303
|
-
text: ''
|
|
304
|
-
}]
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
_slate.Transforms.insertNodes(editor, [newTr], {
|
|
308
|
-
at: trPath
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var removeRow = function removeRow() {
|
|
313
|
-
var _getAncestorByType5 = getAncestorByType(editor, 'tbody'),
|
|
314
|
-
_getAncestorByType6 = (0, _slicedToArray2["default"])(_getAncestorByType5, 2),
|
|
315
|
-
tBodyNode = _getAncestorByType6[0],
|
|
316
|
-
tBodyPath = _getAncestorByType6[1];
|
|
317
|
-
log('[removeRow]');
|
|
318
|
-
if (tBodyPath) {
|
|
319
|
-
if (tBodyNode.children.length > 1) {
|
|
320
|
-
var _getAncestorByType7 = getAncestorByType(editor, 'tr'),
|
|
321
|
-
_getAncestorByType8 = (0, _slicedToArray2["default"])(_getAncestorByType7, 2),
|
|
322
|
-
trPath = _getAncestorByType8[1];
|
|
323
|
-
log('[removeRow]');
|
|
324
|
-
if (trPath) {
|
|
325
|
-
_slate.Transforms.removeNodes(editor, {
|
|
326
|
-
at: trPath
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
197
|
+
var change = core.changes.insertRow(value.change());
|
|
198
|
+
onToolbarDone(change, false);
|
|
331
199
|
};
|
|
200
|
+
|
|
332
201
|
var addColumn = function addColumn() {
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
tBodyNode = _getAncestorByType10[0],
|
|
336
|
-
tBodyPath = _getAncestorByType10[1];
|
|
337
|
-
log('[addColumn]');
|
|
338
|
-
if (tBodyNode) {
|
|
339
|
-
var emptyTd = {
|
|
340
|
-
type: 'td',
|
|
341
|
-
children: [{
|
|
342
|
-
text: ''
|
|
343
|
-
}]
|
|
344
|
-
};
|
|
345
|
-
var trElements = _slate.Editor.nodes(editor, {
|
|
346
|
-
at: tBodyPath,
|
|
347
|
-
// Path of Editor
|
|
348
|
-
match: function match(node) {
|
|
349
|
-
return 'tr' === node.type;
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
var _iterator3 = _createForOfIteratorHelper(trElements),
|
|
353
|
-
_step3;
|
|
354
|
-
try {
|
|
355
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
356
|
-
var _step3$value = (0, _slicedToArray2["default"])(_step3.value, 2),
|
|
357
|
-
trNode = _step3$value[0],
|
|
358
|
-
_nodePath = _step3$value[1];
|
|
359
|
-
_slate.Transforms.insertNodes(editor, [emptyTd], {
|
|
360
|
-
at: [].concat((0, _toConsumableArray2["default"])(_nodePath), [trNode.children.length])
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
} catch (err) {
|
|
364
|
-
_iterator3.e(err);
|
|
365
|
-
} finally {
|
|
366
|
-
_iterator3.f();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
202
|
+
var change = core.changes.insertColumn(value.change());
|
|
203
|
+
onToolbarDone(change, false);
|
|
369
204
|
};
|
|
205
|
+
|
|
206
|
+
var removeRow = function removeRow() {
|
|
207
|
+
var change = core.changes.removeRow(value.change());
|
|
208
|
+
onToolbarDone(change, false);
|
|
209
|
+
};
|
|
210
|
+
|
|
370
211
|
var removeColumn = function removeColumn() {
|
|
371
|
-
var
|
|
372
|
-
|
|
373
|
-
tBodyNode = _getAncestorByType12[0],
|
|
374
|
-
tBodyPath = _getAncestorByType12[1];
|
|
375
|
-
log('[addColumn]');
|
|
376
|
-
if (tBodyNode) {
|
|
377
|
-
var currentPath = _slate.Editor.path(editor, editor.selection);
|
|
378
|
-
var columnIndex = currentPath[currentPath.length - 2];
|
|
379
|
-
var trElements = _slate.Editor.nodes(editor, {
|
|
380
|
-
at: tBodyPath,
|
|
381
|
-
// Path of Editor
|
|
382
|
-
match: function match(node) {
|
|
383
|
-
return 'tr' === node.type;
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
var _iterator4 = _createForOfIteratorHelper(trElements),
|
|
387
|
-
_step4;
|
|
388
|
-
try {
|
|
389
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
390
|
-
var _step4$value = (0, _slicedToArray2["default"])(_step4.value, 2),
|
|
391
|
-
trNode = _step4$value[0],
|
|
392
|
-
_nodePath2 = _step4$value[1];
|
|
393
|
-
if (trNode.children.length > 1) {
|
|
394
|
-
_slate.Transforms.removeNodes(editor, {
|
|
395
|
-
at: [].concat((0, _toConsumableArray2["default"])(_nodePath2), [columnIndex])
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
} catch (err) {
|
|
400
|
-
_iterator4.e(err);
|
|
401
|
-
} finally {
|
|
402
|
-
_iterator4.f();
|
|
403
|
-
}
|
|
404
|
-
}
|
|
212
|
+
var change = core.changes.removeColumn(value.change());
|
|
213
|
+
onToolbarDone(change, false);
|
|
405
214
|
};
|
|
215
|
+
|
|
406
216
|
var removeTable = function removeTable() {
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
tableNode = _getAncestorByType14[0],
|
|
410
|
-
tablePath = _getAncestorByType14[1];
|
|
411
|
-
editor.apply({
|
|
412
|
-
type: 'remove_node',
|
|
413
|
-
path: tablePath,
|
|
414
|
-
node: tableNode
|
|
415
|
-
});
|
|
217
|
+
var change = core.changes.removeTable(value.change());
|
|
218
|
+
onToolbarDone(change, false);
|
|
416
219
|
};
|
|
220
|
+
|
|
417
221
|
var toggleBorder = function toggleBorder() {
|
|
418
222
|
var data = tableBlock.data;
|
|
419
|
-
var update =
|
|
420
|
-
border: hasBorder() ? '0' : '1'
|
|
421
|
-
});
|
|
422
|
-
var _getAncestorByType15 = getAncestorByType(editor, 'table'),
|
|
423
|
-
_getAncestorByType16 = (0, _slicedToArray2["default"])(_getAncestorByType15, 2),
|
|
424
|
-
tablePath = _getAncestorByType16[1];
|
|
223
|
+
var update = data.set('border', hasBorder() ? '0' : '1');
|
|
425
224
|
log('[toggleBorder] update: ', update);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
path: tablePath,
|
|
429
|
-
properties: {
|
|
430
|
-
data: node.data
|
|
431
|
-
},
|
|
432
|
-
newProperties: {
|
|
433
|
-
data: update
|
|
434
|
-
}
|
|
225
|
+
var change = value.change().setNodeByKey(tableBlock.key, {
|
|
226
|
+
data: update
|
|
435
227
|
});
|
|
228
|
+
onToolbarDone(change, false);
|
|
436
229
|
};
|
|
230
|
+
|
|
437
231
|
var onDone = function onDone() {
|
|
438
232
|
log('[onDone] call onToolbarDone...');
|
|
439
|
-
onToolbarDone(true);
|
|
233
|
+
onToolbarDone(null, true);
|
|
440
234
|
};
|
|
235
|
+
|
|
441
236
|
var Tb = function Tb() {
|
|
442
237
|
return /*#__PURE__*/_react["default"].createElement(_tableToolbar["default"], {
|
|
443
|
-
editor: editor,
|
|
444
238
|
plugins: toolbarPlugins,
|
|
445
239
|
onChange: function onChange(c) {
|
|
446
240
|
return onToolbarDone(c, false);
|
|
447
241
|
},
|
|
242
|
+
value: value,
|
|
448
243
|
onAddRow: addRow,
|
|
449
244
|
onRemoveRow: removeRow,
|
|
450
245
|
onAddColumn: addColumn,
|
|
@@ -455,12 +250,11 @@ var _default = function _default(opts, toolbarPlugins /* : {toolbar: {}}[] */)
|
|
|
455
250
|
onDone: onDone
|
|
456
251
|
});
|
|
457
252
|
};
|
|
253
|
+
|
|
458
254
|
return Tb;
|
|
459
255
|
}
|
|
460
256
|
};
|
|
461
|
-
|
|
462
|
-
return TABLE_TYPES.includes(node.type);
|
|
463
|
-
};
|
|
257
|
+
|
|
464
258
|
var Node = function Node(props) {
|
|
465
259
|
switch (props.node.type) {
|
|
466
260
|
case 'table':
|
|
@@ -468,49 +262,125 @@ var _default = function _default(opts, toolbarPlugins /* : {toolbar: {}}[] */)
|
|
|
468
262
|
onFocus: opts.onFocus,
|
|
469
263
|
onBlur: opts.onBlur
|
|
470
264
|
}));
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
onFocus: opts.onFocus,
|
|
474
|
-
onBlur: opts.onBlur
|
|
475
|
-
}));
|
|
476
|
-
case 'tr':
|
|
265
|
+
|
|
266
|
+
case 'table_row':
|
|
477
267
|
return /*#__PURE__*/_react["default"].createElement(TableRow, props);
|
|
478
|
-
|
|
268
|
+
|
|
269
|
+
case 'table_cell':
|
|
479
270
|
return /*#__PURE__*/_react["default"].createElement(TableCell, (0, _extends2["default"])({}, props, {
|
|
480
271
|
onFocus: opts.onFocus,
|
|
481
272
|
onBlur: opts.onBlur
|
|
482
273
|
}));
|
|
274
|
+
|
|
483
275
|
default:
|
|
484
276
|
return null;
|
|
485
277
|
}
|
|
486
278
|
};
|
|
279
|
+
|
|
487
280
|
Node.propTypes = {
|
|
488
281
|
node: _propTypes["default"].object
|
|
489
282
|
};
|
|
283
|
+
|
|
284
|
+
core.normalizeNode = function (node) {
|
|
285
|
+
if (node.object !== 'document') {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var tableAdded = node.findDescendant(function (d) {
|
|
290
|
+
return d.data && d.data.get('newTable');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
if (!tableAdded) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
var nodeToSearch = node.getParent(tableAdded.key) || node;
|
|
298
|
+
var shouldAddTextAfterNode = false;
|
|
299
|
+
var indexToNotHaveTableOn = nodeToSearch.nodes.size - 1;
|
|
300
|
+
var indexOfLastTable = nodeToSearch.nodes.findLastIndex(function (d) {
|
|
301
|
+
return d.type === 'table';
|
|
302
|
+
}); // if the last table in the document is of type table, we need to do the change
|
|
303
|
+
|
|
304
|
+
if (indexOfLastTable === indexToNotHaveTableOn) {
|
|
305
|
+
shouldAddTextAfterNode = true;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!shouldAddTextAfterNode) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return function (change) {
|
|
313
|
+
if (shouldAddTextAfterNode) {
|
|
314
|
+
var tableJSON = tableAdded.toJSON(); // we remove the table node because otherwise we can't add the empty block after it
|
|
315
|
+
// we need a block that contains text in order to do it
|
|
316
|
+
|
|
317
|
+
change.removeNodeByKey(tableAdded.key);
|
|
318
|
+
|
|
319
|
+
var newBlock = _slate.Block.create({
|
|
320
|
+
object: 'block',
|
|
321
|
+
type: 'div'
|
|
322
|
+
}); // we add an empty block but that it's going to be normalized
|
|
323
|
+
// because it will add the empty text to it like it should
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
change.insertBlock(newBlock);
|
|
327
|
+
change.withoutNormalization(function () {
|
|
328
|
+
// we do these changes without normalization
|
|
329
|
+
// we get the text previous to the new block added
|
|
330
|
+
var prevText = change.value.document.getPreviousText(newBlock.key);
|
|
331
|
+
|
|
332
|
+
if (prevText) {
|
|
333
|
+
var _prevText$text, _prevText$text2;
|
|
334
|
+
|
|
335
|
+
// we move focus to the previous text
|
|
336
|
+
change.moveFocusTo(prevText.key, (_prevText$text = prevText.text) === null || _prevText$text === void 0 ? void 0 : _prevText$text.length).moveAnchorTo(prevText.key, (_prevText$text2 = prevText.text) === null || _prevText$text2 === void 0 ? void 0 : _prevText$text2.length);
|
|
337
|
+
} // we insert the table block between the first block with text and the last block with text
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
change.insertBlock(_objectSpread(_objectSpread({}, tableJSON), {}, {
|
|
341
|
+
data: _objectSpread(_objectSpread({}, tableJSON.data), {}, {
|
|
342
|
+
newTable: true
|
|
343
|
+
})
|
|
344
|
+
}));
|
|
345
|
+
moveFocusToBeginningOfTable(change);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
|
|
490
351
|
core.renderNode = Node;
|
|
491
352
|
return core;
|
|
492
353
|
};
|
|
354
|
+
|
|
493
355
|
exports["default"] = _default;
|
|
356
|
+
|
|
494
357
|
var parseStyleString = function parseStyleString(s) {
|
|
495
358
|
var regex = /([\w-]*)\s*:\s*([^;]*)/g;
|
|
496
359
|
var match;
|
|
497
360
|
var result = {};
|
|
361
|
+
|
|
498
362
|
while (match = regex.exec(s)) {
|
|
499
363
|
result[match[1]] = match[2].trim();
|
|
500
364
|
}
|
|
365
|
+
|
|
501
366
|
return result;
|
|
502
367
|
};
|
|
368
|
+
|
|
503
369
|
exports.parseStyleString = parseStyleString;
|
|
370
|
+
|
|
504
371
|
var reactAttributes = function reactAttributes(o) {
|
|
505
372
|
return (0, _toStyle.object)(o, {
|
|
506
373
|
camelize: true,
|
|
507
374
|
addUnits: false
|
|
508
375
|
});
|
|
509
376
|
};
|
|
377
|
+
|
|
510
378
|
exports.reactAttributes = reactAttributes;
|
|
379
|
+
|
|
511
380
|
var attributesToMap = function attributesToMap(el) {
|
|
512
381
|
return function (acc, attribute) {
|
|
513
382
|
var value = el.getAttribute(attribute);
|
|
383
|
+
|
|
514
384
|
if (value) {
|
|
515
385
|
if (attribute === 'style') {
|
|
516
386
|
var styleString = el.getAttribute(attribute);
|
|
@@ -520,88 +390,107 @@ var attributesToMap = function attributesToMap(el) {
|
|
|
520
390
|
acc[attribute] = el.getAttribute(attribute);
|
|
521
391
|
}
|
|
522
392
|
}
|
|
393
|
+
|
|
523
394
|
return acc;
|
|
524
395
|
};
|
|
525
396
|
};
|
|
397
|
+
|
|
526
398
|
var dataToAttributes = function dataToAttributes(data) {
|
|
527
|
-
|
|
399
|
+
if (!data || !data.get) {
|
|
400
|
+
return {};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return data.reduce(function (acc, v, name) {
|
|
528
404
|
if (v) {
|
|
529
405
|
acc[(0, _reactAttrConverter["default"])(name)] = v;
|
|
530
406
|
}
|
|
407
|
+
|
|
531
408
|
return acc;
|
|
532
409
|
}, {});
|
|
533
410
|
};
|
|
411
|
+
|
|
534
412
|
var attributes = ['border', 'cellpadding', 'cellspacing', 'class', 'style'];
|
|
535
413
|
var cellAttributes = ['colspan', 'rowspan', 'class', 'style'];
|
|
536
414
|
var serialization = {
|
|
537
415
|
deserialize: function deserialize(el, next) {
|
|
538
416
|
var tag = el.tagName.toLowerCase();
|
|
417
|
+
|
|
539
418
|
switch (tag) {
|
|
540
419
|
case 'table':
|
|
541
420
|
{
|
|
542
421
|
var children = el.children.length === 1 && el.children[0].tagName.toLowerCase() === 'tbody' ? el.children[0].children : el.children;
|
|
543
422
|
var c = Array.from(children);
|
|
544
|
-
return
|
|
423
|
+
return {
|
|
424
|
+
object: 'block',
|
|
545
425
|
type: 'table',
|
|
426
|
+
nodes: next(c),
|
|
546
427
|
data: attributes.reduce(attributesToMap(el), {})
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
case 'tbody':
|
|
550
|
-
{
|
|
551
|
-
return (0, _slateHyperscript.jsx)('element', {
|
|
552
|
-
type: 'tbody'
|
|
553
|
-
}, next(el.childNodes));
|
|
428
|
+
};
|
|
554
429
|
}
|
|
430
|
+
|
|
555
431
|
case 'th':
|
|
556
432
|
{
|
|
557
|
-
return
|
|
558
|
-
|
|
433
|
+
return {
|
|
434
|
+
object: 'block',
|
|
435
|
+
type: 'table_cell',
|
|
436
|
+
nodes: next(el.childNodes),
|
|
559
437
|
data: cellAttributes.reduce(attributesToMap(el), {
|
|
560
438
|
header: true
|
|
561
439
|
})
|
|
562
|
-
}
|
|
440
|
+
};
|
|
563
441
|
}
|
|
442
|
+
|
|
564
443
|
case 'tr':
|
|
565
444
|
{
|
|
566
|
-
return
|
|
567
|
-
|
|
568
|
-
|
|
445
|
+
return {
|
|
446
|
+
object: 'block',
|
|
447
|
+
type: 'table_row',
|
|
448
|
+
nodes: next(Array.from(el.children))
|
|
449
|
+
};
|
|
569
450
|
}
|
|
451
|
+
|
|
570
452
|
case 'td':
|
|
571
453
|
{
|
|
572
|
-
return
|
|
573
|
-
|
|
454
|
+
return {
|
|
455
|
+
object: 'block',
|
|
456
|
+
type: 'table_cell',
|
|
457
|
+
nodes: next(Array.from(el.childNodes)),
|
|
574
458
|
data: cellAttributes.reduce(attributesToMap(el), {
|
|
575
|
-
header:
|
|
459
|
+
header: false
|
|
576
460
|
})
|
|
577
|
-
}
|
|
461
|
+
};
|
|
578
462
|
}
|
|
579
463
|
}
|
|
580
464
|
},
|
|
581
465
|
serialize: function serialize(object, children) {
|
|
466
|
+
if (object.object !== 'block') {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
|
|
582
470
|
switch (object.type) {
|
|
583
471
|
case 'table':
|
|
584
472
|
{
|
|
585
473
|
var _attributes = dataToAttributes(object.data);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
case 'tbody':
|
|
589
|
-
{
|
|
590
|
-
return /*#__PURE__*/_react["default"].createElement("tbody", null, children);
|
|
474
|
+
|
|
475
|
+
return /*#__PURE__*/_react["default"].createElement("table", _attributes, /*#__PURE__*/_react["default"].createElement("tbody", null, children));
|
|
591
476
|
}
|
|
592
|
-
|
|
477
|
+
|
|
478
|
+
case 'table_row':
|
|
593
479
|
{
|
|
594
480
|
return /*#__PURE__*/_react["default"].createElement("tr", null, children);
|
|
595
481
|
}
|
|
596
|
-
|
|
482
|
+
|
|
483
|
+
case 'table_cell':
|
|
597
484
|
{
|
|
598
485
|
var _attributes2 = dataToAttributes(object.data);
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
486
|
+
|
|
487
|
+
delete _attributes2.header;
|
|
488
|
+
|
|
489
|
+
if (object.data.get('header')) {
|
|
490
|
+
return /*#__PURE__*/_react["default"].createElement("th", _attributes2, children);
|
|
491
|
+
} else {
|
|
492
|
+
return /*#__PURE__*/_react["default"].createElement("td", _attributes2, children);
|
|
493
|
+
}
|
|
605
494
|
}
|
|
606
495
|
}
|
|
607
496
|
}
|