md-editor-v3 4.4.0 → 4.5.0-beta.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.
@@ -1,6 +1,6 @@
1
1
  import { PropType, CSSProperties } from 'vue';
2
2
  import { CompletionSource } from '@codemirror/autocomplete';
3
- import { ToolbarNames, MdHeadingId, Themes, Footers, ChangeEvent, SaveEvent, UploadImgEvent, HtmlChangedEvent, GetCatalogEvent, ErrorEvent, EditorEmits } from './type';
3
+ import { ToolbarNames, MdHeadingId, Themes, Footers, ChangeEvent, SaveEvent, UploadImgEvent, HtmlChangedEvent, GetCatalogEvent, ErrorEvent, EditorEmits, CustomIcon } from './type';
4
4
  export declare const mdHeadingId: MdHeadingId;
5
5
  export declare const mdPreviewProps: {
6
6
  /**
@@ -179,6 +179,13 @@ export declare const mdPreviewProps: {
179
179
  type: PropType<boolean>;
180
180
  default: boolean;
181
181
  };
182
+ /**
183
+ * 自定义的图标
184
+ */
185
+ customIcon: {
186
+ type: PropType<CustomIcon>;
187
+ default: {};
188
+ };
182
189
  };
183
190
  export declare const editorProps: {
184
191
  /**
@@ -584,6 +591,13 @@ export declare const editorProps: {
584
591
  type: PropType<boolean>;
585
592
  default: boolean;
586
593
  };
594
+ /**
595
+ * 自定义的图标
596
+ */
597
+ customIcon: {
598
+ type: PropType<CustomIcon>;
599
+ default: {};
600
+ };
587
601
  };
588
602
  export declare const mdPreviewEmits: EditorEmits;
589
603
  export declare const editorEmits: EditorEmits;
@@ -1,9 +1,10 @@
1
1
  import { LooseRequired } from '@vue/shared';
2
2
  import markdownit from 'markdown-it/lib';
3
- import { ExtractPropTypes, SetupContext } from 'vue';
3
+ import { Component, ExtractPropTypes, SetupContext } from 'vue';
4
4
  import { Extension } from '@codemirror/state';
5
5
  import { KeyBinding } from '@codemirror/view';
6
6
  import { editorProps, mdPreviewProps } from './props';
7
+ import { IconName } from './components/Icon/Icon';
7
8
  declare global {
8
9
  interface Window {
9
10
  hljs: any;
@@ -168,7 +169,7 @@ export interface ConfigOption {
168
169
  /**
169
170
  * 编辑器内部依赖库
170
171
  */
171
- editorExtensions?: {
172
+ editorExtensions: {
172
173
  highlight?: {
173
174
  instance?: any;
174
175
  js?: string;
@@ -185,7 +186,14 @@ export interface ConfigOption {
185
186
  js?: string;
186
187
  css?: string;
187
188
  };
189
+ /**
190
+ * Svg方式的图标
191
+ */
188
192
  iconfont?: string;
193
+ /**
194
+ * class方式的图标
195
+ */
196
+ iconfontClass?: string;
189
197
  screenfull?: {
190
198
  instance?: any;
191
199
  js?: string;
@@ -200,7 +208,7 @@ export interface ConfigOption {
200
208
  css?: string;
201
209
  };
202
210
  };
203
- editorConfig?: {
211
+ editorConfig: {
204
212
  /**
205
213
  * 自定义提示语言
206
214
  */
@@ -221,28 +229,36 @@ export interface ConfigOption {
221
229
  *
222
230
  * @params theme 当前主题
223
231
  * @params innerExtensions 当前主题下的扩展列表
224
- * [keymap, minimalSetup, markdown, EditorView.lineWrapping, EditorView.updateListener, EditorView.domEventHandlers, oneDark??oneLight]
232
+ * [keymap, minimalSetup, html, markdown, EditorView.lineWrapping, EditorView.updateListener, EditorView.domEventHandlers, oneDark??oneLight]
225
233
  * [快捷键, 最低配置, markdown识别, 横向自动换行, 更新事件, dom监听事件, oneDark主题(暗夜模式下), oneLight(默认模式下)]
226
234
  *
235
+ * 如果要添加其他自带的扩展,比如java,注意添加到markdown之前,不然自动提示不正常
236
+ *
227
237
  * @params keyBindings md-editor-v3内置的快捷键
228
238
  */
229
- codeMirrorExtensions?: (theme: Themes, extensions: Array<Extension>, keyBindings: Array<KeyBinding>) => Array<Extension>;
239
+ codeMirrorExtensions: (theme: Themes, extensions: Array<Extension>, keyBindings: Array<KeyBinding>) => Array<Extension>;
230
240
  /**
231
241
  * 自定义markdown-it核心库扩展、属性等
232
242
  */
233
- markdownItConfig?: (md: markdownit) => void;
243
+ markdownItConfig: (md: markdownit) => void;
234
244
  /**
235
245
  * 挑选编辑器已预设的markdownIt的扩展
236
246
  *
237
247
  * @param plugins markdownIt的扩展,带编辑器已设定的属性
238
248
  * @returns plugins
239
249
  */
240
- markdownItPlugins?: (plugins: Array<MarkdownItConfigPlugin>) => Array<MarkdownItConfigPlugin>;
250
+ markdownItPlugins: (plugins: Array<MarkdownItConfigPlugin>) => Array<MarkdownItConfigPlugin>;
251
+ /**
252
+ * 如果使用内部的图标,可以切换展示的方式
253
+ *
254
+ * 以规避某些问题,例如Shadow Dom对Svg use的支持问题
255
+ */
256
+ iconfontType: 'svg' | 'class';
241
257
  }
242
258
  /**
243
259
  * 扩展编辑器内部功能,包括marked和一些内部依赖实例,如highlight、cropper等
244
260
  */
245
- export type Config = (options: ConfigOption) => void;
261
+ export type Config = (options: Partial<ConfigOption>) => void;
246
262
  /**
247
263
  * 编辑器操作潜在的错误
248
264
  */
@@ -358,3 +374,16 @@ export type EditorProps = Readonly<LooseRequired<Readonly<ExtractPropTypes<typeo
358
374
  export type MdPreviewProps = Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof mdPreviewProps>>>>;
359
375
  export type EditorEmits = Array<'onChange' | 'onSave' | 'onUploadImg' | 'onHtmlChanged' | 'onGetCatalog' | 'onError' | 'update:modelValue' | 'onBlur' | 'onFocus' | 'onInput'>;
360
376
  export type EditorContext = SetupContext<EditorEmits>;
377
+ /**
378
+ * 自定义图标的数据类型
379
+ */
380
+ export type CustomIcon = {
381
+ [key in IconName]?: {
382
+ component: Component | JSX.Element | string;
383
+ props: {
384
+ [key: string | number | symbol]: any;
385
+ };
386
+ };
387
+ } & {
388
+ copy?: string;
389
+ };
@@ -80,6 +80,10 @@ declare const MdPreview: import("vue").DefineComponent<{
80
80
  type: import("vue").PropType<boolean>;
81
81
  default: boolean;
82
82
  };
83
+ customIcon: {
84
+ type: import("vue").PropType<import('../MdEditor/type').CustomIcon>;
85
+ default: {};
86
+ };
83
87
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import('../MdEditor/type').EditorEmits, "onChange" | "onFocus" | "onBlur" | "onInput" | "onError" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
84
88
  modelValue: {
85
89
  type: import("vue").PropType<string>;
@@ -162,6 +166,10 @@ declare const MdPreview: import("vue").DefineComponent<{
162
166
  type: import("vue").PropType<boolean>;
163
167
  default: boolean;
164
168
  };
169
+ customIcon: {
170
+ type: import("vue").PropType<import('../MdEditor/type').CustomIcon>;
171
+ default: {};
172
+ };
165
173
  }>> & {
166
174
  onOnChange?: ((...args: any[]) => any) | undefined;
167
175
  onOnFocus?: ((...args: any[]) => any) | undefined;
@@ -192,5 +200,6 @@ declare const MdPreview: import("vue").DefineComponent<{
192
200
  codeStyleReverseList: string[];
193
201
  noHighlight: boolean;
194
202
  noImgZoomIn: boolean;
203
+ customIcon: import('../MdEditor/type').CustomIcon;
195
204
  }>;
196
205
  export default MdPreview;
@@ -22,6 +22,7 @@ declare const _default: {
22
22
  codeStyleReverseList: string[];
23
23
  noHighlight: boolean;
24
24
  noImgZoomIn: boolean;
25
+ customIcon: import("..").CustomIcon;
25
26
  }> & Omit<Readonly<import("vue").ExtractPropTypes<{
26
27
  modelValue: {
27
28
  type: import("vue").PropType<string>;
@@ -104,6 +105,10 @@ declare const _default: {
104
105
  type: import("vue").PropType<boolean>;
105
106
  default: boolean;
106
107
  };
108
+ customIcon: {
109
+ type: import("vue").PropType<import("..").CustomIcon>;
110
+ default: {};
111
+ };
107
112
  }>> & {
108
113
  onOnChange?: ((...args: any[]) => any) | undefined;
109
114
  onOnFocus?: ((...args: any[]) => any) | undefined;
@@ -115,7 +120,7 @@ declare const _default: {
115
120
  onOnHtmlChanged?: ((...args: any[]) => any) | undefined;
116
121
  onOnGetCatalog?: ((...args: any[]) => any) | undefined;
117
122
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
118
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "editorId" | "class" | "style" | "mdHeadingId" | "theme" | "modelValue" | "language" | "showCodeRowNumber" | "previewTheme" | "sanitize" | "noMermaid" | "noKatex" | "codeTheme" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList" | "noHighlight" | "noImgZoomIn">;
123
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "editorId" | "class" | "style" | "mdHeadingId" | "theme" | "modelValue" | "language" | "showCodeRowNumber" | "previewTheme" | "sanitize" | "noMermaid" | "noKatex" | "codeTheme" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList" | "noHighlight" | "noImgZoomIn" | "customIcon">;
119
124
  $attrs: {
120
125
  [x: string]: unknown;
121
126
  };
@@ -211,6 +216,10 @@ declare const _default: {
211
216
  type: import("vue").PropType<boolean>;
212
217
  default: boolean;
213
218
  };
219
+ customIcon: {
220
+ type: import("vue").PropType<import("..").CustomIcon>;
221
+ default: {};
222
+ };
214
223
  }>> & {
215
224
  onOnChange?: ((...args: any[]) => any) | undefined;
216
225
  onOnFocus?: ((...args: any[]) => any) | undefined;
@@ -241,6 +250,7 @@ declare const _default: {
241
250
  codeStyleReverseList: string[];
242
251
  noHighlight: boolean;
243
252
  noImgZoomIn: boolean;
253
+ customIcon: import("..").CustomIcon;
244
254
  }, {}, string> & {
245
255
  beforeCreate?: ((() => void) | (() => void)[]) | undefined;
246
256
  created?: ((() => void) | (() => void)[]) | undefined;
@@ -343,6 +353,10 @@ declare const _default: {
343
353
  type: import("vue").PropType<boolean>;
344
354
  default: boolean;
345
355
  };
356
+ customIcon: {
357
+ type: import("vue").PropType<import("..").CustomIcon>;
358
+ default: {};
359
+ };
346
360
  }>> & {
347
361
  onOnChange?: ((...args: any[]) => any) | undefined;
348
362
  onOnFocus?: ((...args: any[]) => any) | undefined;
@@ -440,6 +454,10 @@ declare const _default: {
440
454
  type: import("vue").PropType<boolean>;
441
455
  default: boolean;
442
456
  };
457
+ customIcon: {
458
+ type: import("vue").PropType<import("..").CustomIcon>;
459
+ default: {};
460
+ };
443
461
  }>> & {
444
462
  onOnChange?: ((...args: any[]) => any) | undefined;
445
463
  onOnFocus?: ((...args: any[]) => any) | undefined;
@@ -470,6 +488,7 @@ declare const _default: {
470
488
  codeStyleReverseList: string[];
471
489
  noHighlight: boolean;
472
490
  noImgZoomIn: boolean;
491
+ customIcon: import("..").CustomIcon;
473
492
  }, {}, string> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
474
493
  install: (app: App) => App;
475
494
  };