@seafile/sdoc-editor 1.0.216 → 1.0.218
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/basic-sdk/extension/core/queries/index.js +4 -1
- package/dist/basic-sdk/extension/plugins/check-list/helpers.js +35 -9
- package/dist/basic-sdk/extension/plugins/video/helpers.js +1 -0
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +1 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +6 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +1 -0
- package/package.json +1 -1
|
@@ -104,9 +104,12 @@ const getCommonNode = (root, path, ancestor) => {
|
|
|
104
104
|
exports.getCommonNode = getCommonNode;
|
|
105
105
|
const getSelectedNodeByType = (editor, type) => {
|
|
106
106
|
const match = n => getNodeType(n) === type;
|
|
107
|
+
if (!editor.selection) return;
|
|
108
|
+
const at = _slate.Range.isCollapsed(editor.selection) ? editor.selection : _slate.Editor.start(editor, editor.selection);
|
|
107
109
|
const [nodeEntry] = _slate.Editor.nodes(editor, {
|
|
108
110
|
match,
|
|
109
|
-
universal: true
|
|
111
|
+
universal: true,
|
|
112
|
+
at
|
|
110
113
|
});
|
|
111
114
|
return nodeEntry ? nodeEntry[0] : null;
|
|
112
115
|
};
|
|
@@ -72,16 +72,42 @@ const setCheckListItemType = (editor, newType, insertPosition) => {
|
|
|
72
72
|
});
|
|
73
73
|
_slate.Transforms.select(editor, [path[0] + 1]);
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
if (!(0, _core.isRangeAcrossBlocks)(editor)) {
|
|
76
|
+
const path = _slate.Editor.path(editor, editor.selection);
|
|
77
|
+
if (path) {
|
|
78
|
+
const [targetNode, targetPath] = _slate.Editor.node(editor, [path[0]]);
|
|
79
|
+
if (targetNode && [_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes(targetNode === null || targetNode === void 0 ? void 0 : targetNode.type)) {
|
|
80
|
+
convertToCheck(editor, targetNode, targetPath);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
81
83
|
}
|
|
84
|
+
_slate.Transforms.setNodes(editor, {
|
|
85
|
+
type: newType
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
const nodes = _slate.Editor.nodes(editor, {
|
|
89
|
+
match: n => {
|
|
90
|
+
const type = (0, _core.getNodeType)(n);
|
|
91
|
+
if (!type) return;
|
|
92
|
+
if (type === _constants.PARAGRAPH) return true;
|
|
93
|
+
if (type === _constants.CHECK_LIST_ITEM) return true;
|
|
94
|
+
if (type.startsWith(_constants.HEADER)) return true;
|
|
95
|
+
if (type === _constants.TITLE) return true;
|
|
96
|
+
if (type === _constants.SUBTITLE) return true;
|
|
97
|
+
return false;
|
|
98
|
+
},
|
|
99
|
+
universal: false,
|
|
100
|
+
mode: 'highest' // Match top level
|
|
101
|
+
});
|
|
102
|
+
const nodesEntry = Array.from(nodes);
|
|
103
|
+
if (nodesEntry.length === 0) return;
|
|
104
|
+
nodesEntry.forEach(nodeEntry => {
|
|
105
|
+
_slate.Transforms.setNodes(editor, {
|
|
106
|
+
type: newType
|
|
107
|
+
}, {
|
|
108
|
+
at: nodeEntry[1]
|
|
109
|
+
});
|
|
110
|
+
});
|
|
82
111
|
}
|
|
83
|
-
_slate.Transforms.setNodes(editor, {
|
|
84
|
-
type: newType
|
|
85
|
-
});
|
|
86
112
|
};
|
|
87
113
|
exports.setCheckListItemType = setCheckListItemType;
|
|
@@ -34,6 +34,7 @@ const isInsertVideoMenuDisabled = (editor, readonly) => {
|
|
|
34
34
|
if (type === _constants.MULTI_COLUMN) return true;
|
|
35
35
|
if (type === _constants.BLOCKQUOTE) return true;
|
|
36
36
|
if (type === _constants.CALL_OUT) return true;
|
|
37
|
+
if (type === _constants.TABLE) return true;
|
|
37
38
|
if (_slate.Editor.isVoid(editor, n)) return true;
|
|
38
39
|
return false;
|
|
39
40
|
},
|
|
@@ -134,7 +134,7 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
134
134
|
}, [editor]);
|
|
135
135
|
const isDisableVideo = (0, _react.useMemo)(() => {
|
|
136
136
|
const callout = (0, _core.getAboveBlockNode)(editor, {
|
|
137
|
-
match: n => [_constants.ELEMENT_TYPE.ORDERED_LIST, _constants.ELEMENT_TYPE.UNORDERED_LIST, _constants.ELEMENT_TYPE.CHECK_LIST_ITEM].includes(n.type)
|
|
137
|
+
match: n => [_constants.ELEMENT_TYPE.ORDERED_LIST, _constants.ELEMENT_TYPE.UNORDERED_LIST, _constants.ELEMENT_TYPE.CHECK_LIST_ITEM, _constants.ELEMENT_TYPE.MULTI_COLUMN].includes(n.type)
|
|
138
138
|
});
|
|
139
139
|
return !!callout;
|
|
140
140
|
}, [editor]);
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
|
|
7
|
+
exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isInMultiColumnNode = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
|
|
8
8
|
var _slate = require("@seafile/slate");
|
|
9
9
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
@@ -187,6 +187,11 @@ const isMultiColumn = (editor, path) => {
|
|
|
187
187
|
return false;
|
|
188
188
|
};
|
|
189
189
|
exports.isMultiColumn = isMultiColumn;
|
|
190
|
+
const isInMultiColumnNode = (editor, node) => {
|
|
191
|
+
const topNodePath = [(0, _core.findPath)(editor, node)[0]];
|
|
192
|
+
return isMultiColumn(editor, topNodePath);
|
|
193
|
+
};
|
|
194
|
+
exports.isInMultiColumnNode = isInMultiColumnNode;
|
|
190
195
|
const isList = (editor, path) => {
|
|
191
196
|
var _nodeEntry$3;
|
|
192
197
|
const nodeEntry = _slate.Editor.node(editor, [path[0]]);
|
|
@@ -144,6 +144,7 @@ const InsertBlockMenu = _ref => {
|
|
|
144
144
|
onClick: onInsertImageToggle
|
|
145
145
|
}), editor.editorType !== _constants2.DOCUMENT_PLUGIN_EDITOR && /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
146
146
|
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.VIDEO],
|
|
147
|
+
disabled: (0, _helpers.isInMultiColumnNode)(editor, slateNode),
|
|
147
148
|
menuConfig: {
|
|
148
149
|
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.VIDEO]
|
|
149
150
|
},
|