md-editor-v3 4.19.0-4 → 4.19.0-5
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.
- package/lib/cjs/MdCatalog.cjs +3 -1
- package/lib/cjs/MdEditor.cjs +32 -29
- package/lib/cjs/chunks/index.cjs +3 -0
- package/lib/es/MdCatalog.mjs +3 -1
- package/lib/es/MdEditor.mjs +33 -30
- package/lib/es/chunks/index.mjs +3 -0
- package/lib/types/MdEditor/utils/content-help.d.ts +2 -2
- package/lib/umd/index.js +5 -5
- package/package.json +1 -1
package/lib/cjs/MdCatalog.cjs
CHANGED
|
@@ -245,11 +245,13 @@ const MdCatalog = /* @__PURE__ */ vue.defineComponent({
|
|
|
245
245
|
});
|
|
246
246
|
vue.onMounted(() => {
|
|
247
247
|
rootNodeRef.value = catalogRef.value.getRootNode();
|
|
248
|
-
|
|
248
|
+
let scrollElement = getScrollElement();
|
|
249
249
|
scrollElementRef.value = scrollElement;
|
|
250
250
|
eventName.bus.on(editorId, {
|
|
251
251
|
name: eventName.CATALOG_CHANGED,
|
|
252
252
|
callback: (_list) => {
|
|
253
|
+
scrollElement = getScrollElement();
|
|
254
|
+
scrollElementRef.value = scrollElement;
|
|
253
255
|
scrollElement == null ? void 0 : scrollElement.removeEventListener("scroll", scrollHandler);
|
|
254
256
|
findActiveHeading(_list);
|
|
255
257
|
scrollElement == null ? void 0 : scrollElement.addEventListener("scroll", scrollHandler);
|
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -377,13 +377,6 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
|
377
377
|
const fileReader = new FileReader();
|
|
378
378
|
fileReader.onload = (e) => {
|
|
379
379
|
data.imgSrc = e.target.result;
|
|
380
|
-
vue.nextTick(() => {
|
|
381
|
-
cropper = new Cropper(uploadImgRef.value, {
|
|
382
|
-
viewMode: 2,
|
|
383
|
-
preview: rootRef.value.querySelector(`.${config.prefix}-clip-preview-target`)
|
|
384
|
-
// aspectRatio: 16 / 9,
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
380
|
};
|
|
388
381
|
fileReader.readAsDataURL(fileList[0]);
|
|
389
382
|
}
|
|
@@ -393,18 +386,20 @@ const ClipModal = /* @__PURE__ */ vue.defineComponent({
|
|
|
393
386
|
vue.watch(() => [data.imgSelected], () => {
|
|
394
387
|
previewTargetRef.value.style = "";
|
|
395
388
|
});
|
|
396
|
-
vue.watch(() => data.isFullscreen, () => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
389
|
+
vue.watch([vue.toRef(() => data.isFullscreen), vue.toRef(() => data.imgSrc)], () => {
|
|
390
|
+
if (data.imgSrc) {
|
|
391
|
+
vue.nextTick(() => {
|
|
392
|
+
cropper == null ? void 0 : cropper.destroy();
|
|
393
|
+
previewTargetRef.value.style = "";
|
|
394
|
+
if (uploadImgRef.value) {
|
|
395
|
+
cropper = new Cropper(uploadImgRef.value, {
|
|
396
|
+
viewMode: 2,
|
|
397
|
+
preview: rootRef.value.getRootNode().querySelector(`.${config.prefix}-clip-preview-target`)
|
|
398
|
+
// aspectRatio: 16 / 9,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
408
403
|
});
|
|
409
404
|
const reset = () => {
|
|
410
405
|
cropper.clear();
|
|
@@ -1577,7 +1572,7 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
1577
1572
|
);
|
|
1578
1573
|
vue.onMounted(rebindEvent);
|
|
1579
1574
|
};
|
|
1580
|
-
const directive2flag = (direct, codeMirrorUt, params) => {
|
|
1575
|
+
const directive2flag = async (direct, codeMirrorUt, params) => {
|
|
1581
1576
|
var _a;
|
|
1582
1577
|
let targetValue = "";
|
|
1583
1578
|
let deviationStart = 0;
|
|
@@ -1604,7 +1599,7 @@ const directive2flag = (direct, codeMirrorUt, params) => {
|
|
|
1604
1599
|
});
|
|
1605
1600
|
targetValue = codeMirrorUt.getValue();
|
|
1606
1601
|
} else {
|
|
1607
|
-
targetValue = prettier.format(codeMirrorUt.getValue(), {
|
|
1602
|
+
targetValue = await prettier.format(codeMirrorUt.getValue(), {
|
|
1608
1603
|
parser: "markdown",
|
|
1609
1604
|
plugins: prettierPlugins
|
|
1610
1605
|
});
|
|
@@ -2728,30 +2723,38 @@ const useCodeMirror = (props2) => {
|
|
|
2728
2723
|
});
|
|
2729
2724
|
eventName.bus.on(editorId, {
|
|
2730
2725
|
name: eventName.REPLACE,
|
|
2731
|
-
callback(direct, params = {}) {
|
|
2726
|
+
async callback(direct, params = {}) {
|
|
2732
2727
|
var _a, _b;
|
|
2733
2728
|
if (direct === "image" && params.transform) {
|
|
2734
2729
|
const tv = props2.transformImgUrl(params.url);
|
|
2735
2730
|
if (tv instanceof Promise) {
|
|
2736
|
-
tv.then((url) => {
|
|
2731
|
+
tv.then(async (url) => {
|
|
2737
2732
|
var _a2;
|
|
2738
|
-
const { text, options } = directive2flag(
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2733
|
+
const { text, options } = await directive2flag(
|
|
2734
|
+
direct,
|
|
2735
|
+
codeMirrorUt.value,
|
|
2736
|
+
{
|
|
2737
|
+
...params,
|
|
2738
|
+
url
|
|
2739
|
+
}
|
|
2740
|
+
);
|
|
2742
2741
|
(_a2 = codeMirrorUt.value) == null ? void 0 : _a2.replaceSelectedText(text, options, editorId);
|
|
2743
2742
|
}).catch((err) => {
|
|
2744
2743
|
console.error(err);
|
|
2745
2744
|
});
|
|
2746
2745
|
} else {
|
|
2747
|
-
const { text, options } = directive2flag(direct, codeMirrorUt.value, {
|
|
2746
|
+
const { text, options } = await directive2flag(direct, codeMirrorUt.value, {
|
|
2748
2747
|
...params,
|
|
2749
2748
|
url: tv
|
|
2750
2749
|
});
|
|
2751
2750
|
(_a = codeMirrorUt.value) == null ? void 0 : _a.replaceSelectedText(text, options, editorId);
|
|
2752
2751
|
}
|
|
2753
2752
|
} else {
|
|
2754
|
-
const { text, options } = directive2flag(
|
|
2753
|
+
const { text, options } = await directive2flag(
|
|
2754
|
+
direct,
|
|
2755
|
+
codeMirrorUt.value,
|
|
2756
|
+
params
|
|
2757
|
+
);
|
|
2755
2758
|
(_b = codeMirrorUt.value) == null ? void 0 : _b.replaceSelectedText(text, options, editorId);
|
|
2756
2759
|
}
|
|
2757
2760
|
}
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -2316,6 +2316,9 @@ const useTaskState = (props, html) => {
|
|
|
2316
2316
|
let removeListener = () => {
|
|
2317
2317
|
};
|
|
2318
2318
|
const addListener = () => {
|
|
2319
|
+
if (!rootRef.value) {
|
|
2320
|
+
return false;
|
|
2321
|
+
}
|
|
2319
2322
|
const tasks = rootRef.value.querySelectorAll(".task-list-item.enabled");
|
|
2320
2323
|
const listener = (e) => {
|
|
2321
2324
|
var _a;
|
package/lib/es/MdCatalog.mjs
CHANGED
|
@@ -244,11 +244,13 @@ const MdCatalog = /* @__PURE__ */ defineComponent({
|
|
|
244
244
|
});
|
|
245
245
|
onMounted(() => {
|
|
246
246
|
rootNodeRef.value = catalogRef.value.getRootNode();
|
|
247
|
-
|
|
247
|
+
let scrollElement = getScrollElement();
|
|
248
248
|
scrollElementRef.value = scrollElement;
|
|
249
249
|
bus.on(editorId, {
|
|
250
250
|
name: CATALOG_CHANGED,
|
|
251
251
|
callback: (_list) => {
|
|
252
|
+
scrollElement = getScrollElement();
|
|
253
|
+
scrollElementRef.value = scrollElement;
|
|
252
254
|
scrollElement == null ? void 0 : scrollElement.removeEventListener("scroll", scrollHandler);
|
|
253
255
|
findActiveHeading(_list);
|
|
254
256
|
scrollElement == null ? void 0 : scrollElement.addEventListener("scroll", scrollHandler);
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { defineComponent, createVNode, inject, ref, onMounted, reactive, computed, watch, nextTick, Fragment, cloneVNode,
|
|
7
|
+
import { defineComponent, createVNode, inject, ref, onMounted, reactive, computed, watch, toRef, nextTick, Fragment, cloneVNode, shallowRef, onBeforeUnmount } from "vue";
|
|
8
8
|
import { p as prefix, f as configOption, b as allToolbar, M as MinInputBoxWidth, d as allFooter } from "./chunks/config.mjs";
|
|
9
9
|
import { draggingScroll, linkTo, debounce, createSmoothScroll, throttle } from "@vavt/util";
|
|
10
10
|
import { a as Dropdown, D as DropdownToolbar } from "./chunks/index2.mjs";
|
|
@@ -376,13 +376,6 @@ const ClipModal = /* @__PURE__ */ defineComponent({
|
|
|
376
376
|
const fileReader = new FileReader();
|
|
377
377
|
fileReader.onload = (e) => {
|
|
378
378
|
data.imgSrc = e.target.result;
|
|
379
|
-
nextTick(() => {
|
|
380
|
-
cropper = new Cropper(uploadImgRef.value, {
|
|
381
|
-
viewMode: 2,
|
|
382
|
-
preview: rootRef.value.querySelector(`.${prefix}-clip-preview-target`)
|
|
383
|
-
// aspectRatio: 16 / 9,
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
379
|
};
|
|
387
380
|
fileReader.readAsDataURL(fileList[0]);
|
|
388
381
|
}
|
|
@@ -392,18 +385,20 @@ const ClipModal = /* @__PURE__ */ defineComponent({
|
|
|
392
385
|
watch(() => [data.imgSelected], () => {
|
|
393
386
|
previewTargetRef.value.style = "";
|
|
394
387
|
});
|
|
395
|
-
watch(() => data.isFullscreen, () => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
388
|
+
watch([toRef(() => data.isFullscreen), toRef(() => data.imgSrc)], () => {
|
|
389
|
+
if (data.imgSrc) {
|
|
390
|
+
nextTick(() => {
|
|
391
|
+
cropper == null ? void 0 : cropper.destroy();
|
|
392
|
+
previewTargetRef.value.style = "";
|
|
393
|
+
if (uploadImgRef.value) {
|
|
394
|
+
cropper = new Cropper(uploadImgRef.value, {
|
|
395
|
+
viewMode: 2,
|
|
396
|
+
preview: rootRef.value.getRootNode().querySelector(`.${prefix}-clip-preview-target`)
|
|
397
|
+
// aspectRatio: 16 / 9,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}
|
|
407
402
|
});
|
|
408
403
|
const reset = () => {
|
|
409
404
|
cropper.clear();
|
|
@@ -1576,7 +1571,7 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
1576
1571
|
);
|
|
1577
1572
|
onMounted(rebindEvent);
|
|
1578
1573
|
};
|
|
1579
|
-
const directive2flag = (direct, codeMirrorUt, params) => {
|
|
1574
|
+
const directive2flag = async (direct, codeMirrorUt, params) => {
|
|
1580
1575
|
var _a;
|
|
1581
1576
|
let targetValue = "";
|
|
1582
1577
|
let deviationStart = 0;
|
|
@@ -1603,7 +1598,7 @@ const directive2flag = (direct, codeMirrorUt, params) => {
|
|
|
1603
1598
|
});
|
|
1604
1599
|
targetValue = codeMirrorUt.getValue();
|
|
1605
1600
|
} else {
|
|
1606
|
-
targetValue = prettier.format(codeMirrorUt.getValue(), {
|
|
1601
|
+
targetValue = await prettier.format(codeMirrorUt.getValue(), {
|
|
1607
1602
|
parser: "markdown",
|
|
1608
1603
|
plugins: prettierPlugins
|
|
1609
1604
|
});
|
|
@@ -2727,30 +2722,38 @@ const useCodeMirror = (props2) => {
|
|
|
2727
2722
|
});
|
|
2728
2723
|
bus.on(editorId, {
|
|
2729
2724
|
name: REPLACE,
|
|
2730
|
-
callback(direct, params = {}) {
|
|
2725
|
+
async callback(direct, params = {}) {
|
|
2731
2726
|
var _a, _b;
|
|
2732
2727
|
if (direct === "image" && params.transform) {
|
|
2733
2728
|
const tv = props2.transformImgUrl(params.url);
|
|
2734
2729
|
if (tv instanceof Promise) {
|
|
2735
|
-
tv.then((url) => {
|
|
2730
|
+
tv.then(async (url) => {
|
|
2736
2731
|
var _a2;
|
|
2737
|
-
const { text, options } = directive2flag(
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2732
|
+
const { text, options } = await directive2flag(
|
|
2733
|
+
direct,
|
|
2734
|
+
codeMirrorUt.value,
|
|
2735
|
+
{
|
|
2736
|
+
...params,
|
|
2737
|
+
url
|
|
2738
|
+
}
|
|
2739
|
+
);
|
|
2741
2740
|
(_a2 = codeMirrorUt.value) == null ? void 0 : _a2.replaceSelectedText(text, options, editorId);
|
|
2742
2741
|
}).catch((err) => {
|
|
2743
2742
|
console.error(err);
|
|
2744
2743
|
});
|
|
2745
2744
|
} else {
|
|
2746
|
-
const { text, options } = directive2flag(direct, codeMirrorUt.value, {
|
|
2745
|
+
const { text, options } = await directive2flag(direct, codeMirrorUt.value, {
|
|
2747
2746
|
...params,
|
|
2748
2747
|
url: tv
|
|
2749
2748
|
});
|
|
2750
2749
|
(_a = codeMirrorUt.value) == null ? void 0 : _a.replaceSelectedText(text, options, editorId);
|
|
2751
2750
|
}
|
|
2752
2751
|
} else {
|
|
2753
|
-
const { text, options } = directive2flag(
|
|
2752
|
+
const { text, options } = await directive2flag(
|
|
2753
|
+
direct,
|
|
2754
|
+
codeMirrorUt.value,
|
|
2755
|
+
params
|
|
2756
|
+
);
|
|
2754
2757
|
(_b = codeMirrorUt.value) == null ? void 0 : _b.replaceSelectedText(text, options, editorId);
|
|
2755
2758
|
}
|
|
2756
2759
|
}
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -2315,6 +2315,9 @@ const useTaskState = (props, html) => {
|
|
|
2315
2315
|
let removeListener = () => {
|
|
2316
2316
|
};
|
|
2317
2317
|
const addListener = () => {
|
|
2318
|
+
if (!rootRef.value) {
|
|
2319
|
+
return false;
|
|
2320
|
+
}
|
|
2318
2321
|
const tasks = rootRef.value.querySelectorAll(".task-list-item.enabled");
|
|
2319
2322
|
const listener = (e) => {
|
|
2320
2323
|
var _a;
|
|
@@ -8,7 +8,7 @@ export type ToolDirective = 'bold' | 'underline' | 'italic' | 'strikeThrough' |
|
|
|
8
8
|
*
|
|
9
9
|
* @returns string
|
|
10
10
|
*/
|
|
11
|
-
export declare const directive2flag: (direct: ToolDirective, codeMirrorUt: CodeMirrorUt, params?: any) => {
|
|
11
|
+
export declare const directive2flag: (direct: ToolDirective, codeMirrorUt: CodeMirrorUt, params?: any) => Promise<{
|
|
12
12
|
text: string;
|
|
13
13
|
options: {
|
|
14
14
|
select: boolean;
|
|
@@ -16,4 +16,4 @@ export declare const directive2flag: (direct: ToolDirective, codeMirrorUt: CodeM
|
|
|
16
16
|
deviationEnd: number;
|
|
17
17
|
replaceAll: boolean;
|
|
18
18
|
};
|
|
19
|
-
}
|
|
19
|
+
}>;
|