md-editor-v3 2.5.0-beta.0 → 2.5.0
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/README.md +154 -20
- package/lib/MdEditor/type.d.ts +6 -5
- package/lib/md-editor-v3.es.js +129 -122
- package/lib/md-editor-v3.umd.js +44 -44
- package/lib/style.css +1 -1
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# md-editor-v3
|
|
1
|
+
# 🎄 md-editor-v3
|
|
2
2
|
|
|
3
3
|
    
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
|
|
|
12
12
|
|
|
13
13
|
- The same series editor for react: [md-editor-rt](https://github.com/imzbf/md-editor-rt)
|
|
14
14
|
|
|
15
|
-
## Features
|
|
15
|
+
## ⭐️ Features
|
|
16
16
|
|
|
17
17
|
- Toolbar, screenfull or screenfull in web pages and so on.
|
|
18
18
|
- Themes, Built-in default and dark themes.
|
|
@@ -25,7 +25,7 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
|
|
|
25
25
|
- `mermaid`(>=1.8.0), `katex` mathematical formula(>=1.9.0).
|
|
26
26
|
- Customize the toolbar as you like.
|
|
27
27
|
|
|
28
|
-
## Install
|
|
28
|
+
## 📦 Install
|
|
29
29
|
|
|
30
30
|
```shell
|
|
31
31
|
yarn add md-editor-v3
|
|
@@ -45,7 +45,7 @@ yarn add @vavt/md-editor-extension
|
|
|
45
45
|
|
|
46
46
|
For more ways to use or contribute, please refer to: [md-editor-extension](https://github.com/imzbf/md-editor-extension)
|
|
47
47
|
|
|
48
|
-
## Usage
|
|
48
|
+
## 💡 Usage
|
|
49
49
|
|
|
50
50
|
```vue
|
|
51
51
|
<template>
|
|
@@ -61,7 +61,7 @@ const text = ref('# Hello Editor');
|
|
|
61
61
|
</script>
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
## Preview
|
|
64
|
+
## 🗺 Preview
|
|
65
65
|
|
|
66
66
|
| Default theme | Dark theme | Preview only |
|
|
67
67
|
| --- | --- | --- |
|
|
@@ -71,9 +71,9 @@ mark and emoji extensions
|
|
|
71
71
|
|
|
72
72
|

|
|
73
73
|
|
|
74
|
-
## Apis
|
|
74
|
+
## 🎁 Apis
|
|
75
75
|
|
|
76
|
-
### Props
|
|
76
|
+
### 🔩 Props
|
|
77
77
|
|
|
78
78
|
| name | type | default | description |
|
|
79
79
|
| --- | --- | --- | --- |
|
|
@@ -255,7 +255,141 @@ export interface StaticTextDefaultValue {
|
|
|
255
255
|
|
|
256
256
|
</details>
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
## 🤱🏼 Expose
|
|
259
|
+
|
|
260
|
+
After 2.5.0, Editor exposes several methods on the instance, used to get or change the internal status of the editor.
|
|
261
|
+
|
|
262
|
+
```vue
|
|
263
|
+
<template>
|
|
264
|
+
<md-editor ref="editorRef" />
|
|
265
|
+
</template>
|
|
266
|
+
|
|
267
|
+
<script setup>
|
|
268
|
+
import { ref, onMounted } from 'vue';
|
|
269
|
+
import MdEditor from 'md-editor-v3';
|
|
270
|
+
import type { ExposeParam } from 'md-editor-v3';
|
|
271
|
+
|
|
272
|
+
import 'md-editor-v3/lib/style.css';
|
|
273
|
+
|
|
274
|
+
const editorRef = ref<ExposeParam>();
|
|
275
|
+
|
|
276
|
+
onMounted(() => {
|
|
277
|
+
editorRef.value?.on('catalog', console.log);
|
|
278
|
+
|
|
279
|
+
editorRef.value?.toggleCatalog(true);
|
|
280
|
+
});
|
|
281
|
+
</script>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
> Switched to the opposite status, if toggle without input parameter.
|
|
285
|
+
|
|
286
|
+
### 👂🏼 on
|
|
287
|
+
|
|
288
|
+
Get the internal state of the editor, including pageFullscreen, fullscreen, preview, htmlPreview, catalog, etc.
|
|
289
|
+
|
|
290
|
+
- pageFullscreen
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
editorRef.value?.on('pageFullscreen', (status) => console.log(status));
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
- fullscreen
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
editorRef.value?.on('fullscreen', (status) => console.log(status));
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
- preview
|
|
303
|
+
|
|
304
|
+
```js
|
|
305
|
+
editorRef.value?.on('preview', (status) => console.log(status));
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
- htmlPreview
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
editorRef.value?.on('htmlPreview', (status) => console.log(status));
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
- catalog
|
|
315
|
+
|
|
316
|
+
```js
|
|
317
|
+
editorRef.value?.on('catalog', (status) => console.log(status));
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 💻 togglePageFullscreen
|
|
321
|
+
|
|
322
|
+
Toggle status of fullscreen within the page.
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
editorRef.value?.togglePageFullscreen(true);
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### 🖥 toggleFullscreen
|
|
329
|
+
|
|
330
|
+
Toggle status of fullscreen widthin browser.
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
editorRef.value?.toggleFullscreen(true);
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### 📖 togglePreview
|
|
337
|
+
|
|
338
|
+
Toggle status of preview.
|
|
339
|
+
|
|
340
|
+
```js
|
|
341
|
+
editorRef.value?.togglePreview(true);
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 📼 toggleHtmlPreview
|
|
345
|
+
|
|
346
|
+
Toggle status of htmlPreview.
|
|
347
|
+
|
|
348
|
+
```js
|
|
349
|
+
editorRef.value?.toggleHtmlPreview(true);
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### 🧬 toggleCatalog
|
|
353
|
+
|
|
354
|
+
Toggle status of catalog.
|
|
355
|
+
|
|
356
|
+
```js
|
|
357
|
+
editorRef.value?.toggleCatalog(true);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### 💾 triggerSave
|
|
361
|
+
|
|
362
|
+
```js
|
|
363
|
+
editorRef.value?.triggerSave();
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 💉 insert
|
|
367
|
+
|
|
368
|
+
Manually insert content into textarea.
|
|
369
|
+
|
|
370
|
+
```js
|
|
371
|
+
/**
|
|
372
|
+
* @params selectedText
|
|
373
|
+
*/
|
|
374
|
+
editorRef.value?.insert((selectedText) => {
|
|
375
|
+
/**
|
|
376
|
+
* @return targetValue Content to be inserted
|
|
377
|
+
* @return select Automatically select content
|
|
378
|
+
* @return deviationStart Start position of the selected content
|
|
379
|
+
* @return deviationEnd End position of the selected content
|
|
380
|
+
*/
|
|
381
|
+
return {
|
|
382
|
+
targetValue: `${selectedText}`,
|
|
383
|
+
select: true,
|
|
384
|
+
deviationStart: 0,
|
|
385
|
+
deviationEnd: 0
|
|
386
|
+
};
|
|
387
|
+
});
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
For more examples, refer to source code of [extension component](https://github.com/imzbf/md-editor-v3/blob/dev-docs/src/components/MarkExtension/index.vue)
|
|
391
|
+
|
|
392
|
+
### 🎍 Slots
|
|
259
393
|
|
|
260
394
|
| name | type | default | description |
|
|
261
395
|
| --- | --- | --- | --- |
|
|
@@ -290,7 +424,7 @@ const handler = () => {
|
|
|
290
424
|
</script>
|
|
291
425
|
```
|
|
292
426
|
|
|
293
|
-
### Events
|
|
427
|
+
### 🪢 Events
|
|
294
428
|
|
|
295
429
|
| name | param | description |
|
|
296
430
|
| --- | --- | --- |
|
|
@@ -301,7 +435,7 @@ const handler = () => {
|
|
|
301
435
|
| onGetCatalog | `list: Array<HeadList>` | Get catalog of article |
|
|
302
436
|
| onError | `err: { name: string; message: string }` | Catch run-time error, `Cropper`, `fullscreen` and `prettier` are used when they are not loaded |
|
|
303
437
|
|
|
304
|
-
## Config
|
|
438
|
+
## 💴 Config
|
|
305
439
|
|
|
306
440
|
Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
307
441
|
|
|
@@ -422,7 +556,7 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
422
556
|
|
|
423
557
|
</details>
|
|
424
558
|
|
|
425
|
-
## Shortcut Key
|
|
559
|
+
## 🪡 Shortcut Key
|
|
426
560
|
|
|
427
561
|
| key | function | description |
|
|
428
562
|
| --- | --- | --- |
|
|
@@ -451,11 +585,11 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
451
585
|
| CTRL + ALT + C | code row | |
|
|
452
586
|
| CTRL + SHIFT + ALT + T | table | `\|table\|` |
|
|
453
587
|
|
|
454
|
-
## Components
|
|
588
|
+
## 🪤 Components
|
|
455
589
|
|
|
456
590
|
They are used as attributes of the editor component, eg: `Editor.DropdownToolbar`. For more examples, refer to [document](https://imzbf.github.io/md-editor-v3).
|
|
457
591
|
|
|
458
|
-
### NormalToolbar
|
|
592
|
+
### 🐣 NormalToolbar
|
|
459
593
|
|
|
460
594
|
`Editor.NormalToolbar`
|
|
461
595
|
|
|
@@ -471,7 +605,7 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
471
605
|
|
|
472
606
|
- `trigger`: `string | JSX.Element`, necessary, it is usually an icon, which is displayed on the toolbar.
|
|
473
607
|
|
|
474
|
-
### DropdownToolbar
|
|
608
|
+
### 🐼 DropdownToolbar
|
|
475
609
|
|
|
476
610
|
`Editor.DropdownToolbar`
|
|
477
611
|
|
|
@@ -489,7 +623,7 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
489
623
|
- `trigger`: `string | JSX.Element`, necessary, it is usually an icon, which is displayed on the toolbar.
|
|
490
624
|
- `overlay`: `string | JSX.Element`, necessary, content of dropdown box.
|
|
491
625
|
|
|
492
|
-
### ModalToolbar
|
|
626
|
+
### 🦉 ModalToolbar
|
|
493
627
|
|
|
494
628
|
`Editor.ModalToolbar`
|
|
495
629
|
|
|
@@ -514,7 +648,7 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
514
648
|
- `trigger`: `string | JSX.Element`, necessary, it is usually an icon, which is displayed on the toolbar.
|
|
515
649
|
- `overlay`: `string | JSX.Element`, necessary, content of Modal.
|
|
516
650
|
|
|
517
|
-
### MdCatalog
|
|
651
|
+
### 🐻 MdCatalog
|
|
518
652
|
|
|
519
653
|
`Editor.MdCatalog`
|
|
520
654
|
|
|
@@ -531,9 +665,9 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
531
665
|
|
|
532
666
|
- `onClick`: `(e: MouseEvent, t: TocItem) => void`, not necessary.
|
|
533
667
|
|
|
534
|
-
## Examples
|
|
668
|
+
## 🗂 Examples
|
|
535
669
|
|
|
536
|
-
### Jsx Template
|
|
670
|
+
### 🎸 Jsx Template
|
|
537
671
|
|
|
538
672
|
```js
|
|
539
673
|
import { defineComponent, reactive } from 'vue';
|
|
@@ -552,7 +686,7 @@ export default defineComponent({
|
|
|
552
686
|
});
|
|
553
687
|
```
|
|
554
688
|
|
|
555
|
-
### Upload Picture
|
|
689
|
+
### 🥹 Upload Picture
|
|
556
690
|
|
|
557
691
|
> Tips: When you paste and upload GIF, it will upload a static picture. So you should upload it by file system!
|
|
558
692
|
|
|
@@ -592,7 +726,7 @@ const onUploadImg = async (files, callback) => {
|
|
|
592
726
|
</script>
|
|
593
727
|
```
|
|
594
728
|
|
|
595
|
-
### Change Styles
|
|
729
|
+
### 🧙♂️ Change Styles
|
|
596
730
|
|
|
597
731
|
```less
|
|
598
732
|
.css-vars(@isDark) {
|
package/lib/MdEditor/type.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ export interface CodeCss {
|
|
|
238
238
|
dark: string;
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
export declare type UpdateSetting = (
|
|
241
|
+
export declare type UpdateSetting = (k: keyof SettingType, v?: boolean) => void;
|
|
242
242
|
export declare type ChangeEvent = (v: string) => void;
|
|
243
243
|
export declare type SaveEvent = (v: string, h: Promise<string>) => void;
|
|
244
244
|
export declare type UploadImgEvent = (files: Array<File>, callBack: (urls: string[]) => void) => void;
|
|
@@ -252,12 +252,13 @@ export interface ExposeEvent {
|
|
|
252
252
|
htmlPreview(status: boolean): void;
|
|
253
253
|
catalog(status: boolean): void;
|
|
254
254
|
}
|
|
255
|
-
export
|
|
255
|
+
export interface InsertParam {
|
|
256
256
|
targetValue: string;
|
|
257
257
|
select: boolean;
|
|
258
258
|
deviationStart: number;
|
|
259
259
|
deviationEnd: number;
|
|
260
|
-
}
|
|
260
|
+
}
|
|
261
|
+
export declare type InsertContentGenerator = (selectedText: string) => InsertParam;
|
|
261
262
|
export interface ExposeParam {
|
|
262
263
|
/**
|
|
263
264
|
* 添加事件监听
|
|
@@ -310,8 +311,8 @@ export interface ExposeParam {
|
|
|
310
311
|
*
|
|
311
312
|
* targetValue 待插入内容
|
|
312
313
|
* select 插入后是否自动选中内容
|
|
313
|
-
* deviationStart
|
|
314
|
-
* deviationEnd
|
|
314
|
+
* deviationStart 插入后选中位置的开始偏移量
|
|
315
|
+
* deviationEnd 插入后选中位置的结束偏移量
|
|
315
316
|
*
|
|
316
317
|
*/
|
|
317
318
|
insert(generate: InsertContentGenerator): void;
|