@seafile/sdoc-editor 0.1.123 → 0.1.125-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/basic-sdk/comment/comment/editor-comment.js +11 -2
- package/dist/basic-sdk/comment/comment/style.css +1 -0
- package/dist/basic-sdk/editor.js +25 -171
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +7 -5
- package/dist/basic-sdk/extension/plugins/check-list/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/check-list/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +7 -5
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +5 -9
- package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +2 -0
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/code-block/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +7 -4
- package/dist/basic-sdk/extension/plugins/code-block/plugin.js +9 -1
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +18 -9
- package/dist/basic-sdk/extension/plugins/font/helpers.js +5 -3
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/font/menu/index.js +6 -3
- package/dist/basic-sdk/extension/plugins/header/helpers.js +2 -0
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/image/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/image/menu/index.js +8 -6
- package/dist/basic-sdk/extension/plugins/index.js +2 -1
- package/dist/basic-sdk/extension/plugins/link/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/link/menu/index.js +8 -6
- package/dist/basic-sdk/extension/plugins/list/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/list/menu/index.js +11 -9
- package/dist/basic-sdk/extension/plugins/paragraph/index.js +7 -0
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +35 -0
- package/dist/basic-sdk/extension/plugins/sdoc-link/dialogs/select-sdoc-file-dialog/index.css +55 -0
- package/dist/basic-sdk/extension/plugins/sdoc-link/{menu/sdoc-link-file-dialog.js → dialogs/select-sdoc-file-dialog/index.js} +36 -29
- package/dist/basic-sdk/extension/plugins/sdoc-link/dialogs/select-sdoc-file-dialog/local-files/index.css +75 -0
- package/dist/basic-sdk/extension/plugins/sdoc-link/{menu/local-files.js → dialogs/select-sdoc-file-dialog/local-files/index.js} +42 -32
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/{menu/sdoc-link-hover-menu.js → hover-menu/index.js} +1 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +7 -6
- package/dist/basic-sdk/extension/plugins/sdoc-link/render-elem.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +6 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +12 -6
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/remove-table-menu.js +5 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-column-menu.js +8 -4
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-row-menu.js +8 -4
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +7 -5
- package/dist/basic-sdk/extension/plugins/text-align/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/text-style/helpers.js +2 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +5 -4
- package/dist/basic-sdk/extension/render/render-element.js +14 -48
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +37 -17
- package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +7 -4
- package/dist/basic-sdk/layout/editor-container.js +26 -0
- package/dist/basic-sdk/layout/editor-content.js +56 -0
- package/dist/basic-sdk/layout/index.js +4 -0
- package/dist/basic-sdk/outline/index.js +6 -7
- package/dist/basic-sdk/outline/style.css +5 -1
- package/dist/basic-sdk/slate-editor.js +149 -0
- package/dist/basic-sdk/socket/with-socket-io.js +1 -0
- package/dist/basic-sdk/utils/diff.js +12 -0
- package/dist/basic-sdk/views/diff-viewer.js +10 -5
- package/dist/basic-sdk/views/viewer.js +20 -20
- package/dist/components/doc-operations/index.js +2 -0
- package/dist/components/doc-operations/revision-operations/changes-count/index.css +34 -0
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +85 -0
- package/dist/components/doc-operations/revision-operations/index.js +5 -1
- package/dist/pages/diff-viewer.js +2 -0
- package/dist/pages/simple-editor.js +16 -3
- package/package.json +1 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +4 -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 +14 -6
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/local-files.css +0 -98
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/sdoc-link-file-dialog.css +0 -35
- package/dist/pages/diff-viewer/history-version-viewer.js +0 -15
- package/dist/pages/diff-viewer/index.js +0 -35
- /package/dist/basic-sdk/extension/plugins/sdoc-link/{menu/sdoc-link-hover-menu.css → hover-menu/index.css} +0 -0
package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js
CHANGED
|
@@ -3,20 +3,23 @@ import { useTranslation } from 'react-i18next';
|
|
|
3
3
|
import CommonMenu from './common-menu';
|
|
4
4
|
import { setCellStyle } from '../../helpers';
|
|
5
5
|
var CellTextAlignMenu = function CellTextAlignMenu(_ref) {
|
|
6
|
-
var editor = _ref.editor
|
|
6
|
+
var editor = _ref.editor,
|
|
7
|
+
readonly = _ref.readonly;
|
|
7
8
|
var textAlignRef = useRef(null);
|
|
8
9
|
var _useTranslation = useTranslation(),
|
|
9
10
|
t = _useTranslation.t;
|
|
10
11
|
var setTextAlignStyle = useCallback(function (textAlign) {
|
|
12
|
+
if (readonly) return;
|
|
11
13
|
setCellStyle(editor, {
|
|
12
14
|
textAlign: textAlign
|
|
13
15
|
});
|
|
14
16
|
textAlignRef.current && textAlignRef.current.hidePopover();
|
|
15
|
-
}, [editor]);
|
|
17
|
+
}, [editor, readonly]);
|
|
16
18
|
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
17
19
|
id: "text-align",
|
|
18
20
|
iconClass: "sdocfont sdoc-align-left",
|
|
19
|
-
ref: textAlignRef
|
|
21
|
+
ref: textAlignRef,
|
|
22
|
+
disabled: readonly
|
|
20
23
|
}, /*#__PURE__*/React.createElement("div", {
|
|
21
24
|
className: "sdoc-dropdown-menu-item",
|
|
22
25
|
onClick: function onClick() {
|
|
@@ -46,7 +46,8 @@ var CommonMenu = /*#__PURE__*/function (_Component) {
|
|
|
46
46
|
var _this$props2 = this.props,
|
|
47
47
|
id = _this$props2.id,
|
|
48
48
|
iconClass = _this$props2.iconClass,
|
|
49
|
-
children = _this$props2.children
|
|
49
|
+
children = _this$props2.children,
|
|
50
|
+
disabled = _this$props2.disabled;
|
|
50
51
|
var isShowMenu = this.state.isShowMenu;
|
|
51
52
|
var className = this.getClassName();
|
|
52
53
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
@@ -61,7 +62,7 @@ var CommonMenu = /*#__PURE__*/function (_Component) {
|
|
|
61
62
|
className: "sdoc-menu-with-dropdown-triangle"
|
|
62
63
|
}, /*#__PURE__*/React.createElement("i", {
|
|
63
64
|
className: "sdoc-menu-with-dropdown-triangle-icon sdocfont sdoc-".concat(isShowMenu ? 'caret-up' : 'drop-down')
|
|
64
|
-
}))), /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
65
|
+
}))), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
65
66
|
target: id,
|
|
66
67
|
className: "sdoc-common-menu-popover sdoc-table-menu-popover",
|
|
67
68
|
trigger: "legacy",
|
|
@@ -11,24 +11,30 @@ import './index.css';
|
|
|
11
11
|
var ActiveTableMenu = function ActiveTableMenu(_ref) {
|
|
12
12
|
var isRichEditor = _ref.isRichEditor,
|
|
13
13
|
className = _ref.className,
|
|
14
|
-
editor = _ref.editor
|
|
14
|
+
editor = _ref.editor,
|
|
15
|
+
readonly = _ref.readonly;
|
|
15
16
|
if (!isAllInTable(editor)) return null;
|
|
16
17
|
return /*#__PURE__*/React.createElement(MenuGroup, {
|
|
17
18
|
className: "menu-group sdoc-table-menu-group"
|
|
18
19
|
}, /*#__PURE__*/React.createElement(CellTextAlignMenu, {
|
|
19
|
-
editor: editor
|
|
20
|
+
editor: editor,
|
|
21
|
+
readonly: readonly
|
|
20
22
|
}), /*#__PURE__*/React.createElement(TableColumnMenu, {
|
|
21
|
-
editor: editor
|
|
23
|
+
editor: editor,
|
|
24
|
+
readonly: readonly
|
|
22
25
|
}), /*#__PURE__*/React.createElement(TableRowMenu, {
|
|
23
|
-
editor: editor
|
|
26
|
+
editor: editor,
|
|
27
|
+
readonly: readonly
|
|
24
28
|
}), /*#__PURE__*/React.createElement(CellBgColorMenu, {
|
|
25
29
|
editor: editor,
|
|
26
30
|
isRichEditor: isRichEditor,
|
|
27
|
-
className: className
|
|
31
|
+
className: className,
|
|
32
|
+
readonly: readonly
|
|
28
33
|
}), /*#__PURE__*/React.createElement(RemoveTable, {
|
|
29
34
|
editor: editor,
|
|
30
35
|
isRichEditor: isRichEditor,
|
|
31
|
-
className: className
|
|
36
|
+
className: className,
|
|
37
|
+
readonly: readonly
|
|
32
38
|
}));
|
|
33
39
|
};
|
|
34
40
|
export default withTranslation('sdoc-editor')(ActiveTableMenu);
|
|
@@ -8,15 +8,17 @@ import { TABLE_ELEMENT } from '../../constants';
|
|
|
8
8
|
var RemoveTable = function RemoveTable(_ref) {
|
|
9
9
|
var isRichEditor = _ref.isRichEditor,
|
|
10
10
|
className = _ref.className,
|
|
11
|
-
editor = _ref.editor
|
|
11
|
+
editor = _ref.editor,
|
|
12
|
+
readonly = _ref.readonly;
|
|
12
13
|
var removeTable = useCallback(function () {
|
|
14
|
+
if (readonly) return;
|
|
13
15
|
removeTableElement(editor, TABLE_ELEMENT.TABLE);
|
|
14
|
-
}, [editor]);
|
|
16
|
+
}, [editor, readonly]);
|
|
15
17
|
var menuConfig = MENUS_CONFIG_MAP[REMOVE_TABLE];
|
|
16
18
|
var props = _objectSpread(_objectSpread({
|
|
17
19
|
isRichEditor: isRichEditor,
|
|
18
20
|
className: classnames(className, 'sdoc-remove-table menu-group-item'),
|
|
19
|
-
disabled:
|
|
21
|
+
disabled: readonly,
|
|
20
22
|
isActive: false
|
|
21
23
|
}, menuConfig), {}, {
|
|
22
24
|
onMouseDown: removeTable
|
|
@@ -4,22 +4,26 @@ import CommonMenu from './common-menu';
|
|
|
4
4
|
import { insertTableElement, removeTableElement } from '../../helpers';
|
|
5
5
|
import { TABLE_ELEMENT } from '../../constants';
|
|
6
6
|
var TableColumnMenu = function TableColumnMenu(_ref) {
|
|
7
|
-
var editor = _ref.editor
|
|
7
|
+
var editor = _ref.editor,
|
|
8
|
+
readonly = _ref.readonly;
|
|
8
9
|
var tableColumnRef = useRef(null);
|
|
9
10
|
var _useTranslation = useTranslation(),
|
|
10
11
|
t = _useTranslation.t;
|
|
11
12
|
var insertColumn = useCallback(function (type) {
|
|
13
|
+
if (readonly) return;
|
|
12
14
|
insertTableElement(editor, type);
|
|
13
15
|
tableColumnRef.current && tableColumnRef.current.hidePopover();
|
|
14
|
-
}, [editor]);
|
|
16
|
+
}, [editor, readonly]);
|
|
15
17
|
var removeColumn = useCallback(function (type) {
|
|
18
|
+
if (readonly) return;
|
|
16
19
|
removeTableElement(editor, type);
|
|
17
20
|
tableColumnRef.current && tableColumnRef.current.hidePopover();
|
|
18
|
-
}, [editor]);
|
|
21
|
+
}, [editor, readonly]);
|
|
19
22
|
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
20
23
|
id: "table-column",
|
|
21
24
|
iconClass: "sdocfont sdoc-column",
|
|
22
|
-
ref: tableColumnRef
|
|
25
|
+
ref: tableColumnRef,
|
|
26
|
+
disabled: readonly
|
|
23
27
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24
28
|
className: "sdoc-dropdown-menu-item",
|
|
25
29
|
onClick: function onClick() {
|
|
@@ -4,22 +4,26 @@ import CommonMenu from './common-menu';
|
|
|
4
4
|
import { insertTableElement, removeTableElement } from '../../helpers';
|
|
5
5
|
import { TABLE_ELEMENT } from '../../constants';
|
|
6
6
|
var TableRowMenu = function TableRowMenu(_ref) {
|
|
7
|
-
var editor = _ref.editor
|
|
7
|
+
var editor = _ref.editor,
|
|
8
|
+
readonly = _ref.readonly;
|
|
8
9
|
var tableRowRef = useRef(null);
|
|
9
10
|
var _useTranslation = useTranslation(),
|
|
10
11
|
t = _useTranslation.t;
|
|
11
12
|
var insertRow = useCallback(function (type) {
|
|
13
|
+
if (readonly) return;
|
|
12
14
|
insertTableElement(editor, type);
|
|
13
15
|
tableRowRef.current && tableRowRef.current.hidePopover();
|
|
14
|
-
}, [editor]);
|
|
16
|
+
}, [editor, readonly]);
|
|
15
17
|
var removeRow = useCallback(function (type) {
|
|
18
|
+
if (readonly) return;
|
|
16
19
|
removeTableElement(editor, type);
|
|
17
20
|
tableRowRef.current && tableRowRef.current.hidePopover();
|
|
18
|
-
}, [editor]);
|
|
21
|
+
}, [editor, readonly]);
|
|
19
22
|
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
20
23
|
id: "table-row",
|
|
21
24
|
iconClass: "sdocfont sdoc-row",
|
|
22
|
-
ref: tableRowRef
|
|
25
|
+
ref: tableRowRef,
|
|
26
|
+
disabled: readonly
|
|
23
27
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24
28
|
className: "sdoc-dropdown-menu-item",
|
|
25
29
|
onClick: function onClick() {
|
|
@@ -23,8 +23,10 @@ var TableMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
23
23
|
return false;
|
|
24
24
|
};
|
|
25
25
|
_this.isDisabled = function () {
|
|
26
|
-
var
|
|
27
|
-
|
|
26
|
+
var _this$props = _this.props,
|
|
27
|
+
editor = _this$props.editor,
|
|
28
|
+
readonly = _this$props.readonly;
|
|
29
|
+
return isTableMenuDisabled(editor, readonly);
|
|
28
30
|
};
|
|
29
31
|
_this.createTable = function (size) {
|
|
30
32
|
var editor = _this.props.editor;
|
|
@@ -35,9 +37,9 @@ var TableMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
35
37
|
_createClass(TableMenu, [{
|
|
36
38
|
key: "render",
|
|
37
39
|
value: function render() {
|
|
38
|
-
var _this$
|
|
39
|
-
isRichEditor = _this$
|
|
40
|
-
className = _this$
|
|
40
|
+
var _this$props2 = this.props,
|
|
41
|
+
isRichEditor = _this$props2.isRichEditor,
|
|
42
|
+
className = _this$props2.className;
|
|
41
43
|
var menuConfig = MENUS_CONFIG_MAP[TABLE];
|
|
42
44
|
var props = _objectSpread(_objectSpread({
|
|
43
45
|
isRichEditor: isRichEditor,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { Editor, Transforms, Element } from '@seafile/slate';
|
|
3
3
|
import { TEXT_ALIGN, MENUS_CONFIG_MAP, CODE_BLOCK, TABLE } from '../../constants';
|
|
4
|
-
export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
4
|
+
export var isMenuDisabled = function isMenuDisabled(editor, readonly) {
|
|
5
|
+
if (readonly) return true;
|
|
5
6
|
if (!editor.selection) return true;
|
|
6
7
|
var _Editor$nodes = Editor.nodes(editor, {
|
|
7
8
|
match: function match(node) {
|
|
@@ -8,13 +8,14 @@ import { TEXT_ALIGN, MENUS_CONFIG_MAP } from '../../../constants';
|
|
|
8
8
|
var TextAlignMenu = function TextAlignMenu(_ref) {
|
|
9
9
|
var isRichEditor = _ref.isRichEditor,
|
|
10
10
|
className = _ref.className,
|
|
11
|
-
editor = _ref.editor
|
|
11
|
+
editor = _ref.editor,
|
|
12
|
+
readonly = _ref.readonly;
|
|
12
13
|
var _useState = useState(false),
|
|
13
14
|
_useState2 = _slicedToArray(_useState, 2),
|
|
14
15
|
isShowMenu = _useState2[0],
|
|
15
16
|
setMenuShow = _useState2[1];
|
|
16
17
|
var popoverRef = useRef(null);
|
|
17
|
-
var disabled = isMenuDisabled(editor);
|
|
18
|
+
var disabled = isMenuDisabled(editor, readonly);
|
|
18
19
|
var buttonId = 'sdoc-button-text-align';
|
|
19
20
|
var toggle = useCallback(function (event) {
|
|
20
21
|
popoverRef.current.toggle();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { Editor } from '@seafile/slate';
|
|
3
3
|
import { getNodeType } from '../../core';
|
|
4
|
-
export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
4
|
+
export var isMenuDisabled = function isMenuDisabled(editor, readonly) {
|
|
5
|
+
if (readonly) return true;
|
|
5
6
|
if (editor.selection == null) return true;
|
|
6
7
|
var _Editor$nodes = Editor.nodes(editor, {
|
|
7
8
|
match: function match(n) {
|
|
@@ -12,7 +12,8 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
|
|
|
12
12
|
t = _ref.t,
|
|
13
13
|
isRichEditor = _ref.isRichEditor,
|
|
14
14
|
className = _ref.className,
|
|
15
|
-
idPrefix = _ref.idPrefix
|
|
15
|
+
idPrefix = _ref.idPrefix,
|
|
16
|
+
readonly = _ref.readonly;
|
|
16
17
|
var _useColorContext = useColorContext(),
|
|
17
18
|
lastUsedFontColor = _useColorContext.lastUsedFontColor,
|
|
18
19
|
updateLastUsedFontColor = _useColorContext.updateLastUsedFontColor,
|
|
@@ -25,10 +26,10 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
|
|
|
25
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
27
|
}, [editor]);
|
|
27
28
|
var isDisabled = useCallback(function () {
|
|
28
|
-
return isMenuDisabled(editor);
|
|
29
|
+
return isMenuDisabled(editor, readonly);
|
|
29
30
|
|
|
30
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
-
}, [editor]);
|
|
32
|
+
}, [editor, readonly]);
|
|
32
33
|
var onMouseDown = useCallback(function (event, type) {
|
|
33
34
|
event.preventDefault();
|
|
34
35
|
event.stopPropagation();
|
|
@@ -72,7 +73,7 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
|
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
-
}, [editor, lastUsedFontColor, lastUsedHighlightColor]);
|
|
76
|
+
}, [editor, lastUsedFontColor, lastUsedHighlightColor, readonly]);
|
|
76
77
|
var list = getTextStyleList(TEXT_STYLE);
|
|
77
78
|
var dropdownList = getTextStyleList(TEXT_STYLE_MORE);
|
|
78
79
|
return /*#__PURE__*/React.createElement(React.Fragment, null, list.map(function (itemProps, index) {
|
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import { Node } from '@seafile/slate';
|
|
5
3
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
6
4
|
import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, LIST_LIC, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK } from '../constants';
|
|
7
|
-
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin } from '../plugins';
|
|
8
|
-
import { Placeholder, findPath, getAboveNode } from '../core';
|
|
5
|
+
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin } from '../plugins';
|
|
9
6
|
var CustomElement = function CustomElement(props) {
|
|
10
7
|
var editor = useSlateStatic();
|
|
11
|
-
var
|
|
12
|
-
children = props.children,
|
|
13
|
-
element = props.element;
|
|
14
|
-
var style = {
|
|
15
|
-
textAlign: element.align
|
|
16
|
-
};
|
|
8
|
+
var element = props.element;
|
|
17
9
|
switch (element.type) {
|
|
18
10
|
case PARAGRAPH:
|
|
19
11
|
{
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
isShowPlaceHolder = Node.string(element) === '' && !isComposing;
|
|
24
|
-
}
|
|
25
|
-
if (editor.children.length === 2 && editor.children[0].type.startsWith('header')) {
|
|
26
|
-
var node = editor.children[1];
|
|
27
|
-
isShowPlaceHolder = Node.string(element) === '' && (node === null || node === void 0 ? void 0 : node.id) === (element === null || element === void 0 ? void 0 : element.id) && !isComposing;
|
|
28
|
-
}
|
|
29
|
-
return /*#__PURE__*/React.createElement("p", Object.assign({
|
|
30
|
-
"data-id": element.id
|
|
31
|
-
}, attributes, {
|
|
32
|
-
style: _objectSpread({
|
|
33
|
-
position: isShowPlaceHolder ? 'relative' : ''
|
|
34
|
-
}, style)
|
|
35
|
-
}), children, isShowPlaceHolder && /*#__PURE__*/React.createElement(Placeholder, {
|
|
36
|
-
title: 'Please_enter_text'
|
|
37
|
-
}));
|
|
12
|
+
var _ParagraphPlugin$rend = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
13
|
+
renderParagraph = _ParagraphPlugin$rend[0];
|
|
14
|
+
return renderParagraph(props);
|
|
38
15
|
}
|
|
39
16
|
case HEADER1:
|
|
40
17
|
case HEADER2:
|
|
@@ -80,11 +57,9 @@ var CustomElement = function CustomElement(props) {
|
|
|
80
57
|
}
|
|
81
58
|
case CHECK_LIST_ITEM:
|
|
82
59
|
{
|
|
83
|
-
var _CheckListPlugin$rend = _slicedToArray(CheckListPlugin.renderElements,
|
|
84
|
-
|
|
85
|
-
return
|
|
86
|
-
editor: editor
|
|
87
|
-
}));
|
|
60
|
+
var _CheckListPlugin$rend = _slicedToArray(CheckListPlugin.renderElements, 1),
|
|
61
|
+
renderCheckListItem = _CheckListPlugin$rend[0];
|
|
62
|
+
return renderCheckListItem(props, editor);
|
|
88
63
|
}
|
|
89
64
|
case CODE_BLOCK:
|
|
90
65
|
{
|
|
@@ -94,16 +69,9 @@ var CustomElement = function CustomElement(props) {
|
|
|
94
69
|
}
|
|
95
70
|
case CODE_LINE:
|
|
96
71
|
{
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
if (parentNode[0].type === CODE_BLOCK) {
|
|
102
|
-
return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
|
|
103
|
-
className: 'sdoc-code-line'
|
|
104
|
-
}), children);
|
|
105
|
-
}
|
|
106
|
-
return children;
|
|
72
|
+
var _CodeBlockPlugin$rend2 = _slicedToArray(CodeBlockPlugin.renderElements, 2),
|
|
73
|
+
renderCodeLine = _CodeBlockPlugin$rend2[1];
|
|
74
|
+
return renderCodeLine(props, editor);
|
|
107
75
|
}
|
|
108
76
|
case IMAGE:
|
|
109
77
|
{
|
|
@@ -137,11 +105,9 @@ var CustomElement = function CustomElement(props) {
|
|
|
137
105
|
}
|
|
138
106
|
default:
|
|
139
107
|
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
style: style
|
|
144
|
-
}), children);
|
|
108
|
+
var _ParagraphPlugin$rend2 = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
109
|
+
_renderParagraph = _ParagraphPlugin$rend2[0];
|
|
110
|
+
return _renderParagraph(props);
|
|
145
111
|
}
|
|
146
112
|
}
|
|
147
113
|
};
|
|
@@ -17,44 +17,64 @@ import HistoryMenu from './redo-undo';
|
|
|
17
17
|
import Font from '../../plugins/font/menu';
|
|
18
18
|
import SdocLinkMenu from '../../plugins/sdoc-link/menu';
|
|
19
19
|
var Toolbar = function Toolbar(_ref) {
|
|
20
|
-
var editor = _ref.editor
|
|
20
|
+
var editor = _ref.editor,
|
|
21
|
+
readonly = _ref.readonly;
|
|
21
22
|
useSelectionUpdate();
|
|
22
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
23
24
|
className: "sdoc-editor-toolbar"
|
|
24
25
|
}, /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(HistoryMenu, {
|
|
25
|
-
editor: editor
|
|
26
|
+
editor: editor,
|
|
27
|
+
readonly: readonly
|
|
26
28
|
}), /*#__PURE__*/React.createElement(ClearFormatMenu, {
|
|
27
|
-
editor: editor
|
|
29
|
+
editor: editor,
|
|
30
|
+
readonly: readonly
|
|
28
31
|
})), /*#__PURE__*/React.createElement(HeaderMenu, {
|
|
29
|
-
editor: editor
|
|
32
|
+
editor: editor,
|
|
33
|
+
readonly: readonly
|
|
30
34
|
}), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(Font, {
|
|
31
|
-
editor: editor
|
|
35
|
+
editor: editor,
|
|
36
|
+
readonly: readonly
|
|
32
37
|
}), /*#__PURE__*/React.createElement(TextStyleMenuList, {
|
|
33
|
-
editor: editor
|
|
38
|
+
editor: editor,
|
|
39
|
+
readonly: readonly
|
|
34
40
|
})), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(QuoteMenu, {
|
|
35
|
-
editor: editor
|
|
41
|
+
editor: editor,
|
|
42
|
+
readonly: readonly
|
|
36
43
|
}), /*#__PURE__*/React.createElement(ListMenu, {
|
|
37
44
|
editor: editor,
|
|
38
|
-
type: UNORDERED_LIST
|
|
45
|
+
type: UNORDERED_LIST,
|
|
46
|
+
readonly: readonly
|
|
39
47
|
}), /*#__PURE__*/React.createElement(ListMenu, {
|
|
40
48
|
editor: editor,
|
|
41
|
-
type: ORDERED_LIST
|
|
49
|
+
type: ORDERED_LIST,
|
|
50
|
+
readonly: readonly
|
|
42
51
|
}), /*#__PURE__*/React.createElement(CheckListMenu, {
|
|
43
|
-
editor: editor
|
|
52
|
+
editor: editor,
|
|
53
|
+
readonly: readonly
|
|
44
54
|
}), /*#__PURE__*/React.createElement(TextAlignMenu, {
|
|
45
|
-
editor: editor
|
|
55
|
+
editor: editor,
|
|
56
|
+
readonly: readonly
|
|
46
57
|
})), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(CodeBlockMenu, {
|
|
47
|
-
editor: editor
|
|
58
|
+
editor: editor,
|
|
59
|
+
readonly: readonly
|
|
48
60
|
}), /*#__PURE__*/React.createElement(TableMenu, {
|
|
49
|
-
editor: editor
|
|
61
|
+
editor: editor,
|
|
62
|
+
readonly: readonly
|
|
50
63
|
})), /*#__PURE__*/React.createElement(ActiveTableMenu, {
|
|
51
|
-
editor: editor
|
|
64
|
+
editor: editor,
|
|
65
|
+
readonly: readonly
|
|
52
66
|
}), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(ImageMenu, {
|
|
53
|
-
editor: editor
|
|
67
|
+
editor: editor,
|
|
68
|
+
readonly: readonly
|
|
54
69
|
}), /*#__PURE__*/React.createElement(LinkMenu, {
|
|
55
|
-
editor: editor
|
|
70
|
+
editor: editor,
|
|
71
|
+
readonly: readonly
|
|
56
72
|
})), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(SdocLinkMenu, {
|
|
57
|
-
editor: editor
|
|
73
|
+
editor: editor,
|
|
74
|
+
readonly: readonly
|
|
58
75
|
})));
|
|
59
76
|
};
|
|
77
|
+
Toolbar.defaultProps = {
|
|
78
|
+
readonly: false
|
|
79
|
+
};
|
|
60
80
|
export default Toolbar;
|
|
@@ -17,7 +17,10 @@ var HistoryMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
17
17
|
}
|
|
18
18
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
19
19
|
_this.isDisabled = function (type) {
|
|
20
|
-
var
|
|
20
|
+
var _this$props = _this.props,
|
|
21
|
+
editor = _this$props.editor,
|
|
22
|
+
readonly = _this$props.readonly;
|
|
23
|
+
if (readonly) return true;
|
|
21
24
|
var history = editor.history;
|
|
22
25
|
if (type === UNDO) {
|
|
23
26
|
return history.undos.length === 0;
|
|
@@ -37,9 +40,9 @@ var HistoryMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
37
40
|
_createClass(HistoryMenu, [{
|
|
38
41
|
key: "render",
|
|
39
42
|
value: function render() {
|
|
40
|
-
var _this$
|
|
41
|
-
isRichEditor = _this$
|
|
42
|
-
className = _this$
|
|
43
|
+
var _this$props2 = this.props,
|
|
44
|
+
isRichEditor = _this$props2.isRichEditor,
|
|
45
|
+
className = _this$props2.className;
|
|
43
46
|
var undoConfig = MENUS_CONFIG_MAP[UNDO];
|
|
44
47
|
var redoConfig = MENUS_CONFIG_MAP[REDO];
|
|
45
48
|
var undoProps = _objectSpread(_objectSpread({
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { ColorProvider } from '../hooks/use-color-context';
|
|
4
|
+
import { Toolbar } from '../extension';
|
|
5
|
+
import { isMobile } from '../../utils';
|
|
6
|
+
import '../assets/css/layout.css';
|
|
7
|
+
import '../assets/css/sdoc-editor-plugins.css';
|
|
8
|
+
import '../assets/css/dropdown-menu.css';
|
|
9
|
+
var EditorContainer = function EditorContainer(_ref) {
|
|
10
|
+
var editor = _ref.editor,
|
|
11
|
+
readonly = _ref.readonly,
|
|
12
|
+
children = _ref.children,
|
|
13
|
+
showToolbar = _ref.showToolbar;
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: classnames('sdoc-editor-container', {
|
|
16
|
+
'mobile': isMobile && readonly
|
|
17
|
+
})
|
|
18
|
+
}, /*#__PURE__*/React.createElement(ColorProvider, null, showToolbar && /*#__PURE__*/React.createElement(Toolbar, {
|
|
19
|
+
editor: editor,
|
|
20
|
+
readonly: readonly
|
|
21
|
+
}), children));
|
|
22
|
+
};
|
|
23
|
+
EditorContainer.defaultProps = {
|
|
24
|
+
showToolbar: true
|
|
25
|
+
};
|
|
26
|
+
export default EditorContainer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useRef, useState, useCallback } from 'react';
|
|
3
|
+
import { ScrollContext } from '../hooks/use-scroll-context';
|
|
4
|
+
import SDocOutline from '../outline';
|
|
5
|
+
var EditorContent = function EditorContent(_ref) {
|
|
6
|
+
var readonly = _ref.readonly,
|
|
7
|
+
showOutline = _ref.showOutline,
|
|
8
|
+
children = _ref.children,
|
|
9
|
+
docValue = _ref.docValue;
|
|
10
|
+
var scrollRef = useRef(null);
|
|
11
|
+
var _useState = useState(0),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
scrollLeft = _useState2[0],
|
|
14
|
+
setScrollLeft = _useState2[1];
|
|
15
|
+
var onWrapperScroll = useCallback(function (event) {
|
|
16
|
+
var scrollLeft = event.target.scrollLeft;
|
|
17
|
+
setScrollLeft(scrollLeft);
|
|
18
|
+
}, []);
|
|
19
|
+
if (readonly && !showOutline) {
|
|
20
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: "sdoc-editor-content readonly"
|
|
22
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
ref: scrollRef,
|
|
24
|
+
className: "sdoc-scroll-container",
|
|
25
|
+
id: "sdoc-scroll-container"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
27
|
+
value: {
|
|
28
|
+
scrollRef: scrollRef
|
|
29
|
+
}
|
|
30
|
+
}, children)));
|
|
31
|
+
}
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: "sdoc-editor-content"
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "sdoc-absolute-wrapper"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(SDocOutline, {
|
|
37
|
+
scrollLeft: scrollLeft,
|
|
38
|
+
doc: docValue
|
|
39
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: "sdoc-absolute-wrapper"
|
|
41
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
ref: scrollRef,
|
|
43
|
+
className: "sdoc-scroll-container",
|
|
44
|
+
onScroll: onWrapperScroll,
|
|
45
|
+
id: "sdoc-scroll-container"
|
|
46
|
+
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
47
|
+
value: {
|
|
48
|
+
scrollRef: scrollRef
|
|
49
|
+
}
|
|
50
|
+
}, children))));
|
|
51
|
+
};
|
|
52
|
+
EditorContent.defaultProps = {
|
|
53
|
+
readonly: false,
|
|
54
|
+
showOutline: true
|
|
55
|
+
};
|
|
56
|
+
export default EditorContent;
|
|
@@ -4,22 +4,21 @@ import { withTranslation } from 'react-i18next';
|
|
|
4
4
|
import { UncontrolledTooltip } from 'reactstrap';
|
|
5
5
|
import OutlineItem from './outline-item';
|
|
6
6
|
import './style.css';
|
|
7
|
-
var getOutlineSetting = function getOutlineSetting(
|
|
8
|
-
var currentValue = localStorage.getItem(
|
|
7
|
+
var getOutlineSetting = function getOutlineSetting() {
|
|
8
|
+
var currentValue = localStorage.getItem('sdoc');
|
|
9
9
|
var config = currentValue ? JSON.parse(currentValue) : {};
|
|
10
10
|
var _config$outlineOpen = config.outlineOpen,
|
|
11
11
|
outlineOpen = _config$outlineOpen === void 0 ? false : _config$outlineOpen;
|
|
12
12
|
return outlineOpen;
|
|
13
13
|
};
|
|
14
|
-
var setOutlineSetting = function setOutlineSetting(
|
|
15
|
-
var currentValue = localStorage.getItem(
|
|
14
|
+
var setOutlineSetting = function setOutlineSetting(isShown) {
|
|
15
|
+
var currentValue = localStorage.getItem('sdoc');
|
|
16
16
|
var config = currentValue ? JSON.parse(currentValue) : {};
|
|
17
17
|
config['outlineOpen'] = isShown;
|
|
18
|
-
localStorage.setItem(
|
|
18
|
+
localStorage.setItem('sdoc', JSON.stringify(config));
|
|
19
19
|
};
|
|
20
20
|
var SDocOutline = function SDocOutline(_ref) {
|
|
21
21
|
var scrollLeft = _ref.scrollLeft,
|
|
22
|
-
docUuid = _ref.docUuid,
|
|
23
22
|
doc = _ref.doc,
|
|
24
23
|
t = _ref.t;
|
|
25
24
|
var _useState = useState(false),
|
|
@@ -27,7 +26,7 @@ var SDocOutline = function SDocOutline(_ref) {
|
|
|
27
26
|
isShown = _useState2[0],
|
|
28
27
|
setIsShown = _useState2[1];
|
|
29
28
|
useEffect(function () {
|
|
30
|
-
var outlineOpen = getOutlineSetting(
|
|
29
|
+
var outlineOpen = getOutlineSetting();
|
|
31
30
|
setIsShown(outlineOpen);
|
|
32
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
32
|
}, []);
|