@seafile/sdoc-editor 1.0.5 → 1.0.6
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/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
|
@@ -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() {
|
|
@@ -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);
|