@seafile/sdoc-editor 0.1.125-beta → 0.1.126
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/constants/index.js +2 -1
- package/dist/basic-sdk/editor.js +173 -25
- package/dist/basic-sdk/extension/constants/index.js +71 -0
- package/dist/basic-sdk/extension/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +5 -7
- package/dist/basic-sdk/extension/plugins/blockquote/render-elem.js +2 -1
- package/dist/basic-sdk/extension/plugins/check-list/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +5 -7
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +2 -1
- package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +0 -2
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +2 -3
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +4 -7
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +1 -0
- package/dist/basic-sdk/extension/plugins/font/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +2 -3
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +2 -3
- package/dist/basic-sdk/extension/plugins/font/menu/index.js +3 -6
- package/dist/basic-sdk/extension/plugins/header/helpers.js +0 -2
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +2 -4
- package/dist/basic-sdk/extension/plugins/header/render-elem.js +2 -2
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/image/menu/index.js +6 -8
- package/dist/basic-sdk/extension/plugins/link/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/link/menu/add-link-dialog.js +7 -2
- package/dist/basic-sdk/extension/plugins/link/menu/index.js +6 -8
- package/dist/basic-sdk/extension/plugins/list/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/list/menu/index.js +9 -11
- package/dist/basic-sdk/extension/plugins/list/render-elem.js +3 -1
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +2 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +3 -4
- package/dist/basic-sdk/extension/plugins/sdoc-link/render-elem.js +0 -1
- package/dist/basic-sdk/extension/plugins/table/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +3 -6
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +2 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +6 -12
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/remove-table-menu.js +3 -5
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-column-menu.js +4 -8
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-row-menu.js +4 -8
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +5 -7
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +11 -4
- package/dist/basic-sdk/extension/plugins/table/render/table-root.js +1 -0
- package/dist/basic-sdk/extension/plugins/text-align/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +2 -3
- package/dist/basic-sdk/extension/plugins/text-style/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +4 -5
- package/dist/basic-sdk/extension/render/render-element.js +17 -2
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +17 -37
- package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +4 -7
- package/dist/basic-sdk/extension/toolbar/index.js +2 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +121 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.css +24 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +123 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-below-menu.js +23 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +95 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu-item.js +35 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.css +64 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +76 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/transform-menus.js +41 -0
- package/dist/basic-sdk/layout/article-container.js +3 -2
- package/dist/basic-sdk/outline/index.js +1 -0
- package/dist/basic-sdk/outline/style.css +1 -5
- package/dist/basic-sdk/socket/socket-client.js +1 -1
- package/dist/basic-sdk/socket/socket-manager.js +0 -4
- package/dist/basic-sdk/socket/with-socket-io.js +0 -1
- package/dist/basic-sdk/utils/diff.js +0 -12
- package/dist/basic-sdk/views/diff-viewer.js +5 -10
- package/dist/basic-sdk/views/viewer.js +20 -20
- package/dist/components/doc-operations/index.js +0 -2
- package/dist/components/doc-operations/revision-operations/index.js +1 -5
- package/dist/pages/diff-viewer/history-version-viewer.js +15 -0
- package/dist/pages/diff-viewer/index.js +35 -0
- package/dist/pages/simple-editor.js +3 -16
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +7 -1
- package/public/locales/zh-CN/sdoc-editor.json +8 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +0 -4
- 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 +6 -14
- package/dist/basic-sdk/layout/editor-container.js +0 -26
- package/dist/basic-sdk/layout/editor-content.js +0 -56
- package/dist/basic-sdk/layout/index.js +0 -4
- package/dist/basic-sdk/slate-editor.js +0 -149
- package/dist/components/doc-operations/revision-operations/changes-count/index.css +0 -34
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +0 -85
- package/dist/pages/diff-viewer.js +0 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
5
|
+
import { onSetNodeType } from './helpers';
|
|
6
|
+
import { SIDE_MENUS_CONFIG } from '../../constants';
|
|
7
|
+
var TransformMenus = function TransformMenus(_ref) {
|
|
8
|
+
var target = _ref.target,
|
|
9
|
+
slateNode = _ref.slateNode,
|
|
10
|
+
onReset = _ref.onReset,
|
|
11
|
+
t = _ref.t;
|
|
12
|
+
var editor = useSlateStatic();
|
|
13
|
+
var onSetType = useCallback(function (newType) {
|
|
14
|
+
onSetNodeType(editor, slateNode, newType);
|
|
15
|
+
onReset();
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
}, []);
|
|
18
|
+
return /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
19
|
+
target: target,
|
|
20
|
+
className: "sdoc-side-operation-translate-popover",
|
|
21
|
+
trigger: "hover",
|
|
22
|
+
placement: "right-start",
|
|
23
|
+
hideArrow: true,
|
|
24
|
+
fade: false
|
|
25
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "sdoc-side-inner-menu"
|
|
27
|
+
}, SIDE_MENUS_CONFIG.map(function (item) {
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
key: item.id,
|
|
30
|
+
className: "sdoc-side-menu-item",
|
|
31
|
+
onClick: function onClick() {
|
|
32
|
+
onSetType(item.type);
|
|
33
|
+
}
|
|
34
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
35
|
+
className: "sdoc-side-menu-item__left"
|
|
36
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
37
|
+
className: item.iconClass
|
|
38
|
+
}), /*#__PURE__*/React.createElement("span", null, t(item.title))));
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
export default withTranslation('sdoc-editor')(TransformMenus);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { useScrollContext } from '../hooks/use-scroll-context';
|
|
@@ -39,10 +40,10 @@ export default function ArticleContainer(_ref) {
|
|
|
39
40
|
}, React.Children.count(children) === 1 && /*#__PURE__*/React.createElement("div", {
|
|
40
41
|
className: "article",
|
|
41
42
|
ref: articleRef
|
|
42
|
-
}, children), React.Children.count(children)
|
|
43
|
+
}, children), React.Children.count(children) > 1 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
43
44
|
className: "article",
|
|
44
45
|
ref: articleRef
|
|
45
|
-
}, children[0]), children
|
|
46
|
+
}, children[0]), _toConsumableArray(children.slice(1))));
|
|
46
47
|
}
|
|
47
48
|
ArticleContainer.defaultProps = {
|
|
48
49
|
readOnly: false
|
|
@@ -49,7 +49,7 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
|
|
|
49
49
|
socketManager.dispatchConnectState('reconnect_attempt', attemptNumber);
|
|
50
50
|
};
|
|
51
51
|
this.onReconnectError = function () {
|
|
52
|
-
debug('reconnect_error.
|
|
52
|
+
debug('reconnect_error.');
|
|
53
53
|
var socketManager = SocketManager.getInstance();
|
|
54
54
|
socketManager.dispatchConnectState('reconnect_error');
|
|
55
55
|
};
|
|
@@ -262,10 +262,6 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
262
262
|
_this._sendingOperations = null;
|
|
263
263
|
}
|
|
264
264
|
_this.state = STATE.DISCONNECT;
|
|
265
|
-
|
|
266
|
-
// Update saved state
|
|
267
|
-
var lastSavedAt = new Date().getTime();
|
|
268
|
-
_this.dispatchConnectState('saved', lastSavedAt);
|
|
269
265
|
}
|
|
270
266
|
_this.eventBus.dispatch(type, message);
|
|
271
267
|
};
|
|
@@ -19,7 +19,6 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
19
19
|
SocketManager.destroy();
|
|
20
20
|
};
|
|
21
21
|
newEditor.onChange = function () {
|
|
22
|
-
if (newEditor.readonly) return;
|
|
23
22
|
var operations = newEditor.operations;
|
|
24
23
|
if (!newEditor.isRemote && operations.length > 0) {
|
|
25
24
|
var isAllSetSelection = operations.every(function (operation) {
|
|
@@ -261,18 +261,6 @@ export var getDiff = function getDiff() {
|
|
|
261
261
|
var oldValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
262
262
|
children: []
|
|
263
263
|
};
|
|
264
|
-
if (!currentValue && !oldValue) return {
|
|
265
|
-
value: [],
|
|
266
|
-
changes: []
|
|
267
|
-
};
|
|
268
|
-
if (!currentValue && oldValue) return {
|
|
269
|
-
value: normalizeChildren(oldValue.children),
|
|
270
|
-
changes: []
|
|
271
|
-
};
|
|
272
|
-
if (currentValue && !oldValue) return {
|
|
273
|
-
value: normalizeChildren(currentValue.children),
|
|
274
|
-
changes: []
|
|
275
|
-
};
|
|
276
264
|
var _currentValue$childre = _objectSpread(_objectSpread({}, currentValue), {}, {
|
|
277
265
|
children: normalizeChildren(currentValue.children)
|
|
278
266
|
}),
|
|
@@ -8,10 +8,11 @@ import '../../assets/css/diff-viewer.css';
|
|
|
8
8
|
var DiffViewer = function DiffViewer(_ref) {
|
|
9
9
|
var currentContent = _ref.currentContent,
|
|
10
10
|
lastContent = _ref.lastContent,
|
|
11
|
-
didMountCallback = _ref.didMountCallback
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
didMountCallback = _ref.didMountCallback;
|
|
12
|
+
var diff = currentContent ? getDiff(currentContent, lastContent) : {
|
|
13
|
+
value: [],
|
|
14
|
+
changes: []
|
|
15
|
+
};
|
|
15
16
|
context.initSettings();
|
|
16
17
|
useEffect(function () {
|
|
17
18
|
didMountCallback && didMountCallback(diff);
|
|
@@ -38,8 +39,6 @@ var DiffViewer = function DiffViewer(_ref) {
|
|
|
38
39
|
return renderElement(props, editor);
|
|
39
40
|
}, []);
|
|
40
41
|
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
41
|
-
showToolbar: showToolbar,
|
|
42
|
-
showOutline: showOutline,
|
|
43
42
|
document: {
|
|
44
43
|
children: diff.value
|
|
45
44
|
},
|
|
@@ -47,8 +46,4 @@ var DiffViewer = function DiffViewer(_ref) {
|
|
|
47
46
|
renderElement: customRenderElement
|
|
48
47
|
});
|
|
49
48
|
};
|
|
50
|
-
DiffViewer.defaultProps = {
|
|
51
|
-
showToolbar: false,
|
|
52
|
-
showOutline: false
|
|
53
|
-
};
|
|
54
49
|
export default DiffViewer;
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
import React, { Fragment, useRef } from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
2
|
import { Editable, Slate } from '@seafile/slate-react';
|
|
4
3
|
import defaultEditor, { renderLeaf as _renderLeaf, renderElement as _renderElement } from '../extension';
|
|
5
4
|
import withNodeId from '../node-id';
|
|
6
|
-
import {
|
|
5
|
+
import { ScrollContext } from '../hooks/use-scroll-context';
|
|
6
|
+
import { generateDefaultDocContent, isMobile } from '../../utils';
|
|
7
7
|
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
8
8
|
import { usePipDecorate } from '../decorates';
|
|
9
|
-
import
|
|
9
|
+
import ArticleContainer from '../layout/article-container';
|
|
10
|
+
import '../assets/css/layout.css';
|
|
11
|
+
import '../assets/css/sdoc-editor-plugins.css';
|
|
12
|
+
import '../assets/css/dropdown-menu.css';
|
|
10
13
|
import '../assets/css/simple-viewer.css';
|
|
11
14
|
var SDocViewer = function SDocViewer(_ref) {
|
|
12
15
|
var document = _ref.document,
|
|
13
16
|
customRenderLeaf = _ref.renderLeaf,
|
|
14
|
-
customRenderElement = _ref.renderElement
|
|
15
|
-
showToolbar = _ref.showToolbar,
|
|
16
|
-
showOutline = _ref.showOutline;
|
|
17
|
+
customRenderElement = _ref.renderElement;
|
|
17
18
|
var editor = withNodeId(defaultEditor);
|
|
18
|
-
editor.readonly = true;
|
|
19
19
|
var slateValue = (document || generateDefaultDocContent()).children;
|
|
20
|
+
var scrollRef = useRef(null);
|
|
20
21
|
var decorate = usePipDecorate(editor);
|
|
21
|
-
return /*#__PURE__*/React.createElement(
|
|
22
|
-
editor:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, /*#__PURE__*/React.createElement(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: "sdoc-editor-container ".concat(isMobile ? 'mobile' : '')
|
|
24
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "sdoc-editor-content readonly"
|
|
26
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
ref: scrollRef,
|
|
28
|
+
className: "sdoc-scroll-container"
|
|
29
|
+
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
30
|
+
value: {
|
|
31
|
+
scrollRef: scrollRef
|
|
32
|
+
}
|
|
29
33
|
}, /*#__PURE__*/React.createElement(Slate, {
|
|
30
34
|
editor: editor,
|
|
31
35
|
value: slateValue
|
|
@@ -43,10 +47,6 @@ var SDocViewer = function SDocViewer(_ref) {
|
|
|
43
47
|
},
|
|
44
48
|
onDOMBeforeInput: function onDOMBeforeInput(event) {},
|
|
45
49
|
decorate: decorate
|
|
46
|
-
}))))));
|
|
47
|
-
};
|
|
48
|
-
SDocViewer.defaultProps = {
|
|
49
|
-
showToolbar: false,
|
|
50
|
-
showOutline: false
|
|
50
|
+
}))))))));
|
|
51
51
|
};
|
|
52
52
|
export default SDocViewer;
|
|
@@ -10,14 +10,12 @@ import ShareOperation from './share-operation';
|
|
|
10
10
|
import './style.css';
|
|
11
11
|
var DocOperations = function DocOperations(_ref) {
|
|
12
12
|
var isShowChanges = _ref.isShowChanges,
|
|
13
|
-
changes = _ref.changes,
|
|
14
13
|
toggleViewChanges = _ref.toggleViewChanges;
|
|
15
14
|
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
16
15
|
return /*#__PURE__*/React.createElement("div", {
|
|
17
16
|
className: "doc-ops"
|
|
18
17
|
}, /*#__PURE__*/React.createElement(RevisionOperations, {
|
|
19
18
|
isShowChanges: isShowChanges,
|
|
20
|
-
changes: changes,
|
|
21
19
|
toggleViewChanges: toggleViewChanges
|
|
22
20
|
}), /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
|
|
23
21
|
};
|
|
@@ -4,16 +4,12 @@ import PublishRevision from './publish-button';
|
|
|
4
4
|
import ViewChanges from './view-changes';
|
|
5
5
|
import MoreRevisionOperations from './more-revision-operations';
|
|
6
6
|
import Revisions from './revisions';
|
|
7
|
-
import ChangesCount from './changes-count';
|
|
8
7
|
var RevisionOperations = function RevisionOperations(_ref) {
|
|
9
8
|
var isShowChanges = _ref.isShowChanges,
|
|
10
|
-
changes = _ref.changes,
|
|
11
9
|
toggleViewChanges = _ref.toggleViewChanges;
|
|
12
10
|
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
13
11
|
var isPublished = context.getSetting('isPublished');
|
|
14
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, !isSdocRevision && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MoreRevisionOperations, null), /*#__PURE__*/React.createElement(Revisions, null)), isSdocRevision &&
|
|
15
|
-
changes: changes
|
|
16
|
-
}), isSdocRevision && /*#__PURE__*/React.createElement(ViewChanges, {
|
|
12
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !isSdocRevision && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MoreRevisionOperations, null), /*#__PURE__*/React.createElement(Revisions, null)), isSdocRevision && /*#__PURE__*/React.createElement(ViewChanges, {
|
|
17
13
|
isShowChanges: isShowChanges,
|
|
18
14
|
toggleViewChanges: toggleViewChanges
|
|
19
15
|
}), isSdocRevision && !isPublished && /*#__PURE__*/React.createElement(PublishRevision, null));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { SDocViewer } from '../../basic-sdk';
|
|
4
|
+
import { generateDefaultDocContent } from '../../utils';
|
|
5
|
+
import { normalizeChildren } from '../../basic-sdk/utils/document-utils';
|
|
6
|
+
function HistoryVersionViewer(props) {
|
|
7
|
+
var document = props.document;
|
|
8
|
+
var validDocument = document || generateDefaultDocContent();
|
|
9
|
+
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
10
|
+
document: _objectSpread(_objectSpread({}, validDocument), {}, {
|
|
11
|
+
children: normalizeChildren(validDocument.children)
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export default HistoryVersionViewer;
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import React, { Component } from 'react';
|
|
6
|
+
import HistoryVersionViewer from './history-version-viewer';
|
|
7
|
+
import { DiffViewer } from '../../basic-sdk';
|
|
8
|
+
import context from '../../context';
|
|
9
|
+
var Index = /*#__PURE__*/function (_Component) {
|
|
10
|
+
_inherits(Index, _Component);
|
|
11
|
+
var _super = _createSuper(Index);
|
|
12
|
+
function Index(props) {
|
|
13
|
+
var _this;
|
|
14
|
+
_classCallCheck(this, Index);
|
|
15
|
+
_this = _super.call(this, props);
|
|
16
|
+
context.initSettings();
|
|
17
|
+
return _this;
|
|
18
|
+
}
|
|
19
|
+
_createClass(Index, [{
|
|
20
|
+
key: "render",
|
|
21
|
+
value: function render() {
|
|
22
|
+
var _this$props = this.props,
|
|
23
|
+
currentContent = _this$props.currentContent,
|
|
24
|
+
lastContent = _this$props.lastContent;
|
|
25
|
+
if (!lastContent) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(HistoryVersionViewer, {
|
|
27
|
+
document: currentContent
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/React.createElement(DiffViewer, this.props);
|
|
31
|
+
}
|
|
32
|
+
}]);
|
|
33
|
+
return Index;
|
|
34
|
+
}(Component);
|
|
35
|
+
export default Index;
|
|
@@ -3,13 +3,14 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
3
3
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { withTranslation } from 'react-i18next';
|
|
5
5
|
import deepCopy from 'deep-copy';
|
|
6
|
-
import { SDocEditor
|
|
6
|
+
import { SDocEditor } from '../basic-sdk';
|
|
7
7
|
import Loading from '../components/loading';
|
|
8
8
|
import DocInfo from '../components/doc-info';
|
|
9
9
|
import DocOperations from '../components/doc-operations';
|
|
10
10
|
import Layout, { Header, Content } from '../layout';
|
|
11
11
|
import { generateDefaultDocContent } from '../utils';
|
|
12
12
|
import context from '../context';
|
|
13
|
+
import DiffViewer from './diff-viewer';
|
|
13
14
|
import ErrorBoundary from './error-boundary';
|
|
14
15
|
import '../assets/css/simple-editor.css';
|
|
15
16
|
var SimpleEditor = function SimpleEditor(_ref) {
|
|
@@ -113,20 +114,10 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
113
114
|
initChangesData();
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
|
-
setChanges([]);
|
|
117
117
|
initDocumentData(false);
|
|
118
118
|
|
|
119
119
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
120
|
}, [document]);
|
|
121
|
-
var _useState15 = useState([]),
|
|
122
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
123
|
-
changes = _useState16[0],
|
|
124
|
-
setChanges = _useState16[1];
|
|
125
|
-
var setDiffChanges = useCallback(function (diff) {
|
|
126
|
-
setChanges(diff.changes);
|
|
127
|
-
|
|
128
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
}, [isShowChanges]);
|
|
130
121
|
if (isFirstLoad && !errorMessage) {
|
|
131
122
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
132
123
|
}
|
|
@@ -143,7 +134,6 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
143
134
|
isEditMode: !isShowChanges
|
|
144
135
|
}), /*#__PURE__*/React.createElement(DocOperations, {
|
|
145
136
|
isShowChanges: isShowChanges,
|
|
146
|
-
changes: changes,
|
|
147
137
|
toggleViewChanges: toggleViewChanges
|
|
148
138
|
})), /*#__PURE__*/React.createElement(Content, null, isLoadingSdoc && /*#__PURE__*/React.createElement("div", {
|
|
149
139
|
className: "w-100 h-100 d-flex align-items-center justify-content-center"
|
|
@@ -152,11 +142,8 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
152
142
|
}, /*#__PURE__*/React.createElement("div", {
|
|
153
143
|
className: "error-tip"
|
|
154
144
|
}, t(errorMessage))), !isLoadingSdoc && !errorMessage && /*#__PURE__*/React.createElement(React.Fragment, null, isShowChanges ? /*#__PURE__*/React.createElement(DiffViewer, {
|
|
155
|
-
showToolbar: true,
|
|
156
|
-
showOutline: true,
|
|
157
145
|
currentContent: currentContent,
|
|
158
|
-
lastContent: lastContent
|
|
159
|
-
didMountCallback: setDiffChanges
|
|
146
|
+
lastContent: lastContent
|
|
160
147
|
}) : /*#__PURE__*/React.createElement(SDocEditor, {
|
|
161
148
|
config: context.getEditorConfig(),
|
|
162
149
|
document: document,
|
package/package.json
CHANGED
|
@@ -350,5 +350,11 @@
|
|
|
350
350
|
"Select_sdoc_document": "Select sdoc document",
|
|
351
351
|
"Local_file": "Local file",
|
|
352
352
|
"Internal_server_exec_operations_error": "An exception occurred on the server, please refresh the page and try again",
|
|
353
|
-
"Failed_to_sync_with_server_operations": "Synchronization with the server failed, please refresh the page"
|
|
353
|
+
"Failed_to_sync_with_server_operations": "Synchronization with the server failed, please refresh the page",
|
|
354
|
+
"Style": "Style",
|
|
355
|
+
"Insert": "Insert",
|
|
356
|
+
"Image": "Image",
|
|
357
|
+
"Table": "Table",
|
|
358
|
+
"Link": "Link",
|
|
359
|
+
"Transform_to": "Transform to"
|
|
354
360
|
}
|
|
@@ -352,5 +352,12 @@
|
|
|
352
352
|
"Select_sdoc_document": "选择sdoc文档",
|
|
353
353
|
"Local_file": "本地文件",
|
|
354
354
|
"Internal_server_exec_operations_error": "在服务器执行操作异常,请刷新页面后重试",
|
|
355
|
-
"Failed_to_sync_with_server_operations": "与服务器同步操作失败,请刷新页面"
|
|
355
|
+
"Failed_to_sync_with_server_operations": "与服务器同步操作失败,请刷新页面",
|
|
356
|
+
"Operations_save_error_tip": "操作执行失败,服务器内部错误,请刷新页面",
|
|
357
|
+
"Style": "样式",
|
|
358
|
+
"Insert": "插入",
|
|
359
|
+
"Image": "图片",
|
|
360
|
+
"Table": "表格",
|
|
361
|
+
"Link": "链接",
|
|
362
|
+
"Transform_to": "转化为"
|
|
356
363
|
}
|
|
Binary file
|
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
-
<glyph glyph-name="sdoc-next-page" unicode="" d="M342.4 768c12.8 0 28.8-6.4 38.4-16l329.6-329.6c22.4-22.4 22.4-57.6 0-76.8L380.8 16c-22.4-22.4-57.6-22.4-76.8 0-22.4 22.4-22.4 57.6 0 76.8L595.2 384 304 675.2c-22.4 22.4-22.4 57.6 0 76.8 9.6 9.6 25.6 16 38.4 16z" horiz-adv-x="1024" />
|
|
18
|
-
|
|
19
|
-
<glyph glyph-name="sdoc-previous-page" unicode="" d="M672 768c-12.8 0-28.8-6.4-38.4-16L304 422.4c-22.4-22.4-22.4-57.6 0-76.8L633.6 16c22.4-22.4 57.6-22.4 76.8 0 22.4 22.4 22.4 57.6 0 76.8L419.2 384l291.2 291.2c22.4 22.4 22.4 57.6 0 76.8-9.6 9.6-25.6 16-38.4 16z" horiz-adv-x="1024" />
|
|
20
|
-
|
|
21
17
|
<glyph glyph-name="sdoc-save-tip" unicode="" d="M528 800c153.6 0 272-112 284.8-252.8 121.6-9.6 208-137.6 208-291.2 0-160-86.4-284.8-201.6-288H208c-96 0-208 124.8-208 284.8s89.6 294.4 227.2 288c9.6 0 16 0 22.4-3.2C291.2 694.4 374.4 800 528 800z m3.2-96c-99.2 0-179.2-73.6-208-256-48 3.2-76.8 3.2-96 0-73.6-9.6-131.2-86.4-131.2-185.6S166.4 64 227.2 64h582.4c54.4 0 118.4 96 118.4 198.4 0 89.6-35.2 166.4-99.2 185.6-28.8 9.6-67.2 12.8-92.8 6.4-6.4 169.6-99.2 249.6-204.8 249.6z m163.2-252.8l38.4-41.6c6.4-6.4 6.4-16 0-22.4l-256-249.6c-12.8-12.8-32-16-44.8-3.2l-147.2 140.8c-6.4 6.4-6.4 12.8-3.2 19.2l3.2 3.2 38.4 38.4c6.4 6.4 16 6.4 22.4 0l108.8-105.6L672 448c6.4 9.6 16 9.6 22.4 3.2z" horiz-adv-x="1024" />
|
|
22
18
|
|
|
23
19
|
<glyph glyph-name="sdoc-file" unicode="" d="M460.8 723.2H112c-16 0-35.2-12.8-35.2-35.2v-601.6c0-19.2 16-35.2 35.2-35.2h803.2c16 0 35.2 19.2 35.2 35.2V576c0 19.2-16 35.2-35.2 35.2H588.8c-12.8 0-16 6.4-22.4 12.8l-105.6 99.2z m137.6-38.4h313.6c57.6 0 112-48 112-115.2v-489.6c0-60.8-48-115.2-112-115.2h-800C51.2-32 0 16 0 83.2V684.8C0 745.6 48 800 112 800h361.6c12.8 0 16-6.4 22.4-12.8l102.4-102.4z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "sdocfont"; /* Project id 4097705 */
|
|
3
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1692612471690'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1692612471690#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1692612471690') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1692612471690') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1692612471690') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1692612471690#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,14 +16,6 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.sdoc-next-page:before {
|
|
20
|
-
content: "\e626";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.sdoc-previous-page:before {
|
|
24
|
-
content: "\e651";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
.sdoc-save-tip:before {
|
|
28
20
|
content: "\e650";
|
|
29
21
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,56 +0,0 @@
|
|
|
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;
|