@seafile/sdoc-editor 1.0.108 → 1.0.110

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.
@@ -96,7 +96,8 @@ const FileLink = _ref => {
96
96
  unregisterEventHandle();
97
97
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
98
  }, []);
99
- const onUnwrapFileLinkNode = (0, _react.useCallback)(() => {
99
+ const onUnwrapFileLinkNode = (0, _react.useCallback)(event => {
100
+ event.stopPropagation();
100
101
  (0, _helpers.unwrapLinkNode)(editor, element);
101
102
  // eslint-disable-next-line react-hooks/exhaustive-deps
102
103
  }, []);
@@ -24,7 +24,8 @@ const withHeader = editor => {
24
24
  const {
25
25
  insertBreak,
26
26
  insertFragment,
27
- insertText
27
+ insertText,
28
+ deleteBackward
28
29
  } = editor;
29
30
  const newEditor = editor;
30
31
 
@@ -83,6 +84,23 @@ const withHeader = editor => {
83
84
  }
84
85
  return insertFragment(data);
85
86
  };
87
+ newEditor.deleteBackward = unit => {
88
+ const {
89
+ selection
90
+ } = newEditor;
91
+ if (selection === null) {
92
+ deleteBackward(unit);
93
+ return;
94
+ }
95
+ const headerNode = (0, _core.getSelectedNodeByTypes)(editor, _constants.HEADERS);
96
+ if (headerNode && (0, _core.isSelectionAtBlockStart)(editor) && _slate.Node.string(headerNode).length > 0) {
97
+ _slate.Transforms.setNodes(editor, {
98
+ type: _constants.PARAGRAPH
99
+ });
100
+ return;
101
+ }
102
+ deleteBackward(unit);
103
+ };
86
104
  newEditor.onHotKeyDown = event => {
87
105
  const HOT_KEYS = (0, _utils.isMac)() ? _keyboard.MAC_HOTKEYS_EVENT : _keyboard.WIN_HOTKEYS;
88
106
  const hotEntries = Object.entries(HOT_KEYS);
@@ -164,7 +164,7 @@ const upsertLinkText = (editor, _ref) => {
164
164
  }
165
165
  };
166
166
  exports.upsertLinkText = upsertLinkText;
167
- const unWrapLinkNode = async editor => {
167
+ const unWrapLinkNode = editor => {
168
168
  if (editor.selection == null) return;
169
169
  const [nodeEntry] = _slate.Editor.nodes(editor, {
170
170
  match: n => (0, _core.getNodeType)(n) === 'link',
@@ -67,7 +67,8 @@ class Link extends _react.default.Component {
67
67
  this.registerEventHandle();
68
68
  }, 0);
69
69
  });
70
- (0, _defineProperty2.default)(this, "deleteLink", () => {
70
+ (0, _defineProperty2.default)(this, "deleteLink", event => {
71
+ event.stopPropagation();
71
72
  const {
72
73
  editor
73
74
  } = this.props;
@@ -102,7 +102,8 @@ const SdocFileLink = _ref => {
102
102
  unregisterEventHandle();
103
103
  // eslint-disable-next-line react-hooks/exhaustive-deps
104
104
  }, []);
105
- const onUnwrapFileLinkNode = (0, _react.useCallback)(() => {
105
+ const onUnwrapFileLinkNode = (0, _react.useCallback)(event => {
106
+ event.stopPropagation();
106
107
  (0, _helpers.unwrapLinkNode)(editor, element);
107
108
  // eslint-disable-next-line react-hooks/exhaustive-deps
108
109
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.108",
3
+ "version": "1.0.110",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",