md-editor-v3 4.12.4 → 4.13.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,9 +1,9 @@
1
1
  import { inject, watch, toRef, onMounted, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
2
2
  import { e as configOption, p as prefix, m as mermaidUrl, k as katexUrl, f as codeCss, h as highlightUrl, s as staticTextDefault, a as iconfontSvgUrl, i as iconfontClassUrl, g as prettierUrl, j as cropperUrl, b as allToolbar, d as allFooter } from "./config.mjs";
3
- import { a as generateCodeRowNumber, b as bus, P as PUSH_CATALOG, C as CATALOG_CHANGED, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, d as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, e as PREVIEW_CHANGED, H as HTML_PREVIEW_CHANGED, f as CATALOG_VISIBLE_CHANGED, h as REPLACE, i as CHANGE_FULL_SCREEN, j as EVENT_LISTENER, k as getNextId } from "./index4.mjs";
3
+ import { a as generateCodeRowNumber, b as bus, P as PUSH_CATALOG, C as CATALOG_CHANGED, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, d as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, e as PREVIEW_CHANGED, f as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, h as CATALOG_VISIBLE_CHANGED, i as REPLACE, j as CHANGE_FULL_SCREEN, k as EVENT_LISTENER, l as getNextId } from "./index4.mjs";
4
4
  import { a as appendHandler, u as updateHandler } from "./dom.mjs";
5
+ import { debounce, uuid, deepMerge, deepClone } from "@vavt/util";
5
6
  import mediumZoom from "medium-zoom";
6
- import { debounce, uuid } from "@vavt/util";
7
7
  import copy from "copy-to-clipboard";
8
8
  import mdit from "markdown-it";
9
9
  import ImageFiguresPlugin from "markdown-it-image-figures";
@@ -1049,11 +1049,10 @@ const useProvidePreview = (props) => {
1049
1049
  ...staticTextDefault,
1050
1050
  ...(_b2 = (_a2 = configOption) == null ? void 0 : _a2.editorConfig) == null ? void 0 : _b2.languageUserDefined
1051
1051
  };
1052
- if (allText[props.language]) {
1053
- return allText[props.language];
1054
- } else {
1055
- return staticTextDefault["zh-CN"];
1056
- }
1052
+ return deepMerge(
1053
+ deepClone(staticTextDefault["en-US"]),
1054
+ allText[props.language] || {}
1055
+ );
1057
1056
  });
1058
1057
  provide("usedLanguageText", usedLanguageText);
1059
1058
  provide(
@@ -1144,14 +1143,19 @@ const useConfig = (props, context) => {
1144
1143
  pageFullscreen: props.pageFullscreen,
1145
1144
  fullscreen: false,
1146
1145
  preview: props.preview,
1147
- htmlPreview: props.preview ? false : props.htmlPreview
1146
+ htmlPreview: props.preview ? false : props.htmlPreview,
1147
+ previewOnly: false
1148
1148
  });
1149
1149
  const updateSetting = (k, v) => {
1150
1150
  setting[k] = v === void 0 ? !setting[k] : v;
1151
- if (k === "preview" && setting.preview) {
1151
+ if (k === "preview") {
1152
1152
  setting.htmlPreview = false;
1153
- } else if (k === "htmlPreview" && setting.htmlPreview) {
1153
+ setting.previewOnly = false;
1154
+ } else if (k === "htmlPreview") {
1154
1155
  setting.preview = false;
1156
+ setting.previewOnly = false;
1157
+ } else if (k === "previewOnly" && !setting.preview && !setting.htmlPreview) {
1158
+ setting.preview = true;
1155
1159
  }
1156
1160
  };
1157
1161
  let bodyOverflowHistory = "";
@@ -1226,6 +1230,12 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1226
1230
  bus.emit(editorId, PREVIEW_CHANGED, newVal);
1227
1231
  }
1228
1232
  );
1233
+ watch(
1234
+ () => setting.previewOnly,
1235
+ (newVal) => {
1236
+ bus.emit(editorId, PREVIEW_ONLY_CHANGED, newVal);
1237
+ }
1238
+ );
1229
1239
  watch(
1230
1240
  () => setting.htmlPreview,
1231
1241
  (newVal) => {
@@ -1265,6 +1275,15 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1265
1275
  });
1266
1276
  break;
1267
1277
  }
1278
+ case "previewOnly": {
1279
+ bus.on(editorId, {
1280
+ name: PREVIEW_ONLY_CHANGED,
1281
+ callback(status) {
1282
+ callBack(status);
1283
+ }
1284
+ });
1285
+ break;
1286
+ }
1268
1287
  case "htmlPreview": {
1269
1288
  bus.on(editorId, {
1270
1289
  name: HTML_PREVIEW_CHANGED,
@@ -1294,6 +1313,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1294
1313
  togglePreview(status) {
1295
1314
  updateSetting("preview", status);
1296
1315
  },
1316
+ togglePreviewOnly(status) {
1317
+ updateSetting("previewOnly", status);
1318
+ },
1297
1319
  toggleHtmlPreview(status) {
1298
1320
  updateSetting("htmlPreview", status);
1299
1321
  },
@@ -1323,6 +1345,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1323
1345
  },
1324
1346
  domEventHandlers(handlers) {
1325
1347
  bus.emit(editorId, EVENT_LISTENER, handlers);
1348
+ },
1349
+ execCommand(direct) {
1350
+ bus.emit(editorId, REPLACE, direct);
1326
1351
  }
1327
1352
  };
1328
1353
  ctx.expose(exposeParam);
@@ -57,6 +57,7 @@ const CHANGE_FULL_SCREEN = "changeFullscreen";
57
57
  const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
58
58
  const FULL_SCREEN_CHANGED = "fullscreenChanged";
59
59
  const PREVIEW_CHANGED = "previewChanged";
60
+ const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
60
61
  const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
61
62
  const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
62
63
  const BUILD_FINISHED = "buildFinished";
@@ -129,14 +130,15 @@ export {
129
130
  CHANGE_CATALOG_VISIBLE as c,
130
131
  PAGE_FULL_SCREEN_CHANGED as d,
131
132
  PREVIEW_CHANGED as e,
132
- CATALOG_VISIBLE_CHANGED as f,
133
+ PREVIEW_ONLY_CHANGED as f,
133
134
  getRelativeTop as g,
134
- REPLACE as h,
135
- CHANGE_FULL_SCREEN as i,
136
- EVENT_LISTENER as j,
137
- getNextId as k,
138
- base642File as l,
139
- OPEN_MODALS as m,
140
- CTRL_SHIFT_Z as n,
141
- CTRL_Z as o
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
142
144
  };
@@ -409,6 +409,7 @@ declare const Editor: import('vue').DefineComponent<{
409
409
  htmlPreview: boolean;
410
410
  class: string;
411
411
  style: string | import("vue").CSSProperties;
412
+ language: string;
412
413
  toolbars: import("~/type").ToolbarNames[];
413
414
  toolbarsExclude: import("~/type").ToolbarNames[];
414
415
  noPrettier: boolean;
@@ -421,7 +422,6 @@ declare const Editor: import('vue').DefineComponent<{
421
422
  inputBoxWitdh: string;
422
423
  modelValue: string;
423
424
  theme: import("~/type").Themes;
424
- language: string;
425
425
  editorId: string;
426
426
  showCodeRowNumber: boolean;
427
427
  previewTheme: string;
@@ -1,6 +1,6 @@
1
1
  import { PropType } from 'vue';
2
2
 
3
- export type IconName = 'bold' | 'underline' | 'italic' | 'strike-through' | 'title' | 'sub' | 'sup' | 'quote' | 'unordered-list' | 'ordered-list' | 'task' | 'code-row' | 'code' | 'link' | 'image' | 'table' | 'revoke' | 'next' | 'baocun' | 'prettier' | 'suoxiao' | 'fangda' | 'fullscreen-exit' | 'fullscreen' | 'preview' | 'coding' | 'catalog' | 'github' | 'mermaid' | 'formula' | 'close' | 'delete' | 'upload';
3
+ export type IconName = 'bold' | 'underline' | 'italic' | 'strike-through' | 'title' | 'sub' | 'sup' | 'quote' | 'unordered-list' | 'ordered-list' | 'task' | 'code-row' | 'code' | 'link' | 'image' | 'table' | 'revoke' | 'next' | 'baocun' | 'prettier' | 'suoxiao' | 'fangda' | 'fullscreen-exit' | 'fullscreen' | 'preview-only' | 'preview' | 'coding' | 'catalog' | 'github' | 'mermaid' | 'formula' | 'close' | 'delete' | 'upload';
4
4
  declare const _default: import('vue').DefineComponent<{
5
5
  name: {
6
6
  type: PropType<IconName>;
@@ -1,5 +1,5 @@
1
1
  import { ContentExposeParam } from './layouts/Content/type';
2
- import { SettingType, UpdateSetting, MdPreviewProps, EditorContext, EditorProps } from './type';
2
+ import { SettingType, UpdateSetting, MdPreviewProps, EditorProps, EditorContext } from './type';
3
3
  import { Ref } from 'vue';
4
4
 
5
5
  /**
@@ -2,8 +2,8 @@ import { CodeCss, Config, ConfigOption, Footers, StaticTextDefault } from './typ
2
2
 
3
3
  export declare const prefix = "md-editor";
4
4
  export declare const defaultEditorId = "md-editor-v3";
5
- export declare const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.js";
6
- export declare const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.css";
5
+ export declare const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.js";
6
+ export declare const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.css";
7
7
  export declare const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
8
8
  export declare const highlightUrl = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js";
9
9
  export declare const prettierUrl: {
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  htmlPreview: boolean;
11
11
  class: string;
12
12
  style: string | import('vue').CSSProperties;
13
+ language: string;
13
14
  toolbars: import('./type').ToolbarNames[];
14
15
  toolbarsExclude: import('./type').ToolbarNames[];
15
16
  noPrettier: boolean;
@@ -22,7 +23,6 @@ declare const _default: {
22
23
  inputBoxWitdh: string;
23
24
  modelValue: string;
24
25
  theme: import('./type').Themes;
25
- language: string;
26
26
  editorId: string;
27
27
  showCodeRowNumber: boolean;
28
28
  previewTheme: string;
@@ -247,7 +247,7 @@ declare const _default: {
247
247
  onOnInput?: ((...args: any[]) => any) | undefined;
248
248
  onOnDrop?: ((...args: any[]) => any) | undefined;
249
249
  onOnInputBoxWitdhChange?: ((...args: any[]) => any) | undefined;
250
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, "preview" | "pageFullscreen" | "htmlPreview" | "class" | "style" | "toolbars" | "toolbarsExclude" | "noPrettier" | "tabWidth" | "tableShape" | "placeholder" | "footers" | "scrollAuto" | "showToolbarName" | "inputBoxWitdh" | "modelValue" | "theme" | "language" | "editorId" | "showCodeRowNumber" | "previewTheme" | "mdHeadingId" | "sanitize" | "noMermaid" | "noKatex" | "codeTheme" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList" | "noHighlight" | "noImgZoomIn" | "customIcon" | "sanitizeMermaid">;
250
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, "preview" | "pageFullscreen" | "htmlPreview" | "class" | "style" | "language" | "toolbars" | "toolbarsExclude" | "noPrettier" | "tabWidth" | "tableShape" | "placeholder" | "footers" | "scrollAuto" | "showToolbarName" | "inputBoxWitdh" | "modelValue" | "theme" | "editorId" | "showCodeRowNumber" | "previewTheme" | "mdHeadingId" | "sanitize" | "noMermaid" | "noKatex" | "codeTheme" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList" | "noHighlight" | "noImgZoomIn" | "customIcon" | "sanitizeMermaid">;
251
251
  $attrs: {
252
252
  [x: string]: unknown;
253
253
  };
@@ -476,6 +476,7 @@ declare const _default: {
476
476
  htmlPreview: boolean;
477
477
  class: string;
478
478
  style: string | import("vue").CSSProperties;
479
+ language: string;
479
480
  toolbars: import("./type").ToolbarNames[];
480
481
  toolbarsExclude: import("./type").ToolbarNames[];
481
482
  noPrettier: boolean;
@@ -488,7 +489,6 @@ declare const _default: {
488
489
  inputBoxWitdh: string;
489
490
  modelValue: string;
490
491
  theme: import("./type").Themes;
491
- language: string;
492
492
  editorId: string;
493
493
  showCodeRowNumber: boolean;
494
494
  previewTheme: string;
@@ -952,6 +952,7 @@ declare const _default: {
952
952
  htmlPreview: boolean;
953
953
  class: string;
954
954
  style: string | import("vue").CSSProperties;
955
+ language: string;
955
956
  toolbars: import("./type").ToolbarNames[];
956
957
  toolbarsExclude: import("./type").ToolbarNames[];
957
958
  noPrettier: boolean;
@@ -964,7 +965,6 @@ declare const _default: {
964
965
  inputBoxWitdh: string;
965
966
  modelValue: string;
966
967
  theme: import("./type").Themes;
967
- language: string;
968
968
  editorId: string;
969
969
  showCodeRowNumber: boolean;
970
970
  previewTheme: string;
@@ -110,6 +110,7 @@ declare const ContentPreview: import('vue').DefineComponent<{
110
110
  type: import("vue").PropType<(h: string) => Promise<string>>;
111
111
  };
112
112
  }>>, {
113
+ previewOnly: boolean;
113
114
  onHtmlChanged: (h: string) => void;
114
115
  onGetCatalog: (list: import("~/type").HeadList[]) => void;
115
116
  modelValue: string;
@@ -120,6 +121,5 @@ declare const ContentPreview: import('vue').DefineComponent<{
120
121
  formatCopiedText: (text: string) => string;
121
122
  noHighlight: boolean;
122
123
  setting: import("~/type").SettingType;
123
- previewOnly: boolean;
124
124
  }>;
125
125
  export default ContentPreview;
@@ -233,6 +233,7 @@ declare const _default: import('vue').DefineComponent<{
233
233
  type: import("vue").PropType<(h: string) => Promise<string>>;
234
234
  };
235
235
  }>>, {
236
+ previewOnly: boolean;
236
237
  onChange: (v: string) => void;
237
238
  onHtmlChanged: (h: string) => void;
238
239
  onGetCatalog: (list: import("~/type").HeadList[]) => void;
@@ -250,6 +251,5 @@ declare const _default: import('vue').DefineComponent<{
250
251
  noHighlight: boolean;
251
252
  setting: import("~/type").SettingType;
252
253
  updateModelValue: (v: string) => void;
253
- previewOnly: boolean;
254
254
  }>;
255
255
  export default _default;
@@ -4,6 +4,7 @@ export declare const CHANGE_FULL_SCREEN = "changeFullscreen";
4
4
  export declare const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
5
5
  export declare const FULL_SCREEN_CHANGED = "fullscreenChanged";
6
6
  export declare const PREVIEW_CHANGED = "previewChanged";
7
+ export declare const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
7
8
  export declare const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
8
9
  export declare const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
9
10
  export declare const TEXTAREA_FOCUS = "textareaFocus";
@@ -1,3 +1,4 @@
1
+ import { ToolDirective } from './utils/content-help';
1
2
  import { IconName } from './components/Icon/Icon';
2
3
  import { editorProps, mdPreviewProps } from './props';
3
4
  import { KeyBinding, EditorView } from '@codemirror/view';
@@ -43,6 +44,7 @@ export interface ToolbarTips {
43
44
  pageFullscreen?: string;
44
45
  fullscreen?: string;
45
46
  preview?: string;
47
+ previewOnly?: string;
46
48
  htmlPreview?: string;
47
49
  catalog?: string;
48
50
  github?: string;
@@ -113,6 +115,7 @@ export interface SettingType {
113
115
  fullscreen: boolean;
114
116
  preview: boolean;
115
117
  htmlPreview: boolean;
118
+ previewOnly: boolean;
116
119
  }
117
120
  export type Themes = 'light' | 'dark';
118
121
  /**
@@ -300,6 +303,7 @@ export interface ExposeEvent {
300
303
  pageFullscreen(status: boolean): void;
301
304
  fullscreen(status: boolean): void;
302
305
  preview(status: boolean): void;
306
+ previewOnly(status: boolean): void;
303
307
  htmlPreview(status: boolean): void;
304
308
  catalog(status: boolean): void;
305
309
  }
@@ -351,6 +355,7 @@ export interface ExposeParam {
351
355
  * @param status 是否显示预览
352
356
  */
353
357
  togglePreview(status?: boolean): void;
358
+ togglePreviewOnly(status?: boolean): void;
354
359
  /**
355
360
  * 切换是否显示html预览
356
361
  *
@@ -406,6 +411,12 @@ export interface ExposeParam {
406
411
  * @param handlers
407
412
  */
408
413
  domEventHandlers(handlers: DOMEventHandlers): void;
414
+ /**
415
+ * 执行内部插入命令
416
+ *
417
+ * @param direct
418
+ */
419
+ execCommand(direct: ToolDirective): void;
409
420
  }
410
421
  export type ExposePreviewParam = Pick<ExposeParam, 'rerender'>;
411
422
  export type EditorProps = Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof editorProps>>>>;
@@ -194,9 +194,9 @@ declare const MdPreview: import('vue').DefineComponent<{
194
194
  }, {
195
195
  class: string;
196
196
  style: string | import("vue").CSSProperties;
197
+ language: string;
197
198
  modelValue: string;
198
199
  theme: import("~/type").Themes;
199
- language: string;
200
200
  editorId: string;
201
201
  showCodeRowNumber: boolean;
202
202
  previewTheme: string;
@@ -7,9 +7,9 @@ declare const _default: {
7
7
  $props: Partial<{
8
8
  class: string;
9
9
  style: string | import('vue').CSSProperties;
10
+ language: string;
10
11
  modelValue: string;
11
12
  theme: import('..').Themes;
12
- language: string;
13
13
  editorId: string;
14
14
  showCodeRowNumber: boolean;
15
15
  previewTheme: string;
@@ -128,7 +128,7 @@ declare const _default: {
128
128
  onOnInput?: ((...args: any[]) => any) | undefined;
129
129
  onOnDrop?: ((...args: any[]) => any) | undefined;
130
130
  onOnInputBoxWitdhChange?: ((...args: any[]) => any) | undefined;
131
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, "class" | "style" | "modelValue" | "theme" | "language" | "editorId" | "showCodeRowNumber" | "previewTheme" | "mdHeadingId" | "sanitize" | "noMermaid" | "noKatex" | "codeTheme" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList" | "noHighlight" | "noImgZoomIn" | "customIcon" | "sanitizeMermaid">;
131
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, "class" | "style" | "language" | "modelValue" | "theme" | "editorId" | "showCodeRowNumber" | "previewTheme" | "mdHeadingId" | "sanitize" | "noMermaid" | "noKatex" | "codeTheme" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList" | "noHighlight" | "noImgZoomIn" | "customIcon" | "sanitizeMermaid">;
132
132
  $attrs: {
133
133
  [x: string]: unknown;
134
134
  };
@@ -248,9 +248,9 @@ declare const _default: {
248
248
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("..").EditorEmits, string, {
249
249
  class: string;
250
250
  style: string | import("vue").CSSProperties;
251
+ language: string;
251
252
  modelValue: string;
252
253
  theme: import("..").Themes;
253
- language: string;
254
254
  editorId: string;
255
255
  showCodeRowNumber: boolean;
256
256
  previewTheme: string;
@@ -499,9 +499,9 @@ declare const _default: {
499
499
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("..").EditorEmits, "onChange" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "onError" | "update:modelValue" | "onBlur" | "onFocus" | "onInput" | "onDrop" | "onInputBoxWitdhChange", {
500
500
  class: string;
501
501
  style: string | import("vue").CSSProperties;
502
+ language: string;
502
503
  modelValue: string;
503
504
  theme: import("..").Themes;
504
- language: string;
505
505
  editorId: string;
506
506
  showCodeRowNumber: boolean;
507
507
  previewTheme: string;