@seafile/comment-editor 0.0.1-alpha.6 → 0.0.1-alpha.61
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/_i18n/index.js +37 -0
- package/dist/basic-sdk/context.js +8 -21
- package/dist/basic-sdk/editor/comment-editor.js +19 -64
- package/dist/basic-sdk/extension/commons/color-menu/color-item.js +4 -2
- package/dist/basic-sdk/extension/commons/color-menu/index.js +4 -2
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +54 -96
- package/dist/basic-sdk/extension/commons/select/field-setting.js +3 -2
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +5 -3
- package/dist/basic-sdk/extension/plugins/image/use-copy-image.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +1 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/color-item.js +4 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/comemnt-editor-menu.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/video/render-elem.js +1 -2
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +13 -9
- package/dist/basic-sdk/hooks/use-comment.js +22 -12
- package/dist/basic-sdk/model/index.js +1 -8
- package/dist/basic-sdk/socket/helpers.js +312 -0
- package/dist/components/error-boundary/error-page.js +4 -4
- package/dist/pages/seafile-comment-editor.js +35 -17
- package/package.json +6 -6
- package/dist/basic-sdk/layout/comment-layout/index.css +0 -15
- package/dist/basic-sdk/layout/comment-layout/index.js +0 -87
- package/dist/basic-sdk/layout/comment-layout/resize-width/index.css +0 -38
- package/dist/basic-sdk/layout/comment-layout/resize-width/index.js +0 -132
- package/dist/basic-sdk/layout/editor-container.js +0 -32
- package/dist/basic-sdk/layout/index.js +0 -13
- package/dist/basic-sdk/model/notification.js +0 -18
- package/dist/components/tip-message/index.js +0 -194
- package/dist/components/tip-message/style.css +0 -15
|
@@ -10,10 +10,12 @@ var _reactI18next = require("react-i18next");
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
const ColorItem = _ref => {
|
|
12
12
|
let {
|
|
13
|
-
t,
|
|
14
13
|
color,
|
|
15
14
|
lastUsedColor
|
|
16
15
|
} = _ref;
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
17
19
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
18
20
|
className: (0, _classnames.default)('sdoc-color-item', {
|
|
19
21
|
'selected': lastUsedColor === color.value
|
|
@@ -28,4 +30,4 @@ const ColorItem = _ref => {
|
|
|
28
30
|
}) : t(color.name)
|
|
29
31
|
});
|
|
30
32
|
};
|
|
31
|
-
var _default = exports.default =
|
|
33
|
+
var _default = exports.default = ColorItem;
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
11
10
|
var _constants = require("../../../../../constants");
|
|
12
11
|
var _eventBus = _interopRequireDefault(require("../../../../../utils/event-bus"));
|
|
13
12
|
var _KebabToCamel = _interopRequireDefault(require("../../../../../utils/Kebab-to-camel"));
|
|
@@ -22,6 +21,8 @@ var _horizontalAlignPopover = _interopRequireDefault(require("../horizontal-alig
|
|
|
22
21
|
var _verticalAlignPopover = _interopRequireDefault(require("../vertical-align-popover"));
|
|
23
22
|
var _insertTableElement = _interopRequireDefault(require("./insert-table-element"));
|
|
24
23
|
require("./index.css");
|
|
24
|
+
// import { withTranslation } from 'react-i18next';
|
|
25
|
+
|
|
25
26
|
class TableContextMenu extends _react.default.Component {
|
|
26
27
|
constructor(props) {
|
|
27
28
|
super(props);
|
|
@@ -229,4 +230,4 @@ class TableContextMenu extends _react.default.Component {
|
|
|
229
230
|
}, t('Fit_table_to_page_width'))));
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
|
-
var _default = exports.default =
|
|
233
|
+
var _default = exports.default = TableContextMenu;
|
package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js
CHANGED
|
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _reactI18next = require("react-i18next");
|
|
12
11
|
var _reactstrap = require("reactstrap");
|
|
13
12
|
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
14
13
|
var _constants = require("../../constants");
|
|
14
|
+
// import { withTranslation } from 'react-i18next';
|
|
15
|
+
|
|
15
16
|
class InsertTableElement extends _react.Component {
|
|
16
17
|
constructor(props) {
|
|
17
18
|
super(props);
|
|
@@ -94,4 +95,4 @@ class InsertTableElement extends _react.Component {
|
|
|
94
95
|
}), /*#__PURE__*/_react.default.createElement("span", null, type === _constants.TABLE_ELEMENT.ROW ? t('Row(s)') : t('Column(s)'))));
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
var _default = exports.default =
|
|
98
|
+
var _default = exports.default = InsertTableElement;
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
11
10
|
var _dropdownMenuItem = _interopRequireDefault(require("../../../../commons/dropdown-menu-item"));
|
|
12
11
|
var _constants = require("../../../../constants");
|
|
13
12
|
var _helpers = require("../../helpers");
|
|
@@ -38,4 +37,4 @@ const TableMenu = _ref => {
|
|
|
38
37
|
createTable: createTable
|
|
39
38
|
}));
|
|
40
39
|
};
|
|
41
|
-
var _default = exports.default =
|
|
40
|
+
var _default = exports.default = TableMenu;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactI18next = require("react-i18next");
|
|
10
9
|
var _commons = require("../../../commons");
|
|
11
10
|
var _constants = require("../../../constants");
|
|
12
11
|
var _menusConfig = require("../../../constants/menus-config");
|
|
@@ -69,4 +68,4 @@ const CommentEditorTextStyleMenuList = _ref => {
|
|
|
69
68
|
key: index
|
|
70
69
|
}, itemProps))));
|
|
71
70
|
};
|
|
72
|
-
var _default = exports.default =
|
|
71
|
+
var _default = exports.default = CommentEditorTextStyleMenuList;
|
|
@@ -25,12 +25,14 @@ var _helpers3 = require("../helpers");
|
|
|
25
25
|
const TextStyleMenuList = _ref => {
|
|
26
26
|
let {
|
|
27
27
|
editor,
|
|
28
|
-
t,
|
|
29
28
|
isRichEditor,
|
|
30
29
|
className,
|
|
31
30
|
idPrefix,
|
|
32
31
|
readonly
|
|
33
32
|
} = _ref;
|
|
33
|
+
const {
|
|
34
|
+
t
|
|
35
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
34
36
|
let selectedFontSize = (0, _helpers.getFontSize)(editor);
|
|
35
37
|
let selectedFontSizeValue = selectedFontSize;
|
|
36
38
|
const enableSeafileAI = _context.default.getSetting('enableSeafileAI');
|
|
@@ -159,4 +161,4 @@ const TextStyleMenuList = _ref => {
|
|
|
159
161
|
isRichEditor: isRichEditor
|
|
160
162
|
}));
|
|
161
163
|
};
|
|
162
|
-
var _default = exports.default =
|
|
164
|
+
var _default = exports.default = TextStyleMenuList;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.renderVideo = renderVideo;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactI18next = require("react-i18next");
|
|
10
9
|
var _slate = require("@seafile/slate");
|
|
11
10
|
var _slateReact = require("@seafile/slate-react");
|
|
12
11
|
var _helpers = require("./helpers");
|
|
@@ -128,7 +127,7 @@ const Video = _ref => {
|
|
|
128
127
|
}
|
|
129
128
|
}))));
|
|
130
129
|
};
|
|
131
|
-
const SdocVideo =
|
|
130
|
+
const SdocVideo = Video;
|
|
132
131
|
function renderVideo(props, editor) {
|
|
133
132
|
const {
|
|
134
133
|
element,
|
|
@@ -22,33 +22,37 @@ const CommentEditorToolbar = _ref => {
|
|
|
22
22
|
readonly = false,
|
|
23
23
|
onSubmit,
|
|
24
24
|
submitBtnText,
|
|
25
|
-
onCancel
|
|
25
|
+
onCancel,
|
|
26
|
+
toolMenus
|
|
26
27
|
} = _ref;
|
|
27
28
|
(0, _useSelectionUpdate.default)();
|
|
28
29
|
const eventBus = _eventBus.default.getInstance();
|
|
29
30
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
-
className: "comment-editor-toolbar"
|
|
31
|
-
|
|
31
|
+
className: "comment-editor-toolbar",
|
|
32
|
+
style: {
|
|
33
|
+
justifyContent: toolMenus.length === 0 ? 'end' : ''
|
|
34
|
+
}
|
|
35
|
+
}, toolMenus.length !== 0 && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, {
|
|
32
36
|
className: "menu-group comment-editor-menu-group"
|
|
33
|
-
}, /*#__PURE__*/_react.default.createElement(_comemntEditorMenu.default, {
|
|
37
|
+
}, toolMenus.includes('text_style') && /*#__PURE__*/_react.default.createElement(_comemntEditorMenu.default, {
|
|
34
38
|
editor: editor,
|
|
35
39
|
readonly: readonly
|
|
36
|
-
}), /*#__PURE__*/_react.default.createElement(_menu.default, {
|
|
40
|
+
}), toolMenus.includes(_constants.BLOCKQUOTE) && /*#__PURE__*/_react.default.createElement(_menu.default, {
|
|
37
41
|
editor: editor,
|
|
38
42
|
readonly: readonly
|
|
39
|
-
}), /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
43
|
+
}), toolMenus.includes(_constants.UNORDERED_LIST) && /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
40
44
|
editor: editor,
|
|
41
45
|
type: _constants.UNORDERED_LIST,
|
|
42
46
|
readonly: readonly
|
|
43
|
-
}), /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
47
|
+
}), toolMenus.includes(_constants.ORDERED_LIST) && /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
44
48
|
editor: editor,
|
|
45
49
|
type: _constants.ORDERED_LIST,
|
|
46
50
|
readonly: readonly
|
|
47
|
-
}), /*#__PURE__*/_react.default.createElement(_menu3.default, {
|
|
51
|
+
}), toolMenus.includes(_constants.LINK) && /*#__PURE__*/_react.default.createElement(_menu3.default, {
|
|
48
52
|
editor: editor,
|
|
49
53
|
readonly: readonly,
|
|
50
54
|
eventBus: eventBus
|
|
51
|
-
}), /*#__PURE__*/_react.default.createElement(_menu2.default, {
|
|
55
|
+
}), toolMenus.includes(_constants.IMAGE) && /*#__PURE__*/_react.default.createElement(_menu2.default, {
|
|
52
56
|
editor: editor,
|
|
53
57
|
readonly: readonly,
|
|
54
58
|
eventBus: eventBus
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.useComment = exports.CommentProvider = void 0;
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var
|
|
10
|
+
var _context = _interopRequireDefault(require("../context"));
|
|
11
|
+
var _model = require("../model");
|
|
10
12
|
require("../assets/css/layout.css");
|
|
11
13
|
require("../assets/css/default.css");
|
|
12
14
|
require("../assets/css/sdoc-editor-article.css");
|
|
@@ -18,27 +20,35 @@ const CommentProvider = _ref => {
|
|
|
18
20
|
let {
|
|
19
21
|
children,
|
|
20
22
|
type,
|
|
21
|
-
|
|
22
|
-
pluginName = '',
|
|
23
|
+
// comment or replay
|
|
23
24
|
className = '',
|
|
25
|
+
pluginName = '',
|
|
26
|
+
// sdoc or wiki or txt ...
|
|
24
27
|
pluginEventBus,
|
|
25
28
|
pluginEvent,
|
|
26
|
-
|
|
29
|
+
collaborators = [],
|
|
30
|
+
participants = [],
|
|
31
|
+
addParticipants
|
|
27
32
|
} = _ref;
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
const getCollaborators = (0, _react.useCallback)(() => {
|
|
34
|
+
const newCollaborators = collaborators.map(user => new _model.User(user));
|
|
35
|
+
return newCollaborators;
|
|
36
|
+
}, [collaborators]);
|
|
37
|
+
const getParticipants = (0, _react.useCallback)(() => {
|
|
38
|
+
const newParticipants = participants.map(user => new _model.User(user));
|
|
39
|
+
return newParticipants;
|
|
40
|
+
}, [participants]);
|
|
32
41
|
return /*#__PURE__*/_react.default.createElement(CommentContext.Provider, {
|
|
33
42
|
value: {
|
|
34
43
|
type,
|
|
35
|
-
userInfo,
|
|
36
|
-
pluginName,
|
|
44
|
+
userInfo: _context.default.getUserInfo(),
|
|
37
45
|
className,
|
|
38
|
-
|
|
46
|
+
pluginName,
|
|
39
47
|
pluginEventBus,
|
|
40
48
|
pluginEvent,
|
|
41
|
-
collaborators
|
|
49
|
+
collaborators: getCollaborators(),
|
|
50
|
+
participants: getParticipants(),
|
|
51
|
+
addParticipants
|
|
42
52
|
}
|
|
43
53
|
}, children);
|
|
44
54
|
};
|
|
@@ -4,17 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "Notification", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _notification.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
7
|
Object.defineProperty(exports, "User", {
|
|
14
8
|
enumerable: true,
|
|
15
9
|
get: function () {
|
|
16
10
|
return _user.default;
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
|
-
var _user = _interopRequireDefault(require("./user"));
|
|
20
|
-
var _notification = _interopRequireDefault(require("./notification"));
|
|
13
|
+
var _user = _interopRequireDefault(require("./user"));
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.validateOperation = exports.syncRemoteOperations = exports.syncRemoteCursorLocation = exports.revertOperationList = exports.reExecRevertOperationList = exports.getRevertOperationList = exports.getNodePathById = void 0;
|
|
9
|
+
var _slate = require("@seafile/slate");
|
|
10
|
+
var _deepCopy = _interopRequireDefault(require("deep-copy"));
|
|
11
|
+
var _helper = require("../cursor/helper");
|
|
12
|
+
var _core = require("../extension/core");
|
|
13
|
+
var OPERATION = _interopRequireWildcard(require("../node-id/constants"));
|
|
14
|
+
const getNodePathById = function (rootNode, nodeId) {
|
|
15
|
+
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
16
|
+
if (rootNode.id === nodeId) return path;
|
|
17
|
+
const {
|
|
18
|
+
children = []
|
|
19
|
+
} = rootNode;
|
|
20
|
+
for (let i = 0; i < children.length; i++) {
|
|
21
|
+
const child = children[i];
|
|
22
|
+
path.push(i);
|
|
23
|
+
const nodePath = getNodePathById(child, nodeId, path);
|
|
24
|
+
if (nodePath) return nodePath;
|
|
25
|
+
path.pop();
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
exports.getNodePathById = getNodePathById;
|
|
30
|
+
const validateOperation = (editor, operation) => {
|
|
31
|
+
let isValid = false;
|
|
32
|
+
let newOperation = (0, _deepCopy.default)(operation);
|
|
33
|
+
const {
|
|
34
|
+
type
|
|
35
|
+
} = newOperation;
|
|
36
|
+
switch (type) {
|
|
37
|
+
case OPERATION.INSERT_TEXT:
|
|
38
|
+
case OPERATION.REMOVE_TEXT:
|
|
39
|
+
{
|
|
40
|
+
const {
|
|
41
|
+
node_id,
|
|
42
|
+
path
|
|
43
|
+
} = newOperation;
|
|
44
|
+
const node = (0, _core.getNode)(editor, path);
|
|
45
|
+
// node is exist and node path is not changed
|
|
46
|
+
if (node && node.id === node_id) {
|
|
47
|
+
isValid = true;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// node is exist but node path is changed
|
|
52
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
53
|
+
if (nodePath) {
|
|
54
|
+
isValid = true;
|
|
55
|
+
newOperation.path = nodePath;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
// node is not exist
|
|
59
|
+
isValid = false;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case OPERATION.INSERT_NODE:
|
|
63
|
+
{
|
|
64
|
+
let {
|
|
65
|
+
parent_node_id,
|
|
66
|
+
path
|
|
67
|
+
} = newOperation;
|
|
68
|
+
const parentNodePath = getNodePathById(editor, parent_node_id);
|
|
69
|
+
if (!parentNodePath) {
|
|
70
|
+
isValid = false;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const parentPath = path.slice(0, path.length - 1);
|
|
74
|
+
if (parentPath.join() === parentNodePath.join()) {
|
|
75
|
+
isValid = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// reset insert node path
|
|
80
|
+
const parentNode = (0, _core.getNode)(editor, path);
|
|
81
|
+
if (parentNode) {
|
|
82
|
+
const childLength = parentNode.children.length;
|
|
83
|
+
const index = Math.min(path[path.length - 1], childLength);
|
|
84
|
+
newOperation.path = parentNodePath.concat([index]);
|
|
85
|
+
isValid = true;
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case OPERATION.REMOVE_NODE:
|
|
90
|
+
{
|
|
91
|
+
const {
|
|
92
|
+
node_id,
|
|
93
|
+
path
|
|
94
|
+
} = newOperation;
|
|
95
|
+
const node = (0, _core.getNode)(editor, path);
|
|
96
|
+
// node is exist and node path is not changed
|
|
97
|
+
if (node && node.id === node_id) {
|
|
98
|
+
isValid = true;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// node is exist but node path is changed
|
|
103
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
104
|
+
if (nodePath) {
|
|
105
|
+
isValid = true;
|
|
106
|
+
newOperation.path = nodePath;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// node is not exist
|
|
111
|
+
isValid = false;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case OPERATION.MERGE_NODE:
|
|
115
|
+
{
|
|
116
|
+
// merge next node into prev node
|
|
117
|
+
const {
|
|
118
|
+
node_id,
|
|
119
|
+
path
|
|
120
|
+
} = newOperation;
|
|
121
|
+
const node = (0, _core.getNode)(editor, path);
|
|
122
|
+
// node is exist and node path is not changed
|
|
123
|
+
if (node && node.id === node_id) {
|
|
124
|
+
isValid = true;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// node is exist but node path is changed
|
|
129
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
130
|
+
if (nodePath) {
|
|
131
|
+
isValid = true;
|
|
132
|
+
newOperation.path = nodePath;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// node is not exist
|
|
137
|
+
isValid = false;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case OPERATION.SPLIT_NODE:
|
|
141
|
+
{
|
|
142
|
+
const {
|
|
143
|
+
node_id,
|
|
144
|
+
path
|
|
145
|
+
} = newOperation;
|
|
146
|
+
const node = (0, _core.getNode)(editor, path);
|
|
147
|
+
// node is exist and node path is not changed
|
|
148
|
+
if (node && node.id === node_id) {
|
|
149
|
+
isValid = true;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// node is exist but node path is changed
|
|
154
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
155
|
+
if (nodePath) {
|
|
156
|
+
isValid = true;
|
|
157
|
+
newOperation.path = nodePath;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// node is not exist
|
|
162
|
+
isValid = false;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case OPERATION.SET_NODE:
|
|
166
|
+
{
|
|
167
|
+
const {
|
|
168
|
+
node_id,
|
|
169
|
+
path,
|
|
170
|
+
properties
|
|
171
|
+
} = newOperation;
|
|
172
|
+
const node = (0, _core.getNode)(editor, path);
|
|
173
|
+
// node is exist and node path is not changed
|
|
174
|
+
if (node && node.id === node_id) {
|
|
175
|
+
isValid = true;
|
|
176
|
+
newOperation.properties = {
|
|
177
|
+
...properties,
|
|
178
|
+
type: node.type
|
|
179
|
+
};
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// node is exist but node path is changed
|
|
184
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
185
|
+
if (nodePath) {
|
|
186
|
+
isValid = true;
|
|
187
|
+
const node = (0, _core.getNode)(editor, nodePath);
|
|
188
|
+
newOperation.properties = {
|
|
189
|
+
...properties,
|
|
190
|
+
type: node.type
|
|
191
|
+
};
|
|
192
|
+
newOperation.path = nodePath;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// node is not exist
|
|
197
|
+
isValid = false;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case OPERATION.MOVE_NODE:
|
|
201
|
+
{
|
|
202
|
+
const {
|
|
203
|
+
node_id,
|
|
204
|
+
path
|
|
205
|
+
} = newOperation;
|
|
206
|
+
const node = (0, _core.getNode)(editor, path);
|
|
207
|
+
// node is exist and node path is not changed
|
|
208
|
+
if (node && node.id === node_id) {
|
|
209
|
+
isValid = true;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// TODO: newPath can not calculate by nodePath
|
|
214
|
+
// node is exist but node path is changed
|
|
215
|
+
// const nodePath = getNodePathById(editor, node_id);
|
|
216
|
+
// if (nodePath) {}
|
|
217
|
+
|
|
218
|
+
// node is not exist
|
|
219
|
+
isValid = false;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
default:
|
|
223
|
+
{
|
|
224
|
+
// set_selection
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (isValid) return newOperation;
|
|
229
|
+
return isValid;
|
|
230
|
+
};
|
|
231
|
+
exports.validateOperation = validateOperation;
|
|
232
|
+
const getRevertOperationList = operationList => {
|
|
233
|
+
if (operationList.length === 0) return [];
|
|
234
|
+
|
|
235
|
+
// Generate a duplicate operationList, The original value cannot be modified here
|
|
236
|
+
let revertOperationList = (0, _deepCopy.default)(operationList);
|
|
237
|
+
revertOperationList = revertOperationList.reverse();
|
|
238
|
+
return revertOperationList.map(operations => {
|
|
239
|
+
const ops = operations.reverse();
|
|
240
|
+
return ops.map(item => _slate.Operation.inverse(item));
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
exports.getRevertOperationList = getRevertOperationList;
|
|
244
|
+
const revertOperationList = (editor, operationList) => {
|
|
245
|
+
if (operationList.length === 0) return [];
|
|
246
|
+
const revertOperationList = getRevertOperationList(operationList);
|
|
247
|
+
|
|
248
|
+
// Cancel locale execute operations
|
|
249
|
+
for (let i = 0; i < revertOperationList.length; i++) {
|
|
250
|
+
const operations = revertOperationList[i];
|
|
251
|
+
_slate.Editor.withoutNormalizing(editor, () => {
|
|
252
|
+
for (let j = 0; j < operations.length; j++) {
|
|
253
|
+
const op = operations[j];
|
|
254
|
+
editor.apply(op);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
exports.revertOperationList = revertOperationList;
|
|
260
|
+
const reExecRevertOperationList = (editor, revertOperationList) => {
|
|
261
|
+
if (revertOperationList.length === 0) return;
|
|
262
|
+
|
|
263
|
+
// Re-execute revert operations
|
|
264
|
+
for (let i = 0; i < revertOperationList.length; i++) {
|
|
265
|
+
const operations = revertOperationList[i];
|
|
266
|
+
_slate.Editor.withoutNormalizing(editor, () => {
|
|
267
|
+
for (let j = 0; j < operations.length; j++) {
|
|
268
|
+
const op = validateOperation(editor, operations[j]);
|
|
269
|
+
if (op) {
|
|
270
|
+
editor.apply(op);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
exports.reExecRevertOperationList = reExecRevertOperationList;
|
|
277
|
+
const syncRemoteOperations = (editor, remoteOperations) => {
|
|
278
|
+
if (remoteOperations.length === 0) return;
|
|
279
|
+
_slate.Editor.withoutNormalizing(editor, () => {
|
|
280
|
+
for (let i = 0; i < remoteOperations.length; i++) {
|
|
281
|
+
const op = remoteOperations[i];
|
|
282
|
+
if (op.type === 'set_selection') {
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
editor.apply(op);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
exports.syncRemoteOperations = syncRemoteOperations;
|
|
290
|
+
const syncRemoteCursorLocation = (editor, user, location, cursorData) => {
|
|
291
|
+
const currentUser = editor.user;
|
|
292
|
+
if (user && user.username !== currentUser.username) {
|
|
293
|
+
// Get front Point as cursor
|
|
294
|
+
const {
|
|
295
|
+
anchor,
|
|
296
|
+
focus
|
|
297
|
+
} = location;
|
|
298
|
+
let newLocation = location;
|
|
299
|
+
if (!_slate.Point.equals(anchor, focus)) {
|
|
300
|
+
const frontPoint = _slate.Editor.start(editor, location);
|
|
301
|
+
newLocation = {
|
|
302
|
+
anchor: frontPoint,
|
|
303
|
+
focus: frontPoint
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
(0, _helper.setCursor)(editor, user, newLocation, cursorData);
|
|
307
|
+
|
|
308
|
+
// sync cursor position
|
|
309
|
+
editor.onCursor && editor.onCursor(editor.cursors);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
exports.syncRemoteCursorLocation = syncRemoteCursorLocation;
|
|
@@ -10,10 +10,10 @@ var _reactI18next = require("react-i18next");
|
|
|
10
10
|
var _reactstrap = require("reactstrap");
|
|
11
11
|
var _basicSdk = require("../../basic-sdk");
|
|
12
12
|
require("./error-page.css");
|
|
13
|
-
function ErrorPage(
|
|
14
|
-
|
|
13
|
+
function ErrorPage() {
|
|
14
|
+
const {
|
|
15
15
|
t
|
|
16
|
-
} =
|
|
16
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
17
17
|
const normalizeSdoc = (0, _react.useCallback)(async () => {
|
|
18
18
|
const res = await _basicSdk.context.normalizeSdocContent();
|
|
19
19
|
const {
|
|
@@ -33,4 +33,4 @@ function ErrorPage(_ref) {
|
|
|
33
33
|
onClick: () => normalizeSdoc()
|
|
34
34
|
}, t('Repair')));
|
|
35
35
|
}
|
|
36
|
-
var _default = exports.default =
|
|
36
|
+
var _default = exports.default = ErrorPage;
|
|
@@ -8,39 +8,57 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactI18next = require("react-i18next");
|
|
10
10
|
var _basicSdk = require("../basic-sdk");
|
|
11
|
+
var _i18n = require("../_i18n");
|
|
11
12
|
var _errorBoundary = _interopRequireDefault(require("../components/error-boundary"));
|
|
12
13
|
const SeafileCommentEditor = _ref => {
|
|
13
14
|
let {
|
|
15
|
+
// Provider
|
|
14
16
|
type,
|
|
15
|
-
|
|
16
|
-
pluginName = '',
|
|
17
|
+
// comment or replay
|
|
17
18
|
className = '',
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
pluginName = '',
|
|
20
|
+
// sdoc or wiki or txt ...
|
|
21
|
+
pluginEventBus,
|
|
22
|
+
pluginEvent,
|
|
23
|
+
// Comment editor
|
|
24
|
+
content,
|
|
20
25
|
insertContent,
|
|
21
|
-
hiddenComment,
|
|
22
26
|
onContentChange,
|
|
27
|
+
hiddenUserInfo,
|
|
28
|
+
hiddenComment,
|
|
29
|
+
toolMenus,
|
|
30
|
+
closePanel,
|
|
31
|
+
collaborators,
|
|
32
|
+
participants,
|
|
23
33
|
addParticipants,
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
// settings
|
|
35
|
+
settings,
|
|
26
36
|
api
|
|
27
37
|
} = _ref;
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
const {
|
|
39
|
+
lang
|
|
40
|
+
} = settings || {};
|
|
41
|
+
_basicSdk.context.init(settings, api);
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_reactI18next.I18nextProvider, {
|
|
43
|
+
i18n: (0, _i18n.getI18n)(lang || 'en')
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentProvider, {
|
|
30
45
|
type: type,
|
|
31
|
-
userInfo: userInfo,
|
|
32
|
-
pluginName: pluginName,
|
|
33
46
|
className: className,
|
|
47
|
+
pluginName: pluginName,
|
|
34
48
|
pluginEventBus: pluginEventBus,
|
|
35
49
|
pluginEvent: pluginEvent,
|
|
36
|
-
|
|
50
|
+
collaborators: collaborators,
|
|
51
|
+
participants: participants,
|
|
52
|
+
addParticipants: addParticipants
|
|
37
53
|
}, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
|
|
38
|
-
|
|
39
|
-
hiddenUserInfo: hiddenUserInfo,
|
|
54
|
+
content: content,
|
|
40
55
|
insertContent: insertContent,
|
|
41
|
-
hiddenComment: hiddenComment,
|
|
42
56
|
onContentChange: onContentChange,
|
|
57
|
+
hiddenUserInfo: hiddenUserInfo,
|
|
58
|
+
hiddenComment: hiddenComment,
|
|
59
|
+
toolMenus: toolMenus,
|
|
60
|
+
closePanel: closePanel,
|
|
43
61
|
addParticipants: addParticipants
|
|
44
|
-
})));
|
|
62
|
+
}))));
|
|
45
63
|
};
|
|
46
|
-
var _default = exports.default =
|
|
64
|
+
var _default = exports.default = SeafileCommentEditor;
|