@seafile/sdoc-editor 0.4.36 → 0.5.0
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/api/seafile-api.js +5 -4
- package/dist/basic-sdk/comment/utils/index.js +13 -12
- package/dist/basic-sdk/extension/commons/element-popover/index.js +3 -2
- package/dist/basic-sdk/extension/commons/menu/menu-group.js +3 -2
- package/dist/basic-sdk/extension/core/utils/index.js +8 -0
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +7 -6
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +7 -6
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +3 -2
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +57 -44
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +21 -20
- package/dist/basic-sdk/extension/plugins/image/dialogs/image-previewer.js +7 -6
- package/dist/basic-sdk/extension/plugins/image/helpers.js +13 -8
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +13 -12
- package/dist/basic-sdk/extension/plugins/list/menu/index.js +9 -8
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +9 -8
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +13 -12
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +9 -8
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/render/table-header/index.css +4 -1
- package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +7 -6
- package/dist/basic-sdk/outline/outline-item.js +7 -6
- package/dist/basic-sdk/socket/socket-client.js +49 -48
- package/dist/basic-sdk/socket/socket-manager.js +53 -52
- package/dist/basic-sdk/utils/diff-text.js +21 -20
- package/dist/basic-sdk/utils/event-handler.js +8 -7
- package/dist/basic-sdk/utils/object-utils.js +5 -4
- package/dist/components/doc-operations/collaborators-operation/index.js +5 -4
- package/dist/components/draft-dropdown/index.js +11 -10
- package/dist/components/tip-message/index.js +21 -20
- package/dist/components/toast/toast.js +17 -16
- package/dist/components/toast/toastManager.js +14 -13
- package/dist/components/toast/toaster.js +19 -18
- package/dist/context.js +5 -4
- package/dist/slate-convert/html-to-slate/constants.js +34 -0
- package/dist/slate-convert/html-to-slate/helper.js +54 -0
- package/dist/slate-convert/html-to-slate/index.js +131 -0
- package/dist/slate-convert/html-to-slate/rules/blockquote.js +17 -0
- package/dist/slate-convert/html-to-slate/rules/check-list.js +20 -0
- package/dist/slate-convert/html-to-slate/rules/code-block.js +83 -0
- package/dist/slate-convert/html-to-slate/rules/header.js +17 -0
- package/dist/slate-convert/html-to-slate/rules/image.js +22 -0
- package/dist/slate-convert/html-to-slate/rules/index.js +11 -0
- package/dist/slate-convert/html-to-slate/rules/link.js +22 -0
- package/dist/slate-convert/html-to-slate/rules/list.js +50 -0
- package/dist/slate-convert/html-to-slate/rules/paragraph.js +17 -0
- package/dist/slate-convert/html-to-slate/rules/table.js +38 -0
- package/dist/slate-convert/html-to-slate/rules/text.js +56 -0
- package/dist/slate-convert/index.js +8 -0
- package/dist/slate-convert/md-to-html/index.js +48 -0
- package/dist/slate-convert/md-to-html/sanitize-schema.js +17 -0
- package/dist/slate-convert/md-to-slate/index.js +38 -0
- package/dist/slate-convert/md-to-slate/transform.js +360 -0
- package/dist/slate-convert/slate-to-md/index.js +37 -0
- package/dist/slate-convert/slate-to-md/transform.js +311 -0
- package/dist/utils/is-punctuation-mark.js +44 -0
- package/package.json +21 -6
package/dist/api/seafile-api.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import axios from 'axios';
|
|
2
3
|
import slugid from 'slugid';
|
|
3
4
|
class SeafileAPI {
|
|
4
5
|
constructor(server, token) {
|
|
5
|
-
this
|
|
6
|
+
_defineProperty(this, "deleteSdocRevision", docUuid => {
|
|
6
7
|
const url = 'api/v2.1/seadoc/revision/' + docUuid + '/';
|
|
7
8
|
return this.req.delete(url);
|
|
8
|
-
};
|
|
9
|
-
this
|
|
9
|
+
});
|
|
10
|
+
_defineProperty(this, "deleteSdocOtherRevision", (docUuid, revisionId) => {
|
|
10
11
|
const url = 'api/v2.1/seadoc/delete-revision/' + docUuid + '/' + revisionId + '/';
|
|
11
12
|
return this.req.delete(url);
|
|
12
|
-
};
|
|
13
|
+
});
|
|
13
14
|
this.req = axios.create({
|
|
14
15
|
baseURL: server,
|
|
15
16
|
headers: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import { Editor } from '@seafile/slate';
|
|
2
3
|
import { getEventTransfer } from '../../../utils';
|
|
3
4
|
import { COMMENT_URL_CLASSNAME } from '../constants';
|
|
@@ -53,7 +54,7 @@ export const checkMentionOperation = event => {
|
|
|
53
54
|
};
|
|
54
55
|
class CommentUtilities {
|
|
55
56
|
constructor() {
|
|
56
|
-
this
|
|
57
|
+
_defineProperty(this, "onInsertElement", _ref => {
|
|
57
58
|
let {
|
|
58
59
|
commentRef,
|
|
59
60
|
selection,
|
|
@@ -72,8 +73,8 @@ class CommentUtilities {
|
|
|
72
73
|
content,
|
|
73
74
|
nodeType
|
|
74
75
|
});
|
|
75
|
-
};
|
|
76
|
-
this
|
|
76
|
+
});
|
|
77
|
+
_defineProperty(this, "getHtmlElement", (nodeType, content) => {
|
|
77
78
|
switch (nodeType) {
|
|
78
79
|
case 'image':
|
|
79
80
|
{
|
|
@@ -91,8 +92,8 @@ class CommentUtilities {
|
|
|
91
92
|
return '';
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
};
|
|
95
|
-
this
|
|
95
|
+
});
|
|
96
|
+
_defineProperty(this, "createHtmlElement", _ref2 => {
|
|
96
97
|
let {
|
|
97
98
|
commentRef,
|
|
98
99
|
selection,
|
|
@@ -138,8 +139,8 @@ class CommentUtilities {
|
|
|
138
139
|
selection.addRange(range);
|
|
139
140
|
}
|
|
140
141
|
return range;
|
|
141
|
-
};
|
|
142
|
-
this
|
|
142
|
+
});
|
|
143
|
+
_defineProperty(this, "onSelectParticipant", _ref3 => {
|
|
143
144
|
let {
|
|
144
145
|
selection,
|
|
145
146
|
range,
|
|
@@ -173,7 +174,7 @@ class CommentUtilities {
|
|
|
173
174
|
commentRef.current.focus();
|
|
174
175
|
}
|
|
175
176
|
return newRange;
|
|
176
|
-
};
|
|
177
|
+
});
|
|
177
178
|
/**
|
|
178
179
|
* get the index of '@' from anchor position.
|
|
179
180
|
* @param {*} anchorPosition '@text|anchor position|'
|
|
@@ -182,7 +183,7 @@ class CommentUtilities {
|
|
|
182
183
|
* e.g. '@abc|anchor position|' // 0
|
|
183
184
|
* '@123 @|anchor position| @abc' // 5
|
|
184
185
|
*/
|
|
185
|
-
this
|
|
186
|
+
_defineProperty(this, "getAtIndexWithAnchorPosition", (anchorPosition, text) => {
|
|
186
187
|
let atIndex = -1;
|
|
187
188
|
for (let i = anchorPosition - 1; i > -1; i--) {
|
|
188
189
|
if (text[i] === '@') {
|
|
@@ -191,8 +192,8 @@ class CommentUtilities {
|
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
194
|
return atIndex;
|
|
194
|
-
};
|
|
195
|
-
this
|
|
195
|
+
});
|
|
196
|
+
_defineProperty(this, "onPaste", (event, callBack) => {
|
|
196
197
|
event.stopPropagation();
|
|
197
198
|
let cliperData = getEventTransfer(event);
|
|
198
199
|
if (cliperData.files) {
|
|
@@ -213,7 +214,7 @@ class CommentUtilities {
|
|
|
213
214
|
document.execCommand('paste', false, text);
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
|
-
};
|
|
217
|
+
});
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
export const focusToCommentElement = (editor, element) => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import ReactDOM from 'react-dom';
|
|
3
4
|
class ElementPopover extends React.Component {
|
|
4
5
|
constructor(props) {
|
|
5
6
|
super(props);
|
|
6
|
-
this
|
|
7
|
+
_defineProperty(this, "state", {
|
|
7
8
|
isMounted: false
|
|
8
|
-
};
|
|
9
|
+
});
|
|
9
10
|
this.el = document.createElement('div');
|
|
10
11
|
if (props.className) {
|
|
11
12
|
this.el.className = props.className;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
class MenuGroup extends React.PureComponent {
|
|
3
4
|
render() {
|
|
@@ -7,7 +8,7 @@ class MenuGroup extends React.PureComponent {
|
|
|
7
8
|
}, this.props.children);
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
MenuGroup
|
|
11
|
+
_defineProperty(MenuGroup, "defaultProps", {
|
|
11
12
|
className: 'menu-group'
|
|
12
|
-
};
|
|
13
|
+
});
|
|
13
14
|
export default MenuGroup;
|
|
@@ -2,6 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import slugid from 'slugid';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { PARAGRAPH } from '../../constants';
|
|
5
6
|
export const match = (node, path, predicate) => {
|
|
6
7
|
if (!predicate) return true;
|
|
7
8
|
if (typeof predicate === 'object') {
|
|
@@ -22,6 +23,13 @@ export const generateDefaultText = () => {
|
|
|
22
23
|
text: ''
|
|
23
24
|
};
|
|
24
25
|
};
|
|
26
|
+
export const generateDefaultParagraph = () => {
|
|
27
|
+
return {
|
|
28
|
+
id: slugid.nice(),
|
|
29
|
+
type: PARAGRAPH,
|
|
30
|
+
children: [generateDefaultText()]
|
|
31
|
+
};
|
|
32
|
+
};
|
|
25
33
|
export const generateEmptyElement = function (type) {
|
|
26
34
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
27
35
|
return _objectSpread(_objectSpread({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { BLOCKQUOTE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
4
5
|
import { MenuItem } from '../../../commons';
|
|
@@ -7,27 +8,27 @@ import { focusEditor } from '../../../core';
|
|
|
7
8
|
class QuoteMenu extends React.Component {
|
|
8
9
|
constructor() {
|
|
9
10
|
super(...arguments);
|
|
10
|
-
this
|
|
11
|
+
_defineProperty(this, "isActive", () => {
|
|
11
12
|
const {
|
|
12
13
|
editor
|
|
13
14
|
} = this.props;
|
|
14
15
|
return getBlockQuoteType(editor) === BLOCKQUOTE;
|
|
15
|
-
};
|
|
16
|
-
this
|
|
16
|
+
});
|
|
17
|
+
_defineProperty(this, "isDisabled", () => {
|
|
17
18
|
const {
|
|
18
19
|
editor,
|
|
19
20
|
readonly
|
|
20
21
|
} = this.props;
|
|
21
22
|
return isMenuDisabled(editor, readonly);
|
|
22
|
-
};
|
|
23
|
-
this
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "onMouseDown", e => {
|
|
24
25
|
const {
|
|
25
26
|
editor
|
|
26
27
|
} = this.props;
|
|
27
28
|
const active = this.isActive(editor);
|
|
28
29
|
setBlockQuoteType(editor, active);
|
|
29
30
|
focusEditor(editor);
|
|
30
|
-
};
|
|
31
|
+
});
|
|
31
32
|
}
|
|
32
33
|
render() {
|
|
33
34
|
const {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { CHECK_LIST_ITEM, MENUS_CONFIG_MAP, PARAGRAPH } from '../../../constants';
|
|
4
5
|
import { MenuItem } from '../../../commons';
|
|
@@ -7,20 +8,20 @@ import { focusEditor } from '../../../core';
|
|
|
7
8
|
class CheckListMenu extends React.Component {
|
|
8
9
|
constructor() {
|
|
9
10
|
super(...arguments);
|
|
10
|
-
this
|
|
11
|
+
_defineProperty(this, "isActive", () => {
|
|
11
12
|
const {
|
|
12
13
|
editor
|
|
13
14
|
} = this.props;
|
|
14
15
|
return getCheckListItemType(editor) === CHECK_LIST_ITEM;
|
|
15
|
-
};
|
|
16
|
-
this
|
|
16
|
+
});
|
|
17
|
+
_defineProperty(this, "isDisabled", () => {
|
|
17
18
|
const {
|
|
18
19
|
editor,
|
|
19
20
|
readonly
|
|
20
21
|
} = this.props;
|
|
21
22
|
return isMenuDisabled(editor, readonly);
|
|
22
|
-
};
|
|
23
|
-
this
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "onMouseDown", () => {
|
|
24
25
|
const {
|
|
25
26
|
editor
|
|
26
27
|
} = this.props;
|
|
@@ -28,7 +29,7 @@ class CheckListMenu extends React.Component {
|
|
|
28
29
|
const newType = active ? PARAGRAPH : CHECK_LIST_ITEM;
|
|
29
30
|
setCheckListItemType(editor, newType);
|
|
30
31
|
focusEditor(editor, editor.selection);
|
|
31
|
-
};
|
|
32
|
+
});
|
|
32
33
|
}
|
|
33
34
|
render() {
|
|
34
35
|
const {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { Transforms } from '@seafile/slate';
|
|
3
4
|
import { ReactEditor } from '@seafile/slate-react';
|
|
4
5
|
class CheckListItem extends React.PureComponent {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
7
|
-
this
|
|
8
|
+
_defineProperty(this, "onChange", event => {
|
|
8
9
|
const checked = event.target.checked;
|
|
9
10
|
const {
|
|
10
11
|
editor,
|
|
@@ -16,7 +17,7 @@ class CheckListItem extends React.PureComponent {
|
|
|
16
17
|
}, {
|
|
17
18
|
at: path
|
|
18
19
|
});
|
|
19
|
-
};
|
|
20
|
+
});
|
|
20
21
|
}
|
|
21
22
|
render() {
|
|
22
23
|
const {
|
|
@@ -29,15 +29,50 @@ export const getSelectCodeElem = editor => {
|
|
|
29
29
|
if (codeNode == null) return null;
|
|
30
30
|
return codeNode;
|
|
31
31
|
};
|
|
32
|
+
export const getCodeBlockNode = language => {
|
|
33
|
+
const node = {
|
|
34
|
+
id: slugid.nice(),
|
|
35
|
+
type: CODE_BLOCK,
|
|
36
|
+
language,
|
|
37
|
+
style: {
|
|
38
|
+
white_space: 'nowrap'
|
|
39
|
+
},
|
|
40
|
+
// default nowrap
|
|
41
|
+
children: [{
|
|
42
|
+
id: slugid.nice(),
|
|
43
|
+
type: CODE_LINE,
|
|
44
|
+
children: [{
|
|
45
|
+
text: '',
|
|
46
|
+
id: slugid.nice()
|
|
47
|
+
}]
|
|
48
|
+
}]
|
|
49
|
+
};
|
|
50
|
+
return node;
|
|
51
|
+
};
|
|
32
52
|
export const changeToCodeBlock = function (editor) {
|
|
33
53
|
let language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
34
54
|
let position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INSERT_POSITION.CURRENT;
|
|
35
|
-
|
|
36
|
-
let strArr = [];
|
|
37
|
-
|
|
55
|
+
if (!editor.selection) return;
|
|
56
|
+
let strArr = []; // Summarizes the strings for the selected highest-level node
|
|
57
|
+
const path = Editor.path(editor, editor.selection, {
|
|
58
|
+
edge: 'start'
|
|
59
|
+
});
|
|
60
|
+
const newCodeBlockNode = getCodeBlockNode(language); // New code-block node
|
|
61
|
+
|
|
62
|
+
// Insert after
|
|
38
63
|
if (position === INSERT_POSITION.AFTER) {
|
|
39
64
|
strArr = [''];
|
|
40
|
-
|
|
65
|
+
newCodeBlockNode.children[0].children[0].text = strArr.join('\n');
|
|
66
|
+
Transforms.insertNodes(editor, newCodeBlockNode, {
|
|
67
|
+
mode: 'highest',
|
|
68
|
+
at: [path[0] + 1]
|
|
69
|
+
});
|
|
70
|
+
Transforms.select(editor, [path[0] + 1, 0, 0]);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Insert current
|
|
75
|
+
if (position === INSERT_POSITION.CURRENT) {
|
|
41
76
|
// Select the plain text of the node
|
|
42
77
|
const nodeEntries = Editor.nodes(editor, {
|
|
43
78
|
match: n => editor.children.includes(n),
|
|
@@ -48,55 +83,33 @@ export const changeToCodeBlock = function (editor) {
|
|
|
48
83
|
const [n] = nodeEntry;
|
|
49
84
|
if (n) strArr.push(Node.string(n));
|
|
50
85
|
}
|
|
51
|
-
|
|
52
86
|
// Deletes the selected node at the highest level
|
|
53
87
|
Transforms.removeNodes(editor, {
|
|
54
88
|
mode: 'highest'
|
|
55
89
|
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Insert the codeBlockNode node
|
|
59
|
-
const newCodeBlockNode = {
|
|
60
|
-
id: slugid.nice(),
|
|
61
|
-
type: CODE_BLOCK,
|
|
62
|
-
language,
|
|
63
|
-
style: {
|
|
64
|
-
white_space: 'nowrap' // default nowrap
|
|
65
|
-
},
|
|
66
90
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
// Modify location
|
|
92
|
+
const atPath = [path[0]];
|
|
93
|
+
const atPoint = {
|
|
94
|
+
anchor: {
|
|
95
|
+
offset: 0,
|
|
96
|
+
path: [path[0], 0, 0]
|
|
97
|
+
},
|
|
98
|
+
focus: {
|
|
99
|
+
offset: 0,
|
|
100
|
+
path: [path[0], 0, 0]
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
// Insert new node
|
|
104
|
+
newCodeBlockNode.children[0].children[0].text = strArr.join('\n');
|
|
77
105
|
Transforms.insertNodes(editor, newCodeBlockNode, {
|
|
78
106
|
mode: 'highest',
|
|
79
|
-
at:
|
|
107
|
+
at: atPath
|
|
108
|
+
});
|
|
109
|
+
queueMicrotask(() => {
|
|
110
|
+
Transforms.select(editor, atPoint);
|
|
80
111
|
});
|
|
81
|
-
Transforms.select(editor, [path[0] + 1, 0, 0]);
|
|
82
|
-
return;
|
|
83
112
|
}
|
|
84
|
-
const atPath = path ? [path[0]] : editor.selection;
|
|
85
|
-
const atPoint = path ? {
|
|
86
|
-
anchor: {
|
|
87
|
-
offset: 0,
|
|
88
|
-
path: [path[0], 0, 0]
|
|
89
|
-
},
|
|
90
|
-
focus: {
|
|
91
|
-
offset: 0,
|
|
92
|
-
path: [path[0], 0, 0]
|
|
93
|
-
}
|
|
94
|
-
} : editor.selection;
|
|
95
|
-
Transforms.insertNodes(editor, newCodeBlockNode, {
|
|
96
|
-
mode: 'highest',
|
|
97
|
-
at: atPath
|
|
98
|
-
});
|
|
99
|
-
Transforms.select(editor, atPoint);
|
|
100
113
|
};
|
|
101
114
|
export const changeToPlainText = editor => {
|
|
102
115
|
const elem = getSelectCodeElem(editor);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import React, { Fragment } from 'react';
|
|
2
3
|
import { withTranslation } from 'react-i18next';
|
|
3
4
|
import classnames from 'classnames';
|
|
@@ -9,13 +10,13 @@ import './style.css';
|
|
|
9
10
|
class HeaderMenu extends React.Component {
|
|
10
11
|
constructor(props) {
|
|
11
12
|
super(props);
|
|
12
|
-
this
|
|
13
|
+
_defineProperty(this, "registerEventHandler", () => {
|
|
13
14
|
document.addEventListener('click', this.onHideHeaderMenu, true);
|
|
14
|
-
};
|
|
15
|
-
this
|
|
15
|
+
});
|
|
16
|
+
_defineProperty(this, "unregisterEventHandler", () => {
|
|
16
17
|
document.removeEventListener('click', this.onHideHeaderMenu, true);
|
|
17
|
-
};
|
|
18
|
-
this
|
|
18
|
+
});
|
|
19
|
+
_defineProperty(this, "onHideHeaderMenu", e => {
|
|
19
20
|
const menu = this.menu;
|
|
20
21
|
const clickIsInMenu = menu && menu.contains(e.target) && menu !== e.target;
|
|
21
22
|
if (clickIsInMenu) return;
|
|
@@ -24,24 +25,24 @@ class HeaderMenu extends React.Component {
|
|
|
24
25
|
}, () => {
|
|
25
26
|
this.unregisterEventHandler();
|
|
26
27
|
});
|
|
27
|
-
};
|
|
28
|
-
this
|
|
28
|
+
});
|
|
29
|
+
_defineProperty(this, "getValue", () => {
|
|
29
30
|
const {
|
|
30
31
|
editor
|
|
31
32
|
} = this.props;
|
|
32
33
|
return getHeaderType(editor);
|
|
33
|
-
};
|
|
34
|
-
this
|
|
34
|
+
});
|
|
35
|
+
_defineProperty(this, "isActive", type => {
|
|
35
36
|
return this.getValue() === type;
|
|
36
|
-
};
|
|
37
|
-
this
|
|
37
|
+
});
|
|
38
|
+
_defineProperty(this, "isDisabled", () => {
|
|
38
39
|
const {
|
|
39
40
|
editor,
|
|
40
41
|
readonly
|
|
41
42
|
} = this.props;
|
|
42
43
|
return isMenuDisabled(editor, readonly);
|
|
43
|
-
};
|
|
44
|
-
this
|
|
44
|
+
});
|
|
45
|
+
_defineProperty(this, "onToggleClick", event => {
|
|
45
46
|
event.stopPropagation();
|
|
46
47
|
event.nativeEvent.stopImmediatePropagation();
|
|
47
48
|
const isShowHeaderPopover = !this.state.isShowHeaderPopover;
|
|
@@ -58,8 +59,8 @@ class HeaderMenu extends React.Component {
|
|
|
58
59
|
this.unregisterEventHandler();
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
};
|
|
62
|
-
this
|
|
62
|
+
});
|
|
63
|
+
_defineProperty(this, "onMouseDown", type => {
|
|
63
64
|
return () => {
|
|
64
65
|
const {
|
|
65
66
|
editor
|
|
@@ -74,15 +75,15 @@ class HeaderMenu extends React.Component {
|
|
|
74
75
|
this.unregisterEventHandler();
|
|
75
76
|
});
|
|
76
77
|
};
|
|
77
|
-
};
|
|
78
|
-
this
|
|
78
|
+
});
|
|
79
|
+
_defineProperty(this, "setMenuRef", ref => {
|
|
79
80
|
this.menu = ref;
|
|
80
|
-
};
|
|
81
|
-
this
|
|
81
|
+
});
|
|
82
|
+
_defineProperty(this, "getToolTip", type => {
|
|
82
83
|
// chrome in Mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
|
|
83
84
|
const isMac = window.navigator.userAgent.indexOf('Macintosh') !== -1;
|
|
84
85
|
return isMac ? MAC_HOTKEYS[type] : WIN_HOTKEYS[type];
|
|
85
|
-
};
|
|
86
|
+
});
|
|
86
87
|
this.state = {
|
|
87
88
|
isShowHeaderPopover: false
|
|
88
89
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import Lightbox from '@seafile/react-image-lightbox';
|
|
3
4
|
import { getImageURL } from '../helpers';
|
|
@@ -5,7 +6,7 @@ import '@seafile/react-image-lightbox/style.css';
|
|
|
5
6
|
class ImagePreviewer extends React.Component {
|
|
6
7
|
constructor(props) {
|
|
7
8
|
super(props);
|
|
8
|
-
this
|
|
9
|
+
_defineProperty(this, "getImageNodes", nodes => {
|
|
9
10
|
let nodeIndex = 0;
|
|
10
11
|
const list = [];
|
|
11
12
|
while (nodes && nodeIndex <= nodes.length - 1) {
|
|
@@ -19,17 +20,17 @@ class ImagePreviewer extends React.Component {
|
|
|
19
20
|
nodeIndex++;
|
|
20
21
|
}
|
|
21
22
|
return list;
|
|
22
|
-
};
|
|
23
|
-
this
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "moveToPrevImage", () => {
|
|
24
25
|
this.setState(prevState => ({
|
|
25
26
|
imageIndex: (prevState.imageIndex + this.images.length - 1) % this.images.length
|
|
26
27
|
}));
|
|
27
|
-
};
|
|
28
|
-
this
|
|
28
|
+
});
|
|
29
|
+
_defineProperty(this, "moveToNextImage", () => {
|
|
29
30
|
this.setState(prevState => ({
|
|
30
31
|
imageIndex: (prevState.imageIndex + 1) % this.images.length
|
|
31
32
|
}));
|
|
32
|
-
};
|
|
33
|
+
});
|
|
33
34
|
const {
|
|
34
35
|
editor,
|
|
35
36
|
imageUrl
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import urlJoin from 'url-join';
|
|
3
3
|
import { Editor, Range, Transforms, Path, Node } from '@seafile/slate';
|
|
4
|
-
import { ReactEditor } from '@seafile/slate-react';
|
|
5
4
|
import context from '../../../../context';
|
|
6
5
|
import EventBus from '../../../utils/event-bus';
|
|
7
|
-
import { generateEmptyElement, getNodeType, isTextNode, getParentNode } from '../../core';
|
|
6
|
+
import { generateEmptyElement, getNodeType, isTextNode, getParentNode, focusEditor } from '../../core';
|
|
7
|
+
import { isList } from '../../toolbar/side-toolbar/helpers';
|
|
8
8
|
import { INTERNAL_EVENT } from '../../../constants';
|
|
9
|
-
import { CODE_BLOCK, ELEMENT_TYPE, IMAGE, INSERT_POSITION
|
|
9
|
+
import { CODE_BLOCK, ELEMENT_TYPE, IMAGE, INSERT_POSITION } from '../../constants';
|
|
10
10
|
export const isInsertImageMenuDisabled = (editor, readonly) => {
|
|
11
11
|
if (readonly) return true;
|
|
12
12
|
const {
|
|
@@ -48,14 +48,16 @@ export const insertImage = function (editor, srcList, selection) {
|
|
|
48
48
|
}
|
|
49
49
|
const imageNodes = srcList.map(src => generateImageNode(src));
|
|
50
50
|
const validSelection = selection || editor.selection;
|
|
51
|
+
let path = Editor.path(editor, validSelection);
|
|
51
52
|
if (position === INSERT_POSITION.AFTER) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const nextPath = Path.next(path);
|
|
53
|
+
if (isList(editor, path)) {
|
|
54
|
+
const targetPath = path.slice(0, -2);
|
|
55
|
+
targetPath[targetPath.length - 1] = targetPath[targetPath.length - 1] + 1;
|
|
56
56
|
Transforms.insertNodes(editor, imageNodes, {
|
|
57
|
-
at:
|
|
57
|
+
at: targetPath
|
|
58
58
|
});
|
|
59
|
+
const imageEndSelection = Path.next(Path.next([...targetPath, 0, 0]));
|
|
60
|
+
focusEditor(editor, imageEndSelection);
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
const p = generateEmptyElement(ELEMENT_TYPE.PARAGRAPH);
|
|
@@ -65,11 +67,14 @@ export const insertImage = function (editor, srcList, selection) {
|
|
|
65
67
|
Transforms.insertNodes(editor, p, {
|
|
66
68
|
at: [path[0] + 1]
|
|
67
69
|
});
|
|
70
|
+
focusEditor(editor, [path[0] + 1, 2]);
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
73
|
Transforms.insertNodes(editor, imageNodes, {
|
|
71
74
|
at: validSelection
|
|
72
75
|
});
|
|
76
|
+
const imageEndSelection = Path.next(Path.next(path));
|
|
77
|
+
focusEditor(editor, imageEndSelection);
|
|
73
78
|
};
|
|
74
79
|
export const updateImage = (editor, data) => {
|
|
75
80
|
Transforms.setNodes(editor, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { Range } from '@seafile/slate';
|
|
3
4
|
import { unWrapLinkNode } from './helpers';
|
|
@@ -8,20 +9,20 @@ import { ELEMENT_TYPE } from '../../constants';
|
|
|
8
9
|
class LinkHoverMenuComponent extends React.Component {
|
|
9
10
|
constructor(props) {
|
|
10
11
|
super(props);
|
|
11
|
-
this
|
|
12
|
+
_defineProperty(this, "registerEventHandle", () => {
|
|
12
13
|
document.addEventListener('click', this.onHideLinkMenu);
|
|
13
|
-
};
|
|
14
|
-
this
|
|
14
|
+
});
|
|
15
|
+
_defineProperty(this, "unregisterEventHandle", () => {
|
|
15
16
|
document.removeEventListener('click', this.onHideLinkMenu);
|
|
16
|
-
};
|
|
17
|
-
this
|
|
17
|
+
});
|
|
18
|
+
_defineProperty(this, "onHideLinkMenu", () => {
|
|
18
19
|
this.setState({
|
|
19
20
|
isShowLinkMenu: false
|
|
20
21
|
}, () => {
|
|
21
22
|
this.unregisterEventHandle();
|
|
22
23
|
});
|
|
23
|
-
};
|
|
24
|
-
this
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "onLinkClick", e => {
|
|
25
26
|
const {
|
|
26
27
|
top,
|
|
27
28
|
left,
|
|
@@ -41,14 +42,14 @@ class LinkHoverMenuComponent extends React.Component {
|
|
|
41
42
|
setTimeout(() => {
|
|
42
43
|
this.registerEventHandle();
|
|
43
44
|
}, 0);
|
|
44
|
-
};
|
|
45
|
-
this
|
|
45
|
+
});
|
|
46
|
+
_defineProperty(this, "deleteLink", () => {
|
|
46
47
|
const {
|
|
47
48
|
editor
|
|
48
49
|
} = this.props;
|
|
49
50
|
unWrapLinkNode(editor);
|
|
50
|
-
};
|
|
51
|
-
this
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(this, "openDialog", () => {
|
|
52
53
|
const {
|
|
53
54
|
element
|
|
54
55
|
} = this.props;
|
|
@@ -56,7 +57,7 @@ class LinkHoverMenuComponent extends React.Component {
|
|
|
56
57
|
type: ELEMENT_TYPE.LINK,
|
|
57
58
|
element
|
|
58
59
|
});
|
|
59
|
-
};
|
|
60
|
+
});
|
|
60
61
|
this.state = {
|
|
61
62
|
isShowLinkMenu: false,
|
|
62
63
|
menuPosition: null
|