@seafile/sdoc-editor 1.0.5 → 1.0.7
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.
- package/dist/basic-sdk/extension/constants/menus-config.js +5 -0
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +6 -2
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +2 -4
- package/dist/basic-sdk/extension/plugins/header/render-elem.js +3 -3
- package/dist/basic-sdk/extension/plugins/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +1 -1
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/const.js +3 -2
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +12 -2
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +12 -2
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +2 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/es_AR/sdoc-editor.json +2 -1
- package/public/locales/es_MX/sdoc-editor.json +2 -1
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +4 -3
- package/public/locales/zh_CN/sdoc-editor.json +2 -1
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import { Editor, Transforms, Element, Node } from '@seafile/slate';
|
|
3
3
|
import slugid from 'slugid';
|
|
4
4
|
import { BLOCKQUOTE, CHECK_LIST_ITEM, IMAGE, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, TABLE, CALL_OUT } from '../../constants';
|
|
5
|
-
import { getNodeType } from '../../core';
|
|
5
|
+
import { focusEditor, getNodeType } from '../../core';
|
|
6
6
|
export const isMenuDisabled = (editor, readonly) => {
|
|
7
7
|
if (readonly) return true;
|
|
8
8
|
if (editor.selection == null) return true;
|
|
@@ -41,7 +41,7 @@ export const getBlockQuoteType = editor => {
|
|
|
41
41
|
return getNodeType(n);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
// If cursor is in
|
|
44
|
+
// If cursor is in callout, insert block quote in callout, otherwise wrap block quote directly
|
|
45
45
|
export const setBlockQuoteType = (editor, active) => {
|
|
46
46
|
if (!active) {
|
|
47
47
|
const blockquoteNode = {
|
|
@@ -108,4 +108,8 @@ export const getFormattedRestElements = data => {
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
return restElements;
|
|
111
|
+
};
|
|
112
|
+
export const insertBlockQuote = (editor, active) => {
|
|
113
|
+
setBlockQuoteType(editor, active);
|
|
114
|
+
focusEditor(editor);
|
|
111
115
|
};
|
|
@@ -3,8 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { BLOCKQUOTE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
5
5
|
import { MenuItem } from '../../../commons';
|
|
6
|
-
import { getBlockQuoteType,
|
|
7
|
-
import { focusEditor } from '../../../core';
|
|
6
|
+
import { getBlockQuoteType, insertBlockQuote, isMenuDisabled } from '../helpers';
|
|
8
7
|
class QuoteMenu extends React.Component {
|
|
9
8
|
constructor() {
|
|
10
9
|
super(...arguments);
|
|
@@ -26,8 +25,7 @@ class QuoteMenu extends React.Component {
|
|
|
26
25
|
editor
|
|
27
26
|
} = this.props;
|
|
28
27
|
const active = this.isActive(editor);
|
|
29
|
-
|
|
30
|
-
focusEditor(editor);
|
|
28
|
+
insertBlockQuote(editor, active);
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
render() {
|
|
@@ -56,8 +56,7 @@ export const renderHeader = (props, editor) => {
|
|
|
56
56
|
fontStyle: 'italic'
|
|
57
57
|
});
|
|
58
58
|
let isShowPlaceHolder = false;
|
|
59
|
-
|
|
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: '
|
|
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,
|
|
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 };
|
|
@@ -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 = '
|
|
8
|
+
const PLACEHOLDER = 'Enter_text_or_press_forward_slash_to_insert_element';
|
|
9
9
|
const Paragraph = _ref => {
|
|
10
10
|
let {
|
|
11
11
|
isComposing,
|
|
@@ -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
|
};
|
|
@@ -8,7 +8,7 @@ import TableSizePopover from '../../plugins/table/popover/table-size-popover';
|
|
|
8
8
|
import { changeToCodeBlock } from '../../plugins/code-block/helpers';
|
|
9
9
|
import { toggleList } from '../../plugins/list/transforms';
|
|
10
10
|
import { setCheckListItemType } from '../../plugins/check-list/helpers';
|
|
11
|
-
import { ELEMENT_TYPE, IMAGE, INSERT_POSITION, LINK, LOCAL_IMAGE, PARAGRAPH, SIDE_INSERT_MENUS_CONFIG, TABLE, CODE_BLOCK, CALL_OUT, UNORDERED_LIST, ORDERED_LIST, CHECK_LIST_ITEM, QUICK_INSERT } from '../../constants';
|
|
11
|
+
import { ELEMENT_TYPE, IMAGE, INSERT_POSITION, LINK, LOCAL_IMAGE, PARAGRAPH, SIDE_INSERT_MENUS_CONFIG, TABLE, CODE_BLOCK, CALL_OUT, UNORDERED_LIST, ORDERED_LIST, CHECK_LIST_ITEM, QUICK_INSERT, BLOCKQUOTE } from '../../constants';
|
|
12
12
|
import EventBus from '../../../utils/event-bus';
|
|
13
13
|
import { INTERNAL_EVENT } from '../../../constants';
|
|
14
14
|
import DropdownMenuItem from '../../commons/dropdown-menu-item';
|
|
@@ -16,6 +16,7 @@ import { wrapCallout } from '../../plugins/callout/helper';
|
|
|
16
16
|
import keyCodes from '../../../../constants/key-codes';
|
|
17
17
|
import { SELECTED_ITEM_CLASS_NAME, SHORT_INSERT_ELEMENT_USER_INPUT_MAP } from './const';
|
|
18
18
|
import { getAboveBlockNode } from '../../core';
|
|
19
|
+
import { insertBlockQuote } from '../../plugins/blockquote/helpers';
|
|
19
20
|
import './style.css';
|
|
20
21
|
const QuickInsertBlockMenu = _ref => {
|
|
21
22
|
let {
|
|
@@ -97,6 +98,10 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
97
98
|
});
|
|
98
99
|
return !!callout;
|
|
99
100
|
}, [editor]);
|
|
101
|
+
const onInsertBlockQuote = useCallback(() => {
|
|
102
|
+
callback && callback();
|
|
103
|
+
insertBlockQuote(editor, false);
|
|
104
|
+
}, [callback, editor]);
|
|
100
105
|
const dropDownItems = useMemo(() => {
|
|
101
106
|
let items = {
|
|
102
107
|
[IMAGE]: /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
@@ -126,6 +131,11 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
126
131
|
menuConfig: _objectSpread({}, SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.LINK]),
|
|
127
132
|
onClick: openLinkDialog
|
|
128
133
|
}),
|
|
134
|
+
[BLOCKQUOTE]: /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
135
|
+
key: "sdoc-insert-menu-blockquote",
|
|
136
|
+
menuConfig: _objectSpread({}, SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.BLOCKQUOTE]),
|
|
137
|
+
onClick: onInsertBlockQuote
|
|
138
|
+
}),
|
|
129
139
|
[CODE_BLOCK]: /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
130
140
|
key: "sdoc-insert-menu-code-block",
|
|
131
141
|
menuConfig: _objectSpread({}, SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.CODE_BLOCK]),
|
|
@@ -171,7 +181,7 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
171
181
|
});
|
|
172
182
|
});
|
|
173
183
|
return items;
|
|
174
|
-
}, [createTable, editor, isDisableCallout, isEmptyNode, onInsert, onInsertCallout, onInsertCheckList, onInsertCodeBlock, onInsertImageToggle, onInsertList, openLinkDialog]);
|
|
184
|
+
}, [createTable, editor, isDisableCallout, isEmptyNode, onInsert, onInsertBlockQuote, onInsertCallout, onInsertCheckList, onInsertCodeBlock, onInsertImageToggle, onInsertList, openLinkDialog]);
|
|
175
185
|
const getSelectItemDom = selectIndex => {
|
|
176
186
|
const dropDownItemWrapper = downDownWrapperRef.current;
|
|
177
187
|
const currentSelectItem = dropDownItemWrapper.children[selectIndex];
|
|
@@ -8,7 +8,7 @@ import { useScrollContext } from '../../../hooks/use-scroll-context';
|
|
|
8
8
|
import { focusEditor } from '../../core';
|
|
9
9
|
import { getDomTopHeight, setSelection, isVoidNode, getNodeEntry, isBlockquote, isList, onWrapListItem } from './helpers';
|
|
10
10
|
import { insertImageFiles } from '../../plugins/image/helpers';
|
|
11
|
-
import { INTERNAL_EVENT } from '../../../constants';
|
|
11
|
+
import { INTERNAL_EVENT, WIKI_EDITOR } from '../../../constants';
|
|
12
12
|
import { CODE_BLOCK, TABLE, BLOCKQUOTE, CHECK_LIST_ITEM, CALL_OUT, TABLE_DRAG_KEY } from '../../constants';
|
|
13
13
|
import { getCalloutEntry } from '../../plugins/callout/helper';
|
|
14
14
|
import './index.css';
|
|
@@ -77,11 +77,21 @@ const SideToolbar = () => {
|
|
|
77
77
|
const offsetY = !editor.editorType ? -1 : 0; // editorType is undefined means sdoc editor
|
|
78
78
|
const topValue = top + scrollRef.current.scrollTop + offsetY;
|
|
79
79
|
if (topValue !== sidePosition.top) setIsMoving(true);
|
|
80
|
+
let left = 20;
|
|
81
|
+
if (editor.editorType === WIKI_EDITOR) {
|
|
82
|
+
const {
|
|
83
|
+
left: editorLeft
|
|
84
|
+
} = document.querySelector('#sdoc-editor').getBoundingClientRect();
|
|
85
|
+
const {
|
|
86
|
+
left: containerLeft
|
|
87
|
+
} = document.querySelector('.sdoc-editor-container').getBoundingClientRect();
|
|
88
|
+
left = editorLeft - containerLeft - 40;
|
|
89
|
+
}
|
|
80
90
|
setTimeout(() => {
|
|
81
91
|
// wait animation
|
|
82
92
|
setSidePosition({
|
|
83
93
|
top: topValue,
|
|
84
|
-
left:
|
|
94
|
+
left: left
|
|
85
95
|
});
|
|
86
96
|
}, 150);
|
|
87
97
|
setSlateNode(node);
|
package/package.json
CHANGED
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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 "
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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"
|
|
471
472
|
}
|
|
@@ -465,7 +465,8 @@
|
|
|
465
465
|
"SeaTable_table": "Таблица SeaTable",
|
|
466
466
|
"And_x_more_records": "и ещё {{count}} записей",
|
|
467
467
|
"Print_limit_exceeded": "При превышении лимита печати будут напечатаны только первые 200 строк",
|
|
468
|
-
"Show_record_numbers": "
|
|
469
|
-
"Alternate_color": "
|
|
470
|
-
"Select_column_display_option_color_tip": "
|
|
468
|
+
"Show_record_numbers": "Показывать номера записей",
|
|
469
|
+
"Alternate_color": "Альтернативный цвет",
|
|
470
|
+
"Select_column_display_option_color_tip": "Цвета параметров отображения столбцов с одиночным и множественным выбором",
|
|
471
|
+
"Header": "Заголовок"
|
|
471
472
|
}
|
|
@@ -467,5 +467,6 @@
|
|
|
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": "标题"
|
|
471
472
|
}
|