@seafile/sdoc-editor 1.0.82 → 1.0.83

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.
@@ -104,26 +104,45 @@ const withImage = editor => {
104
104
  };
105
105
  newEditor.imageOnKeyDown = e => {
106
106
  if (e.keyCode === 13) {
107
- const {
108
- selection
109
- } = newEditor;
110
- const {
111
- focus
112
- } = selection;
113
- const parentPath = _slate.Path.parent(focus.path);
114
- const nextPath = _slate.Path.next(parentPath);
115
- const nextSelection = {
116
- anchor: {
117
- offset: 0,
118
- path: nextPath
119
- },
120
- focus: {
121
- offset: 0,
122
- path: nextPath
123
- }
124
- };
125
- _slate.Transforms.setSelection(editor, nextSelection);
126
- return;
107
+ const [, imagePath] = (0, _core.getSelectedNodeEntryByType)(editor, _constants.ELEMENT_TYPE.IMAGE);
108
+ const nextPath = _slate.Path.next(imagePath);
109
+ const parentPath = _slate.Path.parent(imagePath);
110
+ const [parentNode] = _slate.Editor.node(editor, parentPath);
111
+ if (parentNode.type === _constants.IMAGE_BLOCK) {
112
+ const nextPath = _slate.Path.next(parentPath);
113
+ const p = (0, _core.generateEmptyElement)(_constants.PARAGRAPH);
114
+ _slate.Transforms.insertNodes(editor, p, {
115
+ at: nextPath
116
+ });
117
+ setTimeout(() => {
118
+ (0, _core.focusEditor)(editor, nextPath);
119
+ }, 0);
120
+ return;
121
+ }
122
+ if (_slate.Editor.hasPath(editor, nextPath)) {
123
+ const nextSelection = {
124
+ anchor: {
125
+ offset: 0,
126
+ path: nextPath
127
+ },
128
+ focus: {
129
+ offset: 0,
130
+ path: nextPath
131
+ }
132
+ };
133
+ _slate.Transforms.setSelection(editor, nextSelection);
134
+ return true;
135
+ } else {
136
+ const nextPath = _slate.Path.next(parentPath);
137
+ const p = (0, _core.generateEmptyElement)(_constants.PARAGRAPH);
138
+ _slate.Transforms.insertNodes(editor, p, {
139
+ at: nextPath
140
+ });
141
+ setTimeout(() => {
142
+ (0, _core.focusEditor)(editor, nextPath);
143
+ }, 0);
144
+ }
145
+ return true;
127
146
  }
128
147
  };
129
148
  newEditor.deleteBackward = unit => {
@@ -315,6 +315,12 @@ const transformMention = node => {
315
315
  value: data.value
316
316
  };
317
317
  };
318
+ const transformImageBlock = node => {
319
+ return {
320
+ type: 'paragraph',
321
+ children: transformNodeWithInlineChildren(node)
322
+ };
323
+ };
318
324
  const elementHandlers = {
319
325
  'paragraph': transformParagraph,
320
326
  'header1': transformHeader,
@@ -330,7 +336,8 @@ const elementHandlers = {
330
336
  'unordered_list': transformList,
331
337
  'code_block': transformCodeBlock,
332
338
  'formula': transformFormula,
333
- 'mention': transformMention
339
+ 'mention': transformMention,
340
+ 'image_block': transformImageBlock
334
341
  };
335
342
  const formatSlateToMd = children => {
336
343
  const validChildren = children.filter(child => elementHandlers[child.type]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",