vue-devui 1.6.4-alpha.0 → 1.6.4-markdown.1
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/editor-md/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { toRefs, onMounted, onUnmounted, watch, defineComponent, ref, renderSlot, useSlots, createVNode, reactive, computed, nextTick,
|
|
24
|
+
import { toRefs, onMounted, onUnmounted, watch, defineComponent, ref, renderSlot, useSlots, createVNode, reactive, computed, nextTick, onBeforeUnmount, onBeforeMount, Transition, mergeProps, unref, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, provide, Teleport, vShow, createTextVNode, isVNode } from "vue";
|
|
25
25
|
import "clipboard";
|
|
26
26
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
27
27
|
import { onClickOutside } from "@vueuse/core";
|
|
@@ -7268,13 +7268,15 @@ function useEditorMd(props, ctx) {
|
|
|
7268
7268
|
customHintReplaceFn,
|
|
7269
7269
|
hintConfig,
|
|
7270
7270
|
disableChangeEvent,
|
|
7271
|
-
modelValue
|
|
7271
|
+
modelValue,
|
|
7272
|
+
beforeShowHint
|
|
7272
7273
|
} = toRefs(props);
|
|
7273
7274
|
const toolbars = reactive(cloneDeep_1(DEFAULT_TOOLBARS));
|
|
7274
7275
|
const editorRef = ref();
|
|
7275
7276
|
const renderRef = ref();
|
|
7276
7277
|
const overlayRef = ref();
|
|
7277
7278
|
const cursorRef = ref();
|
|
7279
|
+
const containerRef = ref();
|
|
7278
7280
|
const isHintShow = ref();
|
|
7279
7281
|
const previewHtmlList = ref([]);
|
|
7280
7282
|
let editorIns;
|
|
@@ -7388,6 +7390,13 @@ function useEditorMd(props, ctx) {
|
|
|
7388
7390
|
const cursor = editorIns.getCursor();
|
|
7389
7391
|
let i = prefixes.value.length;
|
|
7390
7392
|
const value = editorIns.getLine(cursor.line).replace(/\t/g, " ");
|
|
7393
|
+
let result = false;
|
|
7394
|
+
if (beforeShowHint == null ? void 0 : beforeShowHint.value) {
|
|
7395
|
+
result = beforeShowHint.value(value);
|
|
7396
|
+
}
|
|
7397
|
+
if (result) {
|
|
7398
|
+
return;
|
|
7399
|
+
}
|
|
7391
7400
|
const selection = editorIns.getSelection();
|
|
7392
7401
|
const isImgRegx = /^\!\[\S+/;
|
|
7393
7402
|
if (selection) {
|
|
@@ -7502,12 +7511,22 @@ function useEditorMd(props, ctx) {
|
|
|
7502
7511
|
}
|
|
7503
7512
|
}
|
|
7504
7513
|
};
|
|
7514
|
+
const onDocumentClick = (e) => {
|
|
7515
|
+
var _a;
|
|
7516
|
+
if (isHintShow.value && e.target !== containerRef.value && !((_a = containerRef.value) == null ? void 0 : _a.contains(e.target))) {
|
|
7517
|
+
hideHint();
|
|
7518
|
+
}
|
|
7519
|
+
};
|
|
7505
7520
|
onMounted(async () => {
|
|
7506
7521
|
await import("codemirror/addon/display/placeholder.js");
|
|
7507
7522
|
await import("codemirror/mode/markdown/markdown.js");
|
|
7508
7523
|
const module = await import("codemirror");
|
|
7509
7524
|
CodeMirror = module.default;
|
|
7510
7525
|
initEditor();
|
|
7526
|
+
document.addEventListener("click", onDocumentClick);
|
|
7527
|
+
});
|
|
7528
|
+
onBeforeUnmount(() => {
|
|
7529
|
+
document.removeEventListener("click", onDocumentClick);
|
|
7511
7530
|
});
|
|
7512
7531
|
watch(modelValue, (val) => {
|
|
7513
7532
|
if (editorIns) {
|
|
@@ -7548,6 +7567,7 @@ function useEditorMd(props, ctx) {
|
|
|
7548
7567
|
overlayRef,
|
|
7549
7568
|
cursorRef,
|
|
7550
7569
|
renderRef,
|
|
7570
|
+
containerRef,
|
|
7551
7571
|
toolbars,
|
|
7552
7572
|
previewHtmlList,
|
|
7553
7573
|
isHintShow,
|
|
@@ -7675,6 +7695,9 @@ const editorMdProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
|
7675
7695
|
},
|
|
7676
7696
|
customHintReplaceFn: {
|
|
7677
7697
|
type: Function
|
|
7698
|
+
},
|
|
7699
|
+
beforeShowHint: {
|
|
7700
|
+
type: Function
|
|
7678
7701
|
}
|
|
7679
7702
|
});
|
|
7680
7703
|
const EditorMdInjectionKey = Symbol("d-editor-md");
|
|
@@ -9237,6 +9260,7 @@ var EditorMd = defineComponent({
|
|
|
9237
9260
|
overlayRef,
|
|
9238
9261
|
cursorRef,
|
|
9239
9262
|
renderRef,
|
|
9263
|
+
containerRef,
|
|
9240
9264
|
isHintShow,
|
|
9241
9265
|
toolbars,
|
|
9242
9266
|
previewHtmlList,
|
|
@@ -9267,6 +9291,7 @@ var EditorMd = defineComponent({
|
|
|
9267
9291
|
"z-index": fullscreenZIndex.value
|
|
9268
9292
|
}, {
|
|
9269
9293
|
default: () => [createVNode("div", {
|
|
9294
|
+
"ref": containerRef,
|
|
9270
9295
|
"class": ["dp-md-container", {
|
|
9271
9296
|
"dp-md-readonly": mode.value === "readonly",
|
|
9272
9297
|
"dp-md-editonly": mode.value === "editonly",
|
|
@@ -9293,7 +9318,9 @@ var EditorMd = defineComponent({
|
|
|
9293
9318
|
"onUpdate:modelValue": ($event) => isHintShow.value = $event,
|
|
9294
9319
|
"origin": cursorRef.value || void 0,
|
|
9295
9320
|
"align": "start",
|
|
9296
|
-
"position": ["bottom-start"]
|
|
9321
|
+
"position": ["bottom-start"],
|
|
9322
|
+
"onClick": withModifiers(() => {
|
|
9323
|
+
}, ["stop"])
|
|
9297
9324
|
}, {
|
|
9298
9325
|
default: () => {
|
|
9299
9326
|
var _a, _b;
|