@seafile/sdoc-editor 0.1.25 → 0.1.26
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/assets/css/sdoc-editor-toolbar.css +1 -1
- package/dist/basic-sdk/editor.js +4 -1
- package/dist/basic-sdk/extension/constants/index.js +15 -1
- package/dist/basic-sdk/extension/index.js +3 -1
- package/dist/basic-sdk/extension/toolbar/index.js +4 -1
- package/dist/basic-sdk/extension/toolbar/redo-undo.js +66 -0
- package/dist/basic-sdk/outline.js +11 -1
- package/package.json +3 -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 +8 -0
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -63,6 +63,8 @@ var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
63
63
|
value: function render() {
|
|
64
64
|
var _this2 = this;
|
|
65
65
|
var slateValue = this.state.slateValue;
|
|
66
|
+
var config = this.props.config;
|
|
67
|
+
var docUuid = config.docUuid;
|
|
66
68
|
return /*#__PURE__*/React.createElement("div", {
|
|
67
69
|
className: "sdoc-editor-container"
|
|
68
70
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
@@ -70,7 +72,8 @@ var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
70
72
|
}), /*#__PURE__*/React.createElement("div", {
|
|
71
73
|
className: "sdoc-editor-content"
|
|
72
74
|
}, /*#__PURE__*/React.createElement(SDocOutline, {
|
|
73
|
-
doc: slateValue
|
|
75
|
+
doc: slateValue,
|
|
76
|
+
docUuid: docUuid
|
|
74
77
|
}), /*#__PURE__*/React.createElement("div", {
|
|
75
78
|
className: "flex-fill o-auto"
|
|
76
79
|
}, /*#__PURE__*/React.createElement(Slate, {
|
|
@@ -31,6 +31,10 @@ export var COLUMN = 'column';
|
|
|
31
31
|
export var TEXTSTYLE = 'text-style';
|
|
32
32
|
export var BOLD_ITALIC = 'bold-italic';
|
|
33
33
|
|
|
34
|
+
// history
|
|
35
|
+
export var UNDO = 'undo';
|
|
36
|
+
export var REDO = 'redo';
|
|
37
|
+
|
|
34
38
|
// menus config
|
|
35
39
|
export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CONFIG_MAP, BLOCKQUOTE, {
|
|
36
40
|
id: "sdoc_".concat(BLOCKQUOTE),
|
|
@@ -66,5 +70,15 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
66
70
|
iconClass: 'iconfont icon-bold',
|
|
67
71
|
text: 'bold',
|
|
68
72
|
type: 'BOLD'
|
|
69
|
-
}]), _MENUS_CONFIG_MAP
|
|
73
|
+
}]), _defineProperty(_MENUS_CONFIG_MAP, UNDO, {
|
|
74
|
+
id: UNDO,
|
|
75
|
+
iconClass: 'iconfont icon-revoke',
|
|
76
|
+
text: 'undo',
|
|
77
|
+
type: 'undo'
|
|
78
|
+
}), _defineProperty(_MENUS_CONFIG_MAP, REDO, {
|
|
79
|
+
id: REDO,
|
|
80
|
+
iconClass: 'iconfont icon-redo',
|
|
81
|
+
text: 'redo',
|
|
82
|
+
type: 'redo'
|
|
83
|
+
}), _MENUS_CONFIG_MAP);
|
|
70
84
|
export var HEADER_TITLE_MAP = (_HEADER_TITLE_MAP = {}, _defineProperty(_HEADER_TITLE_MAP, HEADER1, 'header_one'), _defineProperty(_HEADER_TITLE_MAP, HEADER2, 'header_two'), _defineProperty(_HEADER_TITLE_MAP, HEADER3, 'header_three'), _defineProperty(_HEADER_TITLE_MAP, HEADER4, 'header_four'), _defineProperty(_HEADER_TITLE_MAP, HEADER5, 'header_five'), _defineProperty(_HEADER_TITLE_MAP, HEADER6, 'header_six'), _defineProperty(_HEADER_TITLE_MAP, PARAGRAPH, 'paragraph'), _HEADER_TITLE_MAP);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { createEditor } from '@seafile/slate';
|
|
2
2
|
import { withReact } from '@seafile/slate-react';
|
|
3
|
+
import { withHistory } from '@seafile/slate-history';
|
|
3
4
|
import Plugins from './plugins';
|
|
4
5
|
import renderElement from './render/render-element';
|
|
5
6
|
import renderLeaf from './render/render-leaf';
|
|
6
7
|
import Toolbar from './toolbar';
|
|
8
|
+
var baseEditor = withHistory(withReact(createEditor()));
|
|
7
9
|
var editor = Plugins.reduce(function (editor, pluginItem) {
|
|
8
10
|
var withPlugin = pluginItem.editorPlugin;
|
|
9
11
|
if (withPlugin) {
|
|
10
12
|
return withPlugin(editor);
|
|
11
13
|
}
|
|
12
14
|
return editor;
|
|
13
|
-
},
|
|
15
|
+
}, baseEditor);
|
|
14
16
|
export default editor;
|
|
15
17
|
export { renderLeaf, renderElement, Toolbar };
|
|
@@ -12,6 +12,7 @@ import CheckListMenu from '../plugins/check-list/menu';
|
|
|
12
12
|
import { MenuGroup } from '../menu';
|
|
13
13
|
import TextStyleMenuList from '../plugins/text-style/menu';
|
|
14
14
|
import CodeBlockMenu from '../plugins/code-block/menu';
|
|
15
|
+
import HistoryMenu from './redo-undo';
|
|
15
16
|
import '../../assets/css/sdoc-editor-toolbar.css';
|
|
16
17
|
var Toolbar = /*#__PURE__*/function (_React$Component) {
|
|
17
18
|
_inherits(Toolbar, _React$Component);
|
|
@@ -25,7 +26,9 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
25
26
|
value: function render() {
|
|
26
27
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
28
|
className: "sdoc-editor-toolbar"
|
|
28
|
-
}, /*#__PURE__*/React.createElement(
|
|
29
|
+
}, /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(HistoryMenu, {
|
|
30
|
+
editor: this.props.editor
|
|
31
|
+
})), /*#__PURE__*/React.createElement(HeaderMenu, {
|
|
29
32
|
editor: this.props.editor
|
|
30
33
|
}), /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(TextStyleMenuList, {
|
|
31
34
|
editor: this.props.editor
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { MenuItem } from '../menu';
|
|
8
|
+
import { MENUS_CONFIG_MAP, REDO, UNDO } from '../constants';
|
|
9
|
+
var HistoryMenu = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(HistoryMenu, _React$Component);
|
|
11
|
+
var _super = _createSuper(HistoryMenu);
|
|
12
|
+
function HistoryMenu() {
|
|
13
|
+
var _this;
|
|
14
|
+
_classCallCheck(this, HistoryMenu);
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
args[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
19
|
+
_this.isDisabled = function (type) {
|
|
20
|
+
var editor = _this.props.editor;
|
|
21
|
+
var history = editor.history;
|
|
22
|
+
if (type === UNDO) {
|
|
23
|
+
return history.undos.length === 0;
|
|
24
|
+
}
|
|
25
|
+
return history.redos.length === 0;
|
|
26
|
+
};
|
|
27
|
+
_this.onUndoMouseDown = function () {
|
|
28
|
+
var editor = _this.props.editor;
|
|
29
|
+
editor.undo();
|
|
30
|
+
};
|
|
31
|
+
_this.onRedoMouseDown = function () {
|
|
32
|
+
var editor = _this.props.editor;
|
|
33
|
+
editor.redo();
|
|
34
|
+
};
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
_createClass(HistoryMenu, [{
|
|
38
|
+
key: "render",
|
|
39
|
+
value: function render() {
|
|
40
|
+
var _this$props = this.props,
|
|
41
|
+
isRichEditor = _this$props.isRichEditor,
|
|
42
|
+
className = _this$props.className;
|
|
43
|
+
var undoConfig = MENUS_CONFIG_MAP[UNDO];
|
|
44
|
+
var redoConfig = MENUS_CONFIG_MAP[REDO];
|
|
45
|
+
var undoProps = _objectSpread(_objectSpread({
|
|
46
|
+
isRichEditor: isRichEditor,
|
|
47
|
+
className: className
|
|
48
|
+
}, undoConfig), {}, {
|
|
49
|
+
disabled: this.isDisabled(UNDO),
|
|
50
|
+
isActive: false,
|
|
51
|
+
onMouseDown: this.onUndoMouseDown
|
|
52
|
+
});
|
|
53
|
+
var redoProps = _objectSpread(_objectSpread({
|
|
54
|
+
isRichEditor: isRichEditor,
|
|
55
|
+
className: className
|
|
56
|
+
}, redoConfig), {}, {
|
|
57
|
+
disabled: this.isDisabled(REDO),
|
|
58
|
+
isActive: false,
|
|
59
|
+
onMouseDown: this.onRedoMouseDown
|
|
60
|
+
});
|
|
61
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MenuItem, undoProps), /*#__PURE__*/React.createElement(MenuItem, redoProps));
|
|
62
|
+
}
|
|
63
|
+
}]);
|
|
64
|
+
return HistoryMenu;
|
|
65
|
+
}(React.Component);
|
|
66
|
+
export default HistoryMenu;
|
|
@@ -14,12 +14,22 @@ var SDocOutline = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
14
14
|
_classCallCheck(this, SDocOutline);
|
|
15
15
|
_this = _super.call(this, props);
|
|
16
16
|
_this.toggleShow = function () {
|
|
17
|
+
var docUuid = _this.props.docUuid;
|
|
17
18
|
_this.setState({
|
|
18
19
|
isShown: !_this.state.isShown
|
|
20
|
+
}, function () {
|
|
21
|
+
var currentValue = localStorage.getItem(docUuid);
|
|
22
|
+
var options = currentValue ? JSON.parse(currentValue) : {};
|
|
23
|
+
options['outlineOpen'] = _this.state.isShown;
|
|
24
|
+
localStorage.setItem(docUuid, JSON.stringify(options));
|
|
19
25
|
});
|
|
20
26
|
};
|
|
27
|
+
var _currentValue = localStorage.getItem(props.docUuid);
|
|
28
|
+
var _options = _currentValue ? JSON.parse(_currentValue) : {};
|
|
29
|
+
var _options$outlineOpen = _options.outlineOpen,
|
|
30
|
+
outlineOpen = _options$outlineOpen === void 0 ? false : _options$outlineOpen;
|
|
21
31
|
_this.state = {
|
|
22
|
-
isShown:
|
|
32
|
+
isShown: outlineOpen
|
|
23
33
|
};
|
|
24
34
|
return _this;
|
|
25
35
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a sdoc editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@seafile/react-image-lightbox": "2.0.2",
|
|
9
9
|
"@seafile/slate": "0.91.8",
|
|
10
|
+
"@seafile/slate-history": "0.86.2",
|
|
10
11
|
"@seafile/slate-hyperscript": "0.81.7",
|
|
11
12
|
"@seafile/slate-react": "0.92.2",
|
|
12
13
|
"classnames": "2.3.2",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"@typescript-eslint/eslint-plugin": "^2.2.0",
|
|
47
48
|
"@typescript-eslint/parser": "^2.2.0",
|
|
48
49
|
"autoprefixer": "7.1.6",
|
|
50
|
+
"axios": "1.4.0",
|
|
49
51
|
"babel-eslint": "10.0.3",
|
|
50
52
|
"babel-jest": "^24.9.0",
|
|
51
53
|
"babel-loader": "8.0.6",
|
|
Binary file
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="revoke" unicode="" d="M380.8 438.4c0-41.6-51.2-67.2-86.4-41.6L57.6 550.4c-32 19.2-32 64 0 83.2l236.8 153.6c35.2 25.6 86.4 0 86.4-41.6v-92.8H672c41.6 0 83.2-9.6 121.6-25.6 38.4-16 70.4-38.4 99.2-70.4 28.8-28.8 51.2-64 67.2-102.4 16-38.4 25.6-83.2 25.6-124.8s-6.4-96-22.4-134.4c-16-38.4-38.4-73.6-67.2-102.4-32-28.8-64-51.2-102.4-67.2-38.4-16-80-25.6-121.6-25.6H243.2c-32 0-60.8 28.8-60.8 64s25.6 64 60.8 64H672c105.6 0 188.8 96 188.8 204.8S777.6 528 672 528H380.8v-89.6z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
19
|
+
<glyph glyph-name="redo" unicode="" d="M643.2 438.4c0-41.6 51.2-67.2 86.4-41.6l236.8 153.6c32 19.2 32 64 0 83.2L729.6 787.2c-35.2 25.6-86.4 0-86.4-41.6v-92.8H352c-41.6 0-83.2-9.6-121.6-25.6-38.4-16-70.4-38.4-99.2-70.4C102.4 528 80 492.8 64 454.4 48 416 38.4 371.2 38.4 329.6s6.4-96 22.4-134.4c16-38.4 38.4-73.6 67.2-102.4 32-28.8 64-51.2 102.4-67.2 38.4-16 80-25.6 121.6-25.6h428.8c32 0 60.8 28.8 60.8 64s-25.6 64-60.8 64H352c-105.6 0-188.8 96-188.8 204.8S246.4 528 352 528h291.2v-89.6z" horiz-adv-x="1024" />
|
|
20
|
+
|
|
17
21
|
<glyph glyph-name="cancel" unicode="" d="M512 441.6L214.4 742.4 185.6 768 128 710.4l25.6-28.8 300.8-297.6-300.8-297.6-25.6-28.8L185.6 0l28.8 25.6 297.6 300.8 297.6-300.8 28.8-25.6 57.6 57.6-25.6 28.8-300.8 297.6 300.8 297.6 25.6 28.8L838.4 768l-28.8-25.6-297.6-300.8z" horiz-adv-x="1024" />
|
|
18
22
|
|
|
19
23
|
<glyph glyph-name="table-of-content" unicode="" d="M64 800h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64C28.8 672 0 700.8 0 736s28.8 64 64 64zM998.4 355.2l-12.8-12.8-172.8-172.8c-25.6-25.6-64-25.6-89.6 0s-25.6 64 0 89.6l134.4 134.4-134.4 134.4c-25.6 25.6-25.6 64 0 89.6s64 25.6 89.6 0l172.8-172.8 9.6-9.6c12.8-12.8 19.2-25.6 19.2-41.6v-3.2c0-12.8-9.6-28.8-16-35.2zM64 448h800c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64zM64 96h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|