@seafile/sea-email-editor 0.0.4 → 0.0.5
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/dist/extension/plugins/table/context-menu/index.css +1 -1
- package/dist/extension/plugins/table/context-menu/index.js +9 -3
- package/dist/extension/plugins/table/render-elem/index.js +8 -3
- package/dist/slate-convert/html-to-slate/constants.js +1 -1
- package/dist/slate-convert/html-to-slate/index.js +18 -0
- package/dist/slate-convert/html-to-slate/rules/table.js +6 -2
- package/dist/slate-convert/slate-to-html/index.js +4 -2
- package/package.json +1 -1
|
@@ -45,9 +45,15 @@ const ContextMenu = _ref => {
|
|
|
45
45
|
top,
|
|
46
46
|
left
|
|
47
47
|
} = position;
|
|
48
|
+
const {
|
|
49
|
+
width,
|
|
50
|
+
height
|
|
51
|
+
} = contextMenuRef.current.getBoundingClientRect();
|
|
52
|
+
const validTop = window.innerHeight - top >= height ? top : window.innerHeight - height;
|
|
53
|
+
const validLeft = window.innerWidth - left >= width ? left : window.innerWidth - width;
|
|
48
54
|
setContextMenuStyle({
|
|
49
|
-
top,
|
|
50
|
-
left,
|
|
55
|
+
top: validTop,
|
|
56
|
+
left: validLeft,
|
|
51
57
|
zIndex: '1071',
|
|
52
58
|
display: 'block'
|
|
53
59
|
});
|
|
@@ -66,11 +72,11 @@ const ContextMenu = _ref => {
|
|
|
66
72
|
};
|
|
67
73
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
68
74
|
contentEditable: false,
|
|
69
|
-
ref: contextMenuRef,
|
|
70
75
|
style: contextMenuStyle,
|
|
71
76
|
className: "sea-email-option-editor-popover show sea-email-table-context-menu",
|
|
72
77
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
73
78
|
className: "popover show bs-popover-auto",
|
|
79
|
+
ref: contextMenuRef,
|
|
74
80
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
75
81
|
className: "popover-inner",
|
|
76
82
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -12,7 +12,6 @@ var _slate = require("slate");
|
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
var _constant = require("../constant");
|
|
14
14
|
var _contextMenu = _interopRequireDefault(require("../context-menu"));
|
|
15
|
-
var _helper = require("../helper");
|
|
16
15
|
var _core = require("../../../core");
|
|
17
16
|
var _constants = require("../../../constants");
|
|
18
17
|
var _eventBus = _interopRequireDefault(require("../../../../utils/event-bus"));
|
|
@@ -165,8 +164,14 @@ const RenderTableContainer = (_ref, editor) => {
|
|
|
165
164
|
}
|
|
166
165
|
e.preventDefault();
|
|
167
166
|
e.stopPropagation();
|
|
168
|
-
const
|
|
169
|
-
|
|
167
|
+
const {
|
|
168
|
+
clientY,
|
|
169
|
+
clientX
|
|
170
|
+
} = e;
|
|
171
|
+
setContextMenuPosition({
|
|
172
|
+
left: clientX,
|
|
173
|
+
top: clientY
|
|
174
|
+
});
|
|
170
175
|
setIsShowContextMenu(true);
|
|
171
176
|
}, []);
|
|
172
177
|
const handleCloseContextMenu = () => {
|
|
@@ -133,7 +133,7 @@ Object.defineProperty(exports, "UNORDERED_LIST", {
|
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
135
|
var _elementTypes = require("../../extension/constants/element-types");
|
|
136
|
-
const TOP_LEVEL_TYPES = exports.TOP_LEVEL_TYPES = [_elementTypes.BLOCKQUOTE, _elementTypes.HEADER1, _elementTypes.HEADER2, _elementTypes.HEADER3, _elementTypes.HEADER4, _elementTypes.HEADER5, _elementTypes.HEADER6, _elementTypes.ORDERED_LIST, _elementTypes.UNORDERED_LIST, _elementTypes.CHECK_LIST_ITEM, _elementTypes.PARAGRAPH, _elementTypes.CODE_BLOCK, _elementTypes.TABLE];
|
|
136
|
+
const TOP_LEVEL_TYPES = exports.TOP_LEVEL_TYPES = [_elementTypes.BLOCKQUOTE, _elementTypes.HEADER1, _elementTypes.HEADER2, _elementTypes.HEADER3, _elementTypes.HEADER4, _elementTypes.HEADER5, _elementTypes.HEADER6, _elementTypes.ORDERED_LIST, _elementTypes.UNORDERED_LIST, _elementTypes.CHECK_LIST_ITEM, _elementTypes.PARAGRAPH, _elementTypes.CODE_BLOCK, _elementTypes.TABLE, _elementTypes.P, _elementTypes.BR];
|
|
137
137
|
const INLINE_LEVEL_TYPES = exports.INLINE_LEVEL_TYPES = [_elementTypes.IMAGE, _elementTypes.LINK];
|
|
138
138
|
const HEADER_LIST = exports.HEADER_LIST = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
|
139
139
|
const HEADER_TYPE_MAP = exports.HEADER_TYPE_MAP = {
|
|
@@ -78,6 +78,24 @@ const deserializeElements = function () {
|
|
|
78
78
|
});
|
|
79
79
|
return (0, _helper.formatInlineNodes)(nodes);
|
|
80
80
|
};
|
|
81
|
+
|
|
82
|
+
// const formatTableNode = (node, path) => {
|
|
83
|
+
// if (node.type === TABLE) {
|
|
84
|
+
// const columnsCount = Math.max(...node.children.map(row => row.children.length));
|
|
85
|
+
// node.children = node.children.map(row => {
|
|
86
|
+
// for (let i = row.children.length; i < columnsCount; i++) {
|
|
87
|
+
// row.children.push(generateTableCell());
|
|
88
|
+
// }
|
|
89
|
+
// return row;
|
|
90
|
+
// });
|
|
91
|
+
// return node;
|
|
92
|
+
// }
|
|
93
|
+
// if (Array.isArray(node.children)) {
|
|
94
|
+
// node.children = node.children.map((child, index) => formatTableNode(child, [...path, index]));
|
|
95
|
+
// }
|
|
96
|
+
// return node;
|
|
97
|
+
// };
|
|
98
|
+
|
|
81
99
|
const formatElementNodes = nodes => {
|
|
82
100
|
if (nodes.length === 0) {
|
|
83
101
|
return [{
|
|
@@ -39,7 +39,7 @@ const tableRule = (element, parseChild) => {
|
|
|
39
39
|
}
|
|
40
40
|
if (nodeName === 'TH' || nodeName === 'TD') {
|
|
41
41
|
const children = Array.from(childNodes);
|
|
42
|
-
const cellChildren = children.flatMap(child => {
|
|
42
|
+
const cellChildren = children.length > 0 ? children.flatMap(child => {
|
|
43
43
|
// Replace paragraph node with text node
|
|
44
44
|
if (child.nodeName === 'P') {
|
|
45
45
|
const textContent = Array.from(child.childNodes).map(child => child.textContent).join('');
|
|
@@ -51,7 +51,11 @@ const tableRule = (element, parseChild) => {
|
|
|
51
51
|
return (0, _helper.mergeElementOther2SlateNode)(child, node);
|
|
52
52
|
}
|
|
53
53
|
return parseChild([child]);
|
|
54
|
-
})
|
|
54
|
+
}) : [{
|
|
55
|
+
id: _slugid.default.nice(),
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: ''
|
|
58
|
+
}];
|
|
55
59
|
const node = {
|
|
56
60
|
id: _slugid.default.nice(),
|
|
57
61
|
type: _constants.TABLE_CELL,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.findElementByPath = exports.default = void 0;
|
|
7
7
|
var _slate = require("slate");
|
|
8
8
|
var _constants = require("../../extension/constants");
|
|
9
9
|
const isContentValid = value => {
|
|
@@ -73,8 +73,9 @@ const ELEMENT_HTML_TAG = {
|
|
|
73
73
|
[_constants.ElementTypes.TABLE_CELL]: 'td'
|
|
74
74
|
};
|
|
75
75
|
const findElementByPath = (value, path) => {
|
|
76
|
-
return path.reduce((element, pathIndex) => element[pathIndex], value);
|
|
76
|
+
return path.reduce((element, pathIndex, currentIndex) => currentIndex === 0 ? element[pathIndex] : element === null || element === void 0 ? void 0 : element.children[pathIndex], value);
|
|
77
77
|
};
|
|
78
|
+
exports.findElementByPath = findElementByPath;
|
|
78
79
|
const element2Html = (value, element, path) => {
|
|
79
80
|
const {
|
|
80
81
|
type
|
|
@@ -142,6 +143,7 @@ const slateToHtml = value => {
|
|
|
142
143
|
value.forEach((element, index) => {
|
|
143
144
|
html += element2Html(value, element, [index]);
|
|
144
145
|
});
|
|
146
|
+
console.log(html);
|
|
145
147
|
return html;
|
|
146
148
|
};
|
|
147
149
|
var _default = exports.default = slateToHtml;
|