md-editor-v3 4.13.5 → 4.14.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.
Files changed (41) hide show
  1. package/README.md +18 -2
  2. package/lib/cjs/MdCatalog.cjs +14 -8
  3. package/lib/cjs/MdEditor.cjs +120 -85
  4. package/lib/cjs/ModalToolbar.cjs +3 -0
  5. package/lib/cjs/chunks/config.cjs +174 -16
  6. package/lib/cjs/chunks/dom.cjs +24 -20
  7. package/lib/cjs/chunks/event-name.cjs +95 -0
  8. package/lib/cjs/chunks/index.cjs +219 -177
  9. package/lib/cjs/chunks/index2.cjs +3 -0
  10. package/lib/cjs/chunks/index3.cjs +3 -8
  11. package/lib/cjs/chunks/index4.cjs +7 -94
  12. package/lib/cjs/config.cjs +1 -0
  13. package/lib/cjs/index.cjs +1 -0
  14. package/lib/es/MdCatalog.mjs +12 -6
  15. package/lib/es/MdEditor.mjs +66 -31
  16. package/lib/es/ModalToolbar.mjs +3 -0
  17. package/lib/es/chunks/config.mjs +176 -18
  18. package/lib/es/chunks/dom.mjs +24 -20
  19. package/lib/es/chunks/event-name.mjs +96 -0
  20. package/lib/es/chunks/index.mjs +170 -128
  21. package/lib/es/chunks/index2.mjs +3 -0
  22. package/lib/es/chunks/index3.mjs +4 -9
  23. package/lib/es/chunks/index4.mjs +11 -98
  24. package/lib/es/config.mjs +2 -1
  25. package/lib/es/index.mjs +2 -1
  26. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +6 -0
  27. package/lib/types/DropdownToolbar/index.d.ts +12 -0
  28. package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
  29. package/lib/types/MdCatalog/index.d.ts +3 -3
  30. package/lib/types/MdEditor/Editor.d.ts +0 -3
  31. package/lib/types/MdEditor/config.d.ts +1 -0
  32. package/lib/types/MdEditor/index.d.ts +0 -7
  33. package/lib/types/MdEditor/props.d.ts +2 -1
  34. package/lib/types/MdEditor/type.d.ts +46 -0
  35. package/lib/types/MdEditor/utils/dom.d.ts +10 -2
  36. package/lib/types/MdEditor/utils/index.d.ts +4 -0
  37. package/lib/types/ModalToolbar/ModalToolbar.d.ts +6 -0
  38. package/lib/types/ModalToolbar/index.d.ts +12 -0
  39. package/lib/types/config.d.ts +1 -1
  40. package/lib/umd/index.js +41 -41
  41. package/package.json +2 -2
@@ -1,76 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- class Bus {
8
- constructor() {
9
- // 事件池
10
- __publicField(this, "pools", {});
11
- }
12
- // 移除事件监听
13
- remove(race, name, func) {
14
- const targetRace = this.pools[race];
15
- const events = targetRace && this.pools[race][name];
16
- if (events) {
17
- this.pools[race][name] = events.filter((item) => item !== func);
18
- }
19
- }
20
- // 清空全部事件,由于单一实例,多次注册会被共享内容
21
- clear(race) {
22
- this.pools[race] = {};
23
- }
24
- // 注册事件监听
25
- on(race, event) {
26
- if (!this.pools[race]) {
27
- this.pools[race] = {};
28
- }
29
- if (!this.pools[race][event.name]) {
30
- this.pools[race][event.name] = [];
31
- }
32
- this.pools[race][event.name].push(event.callback);
33
- return this.pools[race][event.name].includes(event.callback);
34
- }
35
- // 触发事件
36
- emit(race, name, ...params) {
37
- if (!this.pools[race]) {
38
- this.pools[race] = {};
39
- }
40
- const targetRace = this.pools[race];
41
- const events = targetRace[name];
42
- if (events) {
43
- events.forEach((item) => {
44
- try {
45
- item(...params);
46
- } catch (error) {
47
- console.error(`${name} monitor event exception!`, error);
48
- }
49
- });
50
- }
51
- }
52
- }
53
- const bus = new Bus();
54
- const ON_SAVE = "onSave";
55
- const CHANGE_CATALOG_VISIBLE = "changeCatalogVisible";
56
- const CHANGE_FULL_SCREEN = "changeFullscreen";
57
- const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
58
- const FULL_SCREEN_CHANGED = "fullscreenChanged";
59
- const PREVIEW_CHANGED = "previewChanged";
60
- const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
61
- const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
62
- const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
63
- const BUILD_FINISHED = "buildFinished";
64
- const ERROR_CATCHER = "errorCatcher";
65
- const REPLACE = "replace";
66
- const UPLOAD_IMAGE = "uploadImage";
67
- const OPEN_MODALS = "openModals";
68
- const CTRL_Z = "ctrlZ";
69
- const CTRL_SHIFT_Z = "ctrlShiftZ";
70
- const CATALOG_CHANGED = "catalogChanged";
71
- const PUSH_CATALOG = "pushCatalog";
72
- const RERENDER = "rerender";
73
- const EVENT_LISTENER = "eventListener";
74
1
  const base642File = (base64, fileName = "image.png") => {
75
2
  const arr = base64.split(",");
76
3
  const regResult = arr[0].match(/:(.*?);/);
@@ -115,30 +42,16 @@ const getNextId = /* @__PURE__ */ (() => {
115
42
  return prefix + ++count;
116
43
  };
117
44
  })();
45
+ const getZIndexIncrement = /* @__PURE__ */ (() => {
46
+ let startIndex = 0;
47
+ return () => {
48
+ return ++startIndex;
49
+ };
50
+ })();
118
51
  export {
119
- BUILD_FINISHED as B,
120
- CATALOG_CHANGED as C,
121
- ERROR_CATCHER as E,
122
- FULL_SCREEN_CHANGED as F,
123
- HTML_PREVIEW_CHANGED as H,
124
- ON_SAVE as O,
125
- PUSH_CATALOG as P,
126
- RERENDER as R,
127
- UPLOAD_IMAGE as U,
128
- generateCodeRowNumber as a,
129
- bus as b,
130
- CHANGE_CATALOG_VISIBLE as c,
131
- PAGE_FULL_SCREEN_CHANGED as d,
132
- PREVIEW_CHANGED as e,
133
- PREVIEW_ONLY_CHANGED as f,
134
- getRelativeTop as g,
135
- CATALOG_VISIBLE_CHANGED as h,
136
- REPLACE as i,
137
- CHANGE_FULL_SCREEN as j,
138
- EVENT_LISTENER as k,
139
- getNextId as l,
140
- base642File as m,
141
- OPEN_MODALS as n,
142
- CTRL_SHIFT_Z as o,
143
- CTRL_Z as p
52
+ getZIndexIncrement as a,
53
+ generateCodeRowNumber as b,
54
+ getNextId as c,
55
+ base642File as d,
56
+ getRelativeTop as g
144
57
  };
package/lib/es/config.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import { s as staticTextDefault } from "./chunks/config.mjs";
2
- import { d, b, c, i, a } from "./chunks/config.mjs";
2
+ import { d, b, c, e, i, a } from "./chunks/config.mjs";
3
3
  const zh_CN = staticTextDefault["zh-CN"];
4
4
  const en_US = staticTextDefault["en-US"];
5
5
  export {
6
6
  d as allFooter,
7
7
  b as allToolbar,
8
8
  c as config,
9
+ e as editorExtensionsAttrs,
9
10
  en_US,
10
11
  i as iconfontClassUrl,
11
12
  a as iconfontSvgUrl,
package/lib/es/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { default as default4 } from "./ModalToolbar.mjs";
6
6
  import { default as default5 } from "./MdCatalog.mjs";
7
7
  import { M as M2 } from "./chunks/index3.mjs";
8
8
  import { en_US, zh_CN } from "./config.mjs";
9
- import { d, b, c, i, a } from "./chunks/config.mjs";
9
+ import { d, b, c, e, i, a } from "./chunks/config.mjs";
10
10
  export {
11
11
  D as DropdownToolbar,
12
12
  default5 as MdCatalog,
@@ -18,6 +18,7 @@ export {
18
18
  d as allFooter,
19
19
  b as allToolbar,
20
20
  c as config,
21
+ e as editorExtensionsAttrs,
21
22
  en_US,
22
23
  i as iconfontClassUrl,
23
24
  a as iconfontSvgUrl,
@@ -34,6 +34,9 @@ declare const _default: import('vue').DefineComponent<{
34
34
  theme: {
35
35
  type: PropType<Themes>;
36
36
  };
37
+ previewTheme: {
38
+ type: PropType<string>;
39
+ };
37
40
  /**
38
41
  * ==结束
39
42
  */
@@ -73,6 +76,9 @@ declare const _default: import('vue').DefineComponent<{
73
76
  theme: {
74
77
  type: PropType<Themes>;
75
78
  };
79
+ previewTheme: {
80
+ type: PropType<string>;
81
+ };
76
82
  /**
77
83
  * ==结束
78
84
  */
@@ -31,6 +31,9 @@ declare const _default: {
31
31
  theme: {
32
32
  type: import('vue').PropType<import('..').Themes>;
33
33
  };
34
+ previewTheme: {
35
+ type: import('vue').PropType<string>;
36
+ };
34
37
  default: {
35
38
  type: import('vue').PropType<string | Element>;
36
39
  };
@@ -66,6 +69,9 @@ declare const _default: {
66
69
  theme: {
67
70
  type: import('vue').PropType<import('..').Themes>;
68
71
  };
72
+ previewTheme: {
73
+ type: import('vue').PropType<string>;
74
+ };
69
75
  default: {
70
76
  type: import('vue').PropType<string | Element>;
71
77
  };
@@ -110,6 +116,9 @@ declare const _default: {
110
116
  theme: {
111
117
  type: import('vue').PropType<import('..').Themes>;
112
118
  };
119
+ previewTheme: {
120
+ type: import('vue').PropType<string>;
121
+ };
113
122
  default: {
114
123
  type: import('vue').PropType<string | Element>;
115
124
  };
@@ -151,6 +160,9 @@ declare const _default: {
151
160
  theme: {
152
161
  type: import('vue').PropType<import('..').Themes>;
153
162
  };
163
+ previewTheme: {
164
+ type: import('vue').PropType<string>;
165
+ };
154
166
  default: {
155
167
  type: import('vue').PropType<string | Element>;
156
168
  };
@@ -119,7 +119,7 @@ declare const MdCatalog: import('vue').DefineComponent<{
119
119
  class: string;
120
120
  theme: Themes;
121
121
  mdHeadingId: MdHeadingId;
122
- scrollElementOffsetTop: number;
123
122
  offsetTop: number;
123
+ scrollElementOffsetTop: number;
124
124
  }, {}>;
125
125
  export default MdCatalog;
@@ -77,8 +77,8 @@ declare const _default: {
77
77
  class: string;
78
78
  theme: import('..').Themes;
79
79
  mdHeadingId: import('..').MdHeadingId;
80
- scrollElementOffsetTop: number;
81
80
  offsetTop: number;
81
+ scrollElementOffsetTop: number;
82
82
  }, true, {}, {}, {
83
83
  P: {};
84
84
  B: {};
@@ -126,8 +126,8 @@ declare const _default: {
126
126
  class: string;
127
127
  theme: import('..').Themes;
128
128
  mdHeadingId: import('..').MdHeadingId;
129
- scrollElementOffsetTop: number;
130
129
  offsetTop: number;
130
+ scrollElementOffsetTop: number;
131
131
  }>;
132
132
  __isFragment?: undefined;
133
133
  __isTeleport?: undefined;
@@ -172,8 +172,8 @@ declare const _default: {
172
172
  class: string;
173
173
  theme: import('..').Themes;
174
174
  mdHeadingId: import('..').MdHeadingId;
175
- scrollElementOffsetTop: number;
176
175
  offsetTop: number;
176
+ scrollElementOffsetTop: number;
177
177
  }, {}, string, {}> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & {
178
178
  install: (app: App) => App;
179
179
  };
@@ -38,7 +38,6 @@ declare const Editor: import('vue').DefineComponent<{
38
38
  };
39
39
  tableShape: {
40
40
  type: import('vue').PropType<number[]>;
41
- default: () => number[];
42
41
  };
43
42
  placeholder: {
44
43
  type: import('vue').PropType<string>;
@@ -242,7 +241,6 @@ declare const Editor: import('vue').DefineComponent<{
242
241
  };
243
242
  tableShape: {
244
243
  type: import('vue').PropType<number[]>;
245
- default: () => number[];
246
244
  };
247
245
  placeholder: {
248
246
  type: import('vue').PropType<string>;
@@ -430,7 +428,6 @@ declare const Editor: import('vue').DefineComponent<{
430
428
  toolbarsExclude: import('./type').ToolbarNames[];
431
429
  noPrettier: boolean;
432
430
  tabWidth: number;
433
- tableShape: number[];
434
431
  placeholder: string;
435
432
  footers: import('./type').Footers[];
436
433
  scrollAuto: boolean;
@@ -24,6 +24,7 @@ export declare const katexUrl: {
24
24
  css: string;
25
25
  };
26
26
  export declare const codeCss: CodeCss;
27
+ export declare const editorExtensionsAttrs: ConfigOption['editorExtensionsAttrs'];
27
28
  export declare const configOption: ConfigOption;
28
29
  export declare const config: Config;
29
30
  /**
@@ -41,7 +41,6 @@ declare const _default: {
41
41
  };
42
42
  tableShape: {
43
43
  type: import('vue').PropType<number[]>;
44
- default: () => number[];
45
44
  };
46
45
  placeholder: {
47
46
  type: import('vue').PropType<string>;
@@ -258,7 +257,6 @@ declare const _default: {
258
257
  };
259
258
  tableShape: {
260
259
  type: import('vue').PropType<number[]>;
261
- default: () => number[];
262
260
  };
263
261
  placeholder: {
264
262
  type: import('vue').PropType<string>;
@@ -446,7 +444,6 @@ declare const _default: {
446
444
  toolbarsExclude: import('./type').ToolbarNames[];
447
445
  noPrettier: boolean;
448
446
  tabWidth: number;
449
- tableShape: number[];
450
447
  placeholder: string;
451
448
  footers: import('./type').Footers[];
452
449
  scrollAuto: boolean;
@@ -517,7 +514,6 @@ declare const _default: {
517
514
  };
518
515
  tableShape: {
519
516
  type: import('vue').PropType<number[]>;
520
- default: () => number[];
521
517
  };
522
518
  placeholder: {
523
519
  type: import('vue').PropType<string>;
@@ -705,7 +701,6 @@ declare const _default: {
705
701
  toolbarsExclude: import('./type').ToolbarNames[];
706
702
  noPrettier: boolean;
707
703
  tabWidth: number;
708
- tableShape: number[];
709
704
  placeholder: string;
710
705
  footers: import('./type').Footers[];
711
706
  scrollAuto: boolean;
@@ -773,7 +768,6 @@ declare const _default: {
773
768
  };
774
769
  tableShape: {
775
770
  type: import('vue').PropType<number[]>;
776
- default: () => number[];
777
771
  };
778
772
  placeholder: {
779
773
  type: import('vue').PropType<string>;
@@ -961,7 +955,6 @@ declare const _default: {
961
955
  toolbarsExclude: import('./type').ToolbarNames[];
962
956
  noPrettier: boolean;
963
957
  tabWidth: number;
964
- tableShape: number[];
965
958
  placeholder: string;
966
959
  footers: import('./type').Footers[];
967
960
  scrollAuto: boolean;
@@ -284,11 +284,12 @@ export declare const editorProps: {
284
284
  /**
285
285
  * 表格预设格子数
286
286
  *
287
+ * 也可以是[6, 4, 10, 8]
288
+ *
287
289
  * @default [6, 4]
288
290
  */
289
291
  tableShape: {
290
292
  type: PropType<number[]>;
291
- default: () => number[];
292
293
  };
293
294
  /**
294
295
  * 空提示
@@ -212,6 +212,41 @@ export interface ConfigOption {
212
212
  css?: string;
213
213
  };
214
214
  };
215
+ /**
216
+ * 对应editorExtensions中的cdn链接标签属性
217
+ *
218
+ * 不要尝试在editorExtensionsAttrs定义script的src\onload\id,link的rel\href\id
219
+ * 它们会被默认值覆盖
220
+ */
221
+ editorExtensionsAttrs: {
222
+ highlight?: {
223
+ js?: Partial<HTMLElementTagNameMap['script']>;
224
+ css?: CodeCssAttrs;
225
+ };
226
+ prettier?: {
227
+ standaloneJs?: Partial<HTMLElementTagNameMap['script']>;
228
+ parserMarkdownJs?: Partial<HTMLElementTagNameMap['script']>;
229
+ };
230
+ cropper?: {
231
+ js?: Partial<HTMLElementTagNameMap['script']>;
232
+ css?: Partial<HTMLElementTagNameMap['link']>;
233
+ };
234
+ iconfont?: Partial<HTMLElementTagNameMap['script']>;
235
+ /**
236
+ * class方式的图标
237
+ */
238
+ iconfontClass?: Partial<HTMLElementTagNameMap['link']>;
239
+ screenfull?: {
240
+ js?: Partial<HTMLElementTagNameMap['script']>;
241
+ };
242
+ mermaid?: {
243
+ js?: Partial<HTMLElementTagNameMap['script']>;
244
+ };
245
+ katex?: {
246
+ js?: Partial<HTMLElementTagNameMap['script']>;
247
+ css?: Partial<HTMLElementTagNameMap['link']>;
248
+ };
249
+ };
215
250
  editorConfig: {
216
251
  /**
217
252
  * 自定义提示语言
@@ -227,6 +262,11 @@ export interface ConfigOption {
227
262
  * 输入渲染延迟(ms)
228
263
  */
229
264
  renderDelay?: number;
265
+ /**
266
+ * 内部的弹窗、下拉框等内联zIndex
267
+ * @default 20000
268
+ */
269
+ zIndex?: number;
230
270
  };
231
271
  /**
232
272
  * 根据主题和内部默认的codeMirror扩展自定义新的扩展
@@ -286,6 +326,12 @@ export interface CodeCss {
286
326
  dark: string;
287
327
  };
288
328
  }
329
+ export interface CodeCssAttrs {
330
+ [key: string]: {
331
+ light: Partial<HTMLElementTagNameMap['link']>;
332
+ dark: Partial<HTMLElementTagNameMap['link']>;
333
+ };
334
+ }
289
335
  export type UpdateSetting = (k: keyof SettingType, v?: boolean) => void;
290
336
  export type ChangeEvent = (v: string) => void;
291
337
  export type SaveEvent = (v: string, h: Promise<string>) => void;
@@ -11,7 +11,7 @@ export declare const keyMove: (trigger: HTMLElement, moveHandler?: (left: number
11
11
  * @param ele
12
12
  * @param checkKey 全局名称
13
13
  */
14
- export declare const appendHandler: (ele: HTMLElement, checkKey?: string) => void;
14
+ export declare const appendHandler: <K extends keyof HTMLElementTagNameMap>(tagName: K, attributes: Partial<HTMLElementTagNameMap[K]>, checkKey?: string) => void;
15
15
  /**
16
16
  * 更新插入的元素属性
17
17
  *
@@ -19,4 +19,12 @@ export declare const appendHandler: (ele: HTMLElement, checkKey?: string) => voi
19
19
  * @param attr 属性名
20
20
  * @param value 属性值
21
21
  */
22
- export declare const updateHandler: (...params: string[]) => Promise<unknown>;
22
+ export declare const updateHandler: <K extends keyof HTMLElementTagNameMap>(tagName: K, attributes: Partial<HTMLElementTagNameMap[K]>) => void;
23
+ /**
24
+ * 创建带属性的原始标签
25
+ *
26
+ * @param tagName
27
+ * @param attributes
28
+ * @returns
29
+ */
30
+ export declare const createHTMLElement: <K extends keyof HTMLElementTagNameMap>(tagName: K, attributes: Partial<HTMLElementTagNameMap[K]>) => HTMLElementTagNameMap[K];
@@ -36,3 +36,7 @@ export declare const getRelativeTop: (element: HTMLElement, container: HTMLEleme
36
36
  * 获取递增的ID
37
37
  */
38
38
  export declare const getNextId: (prefix: string) => string;
39
+ /**
40
+ * 获取递增的zIndex
41
+ */
42
+ export declare const getZIndexIncrement: () => number;
@@ -58,6 +58,9 @@ declare const _default: import('vue').DefineComponent<{
58
58
  theme: {
59
59
  type: PropType<Themes>;
60
60
  };
61
+ previewTheme: {
62
+ type: PropType<string>;
63
+ };
61
64
  }, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("onClick" | "onClose" | "onAdjust")[], "onClick" | "onClose" | "onAdjust", import('vue').PublicProps, Readonly<ExtractPropTypes<{
62
65
  title: {
63
66
  type: PropType<string>;
@@ -115,6 +118,9 @@ declare const _default: import('vue').DefineComponent<{
115
118
  theme: {
116
119
  type: PropType<Themes>;
117
120
  };
121
+ previewTheme: {
122
+ type: PropType<string>;
123
+ };
118
124
  }>> & {
119
125
  onOnClose?: ((...args: any[]) => any) | undefined;
120
126
  onOnClick?: ((...args: any[]) => any) | undefined;
@@ -52,6 +52,9 @@ declare const _default: {
52
52
  theme: {
53
53
  type: import('vue').PropType<import('..').Themes>;
54
54
  };
55
+ previewTheme: {
56
+ type: import('vue').PropType<string>;
57
+ };
55
58
  }>> & {
56
59
  onOnClose?: ((...args: any[]) => any) | undefined;
57
60
  onOnClick?: ((...args: any[]) => any) | undefined;
@@ -107,6 +110,9 @@ declare const _default: {
107
110
  theme: {
108
111
  type: import('vue').PropType<import('..').Themes>;
109
112
  };
113
+ previewTheme: {
114
+ type: import('vue').PropType<string>;
115
+ };
110
116
  }>> & {
111
117
  onOnClose?: ((...args: any[]) => any) | undefined;
112
118
  onOnClick?: ((...args: any[]) => any) | undefined;
@@ -176,6 +182,9 @@ declare const _default: {
176
182
  theme: {
177
183
  type: import('vue').PropType<import('..').Themes>;
178
184
  };
185
+ previewTheme: {
186
+ type: import('vue').PropType<string>;
187
+ };
179
188
  }>> & {
180
189
  onOnClose?: ((...args: any[]) => any) | undefined;
181
190
  onOnClick?: ((...args: any[]) => any) | undefined;
@@ -242,6 +251,9 @@ declare const _default: {
242
251
  theme: {
243
252
  type: import('vue').PropType<import('..').Themes>;
244
253
  };
254
+ previewTheme: {
255
+ type: import('vue').PropType<string>;
256
+ };
245
257
  }>> & {
246
258
  onOnClose?: ((...args: any[]) => any) | undefined;
247
259
  onOnClick?: ((...args: any[]) => any) | undefined;
@@ -1,3 +1,3 @@
1
- export { config, iconfontClassUrl, iconfontSvgUrl, allToolbar, allFooter } from './MdEditor/config';
1
+ export { config, iconfontClassUrl, iconfontSvgUrl, allToolbar, allFooter, editorExtensionsAttrs } from './MdEditor/config';
2
2
  export declare const zh_CN: import('.').StaticTextDefaultValue;
3
3
  export declare const en_US: import('.').StaticTextDefaultValue;