md-editor-v3 4.19.1 → 4.19.2

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,6 @@
1
1
  var __defProp = Object.defineProperty;
2
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
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { defineComponent, createVNode, inject, ref, onMounted, reactive, computed, watch, toRef, nextTick, Fragment, cloneVNode, shallowRef, onBeforeUnmount } from "vue";
8
5
  import { p as prefix, f as configOption, b as allToolbar, M as MinInputBoxWidth, d as allFooter } from "./chunks/config.mjs";
9
6
  import { draggingScroll, linkTo, throttle } from "@vavt/util";
@@ -18,7 +15,7 @@ import { EditorView, placeholder, keymap, drawSelection } from "@codemirror/view
18
15
  import { languages } from "@codemirror/language-data";
19
16
  import { markdown } from "@codemirror/lang-markdown";
20
17
  import { EditorSelection, EditorState, Compartment, StateEffect } from "@codemirror/state";
21
- import { deleteLine, defaultKeymap, historyKeymap, indentWithTab, history, undo, redo } from "@codemirror/commands";
18
+ import { deleteLine, history, undo, redo, defaultKeymap, historyKeymap, indentWithTab } from "@codemirror/commands";
22
19
  import { HighlightStyle, syntaxHighlighting, indentUnit } from "@codemirror/language";
23
20
  import { tags } from "@lezer/highlight";
24
21
  import { autocompletion } from "@codemirror/autocomplete";
@@ -221,7 +218,6 @@ const TableShape = /* @__PURE__ */ defineComponent({
221
218
  }, null)]))]))]);
222
219
  }
223
220
  });
224
- const TableShape$1 = TableShape;
225
221
  const props$5 = {
226
222
  type: {
227
223
  type: String,
@@ -873,7 +869,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
873
869
  visible.table = v;
874
870
  },
875
871
  "key": "bar-table",
876
- "overlay": createVNode(TableShape$1, {
872
+ "overlay": createVNode(TableShape, {
877
873
  "tableShape": props2.tableShape,
878
874
  "onSelected": (selectedShape) => {
879
875
  emitHandler("table", {
@@ -2363,9 +2359,15 @@ const useCodeMirror = (props2) => {
2363
2359
  const theme = inject("theme");
2364
2360
  const inputWrapperRef = ref();
2365
2361
  const codeMirrorUt = shallowRef();
2362
+ const spelling = ref(false);
2366
2363
  const languageComp = new Compartment(), themeComp = new Compartment(), autocompletionComp = new Compartment(), historyComp = new Compartment(), eventComp = new Compartment();
2367
2364
  const mdEditorCommands = createCommands(editorId, props2);
2368
- const spelling = ref(false);
2365
+ const getDefaultKeymaps = () => [
2366
+ ...defaultKeymap,
2367
+ ...historyKeymap,
2368
+ ...mdEditorCommands,
2369
+ indentWithTab
2370
+ ];
2369
2371
  const pasteHandler = usePasteUpload(props2, codeMirrorUt);
2370
2372
  const domEventHandlers = {
2371
2373
  paste: pasteHandler,
@@ -2394,7 +2396,7 @@ const useCodeMirror = (props2) => {
2394
2396
  }
2395
2397
  };
2396
2398
  const defaultExtensions = [
2397
- keymap.of([...defaultKeymap, ...historyKeymap, ...mdEditorCommands, indentWithTab]),
2399
+ keymap.of(getDefaultKeymaps()),
2398
2400
  historyComp.of(history()),
2399
2401
  languageComp.of(markdown({ codeLanguages: languages })),
2400
2402
  // 横向换行
@@ -2417,9 +2419,11 @@ const useCodeMirror = (props2) => {
2417
2419
  themeComp.of(theme.value === "light" ? oneLight : oneDark),
2418
2420
  autocompletionComp.of(createAutocompletion(props2.completions))
2419
2421
  ];
2420
- return configOption.codeMirrorExtensions(theme.value, extensions, [
2421
- ...mdEditorCommands
2422
- ]);
2422
+ return configOption.codeMirrorExtensions(
2423
+ theme.value,
2424
+ extensions,
2425
+ getDefaultKeymaps()
2426
+ );
2423
2427
  };
2424
2428
  onMounted(() => {
2425
2429
  const view = new EditorView$1({
@@ -61,8 +61,107 @@ const createHTMLElement = (tagName, attributes) => {
61
61
  });
62
62
  return element;
63
63
  };
64
+ const zoomMermaid = /* @__PURE__ */ (() => {
65
+ const addEvent = (container) => {
66
+ if (!container) {
67
+ return;
68
+ }
69
+ const content = container.firstChild;
70
+ let scale = 1;
71
+ let posX = 0;
72
+ let posY = 0;
73
+ let isDragging = false;
74
+ let startX, startY;
75
+ let initialDistance;
76
+ let initialScale = 1;
77
+ const updateTransform = () => {
78
+ content.style.transform = `translate(${posX}px, ${posY}px) scale(${scale})`;
79
+ };
80
+ container.addEventListener("touchstart", (event) => {
81
+ if (event.touches.length === 1) {
82
+ isDragging = true;
83
+ startX = event.touches[0].clientX - posX;
84
+ startY = event.touches[0].clientY - posY;
85
+ } else if (event.touches.length === 2) {
86
+ initialDistance = Math.hypot(
87
+ event.touches[0].clientX - event.touches[1].clientX,
88
+ event.touches[0].clientY - event.touches[1].clientY
89
+ );
90
+ initialScale = scale;
91
+ }
92
+ });
93
+ container.addEventListener("touchmove", (event) => {
94
+ event.preventDefault();
95
+ if (isDragging && event.touches.length === 1) {
96
+ posX = event.touches[0].clientX - startX;
97
+ posY = event.touches[0].clientY - startY;
98
+ updateTransform();
99
+ } else if (event.touches.length === 2) {
100
+ const newDistance = Math.hypot(
101
+ event.touches[0].clientX - event.touches[1].clientX,
102
+ event.touches[0].clientY - event.touches[1].clientY
103
+ );
104
+ const scaleChange = newDistance / initialDistance;
105
+ const previousScale = scale;
106
+ scale = initialScale * (1 + (scaleChange - 1));
107
+ const centerX = (event.touches[0].clientX + event.touches[1].clientX) / 2;
108
+ const centerY = (event.touches[0].clientY + event.touches[1].clientY) / 2;
109
+ const rect = content.getBoundingClientRect();
110
+ const relativeX = (centerX - rect.left) / previousScale;
111
+ const relativeY = (centerY - rect.top) / previousScale;
112
+ posX -= relativeX * (scale - previousScale);
113
+ posY -= relativeY * (scale - previousScale);
114
+ updateTransform();
115
+ }
116
+ });
117
+ container.addEventListener("touchend", () => {
118
+ isDragging = false;
119
+ });
120
+ container.addEventListener("wheel", (event) => {
121
+ event.preventDefault();
122
+ const scaleAmount = 0.02;
123
+ const previousScale = scale;
124
+ if (event.deltaY < 0) {
125
+ scale += scaleAmount;
126
+ } else {
127
+ scale = Math.max(0.1, scale - scaleAmount);
128
+ }
129
+ const rect = content.getBoundingClientRect();
130
+ const mouseX = event.clientX - rect.left;
131
+ const mouseY = event.clientY - rect.top;
132
+ posX -= mouseX / previousScale * (scale - previousScale);
133
+ posY -= mouseY / previousScale * (scale - previousScale);
134
+ updateTransform();
135
+ });
136
+ container.addEventListener("mousedown", (event) => {
137
+ isDragging = true;
138
+ startX = event.clientX - posX;
139
+ startY = event.clientY - posY;
140
+ });
141
+ container.addEventListener("mousemove", (event) => {
142
+ if (isDragging) {
143
+ posX = event.clientX - startX;
144
+ posY = event.clientY - startY;
145
+ updateTransform();
146
+ }
147
+ });
148
+ container.addEventListener("mouseup", () => {
149
+ isDragging = false;
150
+ });
151
+ container.addEventListener("mouseleave", () => {
152
+ isDragging = false;
153
+ });
154
+ };
155
+ const handler = (containers) => {
156
+ containers.forEach((mm) => {
157
+ addEvent(mm);
158
+ });
159
+ };
160
+ return handler;
161
+ })();
64
162
  export {
65
163
  appendHandler as a,
66
164
  keyMove as k,
67
- updateHandler as u
165
+ updateHandler as u,
166
+ zoomMermaid as z
68
167
  };
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
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
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  class Bus {
8
5
  constructor() {
9
6
  // 事件池