md-editor-v3 5.4.0-2 → 5.4.0-4

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.
@@ -222,8 +222,8 @@ const zoomMermaid = /* @__PURE__ */ (() => {
222
222
  });
223
223
  return () => {
224
224
  removeEventsMap.forEach(({ removeEvent, removeClick }) => {
225
- if (removeEvent) removeEvent();
226
- if (removeClick) removeClick();
225
+ removeEvent == null ? void 0 : removeEvent();
226
+ removeClick == null ? void 0 : removeClick();
227
227
  });
228
228
  removeEventsMap.clear();
229
229
  };
@@ -145,6 +145,7 @@ const mermaidCache = new lruCache.LRUCache({
145
145
  ttl: 6e5
146
146
  });
147
147
  const useMermaid = (props) => {
148
+ const editorId = vue.inject("editorId");
148
149
  const theme = vue.inject("theme");
149
150
  const rootRef = vue.inject("rootRef");
150
151
  const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.configOption;
@@ -244,7 +245,12 @@ const useMermaid = (props) => {
244
245
  p.dataset.line = item.dataset.line;
245
246
  }
246
247
  item.replaceWith(p);
247
- } catch {
248
+ } catch (error) {
249
+ eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
250
+ name: "mermaid",
251
+ message: error.message,
252
+ error
253
+ });
248
254
  }
249
255
  if (--count === 0) {
250
256
  svgContainingElement.remove();
@@ -1457,11 +1463,9 @@ const useErrorCatcher = (props, context, options) => {
1457
1463
  eventName.bus.on(editorId, {
1458
1464
  name: eventName.ERROR_CATCHER,
1459
1465
  callback: (err) => {
1460
- if (props.onError instanceof Function) {
1461
- props.onError(err);
1462
- } else {
1463
- context.emit("onError", err);
1464
- }
1466
+ var _a;
1467
+ (_a = props.onError) == null ? void 0 : _a.call(props, err);
1468
+ context.emit("onError", err);
1465
1469
  }
1466
1470
  });
1467
1471
  });
@@ -221,8 +221,8 @@ const zoomMermaid = /* @__PURE__ */ (() => {
221
221
  });
222
222
  return () => {
223
223
  removeEventsMap.forEach(({ removeEvent, removeClick }) => {
224
- if (removeEvent) removeEvent();
225
- if (removeClick) removeClick();
224
+ removeEvent == null ? void 0 : removeEvent();
225
+ removeClick == null ? void 0 : removeClick();
226
226
  });
227
227
  removeEventsMap.clear();
228
228
  };
@@ -1,6 +1,6 @@
1
1
  import { inject, onMounted, watch, toRef, nextTick, shallowRef, ref, computed, onBeforeUnmount, defineComponent, createVNode, Fragment, reactive, provide, useId } from "vue";
2
2
  import { p as prefix, d as configOption, f as codeCss, s as staticTextDefault, a as allToolbar, b as allFooter } from "./config.mjs";
3
- import { b as bus, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, T as TASK_STATE_CHANGED, c as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, i as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, j as PREVIEW_CHANGED, k as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, l as CATALOG_VISIBLE_CHANGED, R as REPLACE, C as CHANGE_FULL_SCREEN, f as EVENT_LISTENER } from "./event-name.mjs";
3
+ import { b as bus, E as ERROR_CATCHER, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, T as TASK_STATE_CHANGED, c as ON_SAVE, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, i as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, j as PREVIEW_CHANGED, k as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, l as CATALOG_VISIBLE_CHANGED, R as REPLACE, C as CHANGE_FULL_SCREEN, f as EVENT_LISTENER } from "./event-name.mjs";
4
4
  import { debounce, randomId, deepMerge, deepClone } from "@vavt/util";
5
5
  import { a as appendHandler, u as updateHandler, S as StrIcon, z as zoomMermaid } from "./dom.mjs";
6
6
  import mediumZoom from "medium-zoom";
@@ -144,6 +144,7 @@ const mermaidCache = new LRUCache({
144
144
  ttl: 6e5
145
145
  });
146
146
  const useMermaid = (props) => {
147
+ const editorId = inject("editorId");
147
148
  const theme = inject("theme");
148
149
  const rootRef = inject("rootRef");
149
150
  const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = configOption;
@@ -243,7 +244,12 @@ const useMermaid = (props) => {
243
244
  p.dataset.line = item.dataset.line;
244
245
  }
245
246
  item.replaceWith(p);
246
- } catch {
247
+ } catch (error) {
248
+ bus.emit(editorId, ERROR_CATCHER, {
249
+ name: "mermaid",
250
+ message: error.message,
251
+ error
252
+ });
247
253
  }
248
254
  if (--count === 0) {
249
255
  svgContainingElement.remove();
@@ -1456,11 +1462,9 @@ const useErrorCatcher = (props, context, options) => {
1456
1462
  bus.on(editorId, {
1457
1463
  name: ERROR_CATCHER,
1458
1464
  callback: (err) => {
1459
- if (props.onError instanceof Function) {
1460
- props.onError(err);
1461
- } else {
1462
- context.emit("onError", err);
1463
- }
1465
+ var _a;
1466
+ (_a = props.onError) == null ? void 0 : _a.call(props, err);
1467
+ context.emit("onError", err);
1464
1468
  }
1465
1469
  });
1466
1470
  });
@@ -312,9 +312,10 @@ export type Config = (options: Partial<ConfigOption>) => void;
312
312
  * 编辑器操作潜在的错误
313
313
  */
314
314
  export interface InnerError {
315
- name: 'Cropper' | 'fullscreen' | 'prettier' | 'overlength';
315
+ name: 'Cropper' | 'fullscreen' | 'prettier' | 'overlength' | 'mermaid';
316
316
  message: string;
317
- data: any;
317
+ data?: any;
318
+ error?: Error;
318
319
  }
319
320
  export interface CodeCss {
320
321
  [key: string]: {