@seafile/seafile-editor 2.0.48-beta → 2.0.48-beta2

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.
@@ -35,13 +35,14 @@ const InlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
35
35
  isImageUploadOnly,
36
36
  isSupportMultipleFiles,
37
37
  onExpandEditorToggle,
38
- handelEnableEdit
38
+ handelEnableEdit,
39
+ onLinkClick
39
40
  } = _ref;
40
41
  const [slateValue, setSlateValue] = (0, _react.useState)(value);
41
42
  const focusRangeRef = (0, _react.useRef)(null);
42
43
  const editor = (0, _react.useMemo)(() => {
43
- const baseEditor = (0, _extension.inlineEditor)();
44
- return (0, _withPropsEditor.default)(baseEditor, {
44
+ const _editor = (0, _extension.inlineEditor)();
45
+ return (0, _withPropsEditor.default)(_editor, {
45
46
  editorApi,
46
47
  onSave,
47
48
  columns,
@@ -53,7 +54,7 @@ const InlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
53
54
  return new _eventHandler.default(editor);
54
55
  }, [editor]);
55
56
  (0, _useAttachments.default)(editor);
56
- (0, _userLinkClick.default)(editor._id);
57
+ (0, _userLinkClick.default)(editor._id, onLinkClick);
57
58
  const decorate = (0, _extension.useHighlight)(editor);
58
59
  const onChange = (0, _react.useCallback)(value => {
59
60
  setSlateValue(value);
@@ -28,19 +28,23 @@ const SimpleSlateEditor = _ref => {
28
28
  columns,
29
29
  onContentChanged,
30
30
  isSupportFormula,
31
- onExpandEditorToggle
31
+ onExpandEditorToggle,
32
+ onLinkClick
32
33
  } = _ref;
33
34
  const [slateValue, setSlateValue] = (0, _react.useState)(value);
34
- const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(_extension.baseEditor, {
35
- editorApi,
36
- onSave,
37
- columns
38
- }), [columns, editorApi, onSave]);
35
+ const editor = (0, _react.useMemo)(() => {
36
+ const _editor = (0, _extension.baseEditor)();
37
+ return (0, _withPropsEditor.default)(_editor, {
38
+ editorApi,
39
+ onSave,
40
+ columns
41
+ });
42
+ }, [columns, editorApi, onSave]);
39
43
  const eventProxy = (0, _react.useMemo)(() => {
40
44
  return new _eventHandler.default(editor);
41
45
  }, [editor]);
42
46
  (0, _useAttachments.default)(editor);
43
- (0, _userLinkClick.default)(editor._id);
47
+ (0, _userLinkClick.default)(editor._id, onLinkClick);
44
48
  const decorate = (0, _extension.useHighlight)(editor);
45
49
  const onChange = (0, _react.useCallback)(value => {
46
50
  setSlateValue(value);
@@ -38,10 +38,13 @@ function SlateEditor(_ref) {
38
38
  const {
39
39
  containerStyle
40
40
  } = (0, _useContainerStyle.default)(scrollRef);
41
- const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(_extension.baseEditor, {
42
- editorApi,
43
- onSave
44
- }), [editorApi, onSave]);
41
+ const editor = (0, _react.useMemo)(() => {
42
+ const _editor = (0, _extension.baseEditor)();
43
+ return (0, _withPropsEditor.default)(_editor, {
44
+ editorApi,
45
+ onSave
46
+ });
47
+ }, [editorApi, onSave]);
45
48
  const eventProxy = (0, _react.useMemo)(() => {
46
49
  return new _eventHandler.default(editor);
47
50
  }, [editor]);
@@ -10,14 +10,18 @@ var _slateHistory = require("slate-history");
10
10
  var _slateReact = require("slate-react");
11
11
  var _slugid = require("slugid");
12
12
  var _plugins = _interopRequireDefault(require("./plugins"));
13
- const baseEditor = exports.baseEditor = _plugins.default.reduce((editor, pluginItem) => {
14
- const withPlugin = pluginItem.editorPlugin;
15
- if (withPlugin) {
16
- return withPlugin(editor);
17
- }
13
+ const baseEditor = () => {
14
+ const editor = _plugins.default.reduce((editor, pluginItem) => {
15
+ const withPlugin = pluginItem.editorPlugin;
16
+ if (withPlugin) {
17
+ return withPlugin(editor);
18
+ }
19
+ return editor;
20
+ }, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
18
21
  editor._id = (0, _slugid.nice)();
19
22
  return editor;
20
- }, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
23
+ };
24
+ exports.baseEditor = baseEditor;
21
25
  const inlineEditor = () => {
22
26
  const editor = _plugins.default.reduce((editor, pluginItem) => {
23
27
  const withPlugin = pluginItem.editorPlugin;
@@ -33,8 +33,10 @@ const LinkPopover = _ref => {
33
33
  const onLinkClick = (0, _react.useCallback)(e => {
34
34
  if (!(0, _common.isUrl)(linkUrl)) {
35
35
  e.preventDefault();
36
+ const eventBus = _eventBus.default.getInstance();
37
+ eventBus.dispatch(_eventTypes.EXTERNAL_EVENTS.ON_LINK_CLICK, e, editor._id);
36
38
  }
37
- }, [linkUrl]);
39
+ }, [linkUrl, editor]);
38
40
  const onUnwrapLink = (0, _react.useCallback)(e => {
39
41
  e.stopPropagation();
40
42
  (0, _helper.unWrapLinkNode)(editor);
@@ -63,6 +65,7 @@ const LinkPopover = _ref => {
63
65
  style: popoverPosition
64
66
  }, /*#__PURE__*/_react.default.createElement("a", {
65
67
  href: linkUrl,
68
+ "data-url": linkUrl,
66
69
  onClick: onLinkClick,
67
70
  target: "_blank",
68
71
  rel: "noopener noreferrer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "2.0.48-beta",
3
+ "version": "2.0.48-beta2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {