@seafile/sdoc-editor 0.1.87 → 0.1.88-beta
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/assets/css/simple-editor.css +11 -0
- package/dist/basic-sdk/assets/css/dropdown-menu.css +6 -0
- package/dist/basic-sdk/editor.js +12 -38
- package/dist/{components/modal-portal.js → basic-sdk/extension/commons/element-popover/index.js} +11 -8
- package/dist/basic-sdk/extension/constants/color.js +2 -1
- package/dist/basic-sdk/extension/constants/element-type.js +4 -1
- package/dist/basic-sdk/extension/constants/index.js +25 -3
- package/dist/basic-sdk/extension/index.js +1 -2
- package/dist/basic-sdk/{comment → extension/menu}/color-menu/color-item.js +2 -2
- package/dist/basic-sdk/{comment → extension/menu}/color-menu/index.css +61 -9
- package/dist/basic-sdk/{comment → extension/menu}/color-menu/index.js +57 -32
- package/dist/basic-sdk/extension/menu/index.js +1 -2
- package/dist/basic-sdk/extension/menu/menu-item.js +1 -0
- package/dist/basic-sdk/extension/menu/menu.css +52 -1
- package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +56 -0
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +25 -0
- package/dist/{components/code-block-hover-menu → basic-sdk/extension/plugins/code-block/hover-menu}/index.js +4 -4
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +1 -1
- package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +2 -1
- package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/index.js +2 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +9 -5
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +19 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +9 -6
- package/dist/basic-sdk/extension/plugins/table/menu/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/table/menu/{context-menu → table-context-menu}/index.js +15 -11
- package/dist/basic-sdk/extension/plugins/table/render/hooks.js +51 -1
- package/dist/basic-sdk/extension/plugins/table/render/index.css +0 -34
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +19 -7
- package/dist/basic-sdk/extension/plugins/table/render/table-root.js +12 -3
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +81 -110
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +73 -73
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +3 -0
- package/dist/basic-sdk/extension/toolbar/index.js +3 -0
- package/dist/basic-sdk/highlight-decorate/setNodeToDecorations.js +1 -1
- package/dist/basic-sdk/hooks/use-selection-position.js +11 -3
- package/dist/components/more-dropdown/index.js +36 -73
- package/dist/utils/local-storage-utils.js +16 -2
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +4 -1
- package/public/locales/zh-CN/sdoc-editor.json +4 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +6 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +18 -6
- package/dist/basic-sdk/extension/menu/context-menu/index.css +0 -1
- package/dist/basic-sdk/extension/menu/context-menu/index.js +0 -38
- package/dist/basic-sdk/extension/plugins/text-align/menu/style.css +0 -53
- package/dist/components/more-dropdown/style.css +0 -64
- /package/dist/{components/code-block-hover-menu → basic-sdk/extension/plugins/code-block/hover-menu}/index.css +0 -0
- /package/dist/basic-sdk/{utils → extension/plugins/code-block}/prismjs.js +0 -0
- /package/dist/basic-sdk/extension/plugins/table/{number-input.js → dialog/custom-table-size-dialog/number-input.js} +0 -0
- /package/dist/basic-sdk/extension/plugins/table/menu/{context-menu → table-context-menu}/index.css +0 -0
- /package/dist/basic-sdk/extension/plugins/table/menu/{context-menu → table-context-menu}/insert-table-element.js +0 -0
|
@@ -1,116 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import React from 'react';
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useRef, useState, useCallback } from 'react';
|
|
3
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
6
4
|
import { withTranslation } from 'react-i18next';
|
|
7
5
|
import classnames from 'classnames';
|
|
8
6
|
import { getAlignType, isMenuDisabled, setAlignType } from '../helpers';
|
|
9
7
|
import { TEXT_ALIGN, MENUS_CONFIG_MAP } from '../../../constants';
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
8
|
+
var TextAlignMenu = function TextAlignMenu(_ref) {
|
|
9
|
+
var isRichEditor = _ref.isRichEditor,
|
|
10
|
+
className = _ref.className,
|
|
11
|
+
editor = _ref.editor;
|
|
12
|
+
var _useState = useState(false),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
isShowMenu = _useState2[0],
|
|
15
|
+
setMenuShow = _useState2[1];
|
|
16
|
+
var popoverRef = useRef(null);
|
|
17
|
+
var disabled = isMenuDisabled(editor);
|
|
18
|
+
var buttonId = 'sdoc-button-text-align';
|
|
19
|
+
var toggle = useCallback(function (event) {
|
|
20
|
+
popoverRef.current.toggle();
|
|
21
|
+
setMenuShow(!isShowMenu);
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [isShowMenu]);
|
|
25
|
+
var getCurrentType = useCallback(function () {
|
|
26
|
+
return getAlignType(editor);
|
|
27
|
+
}, [editor]);
|
|
28
|
+
var setType = useCallback(function (type) {
|
|
29
|
+
setAlignType(editor, type);
|
|
30
|
+
toggle();
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [editor, isShowMenu]);
|
|
34
|
+
var validClassName = classnames(className, 'sdoc-menu-with-dropdown', {
|
|
35
|
+
'menu-show': isShowMenu,
|
|
36
|
+
'disabled': disabled,
|
|
37
|
+
'rich-icon-btn d-flex': isRichEditor,
|
|
38
|
+
'rich-icon-btn-disabled': isRichEditor && disabled,
|
|
39
|
+
'rich-icon-btn-hover': isRichEditor && !disabled,
|
|
40
|
+
'btn btn-icon btn-secondary btn-active d-flex': !isRichEditor
|
|
41
|
+
});
|
|
42
|
+
var curType = getCurrentType();
|
|
43
|
+
var curIcon = MENUS_CONFIG_MAP[TEXT_ALIGN].filter(function (item) {
|
|
44
|
+
return item.type === curType;
|
|
45
|
+
})[0].iconClass;
|
|
46
|
+
var caretIconClass = "sdoc-menu-with-dropdown-triangle-icon sdocfont sdoc-".concat(isShowMenu ? 'caret-up' : 'drop-down');
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
48
|
+
type: "button",
|
|
49
|
+
className: validClassName,
|
|
50
|
+
id: buttonId,
|
|
51
|
+
disabled: disabled
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "sdoc-menu-with-dropdown-icon"
|
|
54
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
55
|
+
className: curIcon
|
|
56
|
+
})), !disabled && /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "sdoc-menu-with-dropdown-triangle"
|
|
58
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
59
|
+
className: caretIconClass
|
|
60
|
+
}))), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
61
|
+
target: buttonId,
|
|
62
|
+
className: "sdoc-menu-popover sdoc-dropdown-menu",
|
|
63
|
+
trigger: "legacy",
|
|
64
|
+
placement: "bottom-start",
|
|
65
|
+
hideArrow: true,
|
|
66
|
+
toggle: toggle,
|
|
67
|
+
fade: false,
|
|
68
|
+
ref: popoverRef
|
|
69
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: "pt-2 pb-2"
|
|
71
|
+
}, MENUS_CONFIG_MAP[TEXT_ALIGN].map(function (item, index) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
key: index,
|
|
74
|
+
className: "sdoc-dropdown-menu-item",
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return setType(item.type);
|
|
61
77
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
_this.setMenuRef = function (ref) {
|
|
73
|
-
_this.menu = ref;
|
|
74
|
-
};
|
|
75
|
-
_this.state = {
|
|
76
|
-
isDropdownMenuOpen: false
|
|
77
|
-
};
|
|
78
|
-
return _this;
|
|
79
|
-
}
|
|
80
|
-
_createClass(TextAlignMenu, [{
|
|
81
|
-
key: "render",
|
|
82
|
-
value: function render() {
|
|
83
|
-
var _this2 = this;
|
|
84
|
-
var isDropdownMenuOpen = this.state.isDropdownMenuOpen;
|
|
85
|
-
var caretIconClass = "caret-icon sdocfont sdoc-".concat(isDropdownMenuOpen ? 'caret-up' : 'drop-down');
|
|
86
|
-
var curType = this.getCurrentType();
|
|
87
|
-
var curIcon = MENUS_CONFIG_MAP[TEXT_ALIGN].filter(function (item) {
|
|
88
|
-
return item.type == curType;
|
|
89
|
-
})[0].iconClass;
|
|
90
|
-
var disabled = this.isDisabled();
|
|
91
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className: "align-menu"
|
|
93
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
-
className: classnames('align-toggle px-2', {
|
|
95
|
-
'align-toggle-disabled': disabled
|
|
96
|
-
}),
|
|
97
|
-
onClick: disabled ? function () {} : this.onToggleClick
|
|
98
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
99
|
-
className: "mr-1 ".concat(curIcon)
|
|
100
|
-
}), !disabled && /*#__PURE__*/React.createElement("span", {
|
|
101
|
-
className: caretIconClass
|
|
102
|
-
})), isDropdownMenuOpen && /*#__PURE__*/React.createElement("div", {
|
|
103
|
-
ref: this.setMenuRef,
|
|
104
|
-
className: "align-popover sdoc-dropdown-menu"
|
|
105
|
-
}, MENUS_CONFIG_MAP[TEXT_ALIGN].map(function (item, index) {
|
|
106
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
107
|
-
key: index,
|
|
108
|
-
className: "sdoc-dropdown-menu-item ".concat(item.iconClass),
|
|
109
|
-
onClick: _this2.setType.bind(_this2, item.type)
|
|
110
|
-
});
|
|
111
|
-
})));
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
114
|
-
return TextAlignMenu;
|
|
115
|
-
}(React.Component);
|
|
78
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
79
|
+
className: item.iconClass
|
|
80
|
+
}));
|
|
81
|
+
}))));
|
|
82
|
+
};
|
|
83
|
+
TextAlignMenu.defaultProps = {
|
|
84
|
+
isRichEditor: true,
|
|
85
|
+
className: 'menu-group-item'
|
|
86
|
+
};
|
|
116
87
|
export default withTranslation('sdoc-editor')(TextAlignMenu);
|
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { TEXT_STYLE, TEXT_STYLE_MORE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import { Editor } from '@seafile/slate';
|
|
5
|
+
import { TEXT_STYLE, TEXT_STYLE_MORE, MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../../../constants';
|
|
8
6
|
import { focusEditor } from '../../../core';
|
|
9
7
|
import { MenuItem } from '../../../menu';
|
|
10
8
|
import { getValue, isMenuDisabled, addMark, removeMark } from '../helpers';
|
|
11
9
|
import MoreDropdown from '../../../../../components/more-dropdown';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
import ColorMenu from '../../../menu/color-menu';
|
|
11
|
+
var TextStyleMenuList = function TextStyleMenuList(_ref) {
|
|
12
|
+
var editor = _ref.editor,
|
|
13
|
+
t = _ref.t,
|
|
14
|
+
isRichEditor = _ref.isRichEditor,
|
|
15
|
+
className = _ref.className;
|
|
16
|
+
var isActive = useCallback(function (type) {
|
|
17
|
+
var isMark = getValue(editor, type);
|
|
18
|
+
return !!isMark;
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, [editor]);
|
|
22
|
+
var isDisabled = useCallback(function () {
|
|
23
|
+
return isMenuDisabled(editor);
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
}, [editor]);
|
|
27
|
+
var onMouseDown = useCallback(function (event, type) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
if (isDisabled()) return;
|
|
31
|
+
var active = isActive(type);
|
|
32
|
+
if (active) {
|
|
33
|
+
removeMark(editor, type);
|
|
34
|
+
} else {
|
|
35
|
+
addMark(editor, type);
|
|
20
36
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
_this.getTextStyleList = function (key) {
|
|
44
|
-
var _this$props = _this.props,
|
|
45
|
-
isRichEditor = _this$props.isRichEditor,
|
|
46
|
-
className = _this$props.className,
|
|
47
|
-
editor = _this$props.editor;
|
|
48
|
-
var list = MENUS_CONFIG_MAP[key].map(function (item) {
|
|
49
|
-
var itemProps = {
|
|
50
|
-
isRichEditor: isRichEditor,
|
|
51
|
-
className: className,
|
|
52
|
-
disabled: _this.isDisabled(),
|
|
53
|
-
isActive: _this.isActive(editor, item.type),
|
|
54
|
-
onMouseDown: _this.onMouseDown
|
|
37
|
+
focusEditor(editor);
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [editor]);
|
|
41
|
+
var setColor = useCallback(function (type, color) {
|
|
42
|
+
Editor.addMark(editor, type, color);
|
|
43
|
+
focusEditor(editor);
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, [editor]);
|
|
47
|
+
var getTextStyleList = useCallback(function (key) {
|
|
48
|
+
return MENUS_CONFIG_MAP[key].map(function (item) {
|
|
49
|
+
var itemProps = {
|
|
50
|
+
isRichEditor: isRichEditor,
|
|
51
|
+
className: className,
|
|
52
|
+
disabled: isDisabled(),
|
|
53
|
+
isActive: isActive(item.type),
|
|
54
|
+
onMouseDown: item.isColor ? function () {} : onMouseDown
|
|
55
|
+
};
|
|
56
|
+
if (item.isColor) {
|
|
57
|
+
itemProps['setColor'] = function (color) {
|
|
58
|
+
return setColor(item.type, color);
|
|
55
59
|
};
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}]);
|
|
78
|
-
return TextStyleMenuList;
|
|
79
|
-
}(React.Component);
|
|
80
|
-
export default TextStyleMenuList;
|
|
60
|
+
itemProps['defaultColorTip'] = item.type === ELEMENT_TYPE.COLOR ? t('Default') : '';
|
|
61
|
+
}
|
|
62
|
+
return _objectSpread(_objectSpread({}, itemProps), item);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, [editor]);
|
|
67
|
+
var list = getTextStyleList(TEXT_STYLE);
|
|
68
|
+
var dropdownList = getTextStyleList(TEXT_STYLE_MORE);
|
|
69
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, list.map(function (itemProps, index) {
|
|
70
|
+
var Component = itemProps.isColor ? ColorMenu : MenuItem;
|
|
71
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({
|
|
72
|
+
key: index
|
|
73
|
+
}, itemProps));
|
|
74
|
+
}), /*#__PURE__*/React.createElement(MoreDropdown, null, dropdownList.map(function (itemProps, index) {
|
|
75
|
+
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({
|
|
76
|
+
key: index
|
|
77
|
+
}, itemProps));
|
|
78
|
+
})));
|
|
79
|
+
};
|
|
80
|
+
export default withTranslation('sdoc-editor')(TextStyleMenuList);
|
|
@@ -21,6 +21,9 @@ var renderText = function renderText(props, editor) {
|
|
|
21
21
|
if (leaf.color) {
|
|
22
22
|
style['color'] = leaf.color;
|
|
23
23
|
}
|
|
24
|
+
if (leaf['highlight-color']) {
|
|
25
|
+
style['backgroundColor'] = leaf['highlight-color'];
|
|
26
|
+
}
|
|
24
27
|
if (leaf.BOLD) {
|
|
25
28
|
markedChildren = /*#__PURE__*/React.createElement("strong", null, markedChildren);
|
|
26
29
|
}
|
|
@@ -13,6 +13,7 @@ import CodeBlockMenu from '../plugins/code-block/menu';
|
|
|
13
13
|
import TextAlignMenu from '../plugins/text-align/menu';
|
|
14
14
|
import HistoryMenu from './redo-undo';
|
|
15
15
|
import { TableMenu, ActiveTableMenu } from '../plugins/table/menu';
|
|
16
|
+
import ClearFormatMenu from '../plugins/clear-format/menu';
|
|
16
17
|
var Toolbar = function Toolbar(_ref) {
|
|
17
18
|
var editor = _ref.editor;
|
|
18
19
|
useSelectionUpdate();
|
|
@@ -20,6 +21,8 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
20
21
|
className: "sdoc-editor-toolbar"
|
|
21
22
|
}, /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(HistoryMenu, {
|
|
22
23
|
editor: editor
|
|
24
|
+
})), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(ClearFormatMenu, {
|
|
25
|
+
editor: editor
|
|
23
26
|
})), /*#__PURE__*/React.createElement(HeaderMenu, {
|
|
24
27
|
editor: editor
|
|
25
28
|
}), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(TextStyleMenuList, {
|
|
@@ -4,7 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
4
4
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
5
5
|
import { Node, Element, Editor } from '@seafile/slate';
|
|
6
6
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
7
|
-
import Prism, { normalizeTokens, normalizeTokensByLanguageType } from '../
|
|
7
|
+
import Prism, { normalizeTokens, normalizeTokensByLanguageType } from '../extension/plugins/code-block/prismjs';
|
|
8
8
|
import { CODE_BLOCK } from '../extension/constants';
|
|
9
9
|
var mergeMaps = function mergeMaps() {
|
|
10
10
|
var map = new Map();
|
|
@@ -17,9 +17,17 @@ export var useSelectionPosition = function useSelectionPosition() {
|
|
|
17
17
|
x: 0,
|
|
18
18
|
y: 0
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
try {
|
|
21
|
+
var domNode = ReactEditor.toDOMNode(editor, node[0]);
|
|
22
|
+
var rect = domNode.getBoundingClientRect();
|
|
23
|
+
return rect;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
// A new node has not yet been indexed, it cannot be retrieved, and the new node has no comment information, just do not display it
|
|
26
|
+
return {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
23
31
|
};
|
|
24
32
|
export var useCommentListPosition = function useCommentListPosition() {
|
|
25
33
|
var selectionPosition = useSelectionPosition();
|
|
@@ -1,75 +1,38 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
|
-
import '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
isDropdownMenuOpen: isDropdownMenuOpen
|
|
43
|
-
}, function () {
|
|
44
|
-
_this.unregisterEventHandler();
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
_this.setMenuRef = function (ref) {
|
|
49
|
-
_this.menu = ref;
|
|
50
|
-
};
|
|
51
|
-
_this.state = {
|
|
52
|
-
isDropdownMenuOpen: false
|
|
53
|
-
};
|
|
54
|
-
return _this;
|
|
55
|
-
}
|
|
56
|
-
_createClass(MoreDropdownMenu, [{
|
|
57
|
-
key: "render",
|
|
58
|
-
value: function render() {
|
|
59
|
-
var isDropdownMenuOpen = this.state.isDropdownMenuOpen;
|
|
60
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
61
|
-
className: "sdoc-more-menu"
|
|
62
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
className: "more-toggle px-2",
|
|
64
|
-
onClick: this.onToggleClick
|
|
65
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
66
|
-
className: "sdocfont sdoc-more"
|
|
67
|
-
})), isDropdownMenuOpen && /*#__PURE__*/React.createElement("div", {
|
|
68
|
-
ref: this.setMenuRef,
|
|
69
|
-
className: "more-popover"
|
|
70
|
-
}, this.props.children));
|
|
71
|
-
}
|
|
72
|
-
}]);
|
|
73
|
-
return MoreDropdownMenu;
|
|
74
|
-
}(React.Component);
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
4
|
+
var MoreDropdownMenu = function MoreDropdownMenu(_ref) {
|
|
5
|
+
var className = _ref.className,
|
|
6
|
+
disabled = _ref.disabled,
|
|
7
|
+
isRichEditor = _ref.isRichEditor,
|
|
8
|
+
children = _ref.children;
|
|
9
|
+
var validClassName = classnames(className, 'sdoc-more-text-button', {
|
|
10
|
+
'disabled': disabled,
|
|
11
|
+
'rich-icon-btn': isRichEditor,
|
|
12
|
+
'rich-icon-btn-disabled': isRichEditor && disabled,
|
|
13
|
+
'rich-icon-btn-hover': isRichEditor && !disabled,
|
|
14
|
+
'btn btn-icon btn-secondary btn-active': !isRichEditor
|
|
15
|
+
});
|
|
16
|
+
var buttonId = 'sdoc-more-text-operations';
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
18
|
+
className: validClassName,
|
|
19
|
+
type: "button",
|
|
20
|
+
id: buttonId
|
|
21
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
22
|
+
className: "sdocfont sdoc-more"
|
|
23
|
+
})), /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
24
|
+
target: buttonId,
|
|
25
|
+
className: "sdoc-menu-popover sdoc-dropdown-menu",
|
|
26
|
+
trigger: "legacy",
|
|
27
|
+
placement: "bottom-end",
|
|
28
|
+
hideArrow: true,
|
|
29
|
+
fade: false
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "menu-group"
|
|
32
|
+
}, children)));
|
|
33
|
+
};
|
|
34
|
+
MoreDropdownMenu.defaultProps = {
|
|
35
|
+
isRichEditor: true,
|
|
36
|
+
className: 'menu-group-item'
|
|
37
|
+
};
|
|
75
38
|
export default MoreDropdownMenu;
|
|
@@ -7,12 +7,26 @@ var LocalStorage = /*#__PURE__*/function () {
|
|
|
7
7
|
_createClass(LocalStorage, null, [{
|
|
8
8
|
key: "setItem",
|
|
9
9
|
value: function setItem(key, value) {
|
|
10
|
-
|
|
10
|
+
var savedValue;
|
|
11
|
+
var valueType = typeof value;
|
|
12
|
+
if (valueType === 'string') {
|
|
13
|
+
savedValue = value;
|
|
14
|
+
} else if (valueType === 'number') {
|
|
15
|
+
savedValue = value + '';
|
|
16
|
+
} else {
|
|
17
|
+
savedValue = JSON.stringify(value);
|
|
18
|
+
}
|
|
19
|
+
return window.localStorage.setItem(key, savedValue);
|
|
11
20
|
}
|
|
12
21
|
}, {
|
|
13
22
|
key: "getItem",
|
|
14
23
|
value: function getItem(key, defaultValue) {
|
|
15
|
-
|
|
24
|
+
var value = window.localStorage.getItem(key);
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(value) || defaultValue;
|
|
27
|
+
} catch (_unused) {
|
|
28
|
+
return value || defaultValue;
|
|
29
|
+
}
|
|
16
30
|
}
|
|
17
31
|
}, {
|
|
18
32
|
key: "removeItem",
|
package/package.json
CHANGED
|
@@ -305,5 +305,8 @@
|
|
|
305
305
|
"Standard_light_blue": "Standard light blue",
|
|
306
306
|
"Standard_blue": "Standard blue",
|
|
307
307
|
"Standard_dark_blue": "Standard dark blue",
|
|
308
|
-
"Standard_purple": "Standard purple"
|
|
308
|
+
"Standard_purple": "Standard purple",
|
|
309
|
+
"Highlight_color": "Highlight",
|
|
310
|
+
"Font_color": "Font color",
|
|
311
|
+
"Default": "Default"
|
|
309
312
|
}
|
|
Binary file
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-font-color" unicode="" d="M960-96h-160l-80 224h-416L224-96H64L403.2 864h211.2L960-96zM512 704l-160-448h320L512 704z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
19
|
+
<glyph glyph-name="sdoc-highlight-color" unicode="" d="M992 528L640-67.2l-144 80-64-108.8H32l163.2 278.4L32 275.2 380.8 896 992 528zM198.4 320l406.4-224 233.6 390.4L428.8 736 198.4 320z" horiz-adv-x="1024" />
|
|
20
|
+
|
|
21
|
+
<glyph glyph-name="sdoc-format-clear" unicode="" d="M519.488 64H279.552L64 279.552 584.448 800l384.64-384.64L617.728 64h-98.176z m64 64l92.608 92.608-288.64 288.64L161.28 282.88 316.16 128h267.328zM128 0h832v-64H128v64z" horiz-adv-x="1024" />
|
|
22
|
+
|
|
17
23
|
<glyph glyph-name="sdoc-bg-color" unicode="" d="M906.4-64c60.8 0 105.6 48 105.6 105.6 0 38.4-35.2 124.8-105.6 246.4C836 160 800.8 80 800.8 41.6c0-60.8 48-105.6 105.6-105.6zM512.8 761.6l358.4-352c35.2-35.2 35.2-92.8 0-128l-358.4-352c-35.2-35.2-92.8-35.2-131.2 0l-355.2 352c-35.2 35.2-35.2 92.8 0 128L356 736l-19.2 19.2c-25.6 22.4-25.6 64 0 89.6s64 22.4 89.6 0l86.4-83.2z m-368-400h614.4L452 649.6c0-3.2-307.2-288-307.2-288z" horiz-adv-x="1024" />
|
|
18
24
|
|
|
19
25
|
<glyph glyph-name="sdoc-right-slide" unicode="" d="M806.4 438.4L336 812.8c-54.4 44.8-144 9.6-144-54.4v-748.8c0-64 86.4-99.2 144-54.4l470.4 374.4c35.2 28.8 35.2 80 0 108.8z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|