@seafile/seafile-editor 1.0.82-alpha3 → 1.0.82-alpha4
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/simple-slate-editor /index.js +2 -2
- package/dist/extension/editor.js +8 -1
- package/dist/extension/index.js +6 -0
- package/dist/extension/toolbar/inline-toolbar/index.js +3 -1
- package/dist/index.js +7 -0
- package/dist/pages/inline-longtext-editor/index.css +60 -0
- package/dist/pages/inline-longtext-editor/index.js +68 -57
- package/package.json +1 -1
|
@@ -29,11 +29,11 @@ const SimpleSlateEditor = _ref => {
|
|
|
29
29
|
onExpandEditorToggle
|
|
30
30
|
} = _ref;
|
|
31
31
|
const [slateValue, setSlateValue] = (0, _react.useState)(value);
|
|
32
|
-
const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(_extension.baseEditor, {
|
|
32
|
+
const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(isInline ? _extension.inlineEditor : _extension.baseEditor, {
|
|
33
33
|
editorApi,
|
|
34
34
|
onSave,
|
|
35
35
|
columns
|
|
36
|
-
}), [columns, editorApi, onSave]);
|
|
36
|
+
}), [columns, editorApi, onSave, isInline]);
|
|
37
37
|
const eventProxy = (0, _react.useMemo)(() => {
|
|
38
38
|
return new _eventHandler.default(editor);
|
|
39
39
|
}, [editor]);
|
package/dist/extension/editor.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.createSlateEditor = exports.baseEditor = void 0;
|
|
7
|
+
exports.inlineEditor = exports.createSlateEditor = exports.baseEditor = void 0;
|
|
8
8
|
var _slate = require("slate");
|
|
9
9
|
var _slateHistory = require("slate-history");
|
|
10
10
|
var _slateReact = require("slate-react");
|
|
@@ -16,6 +16,13 @@ const baseEditor = exports.baseEditor = _plugins.default.reduce((editor, pluginI
|
|
|
16
16
|
}
|
|
17
17
|
return editor;
|
|
18
18
|
}, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
|
|
19
|
+
const inlineEditor = exports.inlineEditor = _plugins.default.reduce((editor, pluginItem) => {
|
|
20
|
+
const withPlugin = pluginItem.editorPlugin;
|
|
21
|
+
if (withPlugin) {
|
|
22
|
+
return withPlugin(editor);
|
|
23
|
+
}
|
|
24
|
+
return editor;
|
|
25
|
+
}, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
|
|
19
26
|
const createSlateEditor = () => {
|
|
20
27
|
const editor = _plugins.default.reduce((editor, pluginItem) => {
|
|
21
28
|
const withPlugin = pluginItem.editorPlugin;
|
package/dist/extension/index.js
CHANGED
|
@@ -40,6 +40,12 @@ Object.defineProperty(exports, "createSlateEditor", {
|
|
|
40
40
|
return _editor.createSlateEditor;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
Object.defineProperty(exports, "inlineEditor", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _editor.inlineEditor;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
43
49
|
Object.defineProperty(exports, "isEmptyParagraph", {
|
|
44
50
|
enumerable: true,
|
|
45
51
|
get: function () {
|
|
@@ -72,7 +72,9 @@ const InlineToolbar = _ref => {
|
|
|
72
72
|
onClick: onHelpIconToggle
|
|
73
73
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
74
74
|
className: "iconfont icon-use-help"
|
|
75
|
-
})))), onExpandEditorToggle && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, onExpandEditorToggle && /*#__PURE__*/_react.default.createElement(_commons.ExpandEditorMenu,
|
|
75
|
+
})))), onExpandEditorToggle && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, onExpandEditorToggle && /*#__PURE__*/_react.default.createElement(_commons.ExpandEditorMenu, Object.assign({}, commonProps, {
|
|
76
|
+
onExpandEditorToggle: onExpandEditorToggle
|
|
77
|
+
}))), isShowHelpModal && /*#__PURE__*/_react.default.createElement(_shortcutDialog.default, {
|
|
76
78
|
isRichEditor: isRichEditor,
|
|
77
79
|
toggleShortcutDialog: onHelpIconToggle
|
|
78
80
|
}));
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "EventBus", {
|
|
|
22
22
|
return _eventBus.default;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "InlineLongTextEditor", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _inlineLongtextEditor.default;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
25
31
|
Object.defineProperty(exports, "LongTextEditorDialog", {
|
|
26
32
|
enumerable: true,
|
|
27
33
|
get: function () {
|
|
@@ -106,6 +112,7 @@ var _markdownView = _interopRequireDefault(require("./pages/markdown-view"));
|
|
|
106
112
|
var _simpleEditor = _interopRequireDefault(require("./pages/simple-editor"));
|
|
107
113
|
var _emailEditorDialog = _interopRequireDefault(require("./pages/email-editor-dialog"));
|
|
108
114
|
var _longtextEditorDialog = _interopRequireDefault(require("./pages/longtext-editor-dialog"));
|
|
115
|
+
var _inlineLongtextEditor = _interopRequireDefault(require("./pages/inline-longtext-editor"));
|
|
109
116
|
var _markdownPreview = _interopRequireDefault(require("./pages/markdown-preview"));
|
|
110
117
|
var _seatableEditor = _interopRequireDefault(require("./pages/seatable-editor"));
|
|
111
118
|
var _seatableViewer = _interopRequireDefault(require("./pages/seatable-viewer"));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.sf-inline-editor-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
border: 1px solid rgba(0, 40, 100, .12);
|
|
5
|
+
border-radius: 3px;
|
|
6
|
+
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sf-inline-editor-container .sf-simple-slate-editor-container {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sf-inline-editor-container .sf-slate-editor-toolbar {
|
|
15
|
+
border-top-left-radius: 3px;
|
|
16
|
+
border-top-right-radius: 3px;
|
|
17
|
+
height: 33px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.sf-inline-editor-container .sf-slate-editor-content {
|
|
21
|
+
border-bottom-left-radius: 3px;
|
|
22
|
+
border-bottom-right-radius: 3px;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sf-inline-editor-container .sf-slate-editor-toolbar .sf-menu-group:last-child {
|
|
27
|
+
border-right: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sf-inline-editor-container .sf-simple-slate-editor-container .sf-slate-editor-content {
|
|
31
|
+
flex: 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* preview */
|
|
35
|
+
.sf-inline-editor-container .longtext-preview-container {
|
|
36
|
+
padding: 10px;
|
|
37
|
+
background-color: #fff;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sf-inline-editor-container .longtext-preview-container .article h1 {
|
|
41
|
+
margin-top: 1.2em;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.sf-inline-editor-container .longtext-preview-container .article p {
|
|
45
|
+
margin-top: 0.8em;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sf-slate-editor-toolbar .sf-menu-group {
|
|
49
|
+
padding-top: 4px;
|
|
50
|
+
padding-bottom: 4px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.sf-editor-menu-popover .popover-inner {
|
|
54
|
+
display: flex;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sf-editor-menu-popover .popover-inner .sf-menu-group {
|
|
58
|
+
padding-top: 4px;
|
|
59
|
+
padding-bottom: 4px;
|
|
60
|
+
}
|
|
@@ -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 _classnames = _interopRequireDefault(require("classnames"));
|
|
11
10
|
var _simpleEditor = _interopRequireDefault(require("../simple-editor"));
|
|
12
11
|
var _getPreviewContent = _interopRequireDefault(require("../../utils/get-preview-content"));
|
|
13
12
|
var _getBrowserInfo = _interopRequireDefault(require("../../utils/get-browser-Info"));
|
|
@@ -18,106 +17,118 @@ const InlineLongTextEditor = _ref => {
|
|
|
18
17
|
let {
|
|
19
18
|
lang,
|
|
20
19
|
headerName,
|
|
21
|
-
value,
|
|
20
|
+
value: propsValue,
|
|
22
21
|
autoSave = true,
|
|
23
22
|
saveDelay = 60000,
|
|
24
23
|
isCheckBrowser = false,
|
|
25
24
|
editorApi,
|
|
26
|
-
onSaveEditorValue
|
|
27
|
-
onEditorValueChanged
|
|
25
|
+
onSaveEditorValue
|
|
28
26
|
} = _ref;
|
|
27
|
+
const editorContainerRef = (0, _react.useRef)(null);
|
|
29
28
|
const editorRef = (0, _react.useRef)(null);
|
|
29
|
+
const [style, setStyle] = (0, _react.useState)({});
|
|
30
30
|
const [isValueChanged, setValueChanged] = (0, _react.useState)(false);
|
|
31
31
|
const [showExpandEditor, setShowExpandEditor] = (0, _react.useState)(false);
|
|
32
|
+
const [value, setValue] = (0, _react.useState)(typeof propsValue === 'string' ? {
|
|
33
|
+
text: propsValue
|
|
34
|
+
} : propsValue);
|
|
32
35
|
const {
|
|
33
|
-
isValidBrowser,
|
|
34
36
|
isWindowsWechat
|
|
35
37
|
} = (0, _react.useMemo)(() => {
|
|
36
38
|
return (0, _getBrowserInfo.default)(isCheckBrowser);
|
|
37
39
|
}, [isCheckBrowser]);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
previewText,
|
|
45
|
-
images,
|
|
46
|
-
links,
|
|
47
|
-
checklist
|
|
48
|
-
} = (0, _getPreviewContent.default)(slateNodes, false);
|
|
49
|
-
onSaveEditorValue({
|
|
50
|
-
text: markdownString,
|
|
51
|
-
preview: previewText,
|
|
52
|
-
images: images,
|
|
53
|
-
links: links,
|
|
54
|
-
checklist
|
|
55
|
-
});
|
|
40
|
+
const saveValue = (0, _react.useCallback)(function (value) {
|
|
41
|
+
let save = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
42
|
+
setValueChanged(true);
|
|
43
|
+
setValue(value);
|
|
44
|
+
if (!save) return;
|
|
45
|
+
onSaveEditorValue && onSaveEditorValue(value);
|
|
56
46
|
setValueChanged(false);
|
|
57
|
-
}, [
|
|
47
|
+
}, [onSaveEditorValue]);
|
|
48
|
+
const handelAutoSave = (0, _react.useCallback)(() => {
|
|
49
|
+
if (!isValueChanged) return;
|
|
50
|
+
saveValue(value, true);
|
|
51
|
+
}, [isValueChanged, value, saveValue]);
|
|
58
52
|
const onContentChanged = (0, _react.useCallback)(() => {
|
|
59
53
|
// delay to update editor's content
|
|
60
54
|
setTimeout(() => {
|
|
55
|
+
var _editorRef$current, _editorRef$current2;
|
|
61
56
|
// update parent's component cache value
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
setValueChanged(true);
|
|
57
|
+
const markdownString = (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.getValue();
|
|
58
|
+
const slateNodes = (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.getSlateValue();
|
|
59
|
+
const {
|
|
60
|
+
previewText,
|
|
61
|
+
images,
|
|
62
|
+
links,
|
|
63
|
+
checklist
|
|
64
|
+
} = (0, _getPreviewContent.default)(slateNodes, false);
|
|
65
|
+
const value = {
|
|
66
|
+
text: markdownString,
|
|
67
|
+
preview: previewText,
|
|
68
|
+
images: images,
|
|
69
|
+
links: links,
|
|
70
|
+
checklist
|
|
71
|
+
};
|
|
72
|
+
saveValue(value);
|
|
81
73
|
}, 0);
|
|
82
|
-
}, [
|
|
74
|
+
}, [saveValue]);
|
|
83
75
|
const openEditorDialog = (0, _react.useCallback)(() => {
|
|
76
|
+
const {
|
|
77
|
+
height
|
|
78
|
+
} = editorContainerRef.current.getBoundingClientRect();
|
|
79
|
+
setStyle({
|
|
80
|
+
height
|
|
81
|
+
});
|
|
84
82
|
setShowExpandEditor(true);
|
|
85
|
-
}, []);
|
|
86
|
-
const onCloseEditorDialog = (0, _react.useCallback)(
|
|
87
|
-
|
|
83
|
+
}, [editorContainerRef]);
|
|
84
|
+
const onCloseEditorDialog = (0, _react.useCallback)(value => {
|
|
85
|
+
value && saveValue(value);
|
|
86
|
+
setStyle({});
|
|
88
87
|
setShowExpandEditor(false);
|
|
89
|
-
}, [
|
|
88
|
+
}, [saveValue]);
|
|
90
89
|
(0, _react.useEffect)(() => {
|
|
91
90
|
let timer = null;
|
|
92
91
|
if (autoSave) {
|
|
93
92
|
timer = setTimeout(() => {
|
|
94
|
-
|
|
93
|
+
handelAutoSave();
|
|
95
94
|
}, saveDelay);
|
|
96
95
|
}
|
|
97
96
|
return () => {
|
|
98
97
|
timer && clearTimeout(timer);
|
|
99
98
|
};
|
|
100
|
-
}, [autoSave, saveDelay,
|
|
99
|
+
}, [autoSave, saveDelay, handelAutoSave]);
|
|
101
100
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
102
|
-
className: "sf-inline-editor-container"
|
|
103
|
-
|
|
101
|
+
className: "sf-inline-editor-container",
|
|
102
|
+
style: style,
|
|
103
|
+
ref: editorContainerRef
|
|
104
|
+
}, !showExpandEditor && !isWindowsWechat ? /*#__PURE__*/_react.default.createElement(_simpleEditor.default, {
|
|
104
105
|
isInline: true,
|
|
105
106
|
ref: editorRef,
|
|
106
|
-
value: value,
|
|
107
|
+
value: value.text,
|
|
107
108
|
editorApi: editorApi,
|
|
108
109
|
onContentChanged: onContentChanged,
|
|
109
110
|
onExpandEditorToggle: openEditorDialog
|
|
110
|
-
})
|
|
111
|
+
}) : /*#__PURE__*/_react.default.createElement("div", {
|
|
112
|
+
className: "sf-simple-slate-editor-container"
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
114
|
+
className: "sf-slate-editor-toolbar"
|
|
115
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
116
|
+
className: "sf-slate-editor-content"
|
|
117
|
+
}, /*#__PURE__*/_react.default.createElement(_markdownPreview.default, {
|
|
118
|
+
isWindowsWechat: isWindowsWechat,
|
|
119
|
+
value: value.text,
|
|
120
|
+
isShowOutline: false
|
|
121
|
+
})))), showExpandEditor && /*#__PURE__*/_react.default.createElement(_longtextEditorDialog.default, {
|
|
111
122
|
lang: lang,
|
|
112
123
|
readOnly: false,
|
|
113
124
|
headerName: headerName,
|
|
114
|
-
value: value,
|
|
125
|
+
value: value.text,
|
|
115
126
|
autoSave: autoSave,
|
|
116
127
|
saveDelay: saveDelay,
|
|
117
128
|
isCheckBrowser: isCheckBrowser,
|
|
118
129
|
editorApi: editorApi,
|
|
119
|
-
onSaveEditorValue:
|
|
120
|
-
onEditorValueChanged:
|
|
130
|
+
onSaveEditorValue: saveValue,
|
|
131
|
+
onEditorValueChanged: saveValue,
|
|
121
132
|
onCloseEditorDialog: onCloseEditorDialog
|
|
122
133
|
}));
|
|
123
134
|
};
|