@seafile/seafile-editor 1.0.32-7 → 1.0.32-9
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/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import RichMarkdownEditor from './pages/rich-markdown-editor';
|
|
|
4
4
|
import MarkdownEditor from './pages/markdown-editor';
|
|
5
5
|
import MarkdownViewer from './pages/markdown-view';
|
|
6
6
|
import SimpleEditor from './pages/simple-editor';
|
|
7
|
+
import EmailEditorDialog from './pages/email-editor-dialog';
|
|
7
8
|
import LongTextEditorDialog from './pages/longtext-editor-dialog';
|
|
8
9
|
import MarkdownPreview from './pages/markdown-preview';
|
|
9
10
|
import SeaTableEditor from './pages/seatable-editor';
|
|
@@ -12,4 +13,4 @@ import EventBus from './utils/event-bus';
|
|
|
12
13
|
import { mdStringToSlate, slateToMdString, deserializeHtml, processor } from './slate-convert';
|
|
13
14
|
import { replaceColumnData } from './utils/replace-slate-nodes';
|
|
14
15
|
import getPreviewContent from './utils/get-preview-content';
|
|
15
|
-
export { MarkdownEditor, PlainMarkdownEditor, RichMarkdownEditor, MarkdownViewer, SimpleEditor, SeaTableEditor, SeaTableViewer, LongTextEditorDialog, MarkdownPreview, EXTERNAL_EVENTS, EventBus, mdStringToSlate, slateToMdString, deserializeHtml, processor, replaceColumnData, getPreviewContent };
|
|
16
|
+
export { MarkdownEditor, PlainMarkdownEditor, RichMarkdownEditor, MarkdownViewer, SimpleEditor, SeaTableEditor, SeaTableViewer, EmailEditorDialog, LongTextEditorDialog, MarkdownPreview, EXTERNAL_EVENTS, EventBus, mdStringToSlate, slateToMdString, deserializeHtml, processor, replaceColumnData, getPreviewContent };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import getBrowserInfo from '../../utils/get-browser-Info';
|
|
4
|
+
import LongTextModal from '../longtext-editor-dialog/longtext-modal';
|
|
5
|
+
import BrowserTip from '../longtext-editor-dialog/browser-tip';
|
|
6
|
+
import SeaTableEditor from '../seatable-editor';
|
|
7
|
+
import '../longtext-editor-dialog/style.css';
|
|
8
|
+
export default function EmailEditorDialog(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
lang,
|
|
11
|
+
readOnly = false,
|
|
12
|
+
headerName,
|
|
13
|
+
value,
|
|
14
|
+
columns,
|
|
15
|
+
autoSave = true,
|
|
16
|
+
saveDelay = 60000,
|
|
17
|
+
isCheckBrowser = false,
|
|
18
|
+
editorApi,
|
|
19
|
+
onSaveEditorValue,
|
|
20
|
+
onEditorValueChanged,
|
|
21
|
+
onCloseEditorDialog
|
|
22
|
+
} = _ref;
|
|
23
|
+
const editorRef = useRef(null);
|
|
24
|
+
const [isValueChanged, setValueChanged] = useState(false);
|
|
25
|
+
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
26
|
+
const [dialogStyle, setDialogStyle] = useState({});
|
|
27
|
+
const onUpdateEditorValue = useCallback(() => {
|
|
28
|
+
var _editorRef$current;
|
|
29
|
+
if (!isValueChanged || readOnly) return;
|
|
30
|
+
const slateNodes = (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.getSlateValue();
|
|
31
|
+
onSaveEditorValue(slateNodes);
|
|
32
|
+
setValueChanged(false);
|
|
33
|
+
}, [isValueChanged, onSaveEditorValue, readOnly]);
|
|
34
|
+
const onCloseToggle = useCallback(() => {
|
|
35
|
+
onUpdateEditorValue();
|
|
36
|
+
onCloseEditorDialog();
|
|
37
|
+
}, [onCloseEditorDialog, onUpdateEditorValue]);
|
|
38
|
+
const onHotKey = useCallback(event => {
|
|
39
|
+
if (event.keyCode === 27) {
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
onCloseToggle();
|
|
43
|
+
}
|
|
44
|
+
}, [onCloseToggle]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
let timer = null;
|
|
47
|
+
if (autoSave) {
|
|
48
|
+
timer = setTimeout(() => {
|
|
49
|
+
onUpdateEditorValue();
|
|
50
|
+
}, saveDelay);
|
|
51
|
+
}
|
|
52
|
+
document.addEventListener('keydown', onHotKey);
|
|
53
|
+
return () => {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
document.removeEventListener('keydown', onHotKey);
|
|
56
|
+
};
|
|
57
|
+
}, [autoSave, saveDelay, onUpdateEditorValue, onHotKey]);
|
|
58
|
+
const {
|
|
59
|
+
isValidBrowser,
|
|
60
|
+
isWindowsWechat
|
|
61
|
+
} = useMemo(() => {
|
|
62
|
+
return getBrowserInfo(isCheckBrowser);
|
|
63
|
+
}, [isCheckBrowser]);
|
|
64
|
+
const onFullScreenToggle = useCallback(() => {
|
|
65
|
+
let containerStyle = {};
|
|
66
|
+
if (!isFullScreen) {
|
|
67
|
+
containerStyle = {
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '100%',
|
|
70
|
+
top: 0,
|
|
71
|
+
border: 'none'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
setIsFullScreen(!isFullScreen);
|
|
75
|
+
setDialogStyle(containerStyle);
|
|
76
|
+
}, [isFullScreen]);
|
|
77
|
+
const onContentChanged = useCallback(() => {
|
|
78
|
+
// delay to update editor's content
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
// update parent's component cache value
|
|
81
|
+
if (onEditorValueChanged && typeof onEditorValueChanged === 'function') {
|
|
82
|
+
var _editorRef$current2;
|
|
83
|
+
const slateNodes = (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.getSlateValue();
|
|
84
|
+
onEditorValueChanged(slateNodes);
|
|
85
|
+
}
|
|
86
|
+
setValueChanged(true);
|
|
87
|
+
}, 0);
|
|
88
|
+
}, [onEditorValueChanged]);
|
|
89
|
+
const onContainerKeyDown = event => {
|
|
90
|
+
event.stopPropagation();
|
|
91
|
+
onHotKey(event);
|
|
92
|
+
};
|
|
93
|
+
const headerClass = classNames('longtext-header-container', {
|
|
94
|
+
'longtext-header-container-border': readOnly || isWindowsWechat
|
|
95
|
+
});
|
|
96
|
+
const contentClass = classNames('longtext-content-container', {
|
|
97
|
+
'longtext-container-scroll': readOnly || isWindowsWechat
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/React.createElement(LongTextModal, {
|
|
100
|
+
onModalClick: onCloseToggle
|
|
101
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
style: dialogStyle,
|
|
103
|
+
className: "longtext-dialog-container"
|
|
104
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
className: headerClass
|
|
106
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "longtext-header"
|
|
108
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
109
|
+
className: "longtext-header-name"
|
|
110
|
+
}, headerName), /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: "longtext-header-tool"
|
|
112
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
113
|
+
onClick: onFullScreenToggle,
|
|
114
|
+
className: "longtext-header-tool-item mr-1 dtable-font dtable-icon-full-screen ".concat(isFullScreen ? 'long-text-full-screen' : '')
|
|
115
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
116
|
+
onClick: onCloseToggle,
|
|
117
|
+
className: "longtext-header-tool-item dtable-font dtable-icon-x"
|
|
118
|
+
}))), !isValidBrowser && /*#__PURE__*/React.createElement(BrowserTip, {
|
|
119
|
+
lang: lang,
|
|
120
|
+
isWindowsWechat: isWindowsWechat
|
|
121
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
onKeyDown: onContainerKeyDown,
|
|
123
|
+
className: contentClass
|
|
124
|
+
}, /*#__PURE__*/React.createElement(SeaTableEditor, {
|
|
125
|
+
ref: editorRef,
|
|
126
|
+
value: value,
|
|
127
|
+
columns: columns,
|
|
128
|
+
editorApi: editorApi,
|
|
129
|
+
onContentChanged: onContentChanged
|
|
130
|
+
}))));
|
|
131
|
+
}
|