@seafile/sdoc-editor 0.4.20 → 0.4.22

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.
@@ -112,7 +112,7 @@ const withImage = editor => {
112
112
  } = editor;
113
113
  const focusPoint = Editor.before(editor, selection);
114
114
  const point = Editor.before(editor, selection, {
115
- distance: 2
115
+ distance: 1
116
116
  });
117
117
  if (!point) return;
118
118
  const [node, path] = Editor.node(editor, [point.path[0], point.path[1]]);
@@ -131,7 +131,7 @@ export const insertFragmentList = editor => {
131
131
  mode: 'lowest'
132
132
  });
133
133
  if (!liEntry) {
134
- const nodes = isListRoot(fragment) ? [generateDefaultText(), ...fragment] : fragment;
134
+ const nodes = isListRoot(fragment[0]) ? [generateDefaultText(), ...fragment] : fragment;
135
135
  return _insertFragment(nodes);
136
136
  }
137
137
  Transforms.insertFragment(editor, [generateDefaultText()]); // need ' '
@@ -12,7 +12,8 @@ const SearchReplaceMenu = _ref => {
12
12
  let {
13
13
  isRichEditor,
14
14
  className,
15
- editor
15
+ editor,
16
+ readonly
16
17
  } = _ref;
17
18
  const [isOpenPopover, setIsOpenPopover] = useState(false);
18
19
  useEffect(() => {
@@ -38,7 +39,7 @@ const SearchReplaceMenu = _ref => {
38
39
  clientHeight
39
40
  };
40
41
  // eslint-disable-next-line react-hooks/exhaustive-deps
41
- }, [isOpenPopover, editor.children]);
42
+ }, [isOpenPopover]);
42
43
  const renderCanvasses = useMemo(() => {
43
44
  if (!isOpenPopover) return false;
44
45
  const generateCount = Math.ceil(articleContainerSize.offsetHeight / 5000);
@@ -66,6 +67,7 @@ const SearchReplaceMenu = _ref => {
66
67
  onMouseDown: onMouseDown
67
68
  }, menuConfig)), isOpenPopover && /*#__PURE__*/React.createElement(SearchReplacePopover, {
68
69
  editor: editor,
70
+ readonly: readonly,
69
71
  isOpen: isOpenPopover,
70
72
  closePopover: onMouseDown
71
73
  }), isOpenPopover && createPortal( /*#__PURE__*/React.createElement("div", {
@@ -52,6 +52,13 @@
52
52
  justify-content: space-between;
53
53
  }
54
54
 
55
+ .sdoc-search-replace-popover-body .sdoc-search-replace-popover-btn-group .btn {
56
+ padding: 0;
57
+ width: 23%;
58
+ min-height: 35px;
59
+ border-radius: 5px;
60
+ }
61
+
55
62
  .sdoc-replace-all-confirm-modal {
56
63
  position: absolute;
57
64
  top: 0;
@@ -8,11 +8,13 @@ import { handleReplaceKeyword, getHighlightInfos, drawHighlights } from '../help
8
8
  import ReplaceAllConfirmModal from './replace-all-confirm-modal';
9
9
  import EventBus from '../../../../utils/event-bus';
10
10
  import { INTERNAL_EVENT } from '../../../../constants';
11
+ import context from '../../../../../context';
11
12
  import './index.css';
12
13
  const SearchReplacePopover = _ref => {
13
14
  let {
14
15
  editor,
15
- closePopover
16
+ closePopover,
17
+ readonly
16
18
  } = _ref;
17
19
  const [searchContent, setSearchContent] = useState('');
18
20
  const [replacementContent, setReplacementContent] = useState('');
@@ -44,6 +46,17 @@ const SearchReplacePopover = _ref => {
44
46
  y: 95
45
47
  });
46
48
  }, []);
49
+ const isOwnReplacePermission = useMemo(() => {
50
+ if (readonly) return false;
51
+ const isFreezed = context.getSetting('isFreezed');
52
+ if (isFreezed) return false;
53
+ const isPublished = context.getSetting('isPublished');
54
+ const isSdocRevision = context.getSetting('isSdocRevision');
55
+ if (isSdocRevision && isPublished) return false;
56
+ const docPerm = context.getSetting('docPerm');
57
+ if (docPerm === 'rw') return true;
58
+ return false;
59
+ }, [readonly]);
47
60
  const handleDrawHighlight = useCallback((editor, keyword) => {
48
61
  const newHighlightInfos = getHighlightInfos(editor, keyword);
49
62
  setHighlightInfos(newHighlightInfos);
@@ -193,11 +206,11 @@ const SearchReplacePopover = _ref => {
193
206
  onClick: handleNext,
194
207
  className: "btn btn-secondary"
195
208
  }, t('Next')), /*#__PURE__*/React.createElement("button", {
196
- disabled: !highlightInfos.length,
209
+ disabled: !highlightInfos.length || !isOwnReplacePermission,
197
210
  onClick: handleReplace,
198
211
  className: "btn btn-primary"
199
212
  }, t('Replace')), /*#__PURE__*/React.createElement("button", {
200
- disabled: !highlightInfos.length,
213
+ disabled: !highlightInfos.length || !isOwnReplacePermission,
201
214
  onClick: handleOpenReplaceAllModal,
202
215
  className: "btn btn-primary"
203
216
  }, t('Replace_all'))))), /*#__PURE__*/React.createElement(ReplaceAllConfirmModal, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.4.20",
3
+ "version": "0.4.22",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -435,7 +435,7 @@
435
435
  "Replace_as": "替换为",
436
436
  "Type_replace_content": "输入替换内容",
437
437
  "Prevs": "上一个",
438
- "Next": "下一页",
438
+ "Next": "下一个",
439
439
  "Replace": "替换",
440
440
  "Replace_all": "替换全部",
441
441
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "确定要将此文档内的 {{number}} 处 \"{{originalWord}} \" 替换为 \"{{replacedWord}} \" 吗?",