@seafile/sdoc-editor 1.0.6 → 1.0.8

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,10 +112,13 @@ const withBlockquote = editor => {
112
112
  const parentNodeEntry = Editor.parent(editor, paragraphEntry[1]);
113
113
  if (parentNodeEntry && parentNodeEntry[0].type === BLOCKQUOTE) {
114
114
  if (!Node.string(paragraphEntry[0]).length) {
115
- insertFragment(data);
116
- return Transforms.removeNodes(newEditor, {
117
- at: paragraphEntry[1]
115
+ data.forEach(node => {
116
+ if (node.type === BLOCKQUOTE) {
117
+ node.type = PARAGRAPH;
118
+ }
118
119
  });
120
+ insertFragment(data);
121
+ return;
119
122
  }
120
123
  }
121
124
  }
@@ -1,8 +1,10 @@
1
1
  import React, { useCallback, useState } from 'react';
2
2
  import classNames from 'classnames';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import { ElementPopover } from '../../../../commons';
4
5
  import ColorSelector from '../callout-color-selector';
5
6
  import IconSelector from '../callout-icon';
7
+ import { setCalloutIcon } from '../../helper';
6
8
  import './style.css';
7
9
  export default function CalloutHoverMenu(_ref) {
8
10
  let {
@@ -12,6 +14,9 @@ export default function CalloutHoverMenu(_ref) {
12
14
  } = _ref;
13
15
  const [isShowColorSelector, setIsShowColorSelector] = useState(false);
14
16
  const [isShowIcon, setIsShowIcon] = useState(false);
17
+ const {
18
+ t
19
+ } = useTranslation();
15
20
  const onColorSelectorToggle = useCallback(event => {
16
21
  event.stopPropagation();
17
22
  if (!isShowColorSelector) {
@@ -38,6 +43,9 @@ export default function CalloutHoverMenu(_ref) {
38
43
  'callout-menu-item': true,
39
44
  'icon-active': isShowIcon
40
45
  });
46
+ const handleRemoveIcon = () => {
47
+ setCalloutIcon(editor, '');
48
+ };
41
49
  return /*#__PURE__*/React.createElement(ElementPopover, null, /*#__PURE__*/React.createElement("div", {
42
50
  className: "sdoc-callout-hover-menu",
43
51
  style: popoverPosition
@@ -65,5 +73,10 @@ export default function CalloutHoverMenu(_ref) {
65
73
  editor: editor,
66
74
  element: element,
67
75
  onCloseSelector: onCloseSelector
68
- })));
76
+ }), /*#__PURE__*/React.createElement("div", {
77
+ className: "callout-menu-divider"
78
+ }), /*#__PURE__*/React.createElement("div", {
79
+ className: "callout-menu-item",
80
+ onClick: handleRemoveIcon
81
+ }, t('Remove_icon'))));
69
82
  }
@@ -14,12 +14,14 @@
14
14
  display: flex;
15
15
  justify-content: center;
16
16
  align-items: center;
17
- color: #aaa;
17
+ font-size: 12px;
18
+ color: #212529;
18
19
  cursor: pointer;
20
+ border-radius: 3px;
19
21
  }
20
22
 
21
23
  .sdoc-callout-hover-menu .callout-menu-item:hover {
22
- color: #444;
24
+ background-color: #f2f2f2;
23
25
  }
24
26
 
25
27
  .sdoc-callout-hover-menu .callout-menu-item .sdocfont {
@@ -56,8 +56,7 @@ export const renderHeader = (props, editor) => {
56
56
  fontStyle: 'italic'
57
57
  });
58
58
  let isShowPlaceHolder = false;
59
- const firstChild = editor.children[0];
60
- if (firstChild.id === element.id && Node.string(element) === '' && !isComposing) {
59
+ if (Node.string(element) === '' && !isComposing) {
61
60
  isShowPlaceHolder = true;
62
61
  }
63
62
  return /*#__PURE__*/React.createElement("div", Object.assign({
@@ -69,6 +68,7 @@ export const renderHeader = (props, editor) => {
69
68
  position: isShowPlaceHolder ? 'relative' : ''
70
69
  }, style)
71
70
  }), isShowPlaceHolder && /*#__PURE__*/React.createElement(Placeholder, {
72
- title: 'Please_enter_title'
71
+ title: 'Header',
72
+ top: 0
73
73
  }), children);
74
74
  };
@@ -21,8 +21,8 @@ import QuickInsertPlugin from './quick-insert';
21
21
  import WikiLinkPlugin from './wiki-link';
22
22
  import SeaTableColumnPlugin from './seatable-column';
23
23
  import SeaTableViewsPlugin from './seatable-tables';
24
- const Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin];
25
- const WikiPlugins = [...Plugins, QuickInsertPlugin, WikiLinkPlugin];
24
+ const Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin, QuickInsertPlugin];
25
+ const WikiPlugins = [...Plugins, WikiLinkPlugin];
26
26
  const CommentPlugins = [MarkDownPlugin, HtmlPlugin, ParagraphPlugin, TextPlugin, ListPlugin, ImagePlugin, LinkPlugin, MentionPlugin, BlockquotePlugin];
27
27
  export default Plugins;
28
28
  export { MarkDownPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, HtmlPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin, MentionPlugin, QuickInsertPlugin, CommentPlugins, WikiPlugins, WikiLinkPlugin, SeaTableColumnPlugin, SeaTableViewsPlugin };
@@ -29,33 +29,26 @@ const withLink = editor => {
29
29
  }
30
30
  return isInline(elem);
31
31
  };
32
- newEditor.insertData = data => {
32
+ newEditor.insertData = async data => {
33
33
  // Paste link content
34
34
  const text = data.getData('text/plain');
35
+ // Internal link, insert sdoc file link
35
36
  if (isUrl(text) && !isImage(text)) {
36
- const link = genLinkNode(text, text);
37
- Transforms.insertNodes(newEditor, link);
38
- // Void merging text fron link
37
+ if (isSameDomain(text, context.getSetting('serviceUrl'))) {
38
+ const res = await context.getLinkFilesInfo([text]);
39
+ if (isSdocFile(res, text)) {
40
+ const fileName = res.data.files_info[text].name;
41
+ const fileUuid = res.data.files_info[text].file_uuid;
42
+ insertSdocFileLink(editor, fileName, fileUuid);
43
+ }
44
+ } else {
45
+ const link = genLinkNode(text, text);
46
+ Transforms.insertNodes(newEditor, link);
47
+ }
48
+ // Void merging text from link
39
49
  const [, focusPath] = Editor.next(newEditor);
40
50
  const focusPoint = Editor.start(newEditor, focusPath);
41
51
  Transforms.select(newEditor, focusPoint);
42
- if (isSameDomain(text, context.getSetting('serviceUrl'))) {
43
- context.getLinkFilesInfo([text]).then(res => {
44
- if (isSdocFile(res, text)) {
45
- const [nodeEntry] = Editor.nodes(editor, {
46
- match: n => n.type === LINK,
47
- universal: true
48
- });
49
- const fileName = res.data.files_info[text].name;
50
- const fileUuid = res.data.files_info[text].file_uuid;
51
- Transforms.removeNodes(editor, {
52
- at: nodeEntry[1]
53
- });
54
- insertSdocFileLink(editor, fileName, fileUuid);
55
- return;
56
- }
57
- });
58
- }
59
52
  return;
60
53
  }
61
54
  insertData(data);
@@ -5,7 +5,7 @@ import { ReactEditor, useSelected, useSlateStatic } from '@seafile/slate-react';
5
5
  import { Placeholder } from '../../core';
6
6
  import { isEmptyNode } from './helper';
7
7
  import { COMMENT_EDITOR, WIKI_EDITOR } from '../../../constants';
8
- const PLACEHOLDER = 'Please_enter_text';
8
+ const PLACEHOLDER = 'Enter_text_or_press_forward_slash_to_insert_element';
9
9
  const Paragraph = _ref => {
10
10
  let {
11
11
  isComposing,
@@ -87,7 +87,7 @@ const ColorSelectorPopover = _ref => {
87
87
  // eslint-disable-next-line react-hooks/exhaustive-deps
88
88
  }, [readonly]);
89
89
  return /*#__PURE__*/React.createElement(UncontrolledPopover, {
90
- target: target,
90
+ target: target.current,
91
91
  trigger: "hover",
92
92
  placement: "right-start",
93
93
  hideArrow: true,
@@ -190,7 +190,7 @@ class TableContextMenu extends React.Component {
190
190
  onClick: e => console.log('123')
191
191
  }, /*#__PURE__*/React.createElement("span", null, t('Horizontal_align')), /*#__PURE__*/React.createElement("i", {
192
192
  className: "sdocfont sdoc-right-slide"
193
- })), /*#__PURE__*/React.createElement(HorizontalAlignPopover, {
193
+ })), this.horizontalAlignRef.current && /*#__PURE__*/React.createElement(HorizontalAlignPopover, {
194
194
  target: this.horizontalAlignRef,
195
195
  editor: editor,
196
196
  readonly: readonly,
@@ -200,7 +200,7 @@ class TableContextMenu extends React.Component {
200
200
  className: "dropdown-item side-extendable"
201
201
  }, /*#__PURE__*/React.createElement("span", null, t('Vertical_align')), /*#__PURE__*/React.createElement("i", {
202
202
  className: "sdocfont sdoc-right-slide"
203
- })), /*#__PURE__*/React.createElement(VerticalAlignPopover, {
203
+ })), this.verticalAlignRef.current && /*#__PURE__*/React.createElement(VerticalAlignPopover, {
204
204
  target: this.verticalAlignRef,
205
205
  editor: editor,
206
206
  readonly: readonly,
@@ -210,7 +210,7 @@ class TableContextMenu extends React.Component {
210
210
  className: "dropdown-item side-extendable"
211
211
  }, /*#__PURE__*/React.createElement("span", null, t('Background_color')), /*#__PURE__*/React.createElement("i", {
212
212
  className: "sdocfont sdoc-right-slide"
213
- })), /*#__PURE__*/React.createElement(ColorSelectorPopover, {
213
+ })), this.colorSelectorRef.current && /*#__PURE__*/React.createElement(ColorSelectorPopover, {
214
214
  target: this.colorSelectorRef,
215
215
  editor: editor,
216
216
  readonly: readonly
@@ -32,7 +32,7 @@ const VerticalAlignPopover = _ref => {
32
32
  }, 0);
33
33
  }, [editor, readonly]);
34
34
  return /*#__PURE__*/React.createElement(UncontrolledPopover, {
35
- target: target,
35
+ target: target.current,
36
36
  trigger: "hover",
37
37
  placement: "right-start",
38
38
  hideArrow: true,
@@ -1,4 +1,4 @@
1
- import { CALL_OUT, CHECK_LIST_ITEM, CODE_BLOCK, IMAGE, LINK, ORDERED_LIST, PARAGRAPH, TABLE, UNORDERED_LIST, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6 } from '../../constants';
1
+ import { CALL_OUT, CHECK_LIST_ITEM, CODE_BLOCK, IMAGE, LINK, ORDERED_LIST, PARAGRAPH, TABLE, UNORDERED_LIST, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, BLOCKQUOTE } from '../../constants';
2
2
  export const SELECTED_ITEM_CLASS_NAME = 'sdoc-dropdown-item-selected';
3
3
  export const SHORT_INSERT_ELEMENT_USER_INPUT_MAP = {
4
4
  [IMAGE]: 'image',
@@ -15,5 +15,6 @@ export const SHORT_INSERT_ELEMENT_USER_INPUT_MAP = {
15
15
  [HEADER3]: 'header 3',
16
16
  [HEADER4]: 'header 4',
17
17
  [HEADER5]: 'header 5',
18
- [HEADER6]: 'header 6'
18
+ [HEADER6]: 'header 6',
19
+ [BLOCKQUOTE]: 'quote'
19
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Header",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Überschrift",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Header",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Encabezado",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Encabezado",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Encabezado",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "En-tête ",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed",
468
468
  "Show_record_numbers": "Show record numbers",
469
469
  "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
470
+ "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors",
471
+ "Header": "Intestazione",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -465,7 +465,9 @@
465
465
  "SeaTable_table": "Таблица SeaTable",
466
466
  "And_x_more_records": "и ещё {{count}} записей",
467
467
  "Print_limit_exceeded": "При превышении лимита печати будут напечатаны только первые 200 строк",
468
- "Show_record_numbers": "Show record numbers",
469
- "Alternate_color": "Alternate color",
470
- "Select_column_display_option_color_tip": "Single-select and multi-select columns display option colors"
468
+ "Show_record_numbers": "Показывать номера записей",
469
+ "Alternate_color": "Альтернативный цвет",
470
+ "Select_column_display_option_color_tip": "Цвета параметров отображения столбцов с одиночным и множественным выбором",
471
+ "Header": "Заголовок",
472
+ "Remove_icon": "Remove icon"
471
473
  }
@@ -467,5 +467,7 @@
467
467
  "Print_limit_exceeded": "超过打印限制, 只会打印前 200 行",
468
468
  "Show_record_numbers": "显示记录编号",
469
469
  "Alternate_color": "单双行不同背景色",
470
- "Select_column_display_option_color_tip": "单选列和多选列显示选项颜色"
470
+ "Select_column_display_option_color_tip": "单选列和多选列显示选项颜色",
471
+ "Header": "标题",
472
+ "Remove_icon": "移除图标"
471
473
  }