@seafile/seafile-editor 1.0.85-beta7 → 1.0.85-beta9
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 +9 -22
- package/dist/editors/simple-slate-editor/index.js +4 -17
- package/dist/pages/longtext-inline-editor/fallback-editor.js +82 -0
- package/dist/pages/longtext-inline-editor/index.css +6 -0
- package/dist/pages/longtext-inline-editor/index.js +18 -32
- package/dist/pages/longtext-inline-editor/{editor.js → normal-editor.js} +11 -13
- package/dist/pages/simple-editor.js +5 -0
- package/package.json +1 -1
- package/dist/pages/longtext-inline-editor/formatter/index.css +0 -31
- package/dist/pages/longtext-inline-editor/formatter/index.js +0 -66
- package/dist/pages/longtext-inline-editor/simple-editor.js +0 -65
- /package/dist/editors/inline-editor/{style.css → index.css} +0 -0
|
@@ -15,12 +15,11 @@ var _eventHandler = _interopRequireDefault(require("../../utils/event-handler"))
|
|
|
15
15
|
var _withPropsEditor = _interopRequireDefault(require("./with-props-editor"));
|
|
16
16
|
var _core = require("../../extension/core");
|
|
17
17
|
var _common = require("../../utils/common");
|
|
18
|
-
require("./
|
|
18
|
+
require("./index.css");
|
|
19
19
|
const isMacOS = (0, _common.isMac)();
|
|
20
20
|
const InlineEditor = _ref => {
|
|
21
21
|
let {
|
|
22
|
-
|
|
23
|
-
focusNodePath,
|
|
22
|
+
isFocus,
|
|
24
23
|
value,
|
|
25
24
|
editorApi,
|
|
26
25
|
onSave,
|
|
@@ -32,13 +31,13 @@ const InlineEditor = _ref => {
|
|
|
32
31
|
const [slateValue, setSlateValue] = (0, _react.useState)(value);
|
|
33
32
|
const editor = (0, _react.useMemo)(() => {
|
|
34
33
|
const baseEditor = (0, _extension.inlineEditor)();
|
|
35
|
-
if (
|
|
34
|
+
if (isFocus) return (0, _withPropsEditor.default)(baseEditor, {
|
|
36
35
|
editorApi,
|
|
37
36
|
onSave,
|
|
38
37
|
columns
|
|
39
38
|
});
|
|
40
39
|
return baseEditor;
|
|
41
|
-
}, [columns, editorApi, onSave,
|
|
40
|
+
}, [columns, editorApi, onSave, isFocus]);
|
|
42
41
|
const eventProxy = (0, _react.useMemo)(() => {
|
|
43
42
|
return new _eventHandler.default(editor);
|
|
44
43
|
}, [editor]);
|
|
@@ -54,21 +53,9 @@ const InlineEditor = _ref => {
|
|
|
54
53
|
const eventBus = _eventBus.default.getInstance();
|
|
55
54
|
eventBus.dispatch('change');
|
|
56
55
|
}, [editor, onContentChanged]);
|
|
57
|
-
const
|
|
56
|
+
const focusFirstNode = (0, _react.useCallback)(editor => {
|
|
58
57
|
const [firstNode] = editor.children;
|
|
59
58
|
if (!firstNode) return;
|
|
60
|
-
if (focusNodePath) {
|
|
61
|
-
const customFocusNodePath = (0, _core.getNode)(editor, focusNodePath);
|
|
62
|
-
if (customFocusNodePath) {
|
|
63
|
-
const startOfFirstNode = _slate.Editor.start(editor, focusNodePath);
|
|
64
|
-
const range = {
|
|
65
|
-
anchor: startOfFirstNode,
|
|
66
|
-
focus: startOfFirstNode
|
|
67
|
-
};
|
|
68
|
-
(0, _core.focusEditor)(editor, range);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
59
|
const [firstNodeFirstChild] = firstNode.children;
|
|
73
60
|
if (firstNodeFirstChild) {
|
|
74
61
|
const startOfFirstNode = _slate.Editor.start(editor, [0, 0]);
|
|
@@ -104,7 +91,7 @@ const InlineEditor = _ref => {
|
|
|
104
91
|
});
|
|
105
92
|
const timer = setTimeout(() => {
|
|
106
93
|
editor.forceNormalize = false;
|
|
107
|
-
|
|
94
|
+
focusFirstNode(editor);
|
|
108
95
|
}, 300);
|
|
109
96
|
return () => {
|
|
110
97
|
editor.forceNormalize = false;
|
|
@@ -127,12 +114,12 @@ const InlineEditor = _ref => {
|
|
|
127
114
|
const onEditorClick = (0, _react.useCallback)(() => {
|
|
128
115
|
const value = editor.children;
|
|
129
116
|
if (value.length === 1 && _slate.Node.string(value[0]).length === 0) {
|
|
130
|
-
|
|
117
|
+
focusFirstNode(editor);
|
|
131
118
|
}
|
|
132
|
-
}, [editor,
|
|
119
|
+
}, [editor, focusFirstNode]);
|
|
133
120
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
134
121
|
className: "sf-simple-slate-editor-container"
|
|
135
|
-
},
|
|
122
|
+
}, isFocus && /*#__PURE__*/_react.default.createElement(_extension.InlineToolbar, {
|
|
136
123
|
editor: editor,
|
|
137
124
|
isSupportFormula: isSupportFormula,
|
|
138
125
|
isSupportColumn: !!columns,
|
|
@@ -19,7 +19,6 @@ require("./style.css");
|
|
|
19
19
|
const isMacOS = (0, _common.isMac)();
|
|
20
20
|
const SimpleSlateEditor = _ref => {
|
|
21
21
|
let {
|
|
22
|
-
focusNodePath,
|
|
23
22
|
value,
|
|
24
23
|
editorApi,
|
|
25
24
|
onSave,
|
|
@@ -48,21 +47,9 @@ const SimpleSlateEditor = _ref => {
|
|
|
48
47
|
const eventBus = _eventBus.default.getInstance();
|
|
49
48
|
eventBus.dispatch('change');
|
|
50
49
|
}, [editor, onContentChanged]);
|
|
51
|
-
const
|
|
50
|
+
const focusFirstNode = (0, _react.useCallback)(editor => {
|
|
52
51
|
const [firstNode] = editor.children;
|
|
53
52
|
if (!firstNode) return;
|
|
54
|
-
if (focusNodePath) {
|
|
55
|
-
const customFocusNodePath = (0, _core.getNode)(editor, focusNodePath);
|
|
56
|
-
if (customFocusNodePath) {
|
|
57
|
-
const startOfFirstNode = _slate.Editor.start(editor, focusNodePath);
|
|
58
|
-
const range = {
|
|
59
|
-
anchor: startOfFirstNode,
|
|
60
|
-
focus: startOfFirstNode
|
|
61
|
-
};
|
|
62
|
-
(0, _core.focusEditor)(editor, range);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
53
|
const [firstNodeFirstChild] = firstNode.children;
|
|
67
54
|
if (firstNodeFirstChild) {
|
|
68
55
|
const startOfFirstNode = _slate.Editor.start(editor, [0, 0]);
|
|
@@ -98,7 +85,7 @@ const SimpleSlateEditor = _ref => {
|
|
|
98
85
|
});
|
|
99
86
|
const timer = setTimeout(() => {
|
|
100
87
|
editor.forceNormalize = false;
|
|
101
|
-
|
|
88
|
+
focusFirstNode(editor);
|
|
102
89
|
}, 300);
|
|
103
90
|
return () => {
|
|
104
91
|
editor.forceNormalize = false;
|
|
@@ -121,9 +108,9 @@ const SimpleSlateEditor = _ref => {
|
|
|
121
108
|
const onEditorClick = (0, _react.useCallback)(() => {
|
|
122
109
|
const value = editor.children;
|
|
123
110
|
if (value.length === 1 && _slate.Node.string(value[0]).length === 0) {
|
|
124
|
-
|
|
111
|
+
focusFirstNode(editor);
|
|
125
112
|
}
|
|
126
|
-
}, [editor,
|
|
113
|
+
}, [editor, focusFirstNode]);
|
|
127
114
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
128
115
|
className: "sf-simple-slate-editor-container"
|
|
129
116
|
}, /*#__PURE__*/_react.default.createElement(_extension.Toolbar, {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
11
|
+
var _markdownPreview = _interopRequireDefault(require("../markdown-preview"));
|
|
12
|
+
const FallbackEditor = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
isShowEditor,
|
|
15
|
+
value: propsValue,
|
|
16
|
+
onChange: propsOnChange,
|
|
17
|
+
closeEditor
|
|
18
|
+
} = _ref;
|
|
19
|
+
const [value, setValue] = (0, _react.useState)(propsValue);
|
|
20
|
+
const showEditorRef = (0, _react.useRef)(false);
|
|
21
|
+
const inputRef = (0, _react.useRef)(null);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
if (isShowEditor === showEditorRef.current) return;
|
|
24
|
+
if (isShowEditor && !showEditorRef.current) {
|
|
25
|
+
setTimeout(() => inputRef.current.focus());
|
|
26
|
+
}
|
|
27
|
+
}, [isShowEditor]);
|
|
28
|
+
const onChange = (0, _react.useCallback)(event => {
|
|
29
|
+
const newValue = event.target.value;
|
|
30
|
+
if (newValue === value) return;
|
|
31
|
+
setValue(newValue);
|
|
32
|
+
propsOnChange && propsOnChange({
|
|
33
|
+
text: newValue,
|
|
34
|
+
preview: newValue ? newValue.slice(0, 30) : '',
|
|
35
|
+
links: [],
|
|
36
|
+
images: []
|
|
37
|
+
});
|
|
38
|
+
}, [value, propsOnChange]);
|
|
39
|
+
const onKeyDown = (0, _react.useCallback)(e => {
|
|
40
|
+
let {
|
|
41
|
+
selectionStart,
|
|
42
|
+
selectionEnd,
|
|
43
|
+
value
|
|
44
|
+
} = e.currentTarget;
|
|
45
|
+
if ((0, _isHotkey.default)('enter', e)) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
closeEditor && closeEditor();
|
|
48
|
+
inputRef.current.blur();
|
|
49
|
+
} else if (e.keyCode === 37 && selectionStart === 0 || e.keyCode === 39 && selectionEnd === value.length) {
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
}
|
|
52
|
+
}, [closeEditor]);
|
|
53
|
+
const onPaste = (0, _react.useCallback)(e => {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
}, []);
|
|
56
|
+
const onCut = (0, _react.useCallback)(e => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
}, []);
|
|
59
|
+
if (!isShowEditor) {
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
61
|
+
className: "sf-long-text-inline-fallback-editor-container"
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
+
className: "sf-simple-slate-editor-container"
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
+
className: "sf-slate-editor-content"
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement(_markdownPreview.default, {
|
|
67
|
+
value: value,
|
|
68
|
+
isShowOutline: false
|
|
69
|
+
}))));
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("textarea", {
|
|
72
|
+
className: "form-control sf-long-text-inline-fallback-editor-container",
|
|
73
|
+
ref: inputRef,
|
|
74
|
+
rows: 5,
|
|
75
|
+
value: value,
|
|
76
|
+
onChange: onChange,
|
|
77
|
+
onKeyDown: onKeyDown,
|
|
78
|
+
onPaste: onPaste,
|
|
79
|
+
onCut: onCut
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
var _default = exports.default = FallbackEditor;
|
|
@@ -9,11 +9,10 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
11
11
|
var _clickOutside = _interopRequireDefault(require("./click-outside"));
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var _slateConvert = require("../../slate-convert");
|
|
12
|
+
var _normalEditor = _interopRequireDefault(require("./normal-editor"));
|
|
13
|
+
var _fallbackEditor = _interopRequireDefault(require("./fallback-editor"));
|
|
15
14
|
var _getBrowserInfo = _interopRequireDefault(require("../../utils/get-browser-Info"));
|
|
16
|
-
|
|
15
|
+
require("./index.css");
|
|
17
16
|
const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
18
17
|
let {
|
|
19
18
|
autoSave,
|
|
@@ -26,43 +25,25 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
26
25
|
onSaveEditorValue,
|
|
27
26
|
editorApi
|
|
28
27
|
} = _ref;
|
|
29
|
-
const [
|
|
28
|
+
const [isFocusEditor, setFocusEditor] = (0, _react.useState)(false);
|
|
30
29
|
const valueRef = (0, _react.useRef)(typeof value === 'string' ? {
|
|
31
30
|
text: value
|
|
32
31
|
} : value);
|
|
33
32
|
const longTextValueChangedRef = (0, _react.useRef)(false);
|
|
34
|
-
const [focusNodePath, setFocusNodePath] = (0, _react.useState)([0, 0]);
|
|
35
33
|
const {
|
|
36
34
|
isWindowsWechat
|
|
37
35
|
} = (0, _react.useMemo)(() => {
|
|
38
36
|
return (0, _getBrowserInfo.default)(isCheckBrowser);
|
|
39
37
|
}, [isCheckBrowser]);
|
|
40
|
-
const openEditor = (0, _react.useCallback)(
|
|
41
|
-
|
|
42
|
-
setFocusNodePath(focusNodePath);
|
|
43
|
-
setShowEditor(true);
|
|
38
|
+
const openEditor = (0, _react.useCallback)(() => {
|
|
39
|
+
setFocusEditor(true);
|
|
44
40
|
}, []);
|
|
45
41
|
const closeEditor = (0, _react.useCallback)(() => {
|
|
46
42
|
if (longTextValueChangedRef.current) {
|
|
47
43
|
onSaveEditorValue(valueRef.current);
|
|
48
44
|
}
|
|
49
|
-
|
|
45
|
+
setFocusEditor(false);
|
|
50
46
|
}, [longTextValueChangedRef, valueRef, onSaveEditorValue]);
|
|
51
|
-
const getAttributeNode = (0, _react.useCallback)(function (node, attribute) {
|
|
52
|
-
let deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4;
|
|
53
|
-
if (!node || !node.getAttribute) return null;
|
|
54
|
-
if (deep === -1) return null;
|
|
55
|
-
if (node.getAttribute(attribute)) return node.getAttribute(attribute);
|
|
56
|
-
if (node.parentNode) return getAttributeNode(node.parentNode, attribute, deep--);
|
|
57
|
-
}, []);
|
|
58
|
-
const previewClick = (0, _react.useCallback)((event, richValue) => {
|
|
59
|
-
if (event.target.nodeName === 'A') return;
|
|
60
|
-
const nodeId = getAttributeNode(event.target, 'data-id');
|
|
61
|
-
onPreviewClick && onPreviewClick();
|
|
62
|
-
openEditor((0, _extension.getNodePathById)({
|
|
63
|
-
children: richValue
|
|
64
|
-
}, nodeId));
|
|
65
|
-
}, [onPreviewClick, openEditor, getAttributeNode]);
|
|
66
47
|
const onEditorValueChanged = (0, _react.useCallback)(value => {
|
|
67
48
|
valueRef.current = value;
|
|
68
49
|
longTextValueChangedRef.current = true;
|
|
@@ -84,21 +65,26 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
84
65
|
};
|
|
85
66
|
}, [openEditor, closeEditor]);
|
|
86
67
|
const onClick = (0, _react.useCallback)(() => {
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
if (isFocusEditor) return;
|
|
69
|
+
onPreviewClick && onPreviewClick();
|
|
70
|
+
setFocusEditor(true);
|
|
71
|
+
}, [isFocusEditor, onPreviewClick]);
|
|
90
72
|
return /*#__PURE__*/_react.default.createElement(_clickOutside.default, {
|
|
91
73
|
onClickOutside: closeEditor
|
|
92
74
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
93
75
|
className: "w-100",
|
|
94
76
|
onKeyDown: onHotKey,
|
|
95
77
|
onClick: onClick
|
|
96
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
97
|
-
|
|
78
|
+
}, isWindowsWechat ? /*#__PURE__*/_react.default.createElement(_fallbackEditor.default, {
|
|
79
|
+
isShowEditor: isFocusEditor,
|
|
80
|
+
value: valueRef.current.text,
|
|
81
|
+
onChange: onEditorValueChanged,
|
|
82
|
+
closeEditor: closeEditor
|
|
83
|
+
}) : /*#__PURE__*/_react.default.createElement(_normalEditor.default, {
|
|
84
|
+
isFocus: isFocusEditor,
|
|
98
85
|
lang: lang,
|
|
99
86
|
isWindowsWechat: isWindowsWechat,
|
|
100
87
|
headerName: headerName,
|
|
101
|
-
focusNodePath: focusNodePath,
|
|
102
88
|
value: valueRef.current.text,
|
|
103
89
|
autoSave: autoSave,
|
|
104
90
|
saveDelay: saveDelay,
|
|
@@ -7,19 +7,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _simpleEditor = _interopRequireDefault(require("../simple-editor"));
|
|
11
12
|
var _getPreviewContent = _interopRequireDefault(require("../../utils/get-preview-content"));
|
|
12
13
|
var _markdownPreview = _interopRequireDefault(require("../markdown-preview"));
|
|
13
14
|
var _longtextEditorDialog = _interopRequireDefault(require("../longtext-editor-dialog"));
|
|
14
|
-
|
|
15
|
-
const Editor = _ref => {
|
|
15
|
+
const NormalEditor = _ref => {
|
|
16
16
|
let {
|
|
17
|
-
|
|
17
|
+
isFocus,
|
|
18
18
|
lang,
|
|
19
19
|
headerName,
|
|
20
20
|
value: propsValue,
|
|
21
|
-
isWindowsWechat,
|
|
22
|
-
focusNodePath,
|
|
23
21
|
autoSave = true,
|
|
24
22
|
saveDelay = 60000,
|
|
25
23
|
isCheckBrowser = false,
|
|
@@ -97,14 +95,15 @@ const Editor = _ref => {
|
|
|
97
95
|
};
|
|
98
96
|
}, [autoSave, saveDelay, handelAutoSave]);
|
|
99
97
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
100
|
-
className:
|
|
98
|
+
className: (0, _classnames.default)('sf-long-text-inline-editor-container', {
|
|
99
|
+
'preview': !isFocus
|
|
100
|
+
}),
|
|
101
101
|
style: style,
|
|
102
102
|
ref: editorContainerRef
|
|
103
|
-
}, !showExpandEditor
|
|
104
|
-
isInline: true,
|
|
105
|
-
showTitle: showTitle,
|
|
106
|
-
focusNodePath: focusNodePath,
|
|
103
|
+
}, !showExpandEditor ? /*#__PURE__*/_react.default.createElement(_simpleEditor.default, {
|
|
107
104
|
ref: editorRef,
|
|
105
|
+
isFocus: isFocus,
|
|
106
|
+
isInline: true,
|
|
108
107
|
value: value.text,
|
|
109
108
|
onSave: handelAutoSave,
|
|
110
109
|
editorApi: editorApi,
|
|
@@ -117,7 +116,6 @@ const Editor = _ref => {
|
|
|
117
116
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
118
117
|
className: "sf-slate-editor-content"
|
|
119
118
|
}, /*#__PURE__*/_react.default.createElement(_markdownPreview.default, {
|
|
120
|
-
isWindowsWechat: isWindowsWechat,
|
|
121
119
|
value: value.text,
|
|
122
120
|
isShowOutline: false
|
|
123
121
|
})))), showExpandEditor && /*#__PURE__*/_react.default.createElement(_longtextEditorDialog.default, {
|
|
@@ -134,4 +132,4 @@ const Editor = _ref => {
|
|
|
134
132
|
onCloseEditorDialog: onCloseEditorDialog
|
|
135
133
|
}));
|
|
136
134
|
};
|
|
137
|
-
var _default = exports.default =
|
|
135
|
+
var _default = exports.default = NormalEditor;
|
|
@@ -11,8 +11,10 @@ var _loading = _interopRequireDefault(require("../containers/loading"));
|
|
|
11
11
|
var _slateConvert = require("../slate-convert");
|
|
12
12
|
var _useMathjax = _interopRequireDefault(require("../hooks/use-mathjax"));
|
|
13
13
|
var _simpleSlateEditor = _interopRequireDefault(require("../editors/simple-slate-editor"));
|
|
14
|
+
var _inlineEditor = _interopRequireDefault(require("../editors/inline-editor"));
|
|
14
15
|
const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
15
16
|
let {
|
|
17
|
+
isInline,
|
|
16
18
|
isFetching,
|
|
17
19
|
value,
|
|
18
20
|
editorApi,
|
|
@@ -60,6 +62,9 @@ const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
60
62
|
if (isFetching || isLoading || isLoadingMathJax) {
|
|
61
63
|
return /*#__PURE__*/_react.default.createElement(_loading.default, null);
|
|
62
64
|
}
|
|
65
|
+
if (isInline) {
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_inlineEditor.default, props);
|
|
67
|
+
}
|
|
63
68
|
return /*#__PURE__*/_react.default.createElement(_simpleSlateEditor.default, props);
|
|
64
69
|
});
|
|
65
70
|
var _default = exports.default = SimpleEditor;
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
.longtext-preview-container {
|
|
2
|
-
width: 100%;
|
|
3
|
-
height: 100%;
|
|
4
|
-
padding: 16px;
|
|
5
|
-
overflow: auto;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.longtext-preview-container .sf-slate-viewer-scroll-container {
|
|
9
|
-
overflow-y: auto;
|
|
10
|
-
height: fit-content;
|
|
11
|
-
padding: 0;
|
|
12
|
-
background: #fff;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.longtext-preview-container .sf-slate-viewer-article-container {
|
|
16
|
-
height: 100%;
|
|
17
|
-
width: 100%;
|
|
18
|
-
margin: 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.longtext-preview-container .sf-slate-viewer-article-container .article {
|
|
22
|
-
padding: 0;
|
|
23
|
-
height: auto;
|
|
24
|
-
min-height: 100% !important;
|
|
25
|
-
border: 0;
|
|
26
|
-
color: #212529;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.longtext-preview-container .article :first-child {
|
|
30
|
-
margin-top: 0;
|
|
31
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _loading = _interopRequireDefault(require("../../../containers/loading"));
|
|
11
|
-
var _slateConvert = require("../../../slate-convert");
|
|
12
|
-
var _slateViewer = _interopRequireDefault(require("../../../editors/slate-viewer"));
|
|
13
|
-
require("./index.css");
|
|
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
|
-
// Windows new Wechat (lastest version 3.3.5) support seafile-editor markdownViewer
|
|
16
|
-
// so use dangerouslySetInnerHTML to preview
|
|
17
|
-
class Formatter extends _react.default.PureComponent {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
(0, _defineProperty2.default)(this, "convertMarkdown", mdFile => {
|
|
21
|
-
_slateConvert.processor.process(mdFile).then(result => {
|
|
22
|
-
let innerHtml = String(result).replace(/<a /ig, '<a target="_blank" tabindex="-1"');
|
|
23
|
-
this.setState({
|
|
24
|
-
innerHtml
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
this.state = {
|
|
29
|
-
innerHtml: null
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
componentDidMount() {
|
|
33
|
-
const {
|
|
34
|
-
isWindowsWechat,
|
|
35
|
-
value
|
|
36
|
-
} = this.props;
|
|
37
|
-
if (isWindowsWechat) {
|
|
38
|
-
this.convertMarkdown(value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
render() {
|
|
42
|
-
const {
|
|
43
|
-
isWindowsWechat,
|
|
44
|
-
value,
|
|
45
|
-
isShowOutline
|
|
46
|
-
} = this.props;
|
|
47
|
-
const {
|
|
48
|
-
innerHtml
|
|
49
|
-
} = this.state;
|
|
50
|
-
if (isWindowsWechat && innerHtml === null) {
|
|
51
|
-
return /*#__PURE__*/_react.default.createElement(_loading.default, null);
|
|
52
|
-
}
|
|
53
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
54
|
-
className: "longtext-preview-container"
|
|
55
|
-
}, isWindowsWechat && /*#__PURE__*/_react.default.createElement("div", {
|
|
56
|
-
className: "article",
|
|
57
|
-
dangerouslySetInnerHTML: {
|
|
58
|
-
__html: this.state.innerHtml
|
|
59
|
-
}
|
|
60
|
-
}), !isWindowsWechat && /*#__PURE__*/_react.default.createElement(_slateViewer.default, {
|
|
61
|
-
value: value,
|
|
62
|
-
isShowOutline: isShowOutline
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var _default = exports.default = Formatter;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _loading = _interopRequireDefault(require("../../containers/loading"));
|
|
11
|
-
var _slateConvert = require("../../slate-convert");
|
|
12
|
-
var _useMathjax = _interopRequireDefault(require("../../hooks/use-mathjax"));
|
|
13
|
-
var _inlineEditor = _interopRequireDefault(require("../../editors/inline-editor"));
|
|
14
|
-
const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
15
|
-
let {
|
|
16
|
-
isFetching,
|
|
17
|
-
value,
|
|
18
|
-
editorApi,
|
|
19
|
-
mathJaxSource,
|
|
20
|
-
onSave: propsOnSave,
|
|
21
|
-
onContentChanged: propsOnContentChanged,
|
|
22
|
-
...otherProps
|
|
23
|
-
} = _ref;
|
|
24
|
-
const [richValue, setRichValue] = (0, _react.useState)([]);
|
|
25
|
-
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
26
|
-
const {
|
|
27
|
-
isLoadingMathJax
|
|
28
|
-
} = (0, _useMathjax.default)(mathJaxSource);
|
|
29
|
-
(0, _react.useImperativeHandle)(ref, () => {
|
|
30
|
-
return {
|
|
31
|
-
getValue: () => {
|
|
32
|
-
const mdStringValue = (0, _slateConvert.slateToMdString)(richValue);
|
|
33
|
-
return mdStringValue;
|
|
34
|
-
},
|
|
35
|
-
getSlateValue: () => {
|
|
36
|
-
return richValue;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}, [richValue]);
|
|
40
|
-
(0, _react.useEffect)(() => {
|
|
41
|
-
if (!isFetching) {
|
|
42
|
-
const richValue = (0, _slateConvert.mdStringToSlate)(value);
|
|
43
|
-
setRichValue(richValue);
|
|
44
|
-
setIsLoading(false);
|
|
45
|
-
}
|
|
46
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
-
}, [isFetching]);
|
|
48
|
-
const onContentChanged = (0, _react.useCallback)(content => {
|
|
49
|
-
setRichValue(content);
|
|
50
|
-
propsOnContentChanged && propsOnContentChanged();
|
|
51
|
-
}, [propsOnContentChanged]);
|
|
52
|
-
const props = {
|
|
53
|
-
isSupportFormula: !!mathJaxSource,
|
|
54
|
-
value: richValue,
|
|
55
|
-
editorApi: editorApi,
|
|
56
|
-
onSave: propsOnSave,
|
|
57
|
-
onContentChanged: onContentChanged,
|
|
58
|
-
...otherProps
|
|
59
|
-
};
|
|
60
|
-
if (isFetching || isLoading || isLoadingMathJax) {
|
|
61
|
-
return /*#__PURE__*/_react.default.createElement(_loading.default, null);
|
|
62
|
-
}
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement(_inlineEditor.default, props);
|
|
64
|
-
});
|
|
65
|
-
var _default = exports.default = SimpleEditor;
|
|
File without changes
|