@seafile/sdoc-editor 0.5.56 → 0.5.58
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.
- package/dist/basic-sdk/editor/editable-article.js +3 -3
- package/dist/basic-sdk/editor/revision-editor.js +2 -1
- package/dist/basic-sdk/editor/sdoc-editor.js +12 -7
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +6 -1
- package/dist/basic-sdk/views/readonly-article.js +3 -3
- package/dist/basic-sdk/views/sdoc-viewer.js +2 -1
- package/dist/basic-sdk/views/sdoc-wiki-viewer.js +1 -1
- package/dist/components/doc-info/index.js +3 -2
- package/dist/pages/simple-editor.js +8 -3
- package/dist/pages/simple-viewer.js +4 -2
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ import { IMAGE, IMAGE_BLOCK, CODE_LINE } from '../extension/constants';
|
|
|
18
18
|
import { isPreventResetTableSelectedRange } from '../extension/plugins/table/helpers';
|
|
19
19
|
const EditableArticle = _ref => {
|
|
20
20
|
let {
|
|
21
|
-
|
|
21
|
+
showComment,
|
|
22
22
|
editor,
|
|
23
23
|
slateValue,
|
|
24
24
|
updateSlateValue
|
|
@@ -211,12 +211,12 @@ const EditableArticle = _ref => {
|
|
|
211
211
|
onCopy: eventProxy.onCopy,
|
|
212
212
|
onCompositionStart: eventProxy.onCompositionStart,
|
|
213
213
|
id: "sdoc-editor"
|
|
214
|
-
})), /*#__PURE__*/React.createElement(SideToolbar, null),
|
|
214
|
+
})), /*#__PURE__*/React.createElement(SideToolbar, null), showComment && /*#__PURE__*/React.createElement(CommentWrapper, {
|
|
215
215
|
editor: editor,
|
|
216
216
|
type: "editor"
|
|
217
217
|
})));
|
|
218
218
|
};
|
|
219
219
|
EditableArticle.defaultProps = {
|
|
220
|
-
|
|
220
|
+
showComment: true
|
|
221
221
|
};
|
|
222
222
|
export default EditableArticle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo, useCallback } from 'react';
|
|
2
|
+
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo, useCallback, Fragment } from 'react';
|
|
3
3
|
import { Editor } from '@seafile/slate';
|
|
4
4
|
import deepCopy from 'deep-copy';
|
|
5
5
|
import context from '../../context';
|
|
@@ -22,7 +22,8 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
22
22
|
let {
|
|
23
23
|
editor: propsEditor,
|
|
24
24
|
document,
|
|
25
|
-
isReloading
|
|
25
|
+
isReloading,
|
|
26
|
+
showComment
|
|
26
27
|
} = _ref;
|
|
27
28
|
const validEditor = propsEditor || useMemo(() => {
|
|
28
29
|
const defaultEditor = createDefaultEditor();
|
|
@@ -138,7 +139,8 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
138
139
|
showComment: false
|
|
139
140
|
}, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
|
|
140
141
|
editor: validEditor,
|
|
141
|
-
slateValue: slateValue
|
|
142
|
+
slateValue: slateValue,
|
|
143
|
+
showComment: false
|
|
142
144
|
}))));
|
|
143
145
|
}
|
|
144
146
|
if (isFreezed) {
|
|
@@ -157,22 +159,25 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
157
159
|
}, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
|
|
158
160
|
editor: validEditor,
|
|
159
161
|
slateValue: slateValue,
|
|
160
|
-
|
|
162
|
+
showComment: true
|
|
161
163
|
})))));
|
|
162
164
|
}
|
|
165
|
+
const isShowComment = typeof showComment === 'boolean' ? showComment : true;
|
|
166
|
+
const Provider = isShowComment ? CollaboratorsProvider : Fragment;
|
|
163
167
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
|
|
164
168
|
editor: validEditor
|
|
165
|
-
}, /*#__PURE__*/React.createElement(
|
|
169
|
+
}, /*#__PURE__*/React.createElement(Provider, null, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(HeaderToolbar, {
|
|
166
170
|
editor: validEditor
|
|
167
171
|
}), /*#__PURE__*/React.createElement(EditorContent, {
|
|
168
172
|
docValue: slateValue,
|
|
169
173
|
showOutline: true,
|
|
170
174
|
editor: validEditor,
|
|
171
|
-
showComment:
|
|
175
|
+
showComment: isShowComment
|
|
172
176
|
}, /*#__PURE__*/React.createElement(EditableArticle, {
|
|
173
177
|
editor: validEditor,
|
|
174
178
|
slateValue: slateValue,
|
|
175
|
-
updateSlateValue: onValueChange
|
|
179
|
+
updateSlateValue: onValueChange,
|
|
180
|
+
showComment: isShowComment
|
|
176
181
|
}))))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
177
182
|
editor: validEditor
|
|
178
183
|
}));
|
|
@@ -104,9 +104,14 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
104
104
|
setSelectedLanguageText(selectedLanguageOption.text);
|
|
105
105
|
}, [language]);
|
|
106
106
|
const onChange = useCallback(e => {
|
|
107
|
+
// Escapes all special characters in a string for safe use in regular expressions.
|
|
108
|
+
const escapeRegExp = string => string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
107
109
|
const filterData = [];
|
|
110
|
+
const value = e.currentTarget.value.toLowerCase().trim();
|
|
111
|
+
// Generate a RegExp object and perform case-insensitive matching thereafter.
|
|
112
|
+
const regex = new RegExp(escapeRegExp(value), 'i');
|
|
108
113
|
genCodeLangs().forEach(item => {
|
|
109
|
-
if (
|
|
114
|
+
if (regex.test(item.value)) {
|
|
110
115
|
filterData.push(item);
|
|
111
116
|
}
|
|
112
117
|
});
|
|
@@ -9,7 +9,7 @@ const ReadOnlyArticle = _ref => {
|
|
|
9
9
|
let {
|
|
10
10
|
editor,
|
|
11
11
|
slateValue,
|
|
12
|
-
|
|
12
|
+
showComment
|
|
13
13
|
} = _ref;
|
|
14
14
|
const decorate = usePipDecorate(editor);
|
|
15
15
|
return /*#__PURE__*/React.createElement(Slate, {
|
|
@@ -24,12 +24,12 @@ const ReadOnlyArticle = _ref => {
|
|
|
24
24
|
renderElement: renderElement,
|
|
25
25
|
renderLeaf: renderLeaf,
|
|
26
26
|
decorate: decorate
|
|
27
|
-
})),
|
|
27
|
+
})), showComment && /*#__PURE__*/React.createElement(CommentWrapper, {
|
|
28
28
|
editor: editor,
|
|
29
29
|
type: "editor"
|
|
30
30
|
})));
|
|
31
31
|
};
|
|
32
32
|
ReadOnlyArticle.defaultProps = {
|
|
33
|
-
|
|
33
|
+
showComment: false
|
|
34
34
|
};
|
|
35
35
|
export default ReadOnlyArticle;
|
|
@@ -32,7 +32,7 @@ const SDocMdViewer = _ref => {
|
|
|
32
32
|
}, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
|
|
33
33
|
editor: validEditor,
|
|
34
34
|
slateValue: slateValue,
|
|
35
|
-
|
|
35
|
+
showComment: false
|
|
36
36
|
}), showOutline && /*#__PURE__*/React.createElement("div", {
|
|
37
37
|
className: "sdoc-wiki-outline-container"
|
|
38
38
|
}, /*#__PURE__*/React.createElement(Outline, {
|
|
@@ -16,7 +16,8 @@ const DocInfo = _ref => {
|
|
|
16
16
|
isStarred,
|
|
17
17
|
isDraft,
|
|
18
18
|
isEditMode,
|
|
19
|
-
isPublished = false
|
|
19
|
+
isPublished = false,
|
|
20
|
+
showFileTags = true
|
|
20
21
|
} = _ref;
|
|
21
22
|
const isSdocRevision = context.getSetting('isSdocRevision');
|
|
22
23
|
const docName = context.getSetting('docName');
|
|
@@ -61,7 +62,7 @@ const DocInfo = _ref => {
|
|
|
61
62
|
alt: t('Document_frozen'),
|
|
62
63
|
title: t('Document_frozen'),
|
|
63
64
|
width: "16px"
|
|
64
|
-
})), /*#__PURE__*/React.createElement(FileTagQuickView, null), /*#__PURE__*/React.createElement(TipMessage, {
|
|
65
|
+
})), showFileTags && /*#__PURE__*/React.createElement(FileTagQuickView, null), /*#__PURE__*/React.createElement(TipMessage, {
|
|
65
66
|
isEditMode: isEditMode
|
|
66
67
|
}));
|
|
67
68
|
if (!isSdocRevision) {
|
|
@@ -15,6 +15,9 @@ const SimpleEditor = _ref => {
|
|
|
15
15
|
let {
|
|
16
16
|
isStarred,
|
|
17
17
|
isDraft,
|
|
18
|
+
showComment,
|
|
19
|
+
showDocOperations = true,
|
|
20
|
+
showFileTags = true,
|
|
18
21
|
t
|
|
19
22
|
} = _ref;
|
|
20
23
|
context.initApi();
|
|
@@ -99,7 +102,8 @@ const SimpleEditor = _ref => {
|
|
|
99
102
|
return /*#__PURE__*/React.createElement(SDocEditor, {
|
|
100
103
|
ref: editorRef,
|
|
101
104
|
isReloading: isReloading,
|
|
102
|
-
document: document
|
|
105
|
+
document: document,
|
|
106
|
+
showComment: showComment
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
if (isPublished) {
|
|
@@ -117,7 +121,7 @@ const SimpleEditor = _ref => {
|
|
|
117
121
|
revisionContent: revisionContent,
|
|
118
122
|
didMountCallback: setDiffChanges
|
|
119
123
|
});
|
|
120
|
-
}, [isSdocRevision,
|
|
124
|
+
}, [isSdocRevision, isPublished, isShowChanges, isReloading, document, revisionContent, setDiffChanges, showComment]);
|
|
121
125
|
if (isFirstLoading) {
|
|
122
126
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
123
127
|
}
|
|
@@ -131,9 +135,10 @@ const SimpleEditor = _ref => {
|
|
|
131
135
|
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
|
|
132
136
|
isStarred: isStarred,
|
|
133
137
|
isDraft: isDraft,
|
|
138
|
+
showFileTags: showFileTags,
|
|
134
139
|
isPublished: isPublished,
|
|
135
140
|
isEditMode: isPublished ? false : !isShowChanges
|
|
136
|
-
}), /*#__PURE__*/React.createElement(DocOperations, {
|
|
141
|
+
}), showDocOperations && /*#__PURE__*/React.createElement(DocOperations, {
|
|
137
142
|
isShowChanges: isShowChanges,
|
|
138
143
|
isPublished: isPublished,
|
|
139
144
|
changes: changes,
|
|
@@ -81,7 +81,8 @@ class SimpleViewer extends React.Component {
|
|
|
81
81
|
})))), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocViewer, {
|
|
82
82
|
document: document,
|
|
83
83
|
showToolbar: false,
|
|
84
|
-
showOutline: false
|
|
84
|
+
showOutline: false,
|
|
85
|
+
showComment: false
|
|
85
86
|
}))));
|
|
86
87
|
}
|
|
87
88
|
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -100,7 +101,8 @@ class SimpleViewer extends React.Component {
|
|
|
100
101
|
})))), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocViewer, {
|
|
101
102
|
document: document,
|
|
102
103
|
showToolbar: true,
|
|
103
|
-
showOutline: true
|
|
104
|
+
showOutline: true,
|
|
105
|
+
showComment: false
|
|
104
106
|
}))));
|
|
105
107
|
}
|
|
106
108
|
}
|