@seafile/sdoc-editor 0.4.13 → 0.4.14

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.
@@ -78,6 +78,7 @@ const GlobalComment = _ref => {
78
78
  setActiveComment(comment);
79
79
  deleteUnseenNotifications && deleteUnseenNotifications(comment);
80
80
  if (comment.detail.element_id === DOC_COMMENT_ELEMENT_ID) return;
81
+ if (!element) return;
81
82
  const elementDom = ReactEditor.toDOMNode(editor, element, scrollRef);
82
83
  scrollRef.current.scrollTop = elementDom.offsetTop - scrollRef.current.clientHeight / 3;
83
84
  focusToCommentElement(editor, element);
@@ -150,8 +151,7 @@ const GlobalComment = _ref => {
150
151
  className: "sdoc-comment-list-container"
151
152
  }, Array.isArray(commentList) && commentList.map(comment => {
152
153
  const elementId = comment.detail.element_id;
153
- const element = getNodeById(editor.children, elementId);
154
- if (!element && elementId !== DOC_COMMENT_ELEMENT_ID) return null;
154
+ const element = elementId !== DOC_COMMENT_ELEMENT_ID ? getNodeById(editor.children, elementId) : null;
155
155
  const isActive = activeComment && activeComment.id === comment.id;
156
156
  return /*#__PURE__*/React.createElement(CommentItemWrapper, {
157
157
  key: comment.id,
@@ -517,7 +517,6 @@ export const FONT = [
517
517
  }
518
518
  } // 楷体
519
519
  ];
520
-
521
520
  export const SDOC_FONT_SIZE = {
522
521
  DEFAULT: 11,
523
522
  [ELEMENT_TYPE.TITLE]: 26,
@@ -1,7 +1,7 @@
1
1
  import { Editor, Element, Transforms, Node, Path } from '@seafile/slate';
2
- import { focusEditor, generateDefaultText, getSelectedNodeByType, isSelectionAtBlockStart } from '../../core';
2
+ import { focusEditor, generateDefaultText, generateEmptyElement, getSelectedNodeByType, getSelectedNodeEntryByType, isBlockAboveEmpty, isSelectionAtBlockStart } from '../../core';
3
3
  import { BLOCKQUOTE, PARAGRAPH, CODE_BLOCK, TABLE } from '../../constants';
4
- import { setBlockQuoteType, getFormattedElements, getFormattedRestElements } from './helpers';
4
+ import { getFormattedElements, getFormattedRestElements } from './helpers';
5
5
  const withBlockquote = editor => {
6
6
  const {
7
7
  insertBreak,
@@ -54,23 +54,34 @@ const withBlockquote = editor => {
54
54
  deleteBackward(unit);
55
55
  return;
56
56
  }
57
- const node = getSelectedNodeByType(editor, BLOCKQUOTE);
58
- if (node) {
57
+ const blockQuoteEntry = getSelectedNodeEntryByType(editor, BLOCKQUOTE);
58
+ if (blockQuoteEntry) {
59
59
  const [currentLineEntry] = Editor.nodes(newEditor, {
60
60
  match: n => Element.isElement(n) && n.type === PARAGRAPH,
61
61
  mode: 'lowest'
62
62
  });
63
63
  if (!currentLineEntry) return deleteBackward(unit);
64
64
  const currentLineIndex = currentLineEntry[1].slice(-1)[0];
65
- if (currentLineIndex === 0) {
66
- setBlockQuoteType(editor, PARAGRAPH);
65
+ // Transforms to paragraph when Select at the beginning of the first line
66
+ if (currentLineIndex === 0 && isBlockAboveEmpty(newEditor)) {
67
+ const emptyParagraph = generateEmptyElement(PARAGRAPH);
68
+ Transforms.removeNodes(editor, {
69
+ at: currentLineEntry[1]
70
+ });
71
+ Transforms.insertNodes(newEditor, emptyParagraph, {
72
+ at: blockQuoteEntry[1]
73
+ });
74
+ const previous = Path.previous(blockQuoteEntry[1]);
75
+ focusEditor(newEditor, Path.next(previous).concat(0));
67
76
  return;
68
77
  }
78
+ // Merge with previous line when Select at the beginning of the line
69
79
  if (isSelectionAtBlockStart(editor)) {
70
80
  const lineText = Node.string(currentLineEntry[0]);
71
81
  const previousNodeEntry = Editor.previous(editor, {
72
82
  at: currentLineEntry[1]
73
83
  });
84
+ if (!previousNodeEntry) return;
74
85
  const focusPoint = Editor.end(newEditor, previousNodeEntry[1]);
75
86
  Transforms.insertText(newEditor, lineText, {
76
87
  at: Editor.end(newEditor, previousNodeEntry[1])
@@ -51,7 +51,6 @@ const renderCallout = (_ref, editor) => {
51
51
  top: menuTop,
52
52
  left: left // left = code-block left distance
53
53
  };
54
-
55
54
  setPopoverPosition(newMenuPosition);
56
55
  }
57
56
  }, [isShowColorSelector, readOnly]);
@@ -82,7 +81,6 @@ const renderCallout = (_ref, editor) => {
82
81
  top: menuTop,
83
82
  left: left // left = callout left distance
84
83
  };
85
-
86
84
  setPopoverPosition(newMenuPosition);
87
85
  setIsShowColorSelector(true);
88
86
  }, [readOnly]);
@@ -23,7 +23,6 @@ export const isMenuDisabled = (editor, readonly) => {
23
23
  if (isMatch) return false; // enable
24
24
  return true; // disable
25
25
  };
26
-
27
26
  export const getSelectCodeElem = editor => {
28
27
  const codeNode = getSelectedNodeByType(editor, CODE_BLOCK);
29
28
  if (codeNode == null) return null;
@@ -63,7 +62,6 @@ export const changeToCodeBlock = function (editor) {
63
62
  style: {
64
63
  white_space: 'nowrap' // default nowrap
65
64
  },
66
-
67
65
  children: [{
68
66
  id: slugid.nice(),
69
67
  type: CODE_LINE,
@@ -81,7 +81,6 @@ const CodeBlock = _ref => {
81
81
  top: menuTop,
82
82
  left: left // left = code-block left distance
83
83
  };
84
-
85
84
  setMenuPosition(newMenuPosition);
86
85
  }
87
86
  setShowHoverMenu(true);
@@ -105,7 +104,6 @@ const CodeBlock = _ref => {
105
104
  top: menuTop,
106
105
  left: left // left = code-block left distance
107
106
  };
108
-
109
107
  setMenuPosition(newMenuPosition);
110
108
  }
111
109
  }, [readOnly, showHoverMenu]);
@@ -20,7 +20,6 @@ export const isMenuDisabled = (editor, readonly) => {
20
20
  if (notMatch) return true; // disabled
21
21
  return false; // enable
22
22
  };
23
-
24
23
  export const generateFileNode = (uuid, text) => {
25
24
  const fileNode = {
26
25
  id: slugid.nice(),
@@ -68,7 +68,6 @@ const deserializeElements = function () {
68
68
  // nothing todo
69
69
  }
70
70
  });
71
-
72
71
  return nodes;
73
72
  };
74
73
  const formatElementNodes = nodes => {
@@ -115,7 +115,8 @@ const withImage = editor => {
115
115
  distance: 2
116
116
  });
117
117
  const [node, path] = Editor.node(editor, [point.path[0], point.path[1]]);
118
- if (Range.isCollapsed(selection) && isBlockAboveEmpty(editor) && !Path.isCommon(path, selection.anchor.path)) {
118
+ const isPerviousNodeImage = node.type === IMAGE;
119
+ if (isPerviousNodeImage && Range.isCollapsed(selection) && isBlockAboveEmpty(editor) && !Path.isCommon(path, selection.anchor.path)) {
119
120
  deleteBackward(unit);
120
121
  focusEditor(newEditor, Editor.end(newEditor, focusPoint));
121
122
  return;
@@ -19,7 +19,6 @@ export const isMenuDisabled = (editor, readonly) => {
19
19
  if (notMatch) return true; // disabled
20
20
  return false; // enable
21
21
  };
22
-
23
22
  export const checkLink = url => {
24
23
  if (url.indexOf('http') !== 0) {
25
24
  return true;
@@ -21,7 +21,6 @@ export const isMenuDisabled = (editor, readonly) => {
21
21
  if (notMatch) return true; // disabled
22
22
  return false; // enable
23
23
  };
24
-
25
24
  export const generateSdocFileNode = (uuid, text) => {
26
25
  const sdocFileNode = {
27
26
  id: slugid.nice(),
@@ -188,7 +188,7 @@ const SearchReplacePopover = _ref => {
188
188
  disabled: !highlightInfos.length,
189
189
  onClick: handleLast,
190
190
  className: "btn btn-secondary"
191
- }, t('Previous')), /*#__PURE__*/React.createElement("button", {
191
+ }, t('Prevs')), /*#__PURE__*/React.createElement("button", {
192
192
  disabled: !highlightInfos.length,
193
193
  onClick: handleNext,
194
194
  className: "btn btn-secondary"
@@ -175,7 +175,6 @@ export const isAllInTable = editor => {
175
175
  if (firstSelectedNode.type !== ELEMENT_TYPE.TABLE) return false;
176
176
  return selectedNodes.slice(1).every(node => [ELEMENT_TYPE.TABLE_ROW, ELEMENT_TYPE.TABLE_CELL].includes(node.type)); // same table element
177
177
  };
178
-
179
178
  export const setCellStyle = (editor, style) => {
180
179
  // Select single cell
181
180
  if (ObjectUtils.isSameObject(editor.tableSelectedRange, EMPTY_SELECTED_RANGE)) {
@@ -92,7 +92,6 @@ export const getDomTopHeight = (dom, slateNode) => {
92
92
  if (ADD_POSITION_OFFSET_TYPE.includes(slateNode.type)) {
93
93
  offsetY = lightHight / 2 + paddingTop - 12; // side toolbar icon is 12 px
94
94
  }
95
-
96
95
  const HEADER_HEIGHT = 56 + 44;
97
96
  return rect.y - HEADER_HEIGHT + offsetY;
98
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Type search content",
435
435
  "Replace_as": "Replace as",
436
436
  "Type_replace_content": "Type replace content",
437
- "Previous": "Předchozí",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Další",
439
439
  "Replace": "Nahradit",
440
440
  "Replace_all": "Replace all",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Type search content",
435
435
  "Replace_as": "Replace as",
436
436
  "Type_replace_content": "Type replace content",
437
- "Previous": "Vorherige",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Nächste Seite",
439
439
  "Replace": "Ersetzen",
440
440
  "Replace_all": "Replace all",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Type search content",
435
435
  "Replace_as": "Replace as",
436
436
  "Type_replace_content": "Type replace content",
437
- "Previous": "Previous",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Next",
439
439
  "Replace": "Replace",
440
440
  "Replace_all": "Replace all",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Type search content",
435
435
  "Replace_as": "Replace as",
436
436
  "Type_replace_content": "Type replace content",
437
- "Previous": "Anterior",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Siguiente",
439
439
  "Replace": "Reemplazar",
440
440
  "Replace_all": "Replace all",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Type search content",
435
435
  "Replace_as": "Replace as",
436
436
  "Type_replace_content": "Type replace content",
437
- "Previous": "Précédent",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Suivant",
439
439
  "Replace": "Remplacer",
440
440
  "Replace_all": "Replace all",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Type search content",
435
435
  "Replace_as": "Replace as",
436
436
  "Type_replace_content": "Type replace content",
437
- "Previous": "Precedente",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Successivo",
439
439
  "Replace": "Sostituire",
440
440
  "Replace_all": "Replace all",
@@ -434,7 +434,7 @@
434
434
  "Type_search_content": "Введите содержимое для поиска",
435
435
  "Replace_as": "Заменить как",
436
436
  "Type_replace_content": "Введите содержимое для замены",
437
- "Previous": "Предыдущий",
437
+ "Prevs": "Prevs",
438
438
  "Next": "Следующий",
439
439
  "Replace": "Заменить",
440
440
  "Replace_all": "Заменить все",
@@ -434,10 +434,10 @@
434
434
  "Type_search_content": "输入查找内容",
435
435
  "Replace_as": "替换为",
436
436
  "Type_replace_content": "输入替换内容",
437
- "Previous": "上一个",
437
+ "Prevs": "上一个",
438
438
  "Next": "下一页",
439
439
  "Replace": "替换",
440
- "Replace_all": "下一个",
440
+ "Replace_all": "替换全部",
441
441
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "确定要将此文档内的 {{number}} 处 \"{{originalWord}} \" 替换为 \"{{replacedWord}} \" 吗?",
442
442
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "确定将此文档内的 {{number}} 处 \"{{originalWord}}\" 全部清除吗?",
443
443
  "Search_not_found": "未找到"