@seafile/seafile-editor 1.0.65 → 1.0.67

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.
@@ -52,30 +52,31 @@ function SimpleSlateEditor(_ref) {
52
52
  if (!firstNode) return;
53
53
  const [firstNodeFirstChild] = firstNode.children;
54
54
  if (firstNodeFirstChild) {
55
- const endOfFirstNode = _slate.Editor.end(editor, [0, 0]);
55
+ const startOfFirstNode = _slate.Editor.start(editor, [0, 0]);
56
56
  const range = {
57
- anchor: endOfFirstNode,
58
- focus: endOfFirstNode
59
- };
60
- (0, _core.focusEditor)(editor, range);
61
- }
62
- }, []);
63
- const focusEndNode = (0, _react.useCallback)(editor => {
64
- const lastChildIndex = editor.children.length - 1;
65
- if (lastChildIndex < 0) return;
66
- const lastNode = editor.children[lastChildIndex];
67
- if (!lastNode) return;
68
- const [lastNodeFirstChild] = lastNode.children;
69
- if (lastNodeFirstChild) {
70
- const endOfFirstNode = _slate.Editor.end(editor, [lastChildIndex, 0]);
71
- const range = {
72
- anchor: endOfFirstNode,
73
- focus: endOfFirstNode
57
+ anchor: startOfFirstNode,
58
+ focus: startOfFirstNode
74
59
  };
75
60
  (0, _core.focusEditor)(editor, range);
76
61
  }
77
62
  }, []);
78
63
 
64
+ // const focusEndNode = useCallback((editor) => {
65
+ // const lastChildIndex = editor.children.length - 1;
66
+ // if (lastChildIndex < 0) return;
67
+ // const lastNode = editor.children[lastChildIndex];
68
+ // if (!lastNode) return;
69
+ // const [lastNodeFirstChild] = lastNode.children;
70
+ // if (lastNodeFirstChild) {
71
+ // const endOfFirstNode = Editor.end(editor, [lastChildIndex, 0]);
72
+ // const range = {
73
+ // anchor: endOfFirstNode,
74
+ // focus: endOfFirstNode,
75
+ // };
76
+ // focusEditor(editor, range);
77
+ // }
78
+ // }, []);
79
+
79
80
  // useMount: focus editor
80
81
  (0, _react.useEffect)(() => {
81
82
  editor.forceNormalize = true;
@@ -84,7 +85,7 @@ function SimpleSlateEditor(_ref) {
84
85
  });
85
86
  const timer = setTimeout(() => {
86
87
  editor.forceNormalize = false;
87
- focusEndNode(editor);
88
+ focusFirstNode(editor);
88
89
  }, 300);
89
90
  return () => {
90
91
  editor.forceNormalize = false;
@@ -57,10 +57,10 @@ function SlateEditor(_ref) {
57
57
  if (!firstNode) return;
58
58
  const [firstNodeFirstChild] = firstNode.children;
59
59
  if (firstNodeFirstChild) {
60
- const endOfFirstNode = _slate.Editor.end(editor, [0, 0]);
60
+ const startOfFirstNode = _slate.Editor.start(editor, [0, 0]);
61
61
  const range = {
62
- anchor: endOfFirstNode,
63
- focus: endOfFirstNode
62
+ anchor: startOfFirstNode,
63
+ focus: startOfFirstNode
64
64
  };
65
65
  (0, _core.focusEditor)(editor, range);
66
66
  }
@@ -1,6 +1,6 @@
1
1
  .sf-code-block-container {
2
2
  position: relative;
3
- margin: 0 0 20px;
3
+ margin: 10px 0 10px;
4
4
  padding: 0;
5
5
  border-radius: 4px;
6
6
  overflow: hidden;
@@ -66,6 +66,10 @@ const withList = editor => {
66
66
  if ((0, _isHotkey.default)(['tab', 'shift+tab'], event)) {
67
67
  if ((0, _onTabHandle.handleTab)(newEditor, event)) return true;
68
68
  }
69
+ if ((0, _isHotkey.default)('shift+enter', event)) {
70
+ event.preventDefault();
71
+ return true;
72
+ }
69
73
  }
70
74
  return onHotKeyDown && onHotKeyDown(event);
71
75
  };
@@ -34,12 +34,14 @@ const withTable = editor => {
34
34
  const newEditor = editor;
35
35
  newEditor.insertBreak = () => {
36
36
  const isTableActive = (0, _helper.isInTable)(newEditor);
37
- if (!isTableActive) return insertBreak && insertBreak();
37
+ if (!editor.selection || !isTableActive) return insertBreak && insertBreak();
38
38
  (0, _tableOperations.insertRow)(newEditor);
39
- _slate.Transforms.collapse(newEditor, {
40
- edge: 'end'
39
+ const [nodeEntry] = _slate.Editor.nodes(newEditor, {
40
+ match: n => _slate.Element.isElement(n) && n.type === _elementTypes.TABLE_ROW
41
41
  });
42
- _slate.Transforms.select(newEditor, editor.selection);
42
+ const path = _slate.Path.next(nodeEntry[1]);
43
+ const firstCellPath = path.concat(0);
44
+ _slate.Transforms.select(newEditor, firstCellPath);
43
45
  return;
44
46
  };
45
47
  newEditor.insertText = text => {
@@ -228,7 +230,7 @@ const withTable = editor => {
228
230
  (0, _helper.selectCellByGrid)(newEditor, previousRowIndex, previousColumnIndex);
229
231
  return true;
230
232
  }
231
- if ((0, _isHotkey.default)('mod+enter', event)) {
233
+ if ((0, _isHotkey.default)('mod+enter', event) || (0, _isHotkey.default)('shift+enter', event)) {
232
234
  event.preventDefault();
233
235
  (0, _helper.jumpOutTableInEditor)(newEditor);
234
236
  return true;
@@ -197,7 +197,6 @@ const RenderTableRow = _ref2 => {
197
197
  };
198
198
  exports.RenderTableRow = RenderTableRow;
199
199
  const RenderTableCell = _ref3 => {
200
- var _table$align$cellInde;
201
200
  let {
202
201
  attributes,
203
202
  children,
@@ -212,7 +211,11 @@ const RenderTableCell = _ref3 => {
212
211
  const tableEntry = _slate.Editor.parent(editor, rowEntry[1]);
213
212
  const table = tableEntry[0];
214
213
  let style = {};
215
- style['textAlign'] = (_table$align$cellInde = table.align[cellIndex]) !== null && _table$align$cellInde !== void 0 ? _table$align$cellInde : _constants.TEXT_ALIGN.LEFT;
214
+ if (table.align && Array.isArray(table.align)) {
215
+ style['textAlign'] = table.align[cellIndex] || _constants.TEXT_ALIGN.LEFT;
216
+ } else {
217
+ style['textAlign'] = _constants.TEXT_ALIGN.LEFT;
218
+ }
216
219
  return /*#__PURE__*/_react.default.createElement("td", Object.assign({
217
220
  "data-root": "true",
218
221
  style: style
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {