@seafile/seafile-editor 1.0.86-beta3 → 1.0.87-beta

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.
@@ -15,6 +15,7 @@ var _eventHandler = _interopRequireDefault(require("../../utils/event-handler"))
15
15
  var _withPropsEditor = _interopRequireDefault(require("./with-props-editor"));
16
16
  var _core = require("../../extension/core");
17
17
  var _common = require("../../utils/common");
18
+ var _userLinkClick = _interopRequireDefault(require("../../hooks/user-link-click"));
18
19
  require("./index.css");
19
20
  const isMacOS = (0, _common.isMac)();
20
21
  const InlineEditor = _ref => {
@@ -30,7 +31,7 @@ const InlineEditor = _ref => {
30
31
  handelEnableEdit
31
32
  } = _ref;
32
33
  const [slateValue, setSlateValue] = (0, _react.useState)(value);
33
- const [focusRange, setFocusRange] = (0, _react.useState)(null);
34
+ const focusRangeRef = (0, _react.useRef)(null);
34
35
  const editor = (0, _react.useMemo)(() => {
35
36
  const baseEditor = (0, _extension.inlineEditor)();
36
37
  return (0, _withPropsEditor.default)(baseEditor, {
@@ -65,6 +66,7 @@ const InlineEditor = _ref => {
65
66
  };
66
67
  (0, _core.focusEditor)(editor, range);
67
68
  setTimeout(() => (0, _core.focusEditor)(editor, focusRange), 0);
69
+ focusRangeRef.current = null;
68
70
  return;
69
71
  }
70
72
  const [firstNodeFirstChild] = firstNode.children;
@@ -86,6 +88,8 @@ const InlineEditor = _ref => {
86
88
  });
87
89
  const timer = setTimeout(() => {
88
90
  editor.forceNormalize = false;
91
+ if (!enableEdit) return;
92
+ focusNode(editor);
89
93
  }, 300);
90
94
  return () => {
91
95
  editor.forceNormalize = false;
@@ -95,9 +99,10 @@ const InlineEditor = _ref => {
95
99
  }, []);
96
100
  (0, _react.useEffect)(() => {
97
101
  if (!enableEdit) return;
98
- focusNode(editor, focusRange);
102
+ focusNode(editor, focusRangeRef.current);
99
103
  // eslint-disable-next-line react-hooks/exhaustive-deps
100
- }, [enableEdit, focusRange]);
104
+ }, [enableEdit]);
105
+ (0, _userLinkClick.default)();
101
106
 
102
107
  // willUnmount
103
108
  (0, _react.useEffect)(() => {
@@ -112,7 +117,7 @@ const InlineEditor = _ref => {
112
117
  }, []);
113
118
  const onEditorClick = (0, _react.useCallback)(() => {
114
119
  if (!enableEdit) {
115
- setFocusRange(editor.selection);
120
+ focusRangeRef.current = editor.selection;
116
121
  handelEnableEdit();
117
122
  return;
118
123
  }
@@ -97,6 +97,15 @@ const NormalEditor = _ref => {
97
97
  timer && clearTimeout(timer);
98
98
  };
99
99
  }, [autoSave, saveDelay, handelAutoSave]);
100
+ if (!enableEdit && !valueRef.current.text) {
101
+ return /*#__PURE__*/_react.default.createElement("div", {
102
+ className: (0, _classnames.default)('sf-long-text-inline-editor-container', {
103
+ 'preview': !enableEdit
104
+ }),
105
+ ref: editorContainerRef,
106
+ onClick: handelEnableEdit
107
+ });
108
+ }
100
109
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
101
110
  className: (0, _classnames.default)('sf-long-text-inline-editor-container', {
102
111
  'preview': !enableEdit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.86beta3",
3
+ "version": "1.0.87beta",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {