@seafile/sdoc-editor 0.5.0 → 0.5.2

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.
@@ -26,7 +26,7 @@ const HistoryFiles = _ref => {
26
26
  const historyFilesInputRef = useRef();
27
27
  const [files, setFiles] = useState([]);
28
28
  const [position, setPosition] = useState({});
29
- const [header, setHeader] = useState(t('Recent_previews'));
29
+ const [header, setHeader] = useState(t('Recent_visited'));
30
30
  const [newFileName, setNewFileName] = useState('');
31
31
  const getPosition = useCallback(() => {
32
32
  const {
@@ -109,7 +109,7 @@ const HistoryFiles = _ref => {
109
109
 
110
110
  // Show history files when search is empty
111
111
  if (e.target.value.trim().length === 0) {
112
- setHeader(t('Recent_previews'));
112
+ setHeader(t('Recent_visited'));
113
113
  setNewFileName('');
114
114
  getHistoryFiles();
115
115
  return;
@@ -56,12 +56,13 @@ const withBlockquote = editor => {
56
56
  }
57
57
  const blockQuoteEntry = getSelectedNodeEntryByType(editor, BLOCKQUOTE);
58
58
  if (blockQuoteEntry) {
59
+ const [, blockQuotePath] = blockQuoteEntry;
59
60
  const [currentLineEntry] = Editor.nodes(newEditor, {
60
- match: n => Element.isElement(n) && n.type === PARAGRAPH,
61
- mode: 'lowest'
61
+ match: (n, p) => Element.isElement(n) && p.length === blockQuotePath.length + 1 && n.type === PARAGRAPH
62
62
  });
63
63
  if (!currentLineEntry) return deleteBackward(unit);
64
- const currentLineIndex = currentLineEntry[1].slice(-1)[0];
64
+ const [, currentLinePath] = currentLineEntry;
65
+ const currentLineIndex = currentLinePath[blockQuotePath.length];
65
66
  // Transforms to paragraph when Select at the beginning of the first line
66
67
  if (currentLineIndex === 0 && isBlockAboveEmpty(newEditor)) {
67
68
  const emptyParagraph = generateEmptyElement(PARAGRAPH);
@@ -13,12 +13,12 @@
13
13
 
14
14
  .sdoc-callout-container .callout-content {
15
15
  flex: 1;
16
+ position: relative;
16
17
  }
17
18
 
18
19
  .sdoc-callout-container .sdoc-callout-placeholder {
19
20
  position: absolute;
20
- top: 15px;
21
- left: 26px;
21
+ top: 5px;
22
22
  color: #b8b6b6;
23
23
  pointer-events: none;
24
24
  }
@@ -123,16 +123,16 @@ const renderCallout = (_ref, editor) => {
123
123
  ref: calloutRef,
124
124
  className: "".concat(attributes.className, " sdoc-callout-container"),
125
125
  style: containerStyle
126
- }, /*#__PURE__*/React.createElement("div", {
126
+ }, element.callout_icon && /*#__PURE__*/React.createElement("div", {
127
127
  className: "callout-icon"
128
- }, element.callout_icon && /*#__PURE__*/React.createElement("span", {
128
+ }, /*#__PURE__*/React.createElement("span", {
129
129
  className: 'sdoc-emoji ' + element.callout_icon
130
130
  }, calloutIcon)), /*#__PURE__*/React.createElement("div", {
131
131
  className: "callout-content"
132
132
  }, children, isShowPlaceholder() && /*#__PURE__*/React.createElement("div", {
133
133
  contentEditable: false,
134
134
  className: "sdoc-callout-placeholder"
135
- }, t('Please_enter...'))), isShowColorSelector && /*#__PURE__*/React.createElement(CalloutHoverMenu, {
135
+ }, t('Please_enter'), "...")), isShowColorSelector && /*#__PURE__*/React.createElement(CalloutHoverMenu, {
136
136
  editor: editor,
137
137
  element: element,
138
138
  popoverPosition: popoverPosition
@@ -3,12 +3,15 @@ import { onTabHandle } from './on-tab-handle';
3
3
  import { normalizeList } from './normalize-list';
4
4
  import { insertFragmentList } from './insert-fragment-list';
5
5
  import { handleShortcut } from './shortcut';
6
+ import { getAboveBlockNode, getSelectedNodeEntryByType } from '../../../core';
7
+ import { BLOCKQUOTE, LIST_ITEM } from '../../../constants';
8
+ import { Editor, Transforms } from '@seafile/slate';
6
9
  const withList = editor => {
7
10
  const {
8
11
  insertBreak,
9
- deleteBackWord,
10
12
  handleTab,
11
- insertText
13
+ insertText,
14
+ deleteBackward
12
15
  } = editor;
13
16
  const newEditor = editor;
14
17
  newEditor.insertBreak = () => {
@@ -16,16 +19,32 @@ const withList = editor => {
16
19
  insertBreak();
17
20
  return;
18
21
  };
19
- newEditor.deleteBackWord = unit => {
22
+ newEditor.deleteBackward = unit => {
20
23
  const {
21
24
  selection
22
25
  } = newEditor;
23
26
  if (selection === null) {
24
- deleteBackWord(unit);
27
+ deleteBackward(unit);
25
28
  return;
26
29
  }
30
+ const listItemEntry = getSelectedNodeEntryByType(editor, LIST_ITEM);
31
+ if (listItemEntry) {
32
+ const [, listItemPath] = listItemEntry;
33
+ const blockQuoteEntry = getSelectedNodeEntryByType(editor, BLOCKQUOTE);
34
+ if (blockQuoteEntry) {
35
+ const isStart = Editor.isStart(editor, editor.selection.anchor, listItemPath);
36
+ if (isStart) {
37
+ // This is a tricky way to delete the blockquote and create a new paragraph
38
+ Transforms.removeNodes(editor, {
39
+ at: listItemPath
40
+ });
41
+ insertBreak();
42
+ return;
43
+ }
44
+ }
45
+ }
27
46
  // nothing todo
28
- deleteBackWord(unit);
47
+ deleteBackward(unit);
29
48
  };
30
49
  newEditor.handleTab = event => {
31
50
  if (!newEditor.selection) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Freezed",
419
419
  "Callout": "Callout",
420
420
  "The_current_location_does_not_support_pasting": "The current location does not support pasting ",
421
- "Please_enter...": "Please enter...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Combine cells",
423
423
  "Split_cell": "Split cell",
424
424
  "Row_number": "Row number",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Are you sure to replace all {{number}} '{{originalWord}}' in this document with '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Are you sure to clear all {{number}} '{{originalWord}}' in this document?",
444
444
  "Search_not_found": "Not found",
445
- "Recent_previews": "Recent previews",
445
+ "Recent_visited": "Recent visited",
446
446
  "The_document_does_not_exist": "The document does not exist",
447
447
  "Create_a_new_sdoc_file": "Create a new sdoc file",
448
448
  "Create": "Vytvořit"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Freezed",
419
419
  "Callout": "Callout",
420
420
  "The_current_location_does_not_support_pasting": "The current location does not support pasting ",
421
- "Please_enter...": "Please enter...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Combine cells",
423
423
  "Split_cell": "Split cell",
424
424
  "Row_number": "Row number",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Are you sure to replace all {{number}} '{{originalWord}}' in this document with '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Are you sure to clear all {{number}} '{{originalWord}}' in this document?",
444
444
  "Search_not_found": "Not found",
445
- "Recent_previews": "Recent previews",
445
+ "Recent_visited": "Recent visited",
446
446
  "The_document_does_not_exist": "The document does not exist",
447
447
  "Create_a_new_sdoc_file": "Create a new sdoc file",
448
448
  "Create": "Erstellen"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Freezed",
419
419
  "Callout": "Callout",
420
420
  "The_current_location_does_not_support_pasting": "The current location does not support pasting ",
421
- "Please_enter...": "Please enter...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Combine cells",
423
423
  "Split_cell": "Split cell",
424
424
  "Row_number": "Row number",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Are you sure to replace all {{number}} '{{originalWord}}' in this document with '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Are you sure to clear all {{number}} '{{originalWord}}' in this document?",
444
444
  "Search_not_found": "Not found",
445
- "Recent_previews": "Recent previews",
445
+ "Recent_visited": "Recent visited",
446
446
  "The_document_does_not_exist": "The document does not exist",
447
447
  "Create_a_new_sdoc_file": "Create a new sdoc file",
448
448
  "Create": "Create"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Freezed",
419
419
  "Callout": "Callout",
420
420
  "The_current_location_does_not_support_pasting": "The current location does not support pasting ",
421
- "Please_enter...": "Please enter...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Combine cells",
423
423
  "Split_cell": "Split cell",
424
424
  "Row_number": "Row number",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Are you sure to replace all {{number}} '{{originalWord}}' in this document with '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Are you sure to clear all {{number}} '{{originalWord}}' in this document?",
444
444
  "Search_not_found": "Not found",
445
- "Recent_previews": "Recent previews",
445
+ "Recent_visited": "Recent visited",
446
446
  "The_document_does_not_exist": "The document does not exist",
447
447
  "Create_a_new_sdoc_file": "Create a new sdoc file",
448
448
  "Create": "Crear"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Freezed",
419
419
  "Callout": "Callout",
420
420
  "The_current_location_does_not_support_pasting": "The current location does not support pasting ",
421
- "Please_enter...": "Please enter...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Combine cells",
423
423
  "Split_cell": "Split cell",
424
424
  "Row_number": "Row number",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Are you sure to replace all {{number}} '{{originalWord}}' in this document with '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Are you sure to clear all {{number}} '{{originalWord}}' in this document?",
444
444
  "Search_not_found": "Not found",
445
- "Recent_previews": "Recent previews",
445
+ "Recent_visited": "Recent visited",
446
446
  "The_document_does_not_exist": "The document does not exist",
447
447
  "Create_a_new_sdoc_file": "Create a new sdoc file",
448
448
  "Create": "Créer"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Freezed",
419
419
  "Callout": "Callout",
420
420
  "The_current_location_does_not_support_pasting": "The current location does not support pasting ",
421
- "Please_enter...": "Please enter...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Combine cells",
423
423
  "Split_cell": "Split cell",
424
424
  "Row_number": "Row number",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Are you sure to replace all {{number}} '{{originalWord}}' in this document with '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Are you sure to clear all {{number}} '{{originalWord}}' in this document?",
444
444
  "Search_not_found": "Not found",
445
- "Recent_previews": "Recent previews",
445
+ "Recent_visited": "Recent visited",
446
446
  "The_document_does_not_exist": "The document does not exist",
447
447
  "Create_a_new_sdoc_file": "Create a new sdoc file",
448
448
  "Create": "Crea"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "Заморожено",
419
419
  "Callout": "Выноска",
420
420
  "The_current_location_does_not_support_pasting": "Текущее местоположение не поддерживает вставку ",
421
- "Please_enter...": "Пожалуйста, введите...",
421
+ "Please_enter": "Please enter",
422
422
  "Combine_cell": "Объединить ячейки",
423
423
  "Split_cell": "Разделить ячейку",
424
424
  "Row_number": "Номер строки",
@@ -428,7 +428,7 @@
428
428
  "My_modification": "Моя модификация",
429
429
  "Document_history": "История документа",
430
430
  "Freeze_document": "Заморозить документ",
431
- "Document_frozen": "Document frozen",
431
+ "Document_frozen": "Документ заморожен",
432
432
  "Unfreeze": "Разморозить",
433
433
  "Search_and_replace": "Поиск и замена",
434
434
  "Search": "Поиск",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "Вы уверены, что хотите заменить все {{number}} '{{originalWord}}' в этом документе на '{{replacedWord}}'?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "Вы уверены, что хотите очистить все {{number}} '{{originalWord}}' в этом документе?",
444
444
  "Search_not_found": "Не найдено",
445
- "Recent_previews": "Последние предпросмотры",
445
+ "Recent_visited": "Недавно посещенные",
446
446
  "The_document_does_not_exist": "Документ не существует",
447
447
  "Create_a_new_sdoc_file": "Создать новый файл sdoc",
448
448
  "Create": "Создать"
@@ -418,7 +418,7 @@
418
418
  "Freezed": "已冻结",
419
419
  "Callout": "高亮块",
420
420
  "The_current_location_does_not_support_pasting": "当前位置不支持粘贴",
421
- "Please_enter...": "请输入...",
421
+ "Please_enter": "请输入",
422
422
  "Combine_cell": "合并单元格",
423
423
  "Split_cell": "拆分单元格",
424
424
  "Row_number": "行数",
@@ -442,7 +442,7 @@
442
442
  "Are_you_sure_to_replace_all_number_xxx_in_this_document_with_yyy": "确定要将此文档内的 {{number}} 处 \"{{originalWord}} \" 替换为 \"{{replacedWord}} \" 吗?",
443
443
  "Are_you_sure_to_clear_all_number_xxx_in_this_document": "确定将此文档内的 {{number}} 处 \"{{originalWord}}\" 全部清除吗?",
444
444
  "Search_not_found": "未找到",
445
- "Recent_previews": "最近浏览",
445
+ "Recent_visited": "最近浏览",
446
446
  "The_document_does_not_exist": "不存在该文档",
447
447
  "Create_a_new_sdoc_file": "新建 sdoc 文件",
448
448
  "Create": "创建"