@seafile/seafile-editor 0.4.1 → 0.4.2

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.
@@ -1,4 +1,9 @@
1
1
  .dlThau {
2
2
  margin: 0;
3
3
  padding-inline-start: 24px;
4
+ }
5
+
6
+ .editor-container div[data-slate-editor='true'] {
7
+ min-width: 980px;
8
+ background: #f0f0f0;
4
9
  }
@@ -114,6 +114,12 @@ export var getLastChildPath = function getLastChildPath(nodeEntry) {
114
114
  if (!lastChild) return nodeEntry[1].concat([-1]);
115
115
  return lastChild[1];
116
116
  };
117
+ export var getPreviousPath = function getPreviousPath(path) {
118
+ if (path.length === 0) return;
119
+ var last = path[path.length - 1];
120
+ if (last <= 0) return;
121
+ return path.slice(0, -1).concat(last - 1);
122
+ };
117
123
  export var isLastChild = function isLastChild(nodeEntry, childPath) {
118
124
  var lastChildPath = getLastChildPath(nodeEntry);
119
125
  return Path.equals(lastChildPath, childPath);
@@ -9,6 +9,7 @@ export var match = function match(node, path, predicate) {
9
9
  if (value && !Array.isArray(value)) {
10
10
  return node[key] === value;
11
11
  }
12
+ value = value ? value : [];
12
13
  return value.includes(node[key]);
13
14
  });
14
15
  }
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { Node, Element, Transforms, Path } from 'slate';
3
3
  import { LIST_ITEM, LIST_LIC, PARAGRAPH } from '../../../constants';
4
- import { getChildren, getNode, match } from '../../../core';
4
+ import { getChildren, getNode, getPreviousPath, match } from '../../../core';
5
5
  import { getListTypes } from '../queries';
6
6
  import { moveListItemsToList, normalizeListItem, normalizeNestedList } from '../transforms';
7
7
  export var normalizeList = function normalizeList(editor) {
@@ -53,7 +53,7 @@ export var normalizeList = function normalizeList(editor) {
53
53
  deleteFromList: true
54
54
  });
55
55
  }
56
- var prevPath = Path.previous(path);
56
+ var prevPath = getPreviousPath(path);
57
57
  var prevNode = getNode(editor, prevPath);
58
58
  if ((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type) === node.type) {
59
59
  editor.normalizeNode([prevNode, prevPath]);
@@ -38,7 +38,6 @@ export var moveListItemsToList = function moveListItemsToList(editor, _ref) {
38
38
  to = Path.next(lastChildPath);
39
39
  }
40
40
  }
41
- console.log('addddedd');
42
41
  if (!to) return;
43
42
  moved = moveChildren(editor, {
44
43
  at: fromListPath,
@@ -23,9 +23,10 @@ export var normalizeListItem = function normalizeListItem(editor, _ref) {
23
23
  return Editor.pathRef(editor, childPath);
24
24
  });
25
25
  var firstLiChild = liChildren[0];
26
- var _firstLiChild = _slicedToArray(firstLiChild, 2),
27
- firstLiChildNode = _firstLiChild[0],
28
- firstLiChildPath = _firstLiChild[1];
26
+ var _ref6 = firstLiChild !== null && firstLiChild !== void 0 ? firstLiChild : [],
27
+ _ref7 = _slicedToArray(_ref6, 2),
28
+ firstLiChildNode = _ref7[0],
29
+ firstLiChildPath = _ref7[1];
29
30
  if (!firstLiChild || !Editor.isBlock(editor, firstLiChildNode)) {
30
31
  var emptyLic = {
31
32
  type: LIST_LIC,
@@ -92,9 +93,9 @@ export var normalizeListItem = function normalizeListItem(editor, _ref) {
92
93
  _iterator.f();
93
94
  }
94
95
  var to = Path.next((_licChildren = licChildren[licChildren.length - 1]) === null || _licChildren === void 0 ? void 0 : _licChildren[1]);
95
- inlineChildren.reverse().forEach(function (_ref6) {
96
- var _ref7 = _slicedToArray(_ref6, 2),
97
- path = _ref7[1];
96
+ inlineChildren.reverse().forEach(function (_ref8) {
97
+ var _ref9 = _slicedToArray(_ref8, 2),
98
+ path = _ref9[1];
98
99
  Transforms.moveNodes(editor, {
99
100
  at: path,
100
101
  to: to
@@ -8,8 +8,7 @@ export var unwrapList = function unwrapList(editor) {
8
8
  var ancestorListTypeCheck = function ancestorListTypeCheck() {
9
9
  if (getAboveNode(editor, {
10
10
  match: {
11
- type: getListTypes(),
12
- at: at
11
+ type: getListTypes()
13
12
  }
14
13
  })) {
15
14
  return true;
@@ -32,7 +31,6 @@ export var unwrapList = function unwrapList(editor) {
32
31
  type: LIST_LIC
33
32
  }
34
33
  });
35
- console.log(licEntry);
36
34
  if (licEntry) {
37
35
  Transforms.setNodes(editor, {
38
36
  type: PARAGRAPH
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "private": false,
5
5
  "description": "This is a custom markdown editor",
6
6
  "main": "dist/index.js",