@seafile/sdoc-editor 0.5.37 → 0.5.39

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.
@@ -4,6 +4,8 @@
4
4
  min-width: 360px;
5
5
  max-width: 620px;
6
6
  border-left: 1px solid #e2e3e6;
7
+ /* Prevent the image menu from still appearing above the comment drawer when scrolled hidden. */
8
+ z-index: 103;
7
9
  }
8
10
 
9
11
  .sdoc-comment-drawer .comments-panel-wrapper {
@@ -15,6 +15,7 @@ import { EventBus } from '../../basic-sdk';
15
15
  import { EXTERNAL_EVENT } from '../../constants';
16
16
  import CommentEditorToolbar from '../extension/toolbar/comment-editor-toolbar';
17
17
  import CommentArticle from './comment-article';
18
+ import { ScrollContext } from '../hooks/use-scroll-context';
18
19
  const SdocCommentEditor = forwardRef((_ref, ref) => {
19
20
  let {
20
21
  editor: propsEditor,
@@ -110,12 +111,16 @@ const SdocCommentEditor = forwardRef((_ref, ref) => {
110
111
  ref: commentEditorContainerRef,
111
112
  className: "article sdoc-comment-editor",
112
113
  onClick: handleFocusEditor
114
+ }, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
115
+ value: {
116
+ scrollRef: commentEditorContainerRef
117
+ }
113
118
  }, /*#__PURE__*/React.createElement(CommentArticle, {
114
119
  type: type,
115
120
  editor: validEditor,
116
121
  slateValue: slateValue,
117
122
  updateSlateValue: setSlateValue
118
- })), /*#__PURE__*/React.createElement(CommentEditorToolbar, {
123
+ }))), /*#__PURE__*/React.createElement(CommentEditorToolbar, {
119
124
  editor: validEditor,
120
125
  onSubmit: onSubmit,
121
126
  submitBtnText: submitBtnText,
@@ -115,6 +115,11 @@ const SdocEditor = forwardRef((_ref, ref) => {
115
115
 
116
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
117
117
  }), [document, validEditor, slateValue]);
118
+ const onValueChange = value => {
119
+ const eventBus = EventBus.getInstance();
120
+ eventBus.dispatch(INTERNAL_EVENT.UPDATE_SEARCH_REPLACE_HIGHLIGHT, value);
121
+ setSlateValue(value);
122
+ };
118
123
  const isFreezed = context.getSetting('isFreezed');
119
124
  if (isReloading) {
120
125
  return /*#__PURE__*/React.createElement("div", {
@@ -129,7 +134,8 @@ const SdocEditor = forwardRef((_ref, ref) => {
129
134
  docValue: slateValue,
130
135
  readonly: true,
131
136
  showOutline: false,
132
- editor: validEditor
137
+ editor: validEditor,
138
+ showComment: false
133
139
  }, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
134
140
  editor: validEditor,
135
141
  slateValue: slateValue
@@ -146,18 +152,14 @@ const SdocEditor = forwardRef((_ref, ref) => {
146
152
  docValue: slateValue,
147
153
  showOutline: true,
148
154
  readonly: isFreezed,
149
- editor: validEditor
155
+ editor: validEditor,
156
+ showComment: true
150
157
  }, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
151
158
  editor: validEditor,
152
159
  slateValue: slateValue,
153
160
  isShowComment: true
154
161
  })))));
155
162
  }
156
- const onValueChange = value => {
157
- const eventBus = EventBus.getInstance();
158
- eventBus.dispatch(INTERNAL_EVENT.UPDATE_SEARCH_REPLACE_HIGHLIGHT, value);
159
- setSlateValue(value);
160
- };
161
163
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
162
164
  editor: validEditor
163
165
  }, /*#__PURE__*/React.createElement(CollaboratorsProvider, null, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(HeaderToolbar, {
@@ -165,7 +167,8 @@ const SdocEditor = forwardRef((_ref, ref) => {
165
167
  }), /*#__PURE__*/React.createElement(EditorContent, {
166
168
  docValue: slateValue,
167
169
  showOutline: true,
168
- editor: validEditor
170
+ editor: validEditor,
171
+ showComment: true
169
172
  }, /*#__PURE__*/React.createElement(EditableArticle, {
170
173
  editor: validEditor,
171
174
  slateValue: slateValue,
@@ -46,7 +46,8 @@ const InsertElementDialog = _ref => {
46
46
  slateNode,
47
47
  insertFileLinkCallback,
48
48
  insertSdocFileLinkCallback,
49
- isShowHistoryFiles
49
+ isShowHistoryFiles,
50
+ editor: paramEditor
50
51
  } = _ref2;
51
52
  setInsertPosition(insertPosition);
52
53
  setSlateNode(slateNode);
@@ -58,7 +59,7 @@ const InsertElementDialog = _ref => {
58
59
  });
59
60
  setIsShowHistoryFiles(isShowHistoryFiles);
60
61
  // Apply for comment editor, as it has a different editor instance
61
- setValidEditor(editor);
62
+ setValidEditor(paramEditor || editor);
62
63
  if (type === LOCAL_IMAGE) {
63
64
  setTimeout(() => {
64
65
  uploadLocalImageInputRef.current && uploadLocalImageInputRef.current.click();
@@ -22,16 +22,18 @@ export const isMenuDisabled = (editor, readonly) => {
22
22
  return false; // enable
23
23
  };
24
24
 
25
- export const generateSdocFileNode = (uuid, text) => {
25
+ export const generateSdocFileNode = function (uuid) {
26
+ let text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
27
+ const sdocFileName = text.replace(/\.sdoc$/, '');
26
28
  const sdocFileNode = {
27
29
  id: slugid.nice(),
28
30
  type: SDOC_LINK,
29
31
  doc_uuid: uuid,
30
- title: text,
32
+ title: sdocFileName,
31
33
  display_type: INSERT_FILE_DISPLAY_TYPE[1],
32
34
  children: [{
33
35
  id: slugid.nice(),
34
- text: text || ''
36
+ text: sdocFileName
35
37
  }]
36
38
  };
37
39
  return sdocFileNode;
@@ -87,18 +87,13 @@ const ResizeMask = _ref => {
87
87
  }
88
88
  return resizeHandlerInfo;
89
89
  }, [cellInfo, editor, maskStyle, table]);
90
- const handleMouseOver = useCallback((event, mode) => {
90
+ const handleMouseDown = useCallback((event, mode) => {
91
91
  event.stopPropagation();
92
92
  event.preventDefault();
93
- if (isDraggingResizeHandler) return;
93
+ handlerStartDragging();
94
94
  const handlerInfo = getHandlerDisplayInfo(mode);
95
95
  handleShowResizeHandler(handlerInfo);
96
- }, [getHandlerDisplayInfo, handleShowResizeHandler, isDraggingResizeHandler]);
97
- const handleMouseDown = useCallback(event => {
98
- event.stopPropagation();
99
- event.preventDefault();
100
- handlerStartDragging();
101
- }, [handlerStartDragging]);
96
+ }, [getHandlerDisplayInfo, handleShowResizeHandler, handlerStartDragging]);
102
97
  const handleMouseOut = useCallback(event => {
103
98
  event.stopPropagation();
104
99
  event.preventDefault();
@@ -110,23 +105,19 @@ const ResizeMask = _ref => {
110
105
  style: maskStyle
111
106
  }, cellInfo.rowIndex !== 0 && /*#__PURE__*/React.createElement("div", {
112
107
  onMouseOut: handleMouseOut,
113
- onMouseDown: handleMouseDown,
114
- onMouseOver: e => handleMouseOver(e, RESIZE_MASK_TOP),
108
+ onMouseDown: e => handleMouseDown(e, RESIZE_MASK_TOP),
115
109
  className: "sdoc-table-resize-top"
116
110
  }), /*#__PURE__*/React.createElement("div", {
117
111
  onMouseOut: handleMouseOut,
118
- onMouseDown: handleMouseDown,
119
- onMouseOver: e => handleMouseOver(e, RESIZE_MASK_RIGHT),
112
+ onMouseDown: e => handleMouseDown(e, RESIZE_MASK_RIGHT),
120
113
  className: "sdoc-table-resize-right"
121
114
  }), /*#__PURE__*/React.createElement("div", {
122
115
  onMouseOut: handleMouseOut,
123
- onMouseDown: handleMouseDown,
124
- onMouseOver: e => handleMouseOver(e, RESIZE_MASK_BOTTOM),
116
+ onMouseDown: e => handleMouseDown(e, RESIZE_MASK_BOTTOM),
125
117
  className: "sdoc-table-resize-bottom"
126
118
  }), /*#__PURE__*/React.createElement("div", {
127
119
  onMouseOut: handleMouseOut,
128
- onMouseDown: handleMouseDown,
129
- onMouseOver: e => handleMouseOver(e, RESIZE_MASK_LEFT),
120
+ onMouseDown: e => handleMouseDown(e, RESIZE_MASK_LEFT),
130
121
  className: "sdoc-table-resize-left"
131
122
  }));
132
123
  };
@@ -88,11 +88,11 @@ export const getDomTopHeight = (dom, slateNode) => {
88
88
  const rect = dom.getBoundingClientRect();
89
89
  let offsetY = 0;
90
90
  const paddingTop = parseFloat(window.getComputedStyle(dom).getPropertyValue('padding-top'));
91
- const lightHight = parseFloat(window.getComputedStyle(dom).getPropertyValue('line-height'));
91
+ const lineHeight = parseFloat(window.getComputedStyle(dom).getPropertyValue('line-height'));
92
+ const disToolBarHeight = 12; // side toolbar icon is 12 px
92
93
  if (ADD_POSITION_OFFSET_TYPE.includes(slateNode.type)) {
93
- offsetY = lightHight / 2 + paddingTop - 12; // side toolbar icon is 12 px
94
+ offsetY = lineHeight / 2 + paddingTop - disToolBarHeight / 2;
94
95
  }
95
-
96
96
  const HEADER_HEIGHT = 56 + 44;
97
97
  return rect.y - HEADER_HEIGHT + offsetY;
98
98
  };
@@ -11,7 +11,8 @@ const EditorContent = _ref => {
11
11
  showOutline,
12
12
  children,
13
13
  docValue,
14
- editor
14
+ editor,
15
+ showComment
15
16
  } = _ref;
16
17
  const scrollRef = useRef(null);
17
18
  const [scrollLeft, setScrollLeft] = useState(0);
@@ -25,7 +26,7 @@ const EditorContent = _ref => {
25
26
  'readonly': readonly,
26
27
  'no-outline': !showOutline
27
28
  });
28
- if (readonly) {
29
+ if (!showComment) {
29
30
  return /*#__PURE__*/React.createElement("div", {
30
31
  className: "sdoc-content-wrapper"
31
32
  }, /*#__PURE__*/React.createElement("div", {
@@ -69,6 +70,7 @@ const EditorContent = _ref => {
69
70
  };
70
71
  EditorContent.defaultProps = {
71
72
  readonly: false,
72
- showOutline: true
73
+ showOutline: true,
74
+ showComment: false
73
75
  };
74
76
  export default EditorContent;
@@ -48,9 +48,10 @@ const PublishedRevisionDiffViewer = _ref => {
48
48
  children: isShowChanges && (diff === null || diff === void 0 ? void 0 : diff.value) || revisionContent.children
49
49
  };
50
50
  return /*#__PURE__*/React.createElement(SDocViewer, {
51
+ document: document,
51
52
  showToolbar: true,
52
53
  showOutline: true,
53
- document: document
54
+ showComment: false
54
55
  });
55
56
  };
56
57
  export default PublishedRevisionDiffViewer;
@@ -3,6 +3,7 @@ import context from '../../context';
3
3
  import { getDiff } from '../utils/diff';
4
4
  import SDocViewer from './sdoc-viewer';
5
5
  import Loading from '../../components/loading';
6
+ import { CollaboratorsProvider } from '../../hooks';
6
7
  import '../../assets/css/diff-viewer.css';
7
8
  const RevisionDiffViewer = _ref => {
8
9
  let {
@@ -39,13 +40,14 @@ const RevisionDiffViewer = _ref => {
39
40
  if (isLoading) {
40
41
  return /*#__PURE__*/React.createElement(Loading, null);
41
42
  }
42
- return /*#__PURE__*/React.createElement(SDocViewer, {
43
- showToolbar: true,
44
- showOutline: true,
43
+ return /*#__PURE__*/React.createElement(CollaboratorsProvider, null, /*#__PURE__*/React.createElement(SDocViewer, {
45
44
  editor: editor,
46
45
  document: {
47
46
  children: diff.value
48
- }
49
- });
47
+ },
48
+ showToolbar: true,
49
+ showOutline: true,
50
+ showComment: true
51
+ }));
50
52
  };
51
53
  export default RevisionDiffViewer;
@@ -17,11 +17,12 @@ const DiffViewer = _ref => {
17
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
18
18
  }, []);
19
19
  return /*#__PURE__*/React.createElement(SDocViewer, {
20
- showToolbar: false,
21
- showOutline: false,
22
20
  document: {
23
21
  children: diff.value
24
- }
22
+ },
23
+ showToolbar: false,
24
+ showOutline: false,
25
+ showComment: false
25
26
  });
26
27
  };
27
28
  export default DiffViewer;
@@ -11,7 +11,8 @@ const SDocViewer = _ref => {
11
11
  editor,
12
12
  document,
13
13
  showToolbar,
14
- showOutline
14
+ showOutline,
15
+ showComment
15
16
  } = _ref;
16
17
  const validEditor = editor || withNodeId(createDefaultEditor());
17
18
  const slateValue = (document || generateDefaultDocContent()).children;
@@ -25,7 +26,8 @@ const SDocViewer = _ref => {
25
26
  docValue: slateValue,
26
27
  readonly: true,
27
28
  showOutline: showOutline,
28
- editor: validEditor
29
+ editor: validEditor,
30
+ showComment: showComment
29
31
  }, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
30
32
  editor: validEditor,
31
33
  slateValue: slateValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.37",
3
+ "version": "0.5.39",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",