@voicenter-team/voicenter-ui-plus 4.0.0-beta.1 → 4.0.0-beta.3
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/MIGRATION_v3.md +196 -0
- package/README.md +20 -51
- package/library/assets/assets/sass/main.css +1 -1
- package/library/assets/components/VcChatComposer/VcChatComposer.css +1 -1
- package/library/assets/components/VcMdEditor/ParameterNode.css +1 -1
- package/library/assets/components/VcMdEditor/VcMdEditorContent.css +1 -1
- package/library/assets/components/VcSoundplayer/VcSoundPlayerCompact.css +1 -0
- package/library/assets/components/VcSoundplayer/VcSoundVolume.css +1 -1
- package/library/components/VcChatComposer/VcChatComposer.vue.mjs +173 -139
- package/library/components/VcChatComposer/tiptap.mjs +45 -0
- package/library/components/VcCodeBlock/VcCodeBlock.vue.mjs +18 -5
- package/library/components/VcCodeBlock/highlight.mjs +8 -0
- package/library/components/VcEmojiPicker/VcEmojiPicker.vue.mjs +3 -4
- package/library/components/VcEmojiPicker/emojiData.mjs +16 -21
- package/library/components/VcHtmlEditor/VcHtmlEditor.vue.mjs +19 -12
- package/library/components/VcHtmlEditor/codemirror.mjs +14 -0
- package/library/components/VcImageUploader/VcImageUploader.vue.mjs +14 -8
- package/library/components/VcImageUploader/cropper.mjs +5 -0
- package/library/components/VcJsonSchema/Components/JsonCodeMirror.vue.mjs +16 -7
- package/library/components/VcJsonSchema/Components/codemirror.mjs +15 -0
- package/library/components/VcMdEditor/ParameterNode.vue.mjs +1 -1
- package/library/components/VcMdEditor/ParameterNode.vue2.mjs +2 -2
- package/library/components/VcMdEditor/VcMdEditor.vue.mjs +114 -108
- package/library/components/VcMdEditor/VcMdEditorContent.vue.mjs +18 -21
- package/library/components/VcMdEditor/ltrNumbersPlugin.mjs +42 -39
- package/library/components/VcMdEditor/mdEditor.config.mjs +107 -99
- package/library/components/VcMdEditor/milkdown.mjs +67 -0
- package/library/components/VcMdEditor/rtlCursorPlugin.mjs +3 -3
- package/library/components/VcPdfViewer/VcPdfDocument.vue.mjs +4 -8
- package/library/components/VcPdfViewer/pdfjslib.mjs +13 -16
- package/library/components/VcSoundplayer/VcPlayerPlayStopButton.vue.mjs +2 -1
- package/library/components/VcSoundplayer/VcSoundPlayer.vue.mjs +2 -8
- package/library/components/VcSoundplayer/VcSoundPlayerCompact.vue.mjs +197 -0
- package/library/components/VcSoundplayer/VcSoundPlayerCompact.vue3.mjs +5 -0
- package/library/components/VcSoundplayer/VcSoundPlayerProgress.vue.mjs +1 -1
- package/library/components/VcSoundplayer/VcSoundPlayerWrapper.vue.mjs +19 -7
- package/library/components/VcSoundplayer/player.options.mjs +8 -0
- package/library/components/VcSoundplayer/wavesurfer.mjs +14 -0
- package/library/index.mjs +59 -56
- package/library/index.mjs.br +0 -0
- package/library/index.mjs.gz +0 -0
- package/library/plugin-components.gen.mjs +91 -88
- package/library/plugin.mjs +59 -56
- package/library/plugin.mjs.br +0 -0
- package/library/plugin.mjs.gz +0 -0
- package/library/style.css +7 -5
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/types/components/VcChatComposer/VcChatComposer.vue.d.ts +2 -1
- package/library/types/components/VcChatComposer/tiptap.d.ts +61 -0
- package/library/types/components/VcCodeBlock/highlight.d.ts +3 -0
- package/library/types/components/VcEmojiPicker/VcEmojiPicker.vue.d.ts +1 -1
- package/library/types/components/VcEmojiPicker/emojiData.d.ts +3 -3
- package/library/types/components/VcHtmlEditor/codemirror.d.ts +8 -0
- package/library/types/components/VcImageUploader/VcImageUploader.vue.d.ts +1 -1
- package/library/types/components/VcImageUploader/cropper.d.ts +34 -0
- package/library/types/components/VcJsonSchema/Components/codemirror.d.ts +9 -0
- package/library/types/components/VcMdEditor/ltrNumbersPlugin.d.ts +7 -13
- package/library/types/components/VcMdEditor/mdEditor.config.d.ts +12 -16
- package/library/types/components/VcMdEditor/milkdown.d.ts +25 -0
- package/library/types/components/VcMdEditor/rtlCursorPlugin.d.ts +3 -2
- package/library/types/components/VcPdfViewer/VcPdfDocument.vue.d.ts +1 -1
- package/library/types/components/VcPdfViewer/VcPdfDocumentPage.vue.d.ts +1 -1
- package/library/types/components/VcPdfViewer/pdfjslib.d.ts +1 -1
- package/library/types/components/VcSoundplayer/VcPlayerPlayStopButton.vue.d.ts +11 -0
- package/library/types/components/VcSoundplayer/VcSoundPlayerCompact.vue.d.ts +75 -0
- package/library/types/components/VcSoundplayer/VcSoundPlayerWrapper.vue.d.ts +3 -1
- package/library/types/components/VcSoundplayer/player.options.d.ts +2 -0
- package/library/types/components/VcSoundplayer/wavesurfer.d.ts +8 -0
- package/library/types/components/exports.d.ts +3 -1
- package/library/types/components.gen.d.ts +1 -0
- package/library/types/types/VcSoundPlayer.types.d.ts +1 -1
- package/library/types/utils/optionalPeer.d.ts +33 -0
- package/library/utils/excelParser/helper.mjs +2 -7
- package/library/utils/optionalPeer.mjs +32 -0
- package/package.json +96 -1
- package/src/theme/index.ts +101 -101
- package/src/theme/theme.types.ts +31 -31
- package/tailwind.config.d.ts +5 -5
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import '../../assets/components/VcHtmlEditor/VcHtmlEditor.css';
|
|
2
|
-
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeStyle, normalizeClass, createVNode, createCommentVNode, createElementVNode, createBlock,
|
|
2
|
+
import { defineComponent, ref, shallowRef, computed, watch, onMounted, openBlock, createElementBlock, normalizeStyle, normalizeClass, createVNode, createCommentVNode, createElementVNode, createBlock, resolveDynamicComponent, isRef, unref } from "vue";
|
|
3
3
|
import { useVModel } from "@vueuse/core";
|
|
4
|
-
import
|
|
5
|
-
import { html } from "@codemirror/lang-html";
|
|
4
|
+
import { loadHtmlCodeMirror } from "./codemirror.mjs";
|
|
6
5
|
import { convertToUnit } from "../../utils/helpers.mjs";
|
|
7
6
|
import { buildMustacheSnippet } from "../VcMdEditor/buildMustacheSnippet.mjs";
|
|
8
7
|
import { buildHtmlPreviewDocument, getHtmlInsertAnchorOffset, getHtmlInsertSnippet } from "./htmlEditor.config.mjs";
|
|
@@ -31,6 +30,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
31
30
|
const emit = __emit;
|
|
32
31
|
const localModel = useVModel(props, "modelValue", emit);
|
|
33
32
|
const codeMirrorRef = ref(null);
|
|
33
|
+
const codeMirror = shallowRef();
|
|
34
34
|
const isCopied = ref(false);
|
|
35
35
|
const isPreviewMode = ref(false);
|
|
36
36
|
const minHeightProperty = computed(() => {
|
|
@@ -147,6 +147,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
147
147
|
emit("change", value || "");
|
|
148
148
|
}
|
|
149
149
|
);
|
|
150
|
+
onMounted(async () => {
|
|
151
|
+
const { CodeMirror, html } = await loadHtmlCodeMirror();
|
|
152
|
+
codeMirror.value = {
|
|
153
|
+
component: CodeMirror,
|
|
154
|
+
lang: html()
|
|
155
|
+
};
|
|
156
|
+
});
|
|
150
157
|
return (_ctx, _cache) => {
|
|
151
158
|
return openBlock(), createElementBlock("div", {
|
|
152
159
|
ref_key: "editorRoot",
|
|
@@ -177,24 +184,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
177
184
|
}, null, 8, ["is-teleported", "readonly", "is-preview-mode", "use-parameters", "parameters", "is-copied"])
|
|
178
185
|
])) : createCommentVNode("", true),
|
|
179
186
|
createElementVNode("div", _hoisted_2, [
|
|
180
|
-
|
|
187
|
+
isPreviewMode.value ? (openBlock(), createElementBlock("iframe", {
|
|
181
188
|
key: 0,
|
|
189
|
+
class: "vc-html-editor__preview",
|
|
190
|
+
srcdoc: previewDocument.value,
|
|
191
|
+
sandbox: "",
|
|
192
|
+
title: "HTML preview"
|
|
193
|
+
}, null, 8, _hoisted_3)) : codeMirror.value ? (openBlock(), createBlock(resolveDynamicComponent(codeMirror.value.component), {
|
|
194
|
+
key: 1,
|
|
182
195
|
ref_key: "codeMirrorRef",
|
|
183
196
|
ref: codeMirrorRef,
|
|
184
197
|
modelValue: unref(localModel),
|
|
185
198
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(localModel) ? localModel.value = $event : null),
|
|
186
199
|
disabled: __props.disabled,
|
|
187
200
|
readonly: __props.readonly,
|
|
188
|
-
lang:
|
|
201
|
+
lang: codeMirror.value.lang,
|
|
189
202
|
class: normalizeClass([{ "pointer-events-none opacity-50": __props.disabled }, "h-full w-full text-sm vc-html-editor__text-editor"]),
|
|
190
203
|
basic: ""
|
|
191
|
-
}, null, 8, ["modelValue", "disabled", "readonly", "lang", "class"])) : (
|
|
192
|
-
key: 1,
|
|
193
|
-
class: "vc-html-editor__preview",
|
|
194
|
-
srcdoc: previewDocument.value,
|
|
195
|
-
sandbox: "",
|
|
196
|
-
title: "HTML preview"
|
|
197
|
-
}, null, 8, _hoisted_3))
|
|
204
|
+
}, null, 8, ["modelValue", "disabled", "readonly", "lang", "class"])) : createCommentVNode("", true)
|
|
198
205
|
])
|
|
199
206
|
], 6);
|
|
200
207
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cachedLoad, loadOptionalPeer } from "../../utils/optionalPeer.mjs";
|
|
2
|
+
const loadHtmlCodeMirror = cachedLoad(async () => {
|
|
3
|
+
const [{ default: CodeMirror }, { html }] = await Promise.all([
|
|
4
|
+
loadOptionalPeer("vue-codemirror6", import("vue-codemirror6")),
|
|
5
|
+
loadOptionalPeer("@codemirror/lang-html", import("@codemirror/lang-html"))
|
|
6
|
+
]);
|
|
7
|
+
return {
|
|
8
|
+
CodeMirror,
|
|
9
|
+
html
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
export {
|
|
13
|
+
loadHtmlCodeMirror
|
|
14
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../assets/components/VcImageUploader/VcImageUploader.css';
|
|
2
|
-
import { defineComponent, ref, computed, openBlock, createElementBlock, createElementVNode, renderSlot, createVNode, withCtx, createTextVNode, toDisplayString, unref, TransitionGroup, createBlock, createCommentVNode, Fragment } from "vue";
|
|
2
|
+
import { defineComponent, ref, shallowRef, computed, onMounted, openBlock, createElementBlock, createElementVNode, renderSlot, createVNode, withCtx, createTextVNode, toDisplayString, unref, TransitionGroup, createBlock, resolveDynamicComponent, createCommentVNode, Fragment } from "vue";
|
|
3
3
|
import { CloudUpload, Minus, Plus, RotateCw, RotateCcw, Undo2, Save } from "@lucide/vue";
|
|
4
4
|
import { getMimeTypeFromBuffer } from "../../utils/mime-types.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { loadCropper } from "./cropper.mjs";
|
|
6
6
|
import _sfc_main$1 from "../VcButton/VcButton.vue.mjs";
|
|
7
7
|
import '../../assets/components/VcModal/VcModal.css';import '../../assets/components/VcIcon/VcIcon.css';import '../../assets/components/VcButton/VcButton.css';/* empty css */
|
|
8
8
|
import _sfc_main$4 from "../VcIcon/VcIcon.vue.mjs";
|
|
@@ -64,6 +64,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
64
64
|
});
|
|
65
65
|
const cropElementRef = ref();
|
|
66
66
|
const inputUploaderRef = ref();
|
|
67
|
+
const cropperModule = shallowRef();
|
|
67
68
|
const contentTitleText = computed(() => {
|
|
68
69
|
return props.contentTitle || tVU.t("voicenterUi.uploader.image.contentTitle");
|
|
69
70
|
});
|
|
@@ -175,6 +176,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
175
176
|
emit("save", croppedImage, originalData);
|
|
176
177
|
closeDialog();
|
|
177
178
|
}
|
|
179
|
+
onMounted(async () => {
|
|
180
|
+
cropperModule.value = await loadCropper();
|
|
181
|
+
});
|
|
178
182
|
__expose({
|
|
179
183
|
open: openExplorer,
|
|
180
184
|
close: closeDialog,
|
|
@@ -280,7 +284,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
280
284
|
class: "absolute left-0 top-0"
|
|
281
285
|
})) : (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
282
286
|
createElementVNode("div", _hoisted_8, [
|
|
283
|
-
!!imageState.value && !loading.value ? (openBlock(), createBlock(
|
|
287
|
+
cropperModule.value && !!imageState.value && !loading.value ? (openBlock(), createBlock(resolveDynamicComponent(cropperModule.value.Cropper), {
|
|
284
288
|
key: 0,
|
|
285
289
|
ref_key: "cropElementRef",
|
|
286
290
|
ref: cropElementRef,
|
|
@@ -298,7 +302,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
298
302
|
"image-restriction": "stencil",
|
|
299
303
|
onChange: change,
|
|
300
304
|
onError: error
|
|
301
|
-
}, null,
|
|
305
|
+
}, null, 40, ["src"])) : createCommentVNode("", true)
|
|
302
306
|
]),
|
|
303
307
|
createElementVNode("div", _hoisted_9, [
|
|
304
308
|
createElementVNode("div", _hoisted_10, [
|
|
@@ -364,22 +368,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
364
368
|
class: "absolute left-0 top-0 flex gap-4"
|
|
365
369
|
})) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
366
370
|
createElementVNode("div", _hoisted_15, [
|
|
367
|
-
|
|
371
|
+
cropperModule.value ? (openBlock(), createBlock(resolveDynamicComponent(cropperModule.value.Preview), {
|
|
372
|
+
key: 0,
|
|
368
373
|
width: 36,
|
|
369
374
|
height: 36,
|
|
370
375
|
image: result.value.image,
|
|
371
376
|
coordinates: result.value.coordinates,
|
|
372
377
|
class: "rounded-inner transition-all duration-300"
|
|
373
|
-
}, null, 8, ["image", "coordinates"])
|
|
378
|
+
}, null, 8, ["image", "coordinates"])) : createCommentVNode("", true)
|
|
374
379
|
]),
|
|
375
380
|
createElementVNode("div", _hoisted_16, [
|
|
376
|
-
|
|
381
|
+
cropperModule.value ? (openBlock(), createBlock(resolveDynamicComponent(cropperModule.value.Preview), {
|
|
382
|
+
key: 0,
|
|
377
383
|
width: 36,
|
|
378
384
|
height: 36,
|
|
379
385
|
image: result.value.image,
|
|
380
386
|
coordinates: result.value.coordinates,
|
|
381
387
|
class: "rounded-full transition-all duration-300"
|
|
382
|
-
}, null, 8, ["image", "coordinates"])
|
|
388
|
+
}, null, 8, ["image", "coordinates"])) : createCommentVNode("", true)
|
|
383
389
|
])
|
|
384
390
|
], 64))
|
|
385
391
|
]),
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import '../../../assets/components/VcJsonSchema/Components/JsonCodeMirror.css';
|
|
2
|
-
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, createVNode, unref, withCtx, createTextVNode, toDisplayString } from "vue";
|
|
3
|
-
import { jsonParseLinter, json } from "@codemirror/lang-json";
|
|
4
|
-
import CodeMirror from "vue-codemirror6";
|
|
2
|
+
import { defineComponent, ref, shallowRef, computed, watch, onMounted, openBlock, createElementBlock, createBlock, resolveDynamicComponent, createCommentVNode, createVNode, unref, withCtx, createTextVNode, toDisplayString } from "vue";
|
|
5
3
|
import useCopyButton from "../../../composables/useCopyButton.mjs";
|
|
6
4
|
import _sfc_main$1 from "../../VcButton/VcButton.vue.mjs";
|
|
7
5
|
import '../../../assets/components/VcButton/VcButton.css';/* empty css */
|
|
6
|
+
import { loadJsonCodeMirror } from "./codemirror.mjs";
|
|
8
7
|
const _hoisted_1 = { class: "vc-json-code-mirror w-full" };
|
|
9
8
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
9
|
__name: "JsonCodeMirror",
|
|
@@ -16,6 +15,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16
15
|
const { copyTextAction, copyDisabled, onCopyHandler } = useCopyButton();
|
|
17
16
|
const props = __props;
|
|
18
17
|
const isError = ref(false);
|
|
18
|
+
const codeMirror = shallowRef();
|
|
19
19
|
const emit = __emit;
|
|
20
20
|
const jsonCodeMirrorModel = computed({
|
|
21
21
|
get: () => JSON.stringify(props.modelValue, void 0, 2),
|
|
@@ -39,20 +39,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
39
39
|
emit("update:errorState", val);
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
|
+
onMounted(async () => {
|
|
43
|
+
const { CodeMirror, json, jsonParseLinter } = await loadJsonCodeMirror();
|
|
44
|
+
codeMirror.value = {
|
|
45
|
+
component: CodeMirror,
|
|
46
|
+
lang: json(),
|
|
47
|
+
linter: jsonParseLinter()
|
|
48
|
+
};
|
|
49
|
+
});
|
|
42
50
|
__expose({
|
|
43
51
|
hasError: () => isError.value
|
|
44
52
|
});
|
|
45
53
|
return (_ctx, _cache) => {
|
|
46
54
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
47
|
-
|
|
55
|
+
codeMirror.value ? (openBlock(), createBlock(resolveDynamicComponent(codeMirror.value.component), {
|
|
56
|
+
key: 0,
|
|
48
57
|
ref: "codeMirrorRef",
|
|
49
58
|
modelValue: jsonCodeMirrorModel.value,
|
|
50
59
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => jsonCodeMirrorModel.value = $event),
|
|
51
|
-
lang:
|
|
52
|
-
linter:
|
|
60
|
+
lang: codeMirror.value.lang,
|
|
61
|
+
linter: codeMirror.value.linter,
|
|
53
62
|
basic: "",
|
|
54
63
|
class: "h-full w-full text-xs"
|
|
55
|
-
}, null, 8, ["modelValue", "lang", "linter"]),
|
|
64
|
+
}, null, 8, ["modelValue", "lang", "linter"])) : createCommentVNode("", true),
|
|
56
65
|
createVNode(_sfc_main$1, {
|
|
57
66
|
disabled: unref(copyDisabled),
|
|
58
67
|
color: "primary",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cachedLoad, loadOptionalPeer } from "../../../utils/optionalPeer.mjs";
|
|
2
|
+
const loadJsonCodeMirror = cachedLoad(async () => {
|
|
3
|
+
const [{ default: CodeMirror }, { json, jsonParseLinter }] = await Promise.all([
|
|
4
|
+
loadOptionalPeer("vue-codemirror6", import("vue-codemirror6")),
|
|
5
|
+
loadOptionalPeer("@codemirror/lang-json", import("@codemirror/lang-json"))
|
|
6
|
+
]);
|
|
7
|
+
return {
|
|
8
|
+
CodeMirror,
|
|
9
|
+
json,
|
|
10
|
+
jsonParseLinter
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
export {
|
|
14
|
+
loadJsonCodeMirror
|
|
15
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./ParameterNode.vue2.mjs";
|
|
2
2
|
import '../../assets/components/VcMdEditor/ParameterNode.css';/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
4
|
-
const ParameterNode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const ParameterNode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-af1fed49"]]);
|
|
5
5
|
export {
|
|
6
6
|
ParameterNode as default
|
|
7
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, toRef, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, withModifiers, createBlock, createCommentVNode, toDisplayString, createVNode } from "vue";
|
|
2
|
-
import { useWidgetViewContext } from "@prosemirror-adapter/vue";
|
|
3
2
|
import { NodeParameterIcons } from "./mdEditor.config.mjs";
|
|
3
|
+
import { injectMilkdown } from "./milkdown.mjs";
|
|
4
4
|
import _sfc_main$2 from "../VcInput/VcInput.vue.mjs";
|
|
5
5
|
import '../../assets/components/VcIcon/VcIcon.css';import '../../assets/components/VcButton/VcButtonIcon.css';import '../../assets/components/VcInput/VcInput.css';/* empty css */
|
|
6
6
|
import _sfc_main$3 from "../VcButton/VcButtonIcon.vue.mjs";
|
|
@@ -18,7 +18,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18
18
|
__name: "ParameterNode",
|
|
19
19
|
emits: ["onConfirm"],
|
|
20
20
|
setup(__props, { emit: __emit }) {
|
|
21
|
-
const { spec = {} } = useWidgetViewContext();
|
|
21
|
+
const { spec = {} } = injectMilkdown().adapter.useWidgetViewContext();
|
|
22
22
|
const { parameterName = 0, onTest, fullString, class: className = "" } = spec;
|
|
23
23
|
const emit = __emit;
|
|
24
24
|
const localModel = toRef(fullString);
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { defineComponent, useAttrs, ref, computed, onMounted, nextTick, openBlock,
|
|
2
|
-
import { MilkdownProvider } from "@milkdown/vue";
|
|
1
|
+
import { defineComponent, useAttrs, ref, shallowRef, provide, computed, onMounted, nextTick, openBlock, createElementBlock, normalizeStyle, normalizeClass, createElementVNode, createBlock, createCommentVNode, createVNode, unref, withCtx, Fragment, resolveDynamicComponent, mergeProps, isRef } from "vue";
|
|
3
2
|
import _sfc_main$3 from "./VcMdEditorContent.vue.mjs";
|
|
4
3
|
import '../../assets/components/VcButton/VcButtonIcon.css';import '../../assets/node_modules/element-plus/theme-chalk/src/tooltip.css';import '../../assets/node_modules/element-plus/theme-chalk/src/popper.css';import '../../assets/node_modules/element-plus/theme-chalk/src/base.css';import '../../assets/components/VcMdEditor/VcMdEditorContent.css';/* empty css */
|
|
4
|
+
import { milkdownKey, loadMilkdown } from "./milkdown.mjs";
|
|
5
5
|
import { useReadonlyMarkdownDom } from "./readonlyMarkdown.mjs";
|
|
6
6
|
import { streamingInterval } from "./streamingInterval.mjs";
|
|
7
7
|
import { useVModel } from "@vueuse/core";
|
|
8
8
|
import { useThrottledText } from "../../composables/useThrottledText.mjs";
|
|
9
9
|
import { convertToUnit } from "../../utils/helpers.mjs";
|
|
10
|
-
import { markdown } from "@codemirror/lang-markdown";
|
|
11
|
-
import CodeMirror from "vue-codemirror6";
|
|
12
10
|
import _sfc_main$1 from "./VcMdEditorToolbar.vue.mjs";
|
|
13
|
-
import { ProsemirrorAdapterProvider } from "@prosemirror-adapter/vue";
|
|
14
11
|
import { isGroupParameter } from "../../types/VcMdEditor.types.mjs";
|
|
15
12
|
import { ElTooltip } from "element-plus";
|
|
16
13
|
/* empty css */
|
|
@@ -56,6 +53,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
56
53
|
const milkdownEditorContentRef = ref();
|
|
57
54
|
const contentRef = ref();
|
|
58
55
|
const alignMode = ref("ltr");
|
|
56
|
+
const milkdown = shallowRef();
|
|
57
|
+
provide(milkdownKey, milkdown);
|
|
58
|
+
const markdownLanguage = shallowRef();
|
|
59
59
|
const renderedModel = useThrottledText(
|
|
60
60
|
() => localModel.value,
|
|
61
61
|
() => props.streaming,
|
|
@@ -155,6 +155,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
155
155
|
mounted.value = true;
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
|
+
onMounted(async () => {
|
|
159
|
+
const loaded = await loadMilkdown();
|
|
160
|
+
markdownLanguage.value = loaded.langMarkdown.markdown();
|
|
161
|
+
milkdown.value = loaded;
|
|
162
|
+
});
|
|
158
163
|
__expose({
|
|
159
164
|
validate: () => {
|
|
160
165
|
return validateMustacheBlocks(localModel.value || "");
|
|
@@ -181,110 +186,111 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
181
186
|
onInsertParameter
|
|
182
187
|
});
|
|
183
188
|
return (_ctx, _cache) => {
|
|
184
|
-
return openBlock(),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
189
|
+
return openBlock(), createElementBlock("div", {
|
|
190
|
+
class: normalizeClass([{
|
|
191
|
+
"is--scrollable": maxHeightProperty.value,
|
|
192
|
+
"is-direction--rtl": alignMode.value === "rtl",
|
|
193
|
+
"is-direction--ltr": alignMode.value === "ltr",
|
|
194
|
+
"is--readonly": __props.readonly,
|
|
195
|
+
"is--plain": __props.plain,
|
|
196
|
+
"is--streaming": __props.streaming
|
|
197
|
+
}, "vc-markdown-editor__wrapper"]),
|
|
198
|
+
"data-test": "md-editor",
|
|
199
|
+
style: normalizeStyle({
|
|
200
|
+
"--min-md-height": minHeightProperty.value,
|
|
201
|
+
"--max-md-height": maxHeightProperty.value
|
|
202
|
+
})
|
|
203
|
+
}, [
|
|
204
|
+
!__props.disabled && !__props.hideToolbar ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
205
|
+
createElementVNode("div", _hoisted_2, [
|
|
206
|
+
editorMode.value && !__props.readonly ? (openBlock(), createBlock(_sfc_main$1, {
|
|
207
|
+
key: 0,
|
|
208
|
+
parameters: __props.parameters,
|
|
209
|
+
"is-teleported": __props.isTeleported,
|
|
210
|
+
onInsertParameter,
|
|
211
|
+
onSetBlockType
|
|
212
|
+
}, null, 8, ["parameters", "is-teleported"])) : createCommentVNode("", true)
|
|
213
|
+
]),
|
|
214
|
+
createElementVNode("div", _hoisted_3, [
|
|
215
|
+
createVNode(unref(ElTooltip), {
|
|
216
|
+
content: isCopied.value ? unref(tVU).t("voicenterUi.general.copied") : unref(tVU).t("voicenterUi.general.copyCode"),
|
|
217
|
+
teleported: __props.isTeleported
|
|
218
|
+
}, {
|
|
219
|
+
default: withCtx(() => [
|
|
220
|
+
createVNode(_sfc_main$2, {
|
|
221
|
+
icon: isCopied.value ? unref(Check) : unref(Copy),
|
|
222
|
+
onClick: onCopyContent
|
|
223
|
+
}, null, 8, ["icon"])
|
|
224
|
+
]),
|
|
225
|
+
_: 1
|
|
226
|
+
}, 8, ["content", "teleported"]),
|
|
227
|
+
createVNode(unref(ElTooltip), {
|
|
228
|
+
content: editorMode.value ? unref(tVU).t("voicenterUi.mdEditor.source") : unref(tVU).t("voicenterUi.mdEditor.editorMode"),
|
|
229
|
+
teleported: __props.isTeleported
|
|
230
|
+
}, {
|
|
231
|
+
default: withCtx(() => [
|
|
232
|
+
createVNode(_sfc_main$2, {
|
|
233
|
+
icon: editorMode.value ? unref(CodeXml) : unref(TextQuote),
|
|
234
|
+
onClick: _cache[0] || (_cache[0] = ($event) => editorMode.value = !editorMode.value)
|
|
235
|
+
}, null, 8, ["icon"])
|
|
236
|
+
]),
|
|
237
|
+
_: 1
|
|
238
|
+
}, 8, ["content", "teleported"]),
|
|
239
|
+
createVNode(unref(ElTooltip), {
|
|
240
|
+
content: alignMode.value === "rtl" ? unref(tVU).t("voicenterUi.general.alignLeft") : unref(tVU).t("voicenterUi.general.alignRight"),
|
|
241
|
+
teleported: __props.isTeleported
|
|
242
|
+
}, {
|
|
243
|
+
default: withCtx(() => [
|
|
244
|
+
createVNode(_sfc_main$2, {
|
|
245
|
+
icon: alignMode.value === "rtl" ? unref(AlignStartVertical) : unref(AlignEndVertical),
|
|
246
|
+
onClick: changeDirection
|
|
247
|
+
}, null, 8, ["icon"])
|
|
248
|
+
]),
|
|
249
|
+
_: 1
|
|
250
|
+
}, 8, ["content", "teleported"])
|
|
251
|
+
])
|
|
252
|
+
])) : createCommentVNode("", true),
|
|
253
|
+
createElementVNode("div", {
|
|
254
|
+
ref_key: "contentRef",
|
|
255
|
+
ref: contentRef,
|
|
256
|
+
class: "vc-markdown-editor__content"
|
|
257
|
+
}, [
|
|
258
|
+
milkdown.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
259
|
+
editorMode.value ? (openBlock(), createBlock(resolveDynamicComponent(milkdown.value.vue.MilkdownProvider), { key: 0 }, {
|
|
260
|
+
default: withCtx(() => [
|
|
261
|
+
(openBlock(), createBlock(resolveDynamicComponent(milkdown.value.adapter.ProsemirrorAdapterProvider), null, {
|
|
262
|
+
default: withCtx(() => [
|
|
263
|
+
createVNode(_sfc_main$3, mergeProps({
|
|
264
|
+
ref_key: "milkdownEditorContentRef",
|
|
265
|
+
ref: milkdownEditorContentRef,
|
|
266
|
+
html: unref(localHtml),
|
|
267
|
+
"onUpdate:html": _cache[1] || (_cache[1] = ($event) => isRef(localHtml) ? localHtml.value = $event : null),
|
|
268
|
+
"model-value": unref(renderedModel),
|
|
269
|
+
disabled: __props.disabled,
|
|
270
|
+
"min-height": __props.minHeight,
|
|
271
|
+
parameters: flatParameters.value,
|
|
272
|
+
"use-parameters": __props.useParameters,
|
|
273
|
+
readonly: __props.readonly
|
|
274
|
+
}, unref(attributes), { "onUpdate:modelValue": onEditorInput }), null, 16, ["html", "model-value", "disabled", "min-height", "parameters", "use-parameters", "readonly"])
|
|
212
275
|
]),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
createVNode(_sfc_main$2, {
|
|
232
|
-
icon: editorMode.value ? unref(CodeXml) : unref(TextQuote),
|
|
233
|
-
onClick: _cache[0] || (_cache[0] = ($event) => editorMode.value = !editorMode.value)
|
|
234
|
-
}, null, 8, ["icon"])
|
|
235
|
-
]),
|
|
236
|
-
_: 1
|
|
237
|
-
}, 8, ["content", "teleported"]),
|
|
238
|
-
createVNode(unref(ElTooltip), {
|
|
239
|
-
content: alignMode.value === "rtl" ? unref(tVU).t("voicenterUi.general.alignLeft") : unref(tVU).t("voicenterUi.general.alignRight"),
|
|
240
|
-
teleported: __props.isTeleported
|
|
241
|
-
}, {
|
|
242
|
-
default: withCtx(() => [
|
|
243
|
-
createVNode(_sfc_main$2, {
|
|
244
|
-
icon: alignMode.value === "rtl" ? unref(AlignStartVertical) : unref(AlignEndVertical),
|
|
245
|
-
onClick: changeDirection
|
|
246
|
-
}, null, 8, ["icon"])
|
|
247
|
-
]),
|
|
248
|
-
_: 1
|
|
249
|
-
}, 8, ["content", "teleported"])
|
|
250
|
-
])
|
|
251
|
-
])) : createCommentVNode("", true),
|
|
252
|
-
createElementVNode("div", {
|
|
253
|
-
ref_key: "contentRef",
|
|
254
|
-
ref: contentRef,
|
|
255
|
-
class: "vc-markdown-editor__content"
|
|
256
|
-
}, [
|
|
257
|
-
editorMode.value ? (openBlock(), createBlock(_sfc_main$3, mergeProps({
|
|
258
|
-
key: 0,
|
|
259
|
-
ref_key: "milkdownEditorContentRef",
|
|
260
|
-
ref: milkdownEditorContentRef,
|
|
261
|
-
html: unref(localHtml),
|
|
262
|
-
"onUpdate:html": _cache[1] || (_cache[1] = ($event) => isRef(localHtml) ? localHtml.value = $event : null),
|
|
263
|
-
"model-value": unref(renderedModel),
|
|
264
|
-
disabled: __props.disabled,
|
|
265
|
-
"min-height": __props.minHeight,
|
|
266
|
-
parameters: flatParameters.value,
|
|
267
|
-
"use-parameters": __props.useParameters,
|
|
268
|
-
readonly: __props.readonly
|
|
269
|
-
}, unref(attributes), { "onUpdate:modelValue": onEditorInput }), null, 16, ["html", "model-value", "disabled", "min-height", "parameters", "use-parameters", "readonly"])) : (openBlock(), createBlock(unref(CodeMirror), {
|
|
270
|
-
key: 1,
|
|
271
|
-
ref: "codeMirrorRef",
|
|
272
|
-
modelValue: unref(localModel),
|
|
273
|
-
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(localModel) ? localModel.value = $event : null),
|
|
274
|
-
lang: unref(markdown)(),
|
|
275
|
-
disabled: __props.disabled,
|
|
276
|
-
class: normalizeClass([{ "pointer-events-none opacity-50": __props.disabled }, "h-full w-full text-sm vc-markdown-editor__text-editor"]),
|
|
277
|
-
readonly: __props.readonly,
|
|
278
|
-
basic: ""
|
|
279
|
-
}, null, 8, ["modelValue", "lang", "disabled", "class", "readonly"]))
|
|
280
|
-
], 512)
|
|
281
|
-
], 6)
|
|
282
|
-
]),
|
|
283
|
-
_: 1
|
|
284
|
-
})
|
|
285
|
-
]),
|
|
286
|
-
_: 1
|
|
287
|
-
});
|
|
276
|
+
_: 1
|
|
277
|
+
}))
|
|
278
|
+
]),
|
|
279
|
+
_: 1
|
|
280
|
+
})) : (openBlock(), createBlock(resolveDynamicComponent(milkdown.value.codemirror.default), {
|
|
281
|
+
key: 1,
|
|
282
|
+
ref: "codeMirrorRef",
|
|
283
|
+
modelValue: unref(localModel),
|
|
284
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(localModel) ? localModel.value = $event : null),
|
|
285
|
+
lang: markdownLanguage.value,
|
|
286
|
+
disabled: __props.disabled,
|
|
287
|
+
class: normalizeClass([{ "pointer-events-none opacity-50": __props.disabled }, "h-full w-full text-sm vc-markdown-editor__text-editor"]),
|
|
288
|
+
readonly: __props.readonly,
|
|
289
|
+
basic: ""
|
|
290
|
+
}, null, 8, ["modelValue", "lang", "disabled", "class", "readonly"]))
|
|
291
|
+
], 64)) : createCommentVNode("", true)
|
|
292
|
+
], 512)
|
|
293
|
+
], 6);
|
|
288
294
|
};
|
|
289
295
|
}
|
|
290
296
|
});
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import '../../assets/components/VcMdEditor/VcMdEditorContent.css';
|
|
2
|
-
import { defineComponent, ref, watch, onUnmounted, withDirectives, openBlock, createBlock, unref, normalizeStyle, normalizeClass, vShow, nextTick } from "vue";
|
|
3
|
-
import { Crepe, CrepeFeature } from "@milkdown/crepe";
|
|
4
|
-
import { useEditor, Milkdown } from "@milkdown/vue";
|
|
5
|
-
import { replaceAll } from "@milkdown/utils";
|
|
2
|
+
import { defineComponent, ref, watch, onUnmounted, withDirectives, openBlock, createBlock, resolveDynamicComponent, unref, normalizeStyle, normalizeClass, vShow, nextTick } from "vue";
|
|
6
3
|
import { useZIndex } from "element-plus";
|
|
7
|
-
import {
|
|
4
|
+
import { createEditorActions, useMustachePlugin } from "./mdEditor.config.mjs";
|
|
8
5
|
import { buildMustacheSnippet } from "./buildMustacheSnippet.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { DOMSerializer } from "@milkdown/kit/prose/model";
|
|
11
|
-
import { useWidgetViewFactory } from "@prosemirror-adapter/vue";
|
|
12
|
-
import "@milkdown/crepe/theme/common/style.css";
|
|
13
|
-
import "@milkdown/crepe/theme/frame.css";
|
|
6
|
+
import { injectMilkdown } from "./milkdown.mjs";
|
|
14
7
|
import { rtlCursorPlugin } from "./rtlCursorPlugin.mjs";
|
|
15
|
-
import {
|
|
8
|
+
import { createLtrNumbers } from "./ltrNumbersPlugin.mjs";
|
|
16
9
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17
10
|
__name: "VcMdEditorContent",
|
|
18
11
|
props: {
|
|
@@ -28,35 +21,39 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
28
21
|
},
|
|
29
22
|
emits: ["update:modelValue", "update:html", "initialized", "change"],
|
|
30
23
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
31
|
-
const
|
|
24
|
+
const milkdown = injectMilkdown();
|
|
25
|
+
const { editorViewCtx } = milkdown.kit.core;
|
|
26
|
+
const { dispatchAdvancedEditorAction, dispatchEditorAction } = createEditorActions(milkdown);
|
|
27
|
+
const { ltrNumbersPlugin, refreshLtrNumbers } = createLtrNumbers(milkdown);
|
|
28
|
+
const widgetViewFactory = milkdown.adapter.useWidgetViewFactory();
|
|
32
29
|
const props = __props;
|
|
33
30
|
const emit = __emit;
|
|
34
31
|
let crepeInstance = null;
|
|
35
32
|
const crepeMounted = ref(false);
|
|
36
33
|
let isUpdatingFromParent = false;
|
|
37
34
|
const { currentZIndex } = useZIndex();
|
|
38
|
-
useEditor((root) => {
|
|
35
|
+
milkdown.vue.useEditor((root) => {
|
|
39
36
|
var _a;
|
|
40
|
-
const crepe = new Crepe({
|
|
37
|
+
const crepe = new milkdown.crepe.Crepe({
|
|
41
38
|
root,
|
|
42
39
|
defaultValue: props.modelValue,
|
|
43
40
|
featureConfigs: {
|
|
44
|
-
[Crepe.Feature.CodeMirror]: {
|
|
41
|
+
[milkdown.crepe.Crepe.Feature.CodeMirror]: {
|
|
45
42
|
theme: void 0
|
|
46
43
|
}
|
|
47
44
|
},
|
|
48
45
|
features: {
|
|
49
|
-
[CrepeFeature.BlockEdit]: false
|
|
46
|
+
[milkdown.crepe.CrepeFeature.BlockEdit]: false
|
|
50
47
|
}
|
|
51
48
|
});
|
|
52
49
|
if (props.useParameters || ((_a = props.parameters) == null ? void 0 : _a.length)) {
|
|
53
50
|
try {
|
|
54
|
-
crepe.editor.use(useMustachePlugin(replaceTest, widgetViewFactory));
|
|
51
|
+
crepe.editor.use(useMustachePlugin(milkdown, replaceTest, widgetViewFactory));
|
|
55
52
|
} catch (error) {
|
|
56
53
|
console.error("Error initializing mustache plugin:", error);
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
|
-
crepe.editor.use(rtlCursorPlugin);
|
|
56
|
+
crepe.editor.use(rtlCursorPlugin(milkdown));
|
|
60
57
|
crepe.editor.use(ltrNumbersPlugin(() => Boolean(props.readonly)));
|
|
61
58
|
const originalGetMarkdown = crepe.getMarkdown.bind(crepe);
|
|
62
59
|
crepe.getMarkdown = function() {
|
|
@@ -106,7 +103,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
106
103
|
if (currentMarkdown !== value) {
|
|
107
104
|
isUpdatingFromParent = true;
|
|
108
105
|
try {
|
|
109
|
-
crepeInstance.editor.action(replaceAll(value));
|
|
106
|
+
crepeInstance.editor.action(milkdown.utils.replaceAll(value));
|
|
110
107
|
} catch (error) {
|
|
111
108
|
console.error("Error updating Crepe editor:", error);
|
|
112
109
|
} finally {
|
|
@@ -160,7 +157,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
160
157
|
crepe.editor.action((ctx) => {
|
|
161
158
|
const view = ctx.get(editorViewCtx);
|
|
162
159
|
const { state } = view;
|
|
163
|
-
const serializer = DOMSerializer.fromSchema(state.schema);
|
|
160
|
+
const serializer = milkdown.kit.proseModel.DOMSerializer.fromSchema(state.schema);
|
|
164
161
|
const fragment = serializer.serializeFragment(state.doc.content);
|
|
165
162
|
const div = document.createElement("div");
|
|
166
163
|
div.appendChild(fragment);
|
|
@@ -215,7 +212,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
215
212
|
crepeInstance = null;
|
|
216
213
|
});
|
|
217
214
|
return (_ctx, _cache) => {
|
|
218
|
-
return withDirectives((openBlock(), createBlock(unref(Milkdown), {
|
|
215
|
+
return withDirectives((openBlock(), createBlock(resolveDynamicComponent(unref(milkdown).vue.Milkdown), {
|
|
219
216
|
class: normalizeClass(["vc-markdown-editor", {
|
|
220
217
|
"disabled": __props.disabled,
|
|
221
218
|
"is--readonly": __props.readonly
|