@seafile/sdoc-editor 0.4.35 → 0.4.37
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/components/global-comment/index.js +1 -2
- package/dist/basic-sdk/comment/helper.js +2 -2
- package/dist/basic-sdk/comment/utils/index.js +16 -13
- package/dist/basic-sdk/editor/editable-article.js +1 -1
- package/dist/basic-sdk/editor/sdoc-editor.js +1 -2
- package/dist/basic-sdk/extension/commons/element-popover/index.js +3 -2
- package/dist/basic-sdk/extension/commons/history-files/index.js +13 -1
- package/dist/basic-sdk/extension/commons/menu/menu-group.js +3 -2
- package/dist/basic-sdk/extension/constants/font.js +1 -0
- package/dist/basic-sdk/extension/constants/index.js +1 -0
- 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/callout/render-elem/index.js +2 -0
- 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 +4 -2
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +2 -0
- package/dist/basic-sdk/extension/plugins/file-link/helpers.js +1 -0
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +21 -20
- package/dist/basic-sdk/extension/plugins/html/helper.js +1 -0
- 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/image/hover-menu/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/link/helpers.js +1 -0
- 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/sdoc-link/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/helpers.js +1 -0
- 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 +9 -9
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/column-resize-handler.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/row-resize-handler.js +2 -3
- package/dist/basic-sdk/extension/plugins/table/render/table-header/index.css +4 -1
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +1 -1
- package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +7 -6
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +1 -0
- 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/dom-utils.js +2 -2
- 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/get-event-transfer.js +3 -1
- package/dist/utils/index.js +6 -6
- 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,8 +1,7 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
|
-
import { useSlateStatic } from '@seafile/slate-react';
|
|
5
|
-
import { ReactEditor } from '@seafile/slate-react';
|
|
4
|
+
import { useSlateStatic, ReactEditor } from '@seafile/slate-react';
|
|
6
5
|
import { ElementPopover } from '../../../extension/commons';
|
|
7
6
|
import EventBus from '../../../utils/event-bus';
|
|
8
7
|
import useCommentList from '../../hooks/comment-hooks/use-comment-list';
|
|
@@ -13,8 +13,8 @@ export const getSelectionRange = () => {
|
|
|
13
13
|
return null;
|
|
14
14
|
};
|
|
15
15
|
export const getCursorPosition = () => {
|
|
16
|
-
let x = 0
|
|
17
|
-
|
|
16
|
+
let x = 0;
|
|
17
|
+
let y = 0;
|
|
18
18
|
let range = getSelectionRange();
|
|
19
19
|
if (range) {
|
|
20
20
|
const rect = range.getBoundingClientRect();
|
|
@@ -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,
|
|
@@ -100,7 +101,9 @@ class CommentUtilities {
|
|
|
100
101
|
content,
|
|
101
102
|
nodeType
|
|
102
103
|
} = _ref2;
|
|
103
|
-
let spanNode1
|
|
104
|
+
let spanNode1;
|
|
105
|
+
let spanNode2;
|
|
106
|
+
let imageContainer;
|
|
104
107
|
if (nodeType === 'image') {
|
|
105
108
|
spanNode1 = document.createElement('div');
|
|
106
109
|
spanNode1.className = 'image-container';
|
|
@@ -136,8 +139,8 @@ class CommentUtilities {
|
|
|
136
139
|
selection.addRange(range);
|
|
137
140
|
}
|
|
138
141
|
return range;
|
|
139
|
-
};
|
|
140
|
-
this
|
|
142
|
+
});
|
|
143
|
+
_defineProperty(this, "onSelectParticipant", _ref3 => {
|
|
141
144
|
let {
|
|
142
145
|
selection,
|
|
143
146
|
range,
|
|
@@ -171,7 +174,7 @@ class CommentUtilities {
|
|
|
171
174
|
commentRef.current.focus();
|
|
172
175
|
}
|
|
173
176
|
return newRange;
|
|
174
|
-
};
|
|
177
|
+
});
|
|
175
178
|
/**
|
|
176
179
|
* get the index of '@' from anchor position.
|
|
177
180
|
* @param {*} anchorPosition '@text|anchor position|'
|
|
@@ -180,7 +183,7 @@ class CommentUtilities {
|
|
|
180
183
|
* e.g. '@abc|anchor position|' // 0
|
|
181
184
|
* '@123 @|anchor position| @abc' // 5
|
|
182
185
|
*/
|
|
183
|
-
this
|
|
186
|
+
_defineProperty(this, "getAtIndexWithAnchorPosition", (anchorPosition, text) => {
|
|
184
187
|
let atIndex = -1;
|
|
185
188
|
for (let i = anchorPosition - 1; i > -1; i--) {
|
|
186
189
|
if (text[i] === '@') {
|
|
@@ -189,8 +192,8 @@ class CommentUtilities {
|
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
return atIndex;
|
|
192
|
-
};
|
|
193
|
-
this
|
|
195
|
+
});
|
|
196
|
+
_defineProperty(this, "onPaste", (event, callBack) => {
|
|
194
197
|
event.stopPropagation();
|
|
195
198
|
let cliperData = getEventTransfer(event);
|
|
196
199
|
if (cliperData.files) {
|
|
@@ -211,7 +214,7 @@ class CommentUtilities {
|
|
|
211
214
|
document.execCommand('paste', false, text);
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
|
-
};
|
|
217
|
+
});
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
export const focusToCommentElement = (editor, element) => {
|
|
@@ -5,7 +5,7 @@ import deepCopy from 'deep-copy';
|
|
|
5
5
|
import context from '../../context';
|
|
6
6
|
import CommonLoading from '../../components/common-loading';
|
|
7
7
|
import { INTERNAL_EVENT, PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
8
|
-
import { createDefaultEditor } from '../extension';
|
|
8
|
+
import { createDefaultEditor, HeaderToolbar } from '../extension';
|
|
9
9
|
import withNodeId from '../node-id';
|
|
10
10
|
import { withSocketIO } from '../socket';
|
|
11
11
|
import { focusEditor } from '../extension/core';
|
|
@@ -13,7 +13,6 @@ import InsertElementDialog from '../extension/commons/insert-element-dialog';
|
|
|
13
13
|
import { EditorContainer, EditorContent } from '../layout';
|
|
14
14
|
import EditableArticle from './editable-article';
|
|
15
15
|
import { ColorProvider } from '../hooks/use-color-context';
|
|
16
|
-
import { HeaderToolbar } from '../extension';
|
|
17
16
|
import ReadOnlyArticle from '../views/readonly-article';
|
|
18
17
|
import { isMobile } from '../../utils';
|
|
19
18
|
import { CollaboratorsProvider } from '../../hooks';
|
|
@@ -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;
|
|
@@ -8,6 +8,7 @@ import debounce from 'lodash.debounce';
|
|
|
8
8
|
import toaster from '../../../../components/toast';
|
|
9
9
|
import EventBus from '../../../utils/event-bus';
|
|
10
10
|
import context from '../../../../context';
|
|
11
|
+
import { focusEditor } from '../../core';
|
|
11
12
|
import { insertSdocFileLink } from '../../plugins/sdoc-link/helpers';
|
|
12
13
|
import { LocalStorage, isEnglish } from '../../../../utils';
|
|
13
14
|
import { INTERNAL_EVENT } from '../../../constants';
|
|
@@ -83,6 +84,16 @@ const HistoryFiles = _ref => {
|
|
|
83
84
|
};
|
|
84
85
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
86
|
}, []);
|
|
87
|
+
const onKeydown = useCallback(e => {
|
|
88
|
+
const {
|
|
89
|
+
key,
|
|
90
|
+
target
|
|
91
|
+
} = e;
|
|
92
|
+
if (key === 'Backspace' && !target.selectionStart && !target.selectionEnd && !target.value) {
|
|
93
|
+
focusEditor(editor);
|
|
94
|
+
closeDialog();
|
|
95
|
+
}
|
|
96
|
+
}, [closeDialog, editor]);
|
|
86
97
|
const onCompositionStart = e => {
|
|
87
98
|
e.stopPropagation();
|
|
88
99
|
historyFilesInputRef.current.typing = true;
|
|
@@ -167,7 +178,8 @@ const HistoryFiles = _ref => {
|
|
|
167
178
|
autoComplete: "off",
|
|
168
179
|
onChange: debounce(onSearch, 200),
|
|
169
180
|
onCompositionStart: onCompositionStart,
|
|
170
|
-
onCompositionEnd: onCompositionEnd
|
|
181
|
+
onCompositionEnd: onCompositionEnd,
|
|
182
|
+
onKeyDown: onKeydown
|
|
171
183
|
}), /*#__PURE__*/React.createElement("div", {
|
|
172
184
|
className: "sdoc-history-files-content"
|
|
173
185
|
}, header.length !== 0 && /*#__PURE__*/React.createElement("div", {
|
|
@@ -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;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// extension plugin
|
|
2
2
|
import * as ELEMENT_TYPE from './element-type';
|
|
3
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
3
4
|
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT } from './element-type';
|
|
4
5
|
export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
|
|
5
6
|
export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
|
|
@@ -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 {
|
|
@@ -72,6 +72,7 @@ const renderCallout = (_ref, editor) => {
|
|
|
72
72
|
top: menuTop,
|
|
73
73
|
left: left // left = code-block left distance
|
|
74
74
|
};
|
|
75
|
+
|
|
75
76
|
setPopoverPosition(newMenuPosition);
|
|
76
77
|
}
|
|
77
78
|
}, [isShowColorSelector, readOnly]);
|
|
@@ -107,6 +108,7 @@ const renderCallout = (_ref, editor) => {
|
|
|
107
108
|
top: menuTop,
|
|
108
109
|
left: left // left = callout left distance
|
|
109
110
|
};
|
|
111
|
+
|
|
110
112
|
setPopoverPosition(newMenuPosition);
|
|
111
113
|
setIsShowColorSelector(true);
|
|
112
114
|
}, [readOnly]);
|
|
@@ -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 {
|
|
@@ -23,6 +23,7 @@ export const isMenuDisabled = (editor, readonly) => {
|
|
|
23
23
|
if (isMatch) return false; // enable
|
|
24
24
|
return true; // disable
|
|
25
25
|
};
|
|
26
|
+
|
|
26
27
|
export const getSelectCodeElem = editor => {
|
|
27
28
|
const codeNode = getSelectedNodeByType(editor, CODE_BLOCK);
|
|
28
29
|
if (codeNode == null) return null;
|
|
@@ -32,8 +33,8 @@ export const changeToCodeBlock = function (editor) {
|
|
|
32
33
|
let language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
33
34
|
let position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INSERT_POSITION.CURRENT;
|
|
34
35
|
// Summarizes the strings for the selected highest-level node
|
|
35
|
-
let strArr = []
|
|
36
|
-
|
|
36
|
+
let strArr = [];
|
|
37
|
+
let path = Editor.path(editor, editor.selection);
|
|
37
38
|
if (position === INSERT_POSITION.AFTER) {
|
|
38
39
|
strArr = [''];
|
|
39
40
|
} else {
|
|
@@ -62,6 +63,7 @@ export const changeToCodeBlock = function (editor) {
|
|
|
62
63
|
style: {
|
|
63
64
|
white_space: 'nowrap' // default nowrap
|
|
64
65
|
},
|
|
66
|
+
|
|
65
67
|
children: [{
|
|
66
68
|
id: slugid.nice(),
|
|
67
69
|
type: CODE_LINE,
|
|
@@ -81,6 +81,7 @@ const CodeBlock = _ref => {
|
|
|
81
81
|
top: menuTop,
|
|
82
82
|
left: left // left = code-block left distance
|
|
83
83
|
};
|
|
84
|
+
|
|
84
85
|
setMenuPosition(newMenuPosition);
|
|
85
86
|
}
|
|
86
87
|
setShowHoverMenu(true);
|
|
@@ -104,6 +105,7 @@ const CodeBlock = _ref => {
|
|
|
104
105
|
top: menuTop,
|
|
105
106
|
left: left // left = code-block left distance
|
|
106
107
|
};
|
|
108
|
+
|
|
107
109
|
setMenuPosition(newMenuPosition);
|
|
108
110
|
}
|
|
109
111
|
}, [readOnly, showHoverMenu]);
|
|
@@ -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, {
|
|
@@ -71,9 +71,9 @@ const ImageHoverMenu = _ref => {
|
|
|
71
71
|
const beforeLeaf = newNodeEntry[0].children.slice(0, index);
|
|
72
72
|
const imageLeaf = newNodeEntry[0].children.slice(index, index + 1);
|
|
73
73
|
const afterLeaf = newNodeEntry[0].children.slice(index + 1);
|
|
74
|
-
let beforeNode = null
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
let beforeNode = null;
|
|
75
|
+
let centerNode = null;
|
|
76
|
+
let afterNode = null;
|
|
77
77
|
let p = path[0];
|
|
78
78
|
if (!beforeLeaf.every(item => {
|
|
79
79
|
var _item$text;
|