@seafile/seafile-editor 1.0.33 → 1.0.35
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/extension/plugins/header/menu/index.js +1 -1
- package/dist/extension/plugins/image/menu/index.js +4 -5
- package/dist/extension/plugins/image/render-element/style.css +1 -0
- package/dist/extension/plugins/link/render-elem/style.css +1 -0
- package/dist/extension/plugins/list/plugin/index.js +20 -4
- package/dist/extension/plugins/list/plugin/shortcut.js +5 -2
- package/dist/extension/plugins/table/menu/index.js +7 -6
- package/dist/pages/email-editor-dialog/index.js +15 -5
- package/dist/pages/longtext-editor-dialog/index.js +24 -6
- package/dist/pages/longtext-editor-dialog/style.css +34 -1
- package/dist/pages/markdown-preview/index.js +3 -3
- package/dist/utils/get-preview-content.js +4 -6
- package/package.json +1 -1
|
@@ -13,8 +13,8 @@ var _helper = require("../helper");
|
|
|
13
13
|
var _tooltip = _interopRequireDefault(require("../../../commons/tooltip"));
|
|
14
14
|
var _keyboard = require("../../../constants/keyboard");
|
|
15
15
|
var _constants = require("../../../constants");
|
|
16
|
-
require("./style.css");
|
|
17
16
|
var _constants2 = require("../../../../constants");
|
|
17
|
+
require("./style.css");
|
|
18
18
|
const headerPopoverShowerList = [_constants.ELementTypes.PARAGRAPH, ..._constants.HEADERS];
|
|
19
19
|
const HeaderMenu = _ref => {
|
|
20
20
|
let {
|
|
@@ -26,20 +26,19 @@ const ImageMenu = _ref => {
|
|
|
26
26
|
isShowImagePopover ? registerEventHandler() : unregisterEventHandler();
|
|
27
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
28
|
}, [isShowImagePopover]);
|
|
29
|
+
const handleChangePopoverDisplayed = (0, _react.useCallback)(() => {
|
|
30
|
+
setIsShowImagePopover(!isShowImagePopover);
|
|
31
|
+
}, [isShowImagePopover]);
|
|
29
32
|
const onMousedown = (0, _react.useCallback)(e => {
|
|
30
33
|
e.stopPropagation();
|
|
31
34
|
handleChangePopoverDisplayed();
|
|
32
|
-
|
|
33
|
-
}, []);
|
|
35
|
+
}, [handleChangePopoverDisplayed]);
|
|
34
36
|
const registerEventHandler = () => {
|
|
35
37
|
return window.addEventListener('click', handleChangePopoverDisplayed);
|
|
36
38
|
};
|
|
37
39
|
const unregisterEventHandler = () => {
|
|
38
40
|
return window.removeEventListener('click', handleChangePopoverDisplayed);
|
|
39
41
|
};
|
|
40
|
-
const handleChangePopoverDisplayed = (0, _react.useCallback)(() => {
|
|
41
|
-
setIsShowImagePopover(!isShowImagePopover);
|
|
42
|
-
}, [isShowImagePopover]);
|
|
43
42
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_commons.MenuItem, Object.assign({
|
|
44
43
|
type: Image,
|
|
45
44
|
isRichEditor: isRichEditor,
|
|
@@ -13,11 +13,15 @@ var _insertFragmentList = require("./insert-fragment-list");
|
|
|
13
13
|
var _normalizeList = require("./normalize-list");
|
|
14
14
|
var _constant = require("../constant");
|
|
15
15
|
var _shortcut = require("./shortcut");
|
|
16
|
+
var _queries = require("../queries");
|
|
17
|
+
var _core = require("../../../core");
|
|
18
|
+
var _transforms = require("../transforms");
|
|
19
|
+
var _elementTypes = require("../../../constants/element-types");
|
|
16
20
|
const withList = editor => {
|
|
17
21
|
const {
|
|
18
22
|
insertBreak,
|
|
19
23
|
onHotKeyDown,
|
|
20
|
-
|
|
24
|
+
deleteBackward,
|
|
21
25
|
insertText
|
|
22
26
|
} = editor;
|
|
23
27
|
const newEditor = editor;
|
|
@@ -26,16 +30,28 @@ const withList = editor => {
|
|
|
26
30
|
insertBreak();
|
|
27
31
|
return;
|
|
28
32
|
};
|
|
29
|
-
newEditor.
|
|
33
|
+
newEditor.deleteBackward = unit => {
|
|
30
34
|
const {
|
|
31
35
|
selection
|
|
32
36
|
} = newEditor;
|
|
33
37
|
if (selection === null) {
|
|
34
|
-
|
|
38
|
+
deleteBackward(unit);
|
|
35
39
|
return;
|
|
36
40
|
}
|
|
41
|
+
const res = (0, _queries.getListItemEntry)(editor, {});
|
|
42
|
+
if (res && (0, _core.isSelectionAtBlockStart)(editor, {
|
|
43
|
+
match: node => node.type === _elementTypes.LIST_ITEM
|
|
44
|
+
})) {
|
|
45
|
+
const {
|
|
46
|
+
list,
|
|
47
|
+
listItem
|
|
48
|
+
} = res;
|
|
49
|
+
if ((0, _core.isFirstNode)(list[0], listItem[0]) && !(0, _queries.isListNested)(editor, list[1])) {
|
|
50
|
+
(0, _transforms.unwrapList)(editor);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
37
53
|
// nothing todo
|
|
38
|
-
|
|
54
|
+
deleteBackward(unit);
|
|
39
55
|
};
|
|
40
56
|
newEditor.insertText = text => {
|
|
41
57
|
const isPreventInsert = (0, _shortcut.handleShortcut)(newEditor, text);
|
|
@@ -49,9 +49,12 @@ const handleShortcut = (editor, text) => {
|
|
|
49
49
|
if (matchOrderListResult.index !== 0) return false;
|
|
50
50
|
if (matchedOrderListText !== '1.') return false;
|
|
51
51
|
const previousNodePath = (0, _core.getPreviousPath)(aboveNodePath);
|
|
52
|
-
|
|
52
|
+
let previousNodeEntry = null;
|
|
53
|
+
if (previousNodePath) {
|
|
54
|
+
previousNodeEntry = _slate.Editor.node(editor, previousNodePath);
|
|
55
|
+
}
|
|
53
56
|
// If the previous node is not an ordered list and is start with `1.`,transforms to ordered list
|
|
54
|
-
if (
|
|
57
|
+
if (!previousNodePath || previousNodeEntry[0].type !== _elementTypes.ORDERED_LIST) {
|
|
55
58
|
// Delete shortcut key text
|
|
56
59
|
_slate.Transforms.delete(editor, {
|
|
57
60
|
at: range
|
|
@@ -25,25 +25,26 @@ const TableMenu = _ref => {
|
|
|
25
25
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
26
|
const disabled = (0, _react.useMemo)(() => (0, _helper.isDisabled)(editor, readonly), [editor.selection, readonly]);
|
|
27
27
|
const isActive = (0, _helper.isInTable)(editor);
|
|
28
|
-
const
|
|
28
|
+
const onHideSelector = (0, _react.useCallback)(() => {
|
|
29
29
|
setIsOpenTableSizeSelector(false);
|
|
30
30
|
unregisterEvent();
|
|
31
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
32
|
}, [setIsOpenTableSizeSelector]);
|
|
33
33
|
const registerEvent = (0, _react.useCallback)(() => {
|
|
34
|
-
window.addEventListener('click',
|
|
34
|
+
window.addEventListener('click', onHideSelector);
|
|
35
35
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
36
|
}, []);
|
|
37
37
|
const unregisterEvent = (0, _react.useCallback)(() => {
|
|
38
|
-
window.removeEventListener('click',
|
|
38
|
+
window.removeEventListener('click', onHideSelector);
|
|
39
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
40
|
}, []);
|
|
41
41
|
const onMouseDown = (0, _react.useCallback)(e => {
|
|
42
42
|
e.stopPropagation();
|
|
43
43
|
e.preventDefault();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const newState = !isOpenTableSizeSelector;
|
|
45
|
+
setIsOpenTableSizeSelector(newState);
|
|
46
|
+
newState ? registerEvent() : unregisterEvent();
|
|
47
|
+
}, [isOpenTableSizeSelector, registerEvent, unregisterEvent]);
|
|
47
48
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
48
49
|
className: "sf-table-menu-item"
|
|
49
50
|
}, /*#__PURE__*/_react.default.createElement(_menuItem.default, Object.assign({
|
|
@@ -40,9 +40,14 @@ function EmailEditorDialog(_ref) {
|
|
|
40
40
|
setValueChanged(false);
|
|
41
41
|
}, [isValueChanged, onSaveEditorValue, readOnly]);
|
|
42
42
|
const onCloseToggle = (0, _react.useCallback)(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
let value = null;
|
|
44
|
+
if (!readOnly && isValueChanged) {
|
|
45
|
+
var _editorRef$current2;
|
|
46
|
+
const slateNodes = (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.getSlateValue();
|
|
47
|
+
value = slateNodes;
|
|
48
|
+
}
|
|
49
|
+
onCloseEditorDialog(value);
|
|
50
|
+
}, [isValueChanged, onCloseEditorDialog, readOnly]);
|
|
46
51
|
const onHotKey = (0, _react.useCallback)(event => {
|
|
47
52
|
if (event.keyCode === 27) {
|
|
48
53
|
event.stopPropagation();
|
|
@@ -87,8 +92,8 @@ function EmailEditorDialog(_ref) {
|
|
|
87
92
|
setTimeout(() => {
|
|
88
93
|
// update parent's component cache value
|
|
89
94
|
if (onEditorValueChanged && typeof onEditorValueChanged === 'function') {
|
|
90
|
-
var _editorRef$
|
|
91
|
-
const slateNodes = (_editorRef$
|
|
95
|
+
var _editorRef$current3;
|
|
96
|
+
const slateNodes = (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.getSlateValue();
|
|
92
97
|
onEditorValueChanged(slateNodes);
|
|
93
98
|
}
|
|
94
99
|
setValueChanged(true);
|
|
@@ -98,6 +103,10 @@ function EmailEditorDialog(_ref) {
|
|
|
98
103
|
event.stopPropagation();
|
|
99
104
|
onHotKey(event);
|
|
100
105
|
};
|
|
106
|
+
const onEmailContainerClick = event => {
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
109
|
+
};
|
|
101
110
|
const headerClass = (0, _classnames.default)('longtext-header-container', {
|
|
102
111
|
'longtext-header-container-border': readOnly || isWindowsWechat
|
|
103
112
|
});
|
|
@@ -128,6 +137,7 @@ function EmailEditorDialog(_ref) {
|
|
|
128
137
|
isWindowsWechat: isWindowsWechat
|
|
129
138
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
130
139
|
onKeyDown: onContainerKeyDown,
|
|
140
|
+
onClick: onEmailContainerClick,
|
|
131
141
|
className: contentClass
|
|
132
142
|
}, /*#__PURE__*/_react.default.createElement(_seatableEditor.default, {
|
|
133
143
|
ref: editorRef,
|
|
@@ -54,9 +54,27 @@ function LongTextEditorDialog(_ref) {
|
|
|
54
54
|
setValueChanged(false);
|
|
55
55
|
}, [isValueChanged, onSaveEditorValue, readOnly]);
|
|
56
56
|
const onCloseToggle = (0, _react.useCallback)(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
let value = null;
|
|
58
|
+
if (!readOnly && isValueChanged) {
|
|
59
|
+
var _editorRef$current3, _editorRef$current4;
|
|
60
|
+
const markdownString = (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.getValue();
|
|
61
|
+
const slateNodes = (_editorRef$current4 = editorRef.current) === null || _editorRef$current4 === void 0 ? void 0 : _editorRef$current4.getSlateValue();
|
|
62
|
+
const {
|
|
63
|
+
previewText,
|
|
64
|
+
images,
|
|
65
|
+
links,
|
|
66
|
+
checklist
|
|
67
|
+
} = (0, _getPreviewContent.default)(slateNodes, false);
|
|
68
|
+
value = {
|
|
69
|
+
text: markdownString,
|
|
70
|
+
preview: previewText,
|
|
71
|
+
images: images,
|
|
72
|
+
links: links,
|
|
73
|
+
checklist
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
onCloseEditorDialog(value);
|
|
77
|
+
}, [isValueChanged, onCloseEditorDialog, readOnly]);
|
|
60
78
|
const onHotKey = (0, _react.useCallback)(event => {
|
|
61
79
|
if (event.keyCode === 27) {
|
|
62
80
|
event.stopPropagation();
|
|
@@ -101,9 +119,9 @@ function LongTextEditorDialog(_ref) {
|
|
|
101
119
|
setTimeout(() => {
|
|
102
120
|
// update parent's component cache value
|
|
103
121
|
if (onEditorValueChanged && typeof onEditorValueChanged === 'function') {
|
|
104
|
-
var _editorRef$
|
|
105
|
-
const markdownString = (_editorRef$
|
|
106
|
-
const slateNodes = (_editorRef$
|
|
122
|
+
var _editorRef$current5, _editorRef$current6;
|
|
123
|
+
const markdownString = (_editorRef$current5 = editorRef.current) === null || _editorRef$current5 === void 0 ? void 0 : _editorRef$current5.getValue();
|
|
124
|
+
const slateNodes = (_editorRef$current6 = editorRef.current) === null || _editorRef$current6 === void 0 ? void 0 : _editorRef$current6.getSlateValue();
|
|
107
125
|
const {
|
|
108
126
|
previewText,
|
|
109
127
|
images,
|
|
@@ -112,6 +112,10 @@
|
|
|
112
112
|
box-shadow: none;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
.longtext-content-container .sf-slate-editor-content {
|
|
116
|
+
height: calc(100% - 34px);
|
|
117
|
+
}
|
|
118
|
+
|
|
115
119
|
.longtext-content-container .sf-slate-editor-toolbar .sf-menu-group {
|
|
116
120
|
padding: 4px 0 4px 8px;
|
|
117
121
|
}
|
|
@@ -150,6 +154,7 @@
|
|
|
150
154
|
padding: 16px;
|
|
151
155
|
height: auto;
|
|
152
156
|
min-height: 100% !important;
|
|
157
|
+
margin: 0 !important;
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
.longtext-content-container .sf-simple-slate-editor-container .article > div[role="textbox"] > :first-child {
|
|
@@ -166,4 +171,32 @@
|
|
|
166
171
|
|
|
167
172
|
.longtext-content-container .sf-slate-editor-toolbar button:focus {
|
|
168
173
|
outline: none;
|
|
169
|
-
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.longtext-content-container .sf-image-wrapper .full-screen {
|
|
177
|
+
position: absolute;
|
|
178
|
+
display: flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: center;
|
|
181
|
+
height: 28px;
|
|
182
|
+
width: 28px;
|
|
183
|
+
line-height: 28px;
|
|
184
|
+
top: 10px;
|
|
185
|
+
right: 10px;
|
|
186
|
+
padding: 0px;
|
|
187
|
+
box-shadow: none;
|
|
188
|
+
border-radius: 3px;
|
|
189
|
+
border: none;
|
|
190
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
191
|
+
user-select: none !important;
|
|
192
|
+
z-index: 1000;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.longtext-content-container .sf-image-wrapper .full-screen .iconfont {
|
|
196
|
+
color: #fff;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.longtext-content-container .sf-image-wrapper .full-screen:hover {
|
|
200
|
+
display: flex;
|
|
201
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
202
|
+
}
|
|
@@ -8,8 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _loading = _interopRequireDefault(require("../../containers/loading"));
|
|
11
|
-
var _markdownView = _interopRequireDefault(require("../markdown-view"));
|
|
12
11
|
var _slateConvert = require("../../slate-convert");
|
|
12
|
+
var _slateViewer = _interopRequireDefault(require("../../editors/slate-viewer"));
|
|
13
13
|
require("./style.css");
|
|
14
14
|
// Windows old Wechat (3.0 or earlier) inner core is chrome 53 and don't support ECMA6, can't use seafile-editor markdownViewer
|
|
15
15
|
// Windows new Wechat (lastest version 3.3.5) support seafile-editor markdownViewer
|
|
@@ -57,8 +57,8 @@ class MarkdownPreview extends _react.default.PureComponent {
|
|
|
57
57
|
dangerouslySetInnerHTML: {
|
|
58
58
|
__html: this.state.innerHtml
|
|
59
59
|
}
|
|
60
|
-
}), !isWindowsWechat && /*#__PURE__*/_react.default.createElement(
|
|
61
|
-
value: value,
|
|
60
|
+
}), !isWindowsWechat && /*#__PURE__*/_react.default.createElement(_slateViewer.default, {
|
|
61
|
+
value: (0, _slateConvert.mdStringToSlate)(value),
|
|
62
62
|
isShowOutline: isShowOutline
|
|
63
63
|
}));
|
|
64
64
|
}
|
|
@@ -54,6 +54,10 @@ const getPreviewText = (content, previewContent) => {
|
|
|
54
54
|
};
|
|
55
55
|
const getTextOfNode = node => {
|
|
56
56
|
let text = '';
|
|
57
|
+
if (node.type === 'check_list_item') {
|
|
58
|
+
text += '';
|
|
59
|
+
return text;
|
|
60
|
+
}
|
|
57
61
|
for (let index = 0; index < node.children.length; index++) {
|
|
58
62
|
const currentNode = node.children[index];
|
|
59
63
|
const {
|
|
@@ -61,12 +65,6 @@ const getTextOfNode = node => {
|
|
|
61
65
|
} = currentNode;
|
|
62
66
|
if (type === 'link') {
|
|
63
67
|
text += '';
|
|
64
|
-
} else if (type === 'check_list_item') {
|
|
65
|
-
if (Reflect.has(currentNode, 'checked')) {
|
|
66
|
-
text += '';
|
|
67
|
-
} else {
|
|
68
|
-
text += _slate.Node.string(currentNode) + ' ';
|
|
69
|
-
}
|
|
70
68
|
} else {
|
|
71
69
|
text += _slate.Node.string(currentNode) + ' ';
|
|
72
70
|
}
|