@seafile/seafile-editor 2.0.25 → 2.0.26
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/editors/inline-editor/index.js +8 -2
- package/dist/editors/inline-editor/with-props-editor.js +2 -0
- package/dist/extension/plugins/image/helper.js +16 -5
- package/dist/extension/plugins/image/menu/image-menu-popover.js +1 -1
- package/dist/extension/plugins/image/menu/index.js +1 -1
- package/dist/extension/plugins/image/plugin.js +18 -3
- package/dist/pages/longtext-inline-editor/index.js +4 -0
- package/dist/pages/longtext-inline-editor/normal-editor.js +6 -0
- package/package.json +2 -2
|
@@ -18,6 +18,7 @@ var _core = require("../../extension/core");
|
|
|
18
18
|
var _common = require("../../utils/common");
|
|
19
19
|
var _eventTypes = require("../../constants/event-types");
|
|
20
20
|
var _elementTypes = require("../../extension/constants/element-types");
|
|
21
|
+
var _useInsertImage = _interopRequireDefault(require("../../hooks/use-insert-image"));
|
|
21
22
|
require("./index.css");
|
|
22
23
|
const isMacOS = (0, _common.isMac)();
|
|
23
24
|
const InlineEditor = _ref => {
|
|
@@ -29,6 +30,8 @@ const InlineEditor = _ref => {
|
|
|
29
30
|
columns,
|
|
30
31
|
onContentChanged,
|
|
31
32
|
isSupportFormula,
|
|
33
|
+
isSupportFileToLink,
|
|
34
|
+
isSupportMultipleFiles,
|
|
32
35
|
onExpandEditorToggle,
|
|
33
36
|
handelEnableEdit
|
|
34
37
|
} = _ref;
|
|
@@ -39,12 +42,15 @@ const InlineEditor = _ref => {
|
|
|
39
42
|
return (0, _withPropsEditor.default)(baseEditor, {
|
|
40
43
|
editorApi,
|
|
41
44
|
onSave,
|
|
42
|
-
columns
|
|
45
|
+
columns,
|
|
46
|
+
isSupportMultipleFiles,
|
|
47
|
+
isSupportFileToLink
|
|
43
48
|
});
|
|
44
|
-
}, [columns, editorApi, onSave]);
|
|
49
|
+
}, [columns, isSupportFileToLink, isSupportMultipleFiles, editorApi, onSave]);
|
|
45
50
|
const eventProxy = (0, _react.useMemo)(() => {
|
|
46
51
|
return new _eventHandler.default(editor);
|
|
47
52
|
}, [editor]);
|
|
53
|
+
(0, _useInsertImage.default)(editor);
|
|
48
54
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
49
55
|
const onChange = (0, _react.useCallback)(value => {
|
|
50
56
|
setSlateValue(value);
|
|
@@ -16,6 +16,8 @@ const withPropsEditor = function (editor) {
|
|
|
16
16
|
if (props.columns) {
|
|
17
17
|
newEditor.columns = props.columns;
|
|
18
18
|
}
|
|
19
|
+
newEditor.isSupportFileToLink = Boolean(props.isSupportFileToLink);
|
|
20
|
+
newEditor.isSupportMultipleFiles = Boolean(props.isSupportMultipleFiles);
|
|
19
21
|
newEditor.isInlineEditor = true;
|
|
20
22
|
return newEditor;
|
|
21
23
|
};
|
|
@@ -4,13 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateImage = exports.lazyLoadImage = exports.isMenuDisabled = exports.insertSeafileImage = exports.insertImage = exports.
|
|
7
|
+
exports.updateImage = exports.lazyLoadImage = exports.isMenuDisabled = exports.insertSeafileImage = exports.insertImage = exports.handleUpdateFile = exports.getImagesUrlList = void 0;
|
|
8
8
|
var _slate = require("slate");
|
|
9
9
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
10
10
|
var _helper = require("../header/helper");
|
|
11
11
|
var _elementTypes = require("../../constants/element-types");
|
|
12
12
|
var _core = require("../../core");
|
|
13
13
|
var _helpers = require("../code-block/helpers");
|
|
14
|
+
var _helper2 = require("../link/helper");
|
|
14
15
|
const isMenuDisabled = (editor, readonly) => {
|
|
15
16
|
if (readonly) return true;
|
|
16
17
|
const isHeader = (0, _helper.getHeaderType)(editor);
|
|
@@ -91,17 +92,27 @@ const getImagesUrlList = nodes => {
|
|
|
91
92
|
return list;
|
|
92
93
|
};
|
|
93
94
|
exports.getImagesUrlList = getImagesUrlList;
|
|
94
|
-
const
|
|
95
|
+
const handleUpdateFile = async (editor, file, insertPosition) => {
|
|
95
96
|
if (editor.api.uploadLocalImage) {
|
|
96
97
|
try {
|
|
97
|
-
const
|
|
98
|
-
|
|
98
|
+
const url = await editor.api.uploadLocalImage(file);
|
|
99
|
+
const title = file.name;
|
|
100
|
+
if (file.type.includes(_elementTypes.IMAGE)) {
|
|
101
|
+
insertImage(editor, url);
|
|
102
|
+
} else {
|
|
103
|
+
(0, _helper2.insertLink)({
|
|
104
|
+
editor,
|
|
105
|
+
url,
|
|
106
|
+
title,
|
|
107
|
+
insertPosition
|
|
108
|
+
});
|
|
109
|
+
}
|
|
99
110
|
} catch (error) {
|
|
100
111
|
console.log('error', error);
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
};
|
|
104
|
-
exports.
|
|
115
|
+
exports.handleUpdateFile = handleUpdateFile;
|
|
105
116
|
const lazyLoadImage = (url, resolve, reject) => {
|
|
106
117
|
if (!url) {
|
|
107
118
|
reject('img path is require');
|
|
@@ -37,7 +37,7 @@ const ImageMenuPopover = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
37
37
|
}, []);
|
|
38
38
|
const handleUploadLocalImage = (0, _react.useCallback)(async e => {
|
|
39
39
|
const file = e.target.files[0];
|
|
40
|
-
(0, _helper.
|
|
40
|
+
(0, _helper.handleUpdateFile)(editor, file);
|
|
41
41
|
handelClosePopover();
|
|
42
42
|
}, [editor, handelClosePopover]);
|
|
43
43
|
const onToggleImageDialog = (0, _react.useCallback)(() => {
|
|
@@ -37,7 +37,7 @@ const ImageMenu = _ref => {
|
|
|
37
37
|
const handleUploadLocalImage = (0, _react.useCallback)(async e => {
|
|
38
38
|
const file = e.target.files[0];
|
|
39
39
|
if (!file) return;
|
|
40
|
-
(0, _helper.
|
|
40
|
+
(0, _helper.handleUpdateFile)(editor, file);
|
|
41
41
|
e.target.value = null;
|
|
42
42
|
}, [editor]);
|
|
43
43
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
@@ -29,9 +29,24 @@ const withImages = editor => {
|
|
|
29
29
|
return isVoid(element);
|
|
30
30
|
};
|
|
31
31
|
newEditor.insertData = data => {
|
|
32
|
-
if (data.types && data.types.includes('Files') && data.files
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (data.types && data.types.includes('Files') && data.files) {
|
|
33
|
+
if (!newEditor.isSupportMultipleFiles) {
|
|
34
|
+
const file = data.files[0];
|
|
35
|
+
if (!file.type.includes(_elementTypes.IMAGE) && !newEditor.isSupportFileToLink) return;
|
|
36
|
+
(0, _helper.handleUpdateFile)(newEditor, file);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let files = [];
|
|
40
|
+
for (let i = 0; i < data.files.length; i++) {
|
|
41
|
+
const file = data.files[i];
|
|
42
|
+
if (!newEditor.isSupportFileToLink && !file.type.includes(_elementTypes.IMAGE)) continue;
|
|
43
|
+
files.push(file);
|
|
44
|
+
}
|
|
45
|
+
const hasImage = files.some(file => file.type.includes(_elementTypes.IMAGE));
|
|
46
|
+
for (let i = 0; i < files.length; i++) {
|
|
47
|
+
const file = files[i];
|
|
48
|
+
(0, _helper.handleUpdateFile)(newEditor, file, hasImage ? _constants.INSERT_POSITION.AFTER : _constants.INSERT_POSITION.CURRENT);
|
|
49
|
+
}
|
|
35
50
|
return;
|
|
36
51
|
}
|
|
37
52
|
return insertData(data);
|
|
@@ -23,6 +23,8 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
23
23
|
value,
|
|
24
24
|
lang,
|
|
25
25
|
headerName,
|
|
26
|
+
isSupportFileToLink = false,
|
|
27
|
+
isSupportMultipleFiles = false,
|
|
26
28
|
onClick,
|
|
27
29
|
onSaveEditorValue,
|
|
28
30
|
editorApi
|
|
@@ -97,6 +99,8 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
97
99
|
autoSave: autoSave,
|
|
98
100
|
saveDelay: saveDelay,
|
|
99
101
|
isCheckBrowser: isCheckBrowser,
|
|
102
|
+
isSupportFileToLink: isSupportFileToLink,
|
|
103
|
+
isSupportMultipleFiles: isSupportMultipleFiles,
|
|
100
104
|
editorApi: editorApi,
|
|
101
105
|
onSaveEditorValue: onSaveEditorValue,
|
|
102
106
|
onEditorValueChanged: onEditorValueChanged
|
|
@@ -23,6 +23,8 @@ const NormalEditor = _ref => {
|
|
|
23
23
|
autoSave = true,
|
|
24
24
|
saveDelay = 60000,
|
|
25
25
|
isCheckBrowser = false,
|
|
26
|
+
isSupportFileToLink = false,
|
|
27
|
+
isSupportMultipleFiles = false,
|
|
26
28
|
editorApi,
|
|
27
29
|
onSaveEditorValue,
|
|
28
30
|
onEditorValueChanged
|
|
@@ -110,6 +112,8 @@ const NormalEditor = _ref => {
|
|
|
110
112
|
ref: editorRef,
|
|
111
113
|
enableEdit: enableEdit,
|
|
112
114
|
isInline: true,
|
|
115
|
+
isSupportFileToLink: isSupportFileToLink,
|
|
116
|
+
isSupportMultipleFiles: isSupportMultipleFiles,
|
|
113
117
|
value: valueRef.current.text,
|
|
114
118
|
handelEnableEdit: handelEnableEdit,
|
|
115
119
|
onSave: handelAutoSave,
|
|
@@ -128,6 +132,8 @@ const NormalEditor = _ref => {
|
|
|
128
132
|
})))), showExpandEditor && /*#__PURE__*/_react.default.createElement(_longtextEditorDialog.default, {
|
|
129
133
|
lang: lang,
|
|
130
134
|
readOnly: false,
|
|
135
|
+
isSupportFileToLink: isSupportFileToLink,
|
|
136
|
+
isSupportMultipleFiles: isSupportMultipleFiles,
|
|
131
137
|
headerName: headerName,
|
|
132
138
|
value: valueRef.current.text,
|
|
133
139
|
autoSave: autoSave,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/seafile-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react-i18next": "12.1.4",
|
|
65
65
|
"react-router": "6.16.0",
|
|
66
66
|
"react-router-dom": "6.16.0",
|
|
67
|
-
"seafile-js": "0.2.
|
|
67
|
+
"seafile-js": "0.2.238",
|
|
68
68
|
"style-loader": "3.3.3",
|
|
69
69
|
"terser-webpack-plugin": "5.3.9",
|
|
70
70
|
"url-loader": "4.1.1",
|