@seafile/sdoc-editor 0.3.25 → 0.3.26
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useReadOnly } from '@seafile/slate-react';
|
|
4
5
|
import { isWeChat } from '../helpers';
|
|
5
6
|
import '../../../../assets/css/textlink-hovermenu.css';
|
|
6
7
|
const LinkHover = _ref => {
|
|
@@ -11,6 +12,7 @@ const LinkHover = _ref => {
|
|
|
11
12
|
onDeleteLink,
|
|
12
13
|
onEditLink
|
|
13
14
|
} = _ref;
|
|
15
|
+
const readOnly = useReadOnly();
|
|
14
16
|
const {
|
|
15
17
|
t
|
|
16
18
|
} = useTranslation();
|
|
@@ -32,7 +34,7 @@ const LinkHover = _ref => {
|
|
|
32
34
|
rel: "noopener noreferrer",
|
|
33
35
|
className: "link-op-menu-link",
|
|
34
36
|
onMouseDown: onMouseDown
|
|
35
|
-
}, t('Open_link')), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
}, t('Open_link')), !readOnly && /*#__PURE__*/React.createElement("div", {
|
|
36
38
|
className: "link-op-icons d-flex"
|
|
37
39
|
}, /*#__PURE__*/React.createElement("span", {
|
|
38
40
|
role: "button",
|
|
@@ -85,7 +85,7 @@ class LinkHoverMenuComponent extends React.Component {
|
|
|
85
85
|
}), /*#__PURE__*/React.createElement("span", {
|
|
86
86
|
className: "virtual-link",
|
|
87
87
|
title: element.title
|
|
88
|
-
}, children)), isShowLinkMenu && Range.isCollapsed(editor.selection) && /*#__PURE__*/React.createElement(LinkHover, {
|
|
88
|
+
}, children)), isShowLinkMenu && (this.props.readonly || Range.isCollapsed(editor.selection)) && /*#__PURE__*/React.createElement(LinkHover, {
|
|
89
89
|
editor: editor,
|
|
90
90
|
menuPosition: menuPosition,
|
|
91
91
|
element: element,
|
|
@@ -94,9 +94,10 @@ class LinkHoverMenuComponent extends React.Component {
|
|
|
94
94
|
}));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
const renderLink = (props, editor) => {
|
|
97
|
+
const renderLink = (props, editor, readonly) => {
|
|
98
98
|
return /*#__PURE__*/React.createElement(LinkHoverMenuComponent, Object.assign({}, props, {
|
|
99
|
-
editor: editor
|
|
99
|
+
editor: editor,
|
|
100
|
+
readonly: readonly
|
|
100
101
|
}));
|
|
101
102
|
};
|
|
102
103
|
export default renderLink;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { useSlateStatic } from '@seafile/slate-react';
|
|
2
|
+
import { useReadOnly, useSlateStatic } from '@seafile/slate-react';
|
|
3
3
|
import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK, FILE_LINK, TITLE, SUBTITLE, CALL_OUT, SUPPORTED_SIDE_OPERATION_TYPE } from '../constants';
|
|
4
4
|
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin } from '../plugins';
|
|
5
5
|
import { onDragOver, onDragLeave, onDrop } from '../toolbar/side-toolbar/event';
|
|
@@ -7,6 +7,7 @@ import { getParentNode } from '../core';
|
|
|
7
7
|
import { setMouseEnter } from './helper';
|
|
8
8
|
const CustomRenderElement = props => {
|
|
9
9
|
const editor = useSlateStatic();
|
|
10
|
+
const readonly = useReadOnly();
|
|
10
11
|
const {
|
|
11
12
|
element,
|
|
12
13
|
attributes
|
|
@@ -52,7 +53,7 @@ const CustomRenderElement = props => {
|
|
|
52
53
|
case LINK:
|
|
53
54
|
{
|
|
54
55
|
const [renderLink] = LinkPlugin.renderElements;
|
|
55
|
-
return renderLink(props, editor);
|
|
56
|
+
return renderLink(props, editor, readonly);
|
|
56
57
|
}
|
|
57
58
|
case BLOCKQUOTE:
|
|
58
59
|
{
|