@seafile/seafile-editor 1.0.84 → 1.0.85-beta1
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 → simple-slate-editor/index.js} +35 -12
- package/dist/extension/commons/expand-editor-menu.js +28 -0
- package/dist/extension/commons/index.js +15 -1
- package/dist/extension/commons/menu/menu.css +5 -1
- package/dist/extension/commons/more-menu/index.css +28 -0
- package/dist/extension/commons/more-menu/index.js +46 -0
- package/dist/extension/constants/menus-config.js +13 -1
- package/dist/extension/editor.js +8 -1
- package/dist/extension/index.js +12 -0
- package/dist/extension/toolbar/index.js +8 -1
- package/dist/extension/toolbar/inline-toolbar/index.css +40 -0
- package/dist/extension/toolbar/inline-toolbar/index.js +85 -0
- package/dist/index.js +7 -0
- package/dist/pages/longtext-inline-editor/ClickOutside/index.js +86 -0
- package/dist/pages/longtext-inline-editor/editor.js +135 -0
- package/dist/pages/longtext-inline-editor/formatter/index.css +31 -0
- package/dist/pages/longtext-inline-editor/formatter/index.js +66 -0
- package/dist/pages/longtext-inline-editor/index.css +71 -0
- package/dist/pages/longtext-inline-editor/index.js +128 -0
- package/dist/pages/seatable-editor.js +1 -1
- package/dist/pages/simple-editor.js +7 -3
- package/package.json +1 -1
- package/public/locales/cs/seafile-editor.json +2 -1
- package/public/locales/de/seafile-editor.json +2 -1
- package/public/locales/en/seafile-editor.json +6 -1
- package/public/locales/es/seafile-editor.json +2 -1
- package/public/locales/fr/seafile-editor.json +2 -1
- package/public/locales/it/seafile-editor.json +2 -1
- package/public/locales/ru/seafile-editor.json +2 -1
- package/public/locales/zh_CN/seafile-editor.json +2 -1
- package/public/media/seafile-editor-font/iconfont.eot +0 -0
- package/public/media/seafile-editor-font/iconfont.svg +2 -0
- package/public/media/seafile-editor-font/iconfont.ttf +0 -0
- package/public/media/seafile-editor-font/iconfont.woff +0 -0
- package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
- package/public/media/seafile-editor-font.css +10 -6
- package/readme.md +115 -24
- /package/dist/editors/{simple-slate-editor → simple-slate-editor}/style.css +0 -0
- /package/dist/editors/{simple-slate-editor → simple-slate-editor}/with-props-editor.js +0 -0
package/readme.md
CHANGED
|
@@ -8,7 +8,16 @@ SeaMarkdown editor is a WYSIWYG Markdown editor based on slate.js. It is used in
|
|
|
8
8
|
## Integrated markdown editor UI
|
|
9
9
|
> An integrated demo. You can customize it according to the style you design.
|
|
10
10
|
|
|
11
|
-

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Simple editor UI
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Integrated simple editor UI
|
|
17
|
+
> An integrated demo. You can customize it according to the style you design.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
12
21
|
|
|
13
22
|
## Installation
|
|
14
23
|
To install via npm:
|
|
@@ -29,6 +38,7 @@ import { MarkdownEditor } from '@seafile/seafile-editor';
|
|
|
29
38
|
|Name|Explain|
|
|
30
39
|
|-|-|
|
|
31
40
|
|MarkdownEditor|Markdown rich text editor component|
|
|
41
|
+
|SimpleEditor|Simple markdown editor component|
|
|
32
42
|
|MarkdownViewer|Markdown content preview component|
|
|
33
43
|
|
|
34
44
|
### Functions
|
|
@@ -81,7 +91,7 @@ import { Button } from 'reactstrap';
|
|
|
81
91
|
import { MarkdownEditor } from '@seafile/seafile-editor';
|
|
82
92
|
import editorApi from './api';
|
|
83
93
|
|
|
84
|
-
export default function
|
|
94
|
+
export default function MarkdownEditorDemo() {
|
|
85
95
|
|
|
86
96
|
const editorRef = useRef(null);
|
|
87
97
|
const [fileContent, setFileContent] = useState('');
|
|
@@ -140,6 +150,109 @@ Common props you may want to specify include:
|
|
|
140
150
|
* onContentChanged: When the editor content changes, a change event is triggered to facilitate the user to record whether the document
|
|
141
151
|
* mathJaxSource: Supports inserting formulas. If you want to support inserting formulas, please provide a path that can load formula resources. If support is not required, you can ignore this parameter. [math-jax document](https://docs.mathjax.org/en/stable/start.html)
|
|
142
152
|
|
|
153
|
+
## SimpleEditor usage
|
|
154
|
+
|
|
155
|
+
### Define api
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
import axios from 'axios';
|
|
159
|
+
|
|
160
|
+
class API {
|
|
161
|
+
|
|
162
|
+
getFileContent() {
|
|
163
|
+
const fileUrl = '';
|
|
164
|
+
return axios.get(fileUrl);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
saveFileContent(content) {
|
|
168
|
+
const updateLink = '';
|
|
169
|
+
const formData = new FormData();
|
|
170
|
+
const blob = new Blob([data], { type: 'text/plain' });
|
|
171
|
+
formData.append('file', blob);
|
|
172
|
+
axios.post(updateLink, formData);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
uploadLocalImage(file) {
|
|
176
|
+
const uploadLink = '';
|
|
177
|
+
const formData = new FormData();
|
|
178
|
+
formData.append('file', file);
|
|
179
|
+
return axios.post(uploadLink, formData);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const editorApi = new API();
|
|
185
|
+
|
|
186
|
+
export default editorApi;
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Integrate simple into your own page
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
193
|
+
import { Button } from 'reactstrap';
|
|
194
|
+
import { SimpleEditor } from '@seafile/seafile-editor';
|
|
195
|
+
import editorApi from './api';
|
|
196
|
+
|
|
197
|
+
export default function SimpleEditorDemo() {
|
|
198
|
+
|
|
199
|
+
const editorRef = useRef(null);
|
|
200
|
+
const [fileContent, setFileContent] = useState('');
|
|
201
|
+
const [isFetching, setIsFetching] = useState(true);
|
|
202
|
+
const [contentVersion, setContentVersion] = useState(0);
|
|
203
|
+
|
|
204
|
+
const mathJaxSource = '';
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
editorApi.getFileContent().then(res => {
|
|
208
|
+
setFileContent(res.data);
|
|
209
|
+
setIsFetching(false);
|
|
210
|
+
});
|
|
211
|
+
}, []);
|
|
212
|
+
|
|
213
|
+
const onSave = useCallback(() => {
|
|
214
|
+
const content = editorRef.current.getValue();
|
|
215
|
+
editorApi.saveFileContent(content).then(res => {
|
|
216
|
+
window.alert('Saved successfully')
|
|
217
|
+
});
|
|
218
|
+
}, []);
|
|
219
|
+
|
|
220
|
+
const onContentChanged = useCallback(() => {
|
|
221
|
+
setContentVersion(contentVersion + 1);
|
|
222
|
+
}, [contentVersion]);
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<div className='seafile-editor'>
|
|
226
|
+
<SimpleEditor
|
|
227
|
+
ref={editorRef}
|
|
228
|
+
isFetching={isFetching}
|
|
229
|
+
value={fileContent}
|
|
230
|
+
initValue={''}
|
|
231
|
+
editorApi={editorApi}
|
|
232
|
+
onSave={onSave}
|
|
233
|
+
onContentChanged={onContentChanged}
|
|
234
|
+
mathJaxSource={mathJaxSource}
|
|
235
|
+
/>
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Props
|
|
243
|
+
|
|
244
|
+
Common props you may want to specify include:
|
|
245
|
+
|
|
246
|
+
* ref: A reference to the editor, used to obtain the current content in the editor
|
|
247
|
+
* ref.current.getValue: Get the current markdown string value in the editor
|
|
248
|
+
* ref.current.getSlateValue: Get the value of the current slate data format in the editor
|
|
249
|
+
* isFetching: Whether the value of the editor is being obtained, if the loading effect is displayed while obtaining, and if the acquisition is completed, the corresponding content obtained is displayed in the editor.
|
|
250
|
+
* value: The text content obtained
|
|
251
|
+
* onSave: When the editor content changes, the onSave callback event is triggered externally. The user can save the document by implementing this callback function.
|
|
252
|
+
* onContentChanged: When the editor content changes, a change event is triggered to facilitate the user to record whether the document
|
|
253
|
+
* mathJaxSource: Supports inserting formulas. If you want to support inserting formulas, please provide a path that can load formula resources. If support is not required, you can ignore this parameter. [math-jax document](https://docs.mathjax.org/en/stable/start.html)
|
|
254
|
+
|
|
255
|
+
|
|
143
256
|
## Functions
|
|
144
257
|
|
|
145
258
|
### `mdStringToSlate(mdString)`
|
|
@@ -190,31 +303,9 @@ processor.process(string).then(result => {
|
|
|
190
303
|
## 🖥 Environment Support
|
|
191
304
|
|
|
192
305
|
* Modern browsers
|
|
193
|
-
* Software built-in browser
|
|
194
306
|
|
|
195
307
|
### Modern browsers
|
|
196
308
|
|
|
197
309
|
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari |
|
|
198
310
|
| --- | --- | --- | --- |
|
|
199
311
|
| Edge | false | last 2 versions | false |
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
### Software built-in browser
|
|
203
|
-
|
|
204
|
-
**Mac OS**
|
|
205
|
-
|
|
206
|
-
| software | browser | version | internal | isSupport |
|
|
207
|
-
|-|-|-|-|-|
|
|
208
|
-
|<img src="./assets/imgs/wechat.png" width='16'> WeChat| Chrome |107.0.0.0| AppleWebKit/537.36 |false|
|
|
209
|
-
|<img src="./assets/imgs/wecom.png" width='16'> WeCom|Safari||AppleWebKit/605.1.15 |false|
|
|
210
|
-
|
|
211
|
-
**Windows OS**
|
|
212
|
-
> windows 11
|
|
213
|
-
|
|
214
|
-
| software | browser | version | internal | isSupport |
|
|
215
|
-
|-|-|-|-|-|
|
|
216
|
-
|<img src="./assets/imgs/wechat.png" width='16'> WeChat| Chrome |106.0.0.0| AppleWebKit/537.36 |false|
|
|
217
|
-
|<img src="./assets/imgs/wecom.png" width='16'> WeCom|Chrome|108.0.5993.119|AppleWebKit/537.36 |false|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
File without changes
|
|
File without changes
|