@seafile/seafile-editor 1.0.76 → 1.0.78

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2024 Seafile Ltd.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -27,7 +27,9 @@ const normalizeList = editor => {
27
27
  return child.type !== _elementTypes.LIST_ITEM;
28
28
  });
29
29
  if (nonLiChild) {
30
- const listItem = (0, _core.generateElement)(_elementTypes.LIST_ITEM, []);
30
+ const listItem = (0, _core.generateElement)(_elementTypes.LIST_ITEM, {
31
+ childrenOrText: []
32
+ });
31
33
  _slate.Transforms.wrapNodes(editor, listItem, {
32
34
  at: nonLiChild[1]
33
35
  });
@@ -31,7 +31,9 @@ const movedListItemDown = (editor, _ref) => {
31
31
  _slate.Editor.withoutNormalizing(editor, () => {
32
32
  if (!subList) {
33
33
  // Insert a list child element
34
- const list = (0, _core.generateElement)(listNode.type);
34
+ const list = (0, _core.generateElement)(listNode.type, {
35
+ childrenOrText: []
36
+ });
35
37
  _slate.Transforms.wrapNodes(editor, list, {
36
38
  at: listItemPath
37
39
  });
@@ -39,7 +39,9 @@ const movedListItemUp = (editor, _ref) => {
39
39
  const isNotLastChild = !(0, _core.isLastChild)(list, liPath);
40
40
  if (isHasLiChild || isNotLastChild) {
41
41
  // Create a new sibling node
42
- const list = (0, _core.generateElement)(listNode.type);
42
+ const list = (0, _core.generateElement)(listNode.type, {
43
+ childrenOrText: []
44
+ });
43
45
  _slate.Transforms.insertNodes(editor, list, {
44
46
  at: toListPath
45
47
  });
@@ -85,7 +87,9 @@ const movedListItemUp = (editor, _ref) => {
85
87
  // First, move the sibling node of the current node to the child node of the current node "ol".
86
88
  // Second, move the child node of the current node to the sibling node of the current node.
87
89
  if (!(0, _queries.hasListChild)(liNode)) {
88
- const list = (0, _core.generateElement)(listNode.type);
90
+ const list = (0, _core.generateElement)(listNode.type, {
91
+ childrenOrText: []
92
+ });
89
93
  _slate.Transforms.insertNodes(editor, list, {
90
94
  at: toListPath
91
95
  });
@@ -309,6 +309,24 @@ const withTable = editor => {
309
309
  });
310
310
  }
311
311
  }
312
+ if (node.type === _elementTypes.TABLE_ROW) {
313
+ const parentEntry = _slate.Editor.parent(editor, path);
314
+ if ((parentEntry === null || parentEntry === void 0 ? void 0 : parentEntry[0].type) !== _elementTypes.TABLE) {
315
+ (0, _slate.unwrapNodes)(editor, {
316
+ at: path
317
+ });
318
+ return;
319
+ }
320
+ }
321
+ if (node.type === _elementTypes.TABLE_CELL) {
322
+ const parentEntry = _slate.Editor.parent(editor, path);
323
+ if ((parentEntry === null || parentEntry === void 0 ? void 0 : parentEntry[0].type) !== _elementTypes.TABLE_ROW) {
324
+ (0, _slate.unwrapNodes)(editor, {
325
+ at: path
326
+ });
327
+ return;
328
+ }
329
+ }
312
330
  return normalizeNode([node, path]);
313
331
  };
314
332
  return newEditor;
@@ -221,15 +221,15 @@ const transformCheckListItem = node => {
221
221
  return {
222
222
  id: _slugid.default.nice(),
223
223
  type: _elementTypes.CHECK_LIST_ITEM,
224
- checked: checked,
225
- children: [transformNodeWithInlineChildren({})]
224
+ checked: checked ? true : false,
225
+ children: transformNodeWithInlineChildren({})
226
226
  };
227
227
  }
228
228
  if (children.length === 1) {
229
229
  return {
230
230
  id: _slugid.default.nice(),
231
231
  type: _elementTypes.CHECK_LIST_ITEM,
232
- checked: checked,
232
+ checked: checked ? true : false,
233
233
  children: children.map(child => transformNodeWithInlineChildren(child)).flat()
234
234
  };
235
235
  }
@@ -131,6 +131,12 @@ const transformParagraph = node => {
131
131
  const {
132
132
  children
133
133
  } = node;
134
+ if (!Array.isArray(children) || children.length === 0) {
135
+ return {
136
+ type: 'paragraph',
137
+ children: transformNodeWithInlineChildren(node)
138
+ };
139
+ }
134
140
  const voidNodeTypes = ['image', 'column', 'formula'];
135
141
  const hasBlock = children.some(item => voidNodeTypes.includes(item.type));
136
142
  if (!hasBlock && _slate.Node.string(node).length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.76",
3
+ "version": "1.0.78",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -15,11 +15,12 @@
15
15
  },
16
16
  "keywords": [ ],
17
17
  "author": "",
18
- "license": "ISC",
18
+ "license": "Apache-2.0",
19
19
  "files": [
20
20
  "dist/",
21
21
  "public/",
22
- "TODO.md"
22
+ "TODO.md",
23
+ "LICENSE"
23
24
  ],
24
25
  "devDependencies": {
25
26
  "@babel/cli": "7.22.15",
package/readme.md ADDED
@@ -0,0 +1,26 @@
1
+ # sea-markdown-editor
2
+
3
+ SeaMarkdown editor is a WYSIWYG Markdown editor based on slate.js. It is used in Seafile and SeaTable project.
4
+
5
+ ## Provide components
6
+
7
+ |Name|Explain|
8
+ |-|-|
9
+ |MarkdownEditor|markdown Rich text editor component|
10
+ |MarkdownViewer|markdown Content preview component|
11
+
12
+ ## Instructions
13
+
14
+ 1. npm install @seafile/seafile-editor
15
+ 2. code demo
16
+ ```javascript
17
+ import { MarkdownEditor } from '@seafile/seafile-editor';
18
+
19
+ export default Editor = (props) => {
20
+
21
+ return <MarkdownEditor {...props} />;
22
+
23
+ }
24
+ ```
25
+
26
+