@seafile/seafile-editor 0.3.85 → 0.3.89
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/editor/controller/block-element-controller.js +30 -1
- package/dist/editor/controller/shortcut-controller.js +14 -1
- package/dist/editor/editor-plugin.js +10 -2
- package/dist/editor/editor-utils/block-element-utils/list-utils.js +13 -5
- package/dist/editor/editor-utils/common-editor-utils.js +6 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import { Editor } from 'slate';
|
|
4
|
+
import { Editor, Path, Node } from 'slate';
|
|
5
5
|
import ListUtils from '../editor-utils/block-element-utils/list-utils';
|
|
6
6
|
import CodeUtils from '../editor-utils/block-element-utils/code-utils';
|
|
7
7
|
import { isRangeCollapsed } from '../editor-utils/range-utils';
|
|
@@ -311,6 +311,35 @@ var withBlock = function withBlock(editor) {
|
|
|
311
311
|
});
|
|
312
312
|
break;
|
|
313
313
|
|
|
314
|
+
case 'modify_sublist_type':
|
|
315
|
+
var target_list_type = command.target_list_type;
|
|
316
|
+
var items = listUtils.getCurrentListItem();
|
|
317
|
+
var firstListItem = items.at(0);
|
|
318
|
+
var currentListPath = Path.parent(firstListItem[1]);
|
|
319
|
+
var parentPath = Path.parent(currentListPath);
|
|
320
|
+
Editor.withoutNormalizing(editor, function () {
|
|
321
|
+
for (var i = items.length - 1; i >= 0; i--) {
|
|
322
|
+
var _item = items[i];
|
|
323
|
+
var _path = _item[1];
|
|
324
|
+
Editor.liftNodes(editor, {
|
|
325
|
+
at: _path,
|
|
326
|
+
split: true
|
|
327
|
+
});
|
|
328
|
+
var currentListIndex = currentListPath.at(-1);
|
|
329
|
+
|
|
330
|
+
var currentListItemIndex = _path.at(-1);
|
|
331
|
+
|
|
332
|
+
Editor.wrapNodes(editor, {
|
|
333
|
+
type: target_list_type,
|
|
334
|
+
children: []
|
|
335
|
+
}, {
|
|
336
|
+
at: [].concat(_toConsumableArray(parentPath), [currentListItemIndex === 0 ? currentListIndex : currentListIndex + 1]),
|
|
337
|
+
split: true
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
break;
|
|
342
|
+
|
|
314
343
|
case 'set_code_block':
|
|
315
344
|
codeUtils.wrapCodeBlock();
|
|
316
345
|
break;
|
|
@@ -336,7 +336,7 @@ var withMarkdownShortcut = function withMarkdownShortcut(editor) {
|
|
|
336
336
|
var listItemPath = _node3[1];
|
|
337
337
|
var listNode = Node.parent(editor, listItemPath); // Unwrap the list item when the selection is at the first list item of the first node of document
|
|
338
338
|
|
|
339
|
-
if (anchor.path[0] === 0 && anchor.path[1] === 0) {
|
|
339
|
+
if (anchor.path[0] === 0 && anchor.path[1] === 0 && anchor.path[listItemPath.length] === 0) {
|
|
340
340
|
listUtils.unwrapList();
|
|
341
341
|
return;
|
|
342
342
|
} // unwrap an empty list
|
|
@@ -403,6 +403,19 @@ var withMarkdownShortcut = function withMarkdownShortcut(editor) {
|
|
|
403
403
|
exec(command);
|
|
404
404
|
break;
|
|
405
405
|
|
|
406
|
+
case 'delete_fragment':
|
|
407
|
+
var _Range$edges = Range.edges(editor.selection),
|
|
408
|
+
_Range$edges2 = _slicedToArray(_Range$edges, 2),
|
|
409
|
+
end = _Range$edges2[1];
|
|
410
|
+
|
|
411
|
+
var voids = Editor.match(editor, end.path, 'void');
|
|
412
|
+
var endVoid = voids ? voids : null; // do not unhange selection when end point is a void node when delete fragment,
|
|
413
|
+
|
|
414
|
+
Editor.delete(editor, {
|
|
415
|
+
hanging: endVoid ? true : false
|
|
416
|
+
});
|
|
417
|
+
return;
|
|
418
|
+
|
|
406
419
|
default:
|
|
407
420
|
exec(command);
|
|
408
421
|
}
|
|
@@ -233,10 +233,18 @@ var Plugin = function Plugin(_editor) {
|
|
|
233
233
|
|
|
234
234
|
if (nodeList.length === 1) {
|
|
235
235
|
event.preventDefault();
|
|
236
|
-
|
|
236
|
+
|
|
237
|
+
var _nodeList$ = _slicedToArray(nodeList[0], 2),
|
|
238
|
+
node = _nodeList$[0],
|
|
239
|
+
path = _nodeList$[1];
|
|
240
|
+
|
|
241
|
+
path = path.slice(1);
|
|
237
242
|
|
|
238
243
|
if (node && node.type === 'paragraph') {
|
|
239
|
-
|
|
244
|
+
// get selected paragraph node in selection and write to clipboard
|
|
245
|
+
var fragment = Node.fragment(editor, editor.selection);
|
|
246
|
+
var selectedNode = Node.get(fragment[0], Array(path.length).fill(0));
|
|
247
|
+
setEventTransfer(event, 'fragment', [selectedNode]);
|
|
240
248
|
} else {
|
|
241
249
|
setEventTransfer(event, 'text', SfEditor.text(editor, editor.selection));
|
|
242
250
|
}
|
|
@@ -324,10 +324,10 @@ var LitsUtils = function LitsUtils(editor) {
|
|
|
324
324
|
var listItems = [];
|
|
325
325
|
list.children.forEach(function (listItem) {
|
|
326
326
|
var children = listItem.children || [];
|
|
327
|
-
var
|
|
327
|
+
var child = children[0];
|
|
328
328
|
|
|
329
|
-
if (
|
|
330
|
-
listItems.push.apply(listItems, _toConsumableArray(_this.getNormalizedListItems(
|
|
329
|
+
if (child && child.type.includes('_list') && children.length === 1) {
|
|
330
|
+
listItems.push.apply(listItems, _toConsumableArray(_this.getNormalizedListItems(child)));
|
|
331
331
|
} else {
|
|
332
332
|
listItems.push(listItem);
|
|
333
333
|
}
|
|
@@ -371,10 +371,18 @@ var LitsUtils = function LitsUtils(editor) {
|
|
|
371
371
|
|
|
372
372
|
listItems.forEach(function (listItem, index) {
|
|
373
373
|
var itemChildren = listItem.children;
|
|
374
|
-
|
|
374
|
+
|
|
375
|
+
if (itemChildren[0].type.includes('list')) {
|
|
376
|
+
SfEditor.insertNodes(_this.editor, [itemChildren[0]]);
|
|
377
|
+
} else {
|
|
378
|
+
SfEditor.insertFragment(_this.editor, [itemChildren[0]]);
|
|
379
|
+
}
|
|
375
380
|
|
|
376
381
|
if (itemChildren.length > 1) {
|
|
377
|
-
|
|
382
|
+
var currentListItem = Node.get(_this.editor, [].concat(_toConsumableArray(listPath), [currentItemIndex + index]));
|
|
383
|
+
SfEditor.insertNodes(_this.editor, itemChildren.slice(1), {
|
|
384
|
+
at: [].concat(_toConsumableArray(listPath), [currentItemIndex + index, currentListItem.children.length])
|
|
385
|
+
});
|
|
378
386
|
}
|
|
379
387
|
|
|
380
388
|
if (index < listItems.length - 1) {
|
|
@@ -339,9 +339,14 @@ var EditorUtils = /*#__PURE__*/function () {
|
|
|
339
339
|
});
|
|
340
340
|
} else {
|
|
341
341
|
var currentListPath = Path.parent(item[1]);
|
|
342
|
-
var listAncesstor = Node.get(_this.editor, Path.parent(currentListPath)); //
|
|
342
|
+
var listAncesstor = Node.get(_this.editor, Path.parent(currentListPath)); // modify the sublist to different types
|
|
343
343
|
|
|
344
344
|
if (listAncesstor.type && listAncesstor.type.includes('list')) {
|
|
345
|
+
_this.editor.exec({
|
|
346
|
+
type: "modify_sublist_type",
|
|
347
|
+
target_list_type: type
|
|
348
|
+
});
|
|
349
|
+
|
|
345
350
|
return;
|
|
346
351
|
}
|
|
347
352
|
|