@seafile/sdoc-editor 3.0.2 → 3.0.3
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.
|
@@ -182,6 +182,15 @@ var withCodeBlock = function withCodeBlock(editor) {
|
|
|
182
182
|
_slate.Transforms.select(newEditor, [path[0] + 1]);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
+
if ((0, _isHotkey["default"])('enter', event)) {
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
var selectedNode = (0, _core.getSelectedNodeByType)(newEditor, _constants.CODE_LINE);
|
|
188
|
+
var line = (0, _core.generateEmptyElement)(_constants.CODE_LINE);
|
|
189
|
+
_slate.Transforms.insertNodes(editor, line, {
|
|
190
|
+
at: selectedNode[1]
|
|
191
|
+
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
185
194
|
if ((0, _isHotkey["default"])('tab', event)) {
|
|
186
195
|
var selection = newEditor.selection;
|
|
187
196
|
event.preventDefault();
|
|
@@ -24,7 +24,8 @@ var withList = function withList(editor) {
|
|
|
24
24
|
var insertBreak = editor.insertBreak,
|
|
25
25
|
handleTab = editor.handleTab,
|
|
26
26
|
insertText = editor.insertText,
|
|
27
|
-
deleteBackward = editor.deleteBackward
|
|
27
|
+
deleteBackward = editor.deleteBackward,
|
|
28
|
+
onHotKeyDown = editor.onHotKeyDown;
|
|
28
29
|
var newEditor = editor;
|
|
29
30
|
newEditor.insertBreak = function () {
|
|
30
31
|
if ((0, _insertBreakList.insertBreakList)(editor)) return;
|
|
@@ -17,7 +17,7 @@ var _moveListItemUp = require("./move-list-item-up");
|
|
|
17
17
|
var normalizeListItem = exports.normalizeListItem = function normalizeListItem(editor, _ref) {
|
|
18
18
|
var listItem = _ref.listItem;
|
|
19
19
|
var changed = false;
|
|
20
|
-
var validLiChildrenTypes = [].concat((0, _toConsumableArray2["default"])((0, _queries.getListTypes)()), [_constants.PARAGRAPH, _constants.GROUP]);
|
|
20
|
+
var validLiChildrenTypes = [].concat((0, _toConsumableArray2["default"])((0, _queries.getListTypes)()), [_constants.PARAGRAPH, _constants.CODE_BLOCK, _constants.GROUP]);
|
|
21
21
|
var _listItem = (0, _slicedToArray2["default"])(listItem, 2),
|
|
22
22
|
liPath = _listItem[1];
|
|
23
23
|
var liChildren = (0, _core.getChildren)(listItem);
|
|
@@ -328,6 +328,7 @@ var SideToolbar = function SideToolbar() {
|
|
|
328
328
|
}
|
|
329
329
|
var _getNodeEntry3 = (0, _helpers2.getNodeEntry)(editor, targetElement),
|
|
330
330
|
_getNodeEntry4 = (0, _slicedToArray2["default"])(_getNodeEntry3, 2),
|
|
331
|
+
targetNode = _getNodeEntry4[0],
|
|
331
332
|
targetPath = _getNodeEntry4[1];
|
|
332
333
|
// Drag multiple list_items nodes
|
|
333
334
|
if (draggedSourcePaths.current) {
|
|
@@ -394,7 +395,7 @@ var SideToolbar = function SideToolbar() {
|
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
// Dragging into a list is not supported
|
|
397
|
-
if ([_constants2.
|
|
398
|
+
if ([_constants2.CALL_OUT, _constants2.TABLE, _constants2.BLOCKQUOTE, _constants2.CHECK_LIST_ITEM].includes(sourceNode.type) && (0, _helpers2.isList)(editor, targetPath)) {
|
|
398
399
|
return;
|
|
399
400
|
}
|
|
400
401
|
|
|
@@ -409,8 +410,19 @@ var SideToolbar = function SideToolbar() {
|
|
|
409
410
|
return;
|
|
410
411
|
}
|
|
411
412
|
|
|
413
|
+
// Drag out codeblock from list into non-list nodes
|
|
414
|
+
if ((0, _helpers2.isList)(editor, sourcePath) && sourceNode.type === _constants2.CODE_BLOCK && !(0, _helpers2.isList)(editor, targetPath)) {
|
|
415
|
+
var codeblockPath = (0, _core.findPath)(editor, sourceNode);
|
|
416
|
+
var toPath = _slate.Path.next(targetPath);
|
|
417
|
+
_slate.Transforms.moveNodes(editor, {
|
|
418
|
+
at: codeblockPath,
|
|
419
|
+
to: toPath
|
|
420
|
+
});
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
412
424
|
// Drag list
|
|
413
|
-
if ((0, _helpers2.isList)(editor, sourcePath)) {
|
|
425
|
+
if ((0, _helpers2.isList)(editor, sourcePath) && sourceNode !== _constants2.CODE_BLOCK) {
|
|
414
426
|
// ordinary list items
|
|
415
427
|
if (!(0, _helpers2.isBlockquote)(editor, [sourcePath[0]])) {
|
|
416
428
|
// Drag ordinary list items to places other than list and quoteBlock
|
|
@@ -498,39 +510,51 @@ var SideToolbar = function SideToolbar() {
|
|
|
498
510
|
|
|
499
511
|
// Handling drag situations including non-multi_column or non-list item dragged from multiColumn
|
|
500
512
|
if (!isInMultiColumn || isInMultiColumn && ![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(currentSourceNode.type)) {
|
|
513
|
+
// Special situation: drag codeblock into list nodes
|
|
514
|
+
if ((0, _helpers2.isList)(editor, targetPath) && [_constants2.CODE_BLOCK].includes(sourceNode.type)) {
|
|
515
|
+
var childrenPath = (0, _core.findPath)(editor, targetNode);
|
|
516
|
+
var _codeblockPath = (0, _core.findPath)(editor, sourceNode);
|
|
517
|
+
var _toPath = _slate.Path.next(childrenPath);
|
|
518
|
+
_slate.Transforms.moveNodes(editor, {
|
|
519
|
+
at: _codeblockPath,
|
|
520
|
+
to: _toPath
|
|
521
|
+
});
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
|
|
501
525
|
// Drag backward
|
|
502
526
|
if (_slate.Path.isAfter(targetPath, sourcePath)) {
|
|
503
|
-
var
|
|
527
|
+
var _toPath2 = targetPath.slice(0);
|
|
504
528
|
|
|
505
529
|
// Drag elements outside the quoteBlock into the quoteBlock
|
|
506
530
|
if (!(0, _helpers2.isBlockquote)(editor, [sourcePath[0]]) && (0, _helpers2.isBlockquote)(editor, [targetPath[0]]) && targetPath.length > 1) {
|
|
507
|
-
|
|
531
|
+
_toPath2 = _slate.Path.next(targetPath);
|
|
508
532
|
}
|
|
509
533
|
|
|
510
|
-
// Drag into list
|
|
511
|
-
if ((0, _helpers2.isList)(editor, targetPath)) {
|
|
512
|
-
|
|
534
|
+
// Drag non-codeblock into list
|
|
535
|
+
if ((0, _helpers2.isList)(editor, targetPath) && ![_constants2.CODE_BLOCK].includes(currentSourceNode.type)) {
|
|
536
|
+
_toPath2 = _slate.Path.next(targetPath);
|
|
513
537
|
}
|
|
514
538
|
_slate.Transforms.moveNodes(editor, {
|
|
515
539
|
at: sourcePath,
|
|
516
|
-
to:
|
|
540
|
+
to: _toPath2
|
|
517
541
|
});
|
|
518
542
|
}
|
|
519
543
|
|
|
520
544
|
// Drag forward
|
|
521
545
|
if (_slate.Path.isBefore(targetPath, sourcePath)) {
|
|
522
|
-
var
|
|
546
|
+
var _toPath3 = _slate.Path.next(targetPath);
|
|
523
547
|
_slate.Transforms.moveNodes(editor, {
|
|
524
548
|
at: sourcePath,
|
|
525
|
-
to:
|
|
549
|
+
to: _toPath3
|
|
526
550
|
});
|
|
527
551
|
}
|
|
528
552
|
}
|
|
529
553
|
var selectedSourcePath = sourcePath;
|
|
530
554
|
// Handling drag forward situation for multi_column update
|
|
531
555
|
if (_slate.Path.isBefore(targetPath, sourcePath)) {
|
|
532
|
-
var
|
|
533
|
-
if (![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(
|
|
556
|
+
var _targetNode = _slate.Editor.node(editor, [targetPath[0]])[0];
|
|
557
|
+
if (![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(_targetNode.type)) {
|
|
534
558
|
selectedSourcePath[0] += 1;
|
|
535
559
|
}
|
|
536
560
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "0a7ebc1042c83af89889893429b3b1a6b1a13431"
|
|
75
75
|
}
|