vue-stream-markdown 0.2.3 → 0.3.0
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/README.md +1 -1
- package/dist/{blockquote-Crr-D7fY.js → blockquote-DTo6zg12.js} +2 -2
- package/dist/button-1EHxh8s2.js +6 -0
- package/dist/{button-DVWlhfQ9.js → button-B7H9jKmU.js} +2 -2
- package/dist/{code-Bz8LM16H.js → code-DC7KVCvB.js} +10 -10
- package/dist/{code-block-CmUZxKNr.js → code-block-DPC1FZT3.js} +18 -10
- package/dist/code-block-DYrPMONb.js +10 -0
- package/dist/{composables-CzUVrTt_.js → composables-BvaSMf02.js} +3 -0
- package/dist/{delete-DFoiOzHW.js → delete-xkkM7TML.js} +2 -2
- package/dist/dropdown-Cv_yW4GS.js +6 -0
- package/dist/{emphasis-DvaBuxeK.js → emphasis-BmM30dZi.js} +2 -2
- package/dist/error-component-1U-JNS6o.js +5 -0
- package/dist/{error-component-BTe-SuY7.js → error-component-DFBWdaYB.js} +2 -2
- package/dist/{footnote-definition-ByWh1N3S.js → footnote-definition-6cTbdg-J.js} +5 -5
- package/dist/{footnote-reference-BJ4J7BFo.js → footnote-reference-CxJUg8wT.js} +1 -1
- package/dist/{heading-1fssqGGO.js → heading-DQ4lofbm.js} +2 -2
- package/dist/{icon-DcLTFhFW.js → icon-BJa4ovUe.js} +1 -1
- package/dist/icon-CvIgAOPh.js +4 -0
- package/dist/{image-DXnmoID_.js → image-DXu2WF2r.js} +13 -10
- package/dist/image-Dm5xIWs7.js +9 -0
- package/dist/{image-xPrAKT9D.js → image-e0E51Nc3.js} +17 -12
- package/dist/index.d.ts +44 -7
- package/dist/index.js +177 -87
- package/dist/{inline-math-CPkpjl8t.js → inline-math-BuO_dWPX.js} +3 -3
- package/dist/{link-BACrkxRW.js → link-DyD59DzG.js} +4 -4
- package/dist/{list-Cu8G46hK.js → list-De0KPajx.js} +2 -2
- package/dist/{list-item-BMgDS1tS.js → list-item-CuUgvXRC.js} +2 -2
- package/dist/{math-XsZX0VMw.js → math-DnFOOLdz.js} +3 -3
- package/dist/{mermaid-CQdSlhqn.js → mermaid-ZCQPlRUa.js} +6 -6
- package/dist/modal-B5jFKJL4.js +4 -0
- package/dist/{modal-C1riNMrs.js → modal-Bhe0iSs6.js} +1 -1
- package/dist/{node-list-7H-lIfUX.js → node-list-CWy--Gin.js} +2 -81
- package/dist/node-list-Doh9Z-4p.js +4 -0
- package/dist/{paragraph-Cfd37HUK.js → paragraph-D3H1qprZ.js} +2 -2
- package/dist/{previewers-C7PKsIbc.js → previewers-DB2HHDGb.js} +1 -1
- package/dist/{segmented-C9j-IIDc.js → segmented-B-kjIOkd.js} +1 -1
- package/dist/segmented-fbmq_xK1.js +7 -0
- package/dist/{shiki-BoBbCakv.js → shiki-DAu2_FTG.js} +2 -2
- package/dist/{strong-BzOBAWrG.js → strong-BlCQoXCR.js} +2 -2
- package/dist/{table-YY5M01Jm.js → table-Co_MpK6m.js} +13 -8
- package/dist/tooltip-70WIAMmC.js +4 -0
- package/dist/{tooltip-DarhJuZR.js → tooltip-CWv9skVu.js} +1 -1
- package/dist/{vanilla-Z6d1vQmX.js → vanilla-D30b-_ch.js} +1 -1
- package/dist/vanilla-DV7fYrnj.js +4 -0
- package/dist/{zoom-container-DQMpHHGQ.js → zoom-container-DbeN8U39.js} +2 -2
- package/dist/zoom-container-Dc8N-wuo.js +7 -0
- package/package.json +3 -5
- package/dist/button-Dw4uJRaD.js +0 -6
- package/dist/code-block-Bitp8x1w.js +0 -10
- package/dist/dropdown-CSRjqK0u.js +0 -6
- package/dist/error-component-DDnC0bqw.js +0 -5
- package/dist/icon-DE3AzDqz.js +0 -4
- package/dist/image-Dl-r78_E.js +0 -9
- package/dist/modal-C7O4jt5-.js +0 -4
- package/dist/node-list-DMwAmH_n.js +0 -4
- package/dist/segmented-BRTZXoDN.js +0 -7
- package/dist/tooltip-vDDEbLwf.js +0 -4
- package/dist/vanilla-CzQw2_b4.js +0 -4
- package/dist/zoom-container-JLbwB4gy.js +0 -7
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ This project also uses and benefits from:
|
|
|
72
72
|
- [Shiki](https://shiki.style/) - Beautiful syntax highlighting
|
|
73
73
|
- [Mermaid](https://mermaid.js.org/) - Diagramming and charting tool
|
|
74
74
|
- [KaTeX](https://katex.org/) - Fast math typesetting library for the web
|
|
75
|
-
- [Remend](https://github.com/vercel/streamdown/tree/main/packages/remend) -
|
|
75
|
+
- [Remend](https://github.com/vercel/streamdown/tree/main/packages/remend) - This project implements similar functionality inspired by remend for intelligently parsing and completing incomplete Markdown blocks.
|
|
76
76
|
|
|
77
77
|
### Code Sources
|
|
78
78
|
- [markstream-vue](https://github.com/Simon-He95/markstream-vue) - The original inspiration for learning AST-based custom markdown rendering, and the source of the animation implementation used in this project
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./composables-
|
|
2
|
-
import { t as node_list_default } from "./node-list-
|
|
1
|
+
import "./composables-BvaSMf02.js";
|
|
2
|
+
import { t as node_list_default } from "./node-list-CWy--Gin.js";
|
|
3
3
|
import { createElementBlock, createVNode, defineComponent, mergeProps, openBlock } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/components/renderers/blockquote.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as tooltip_default } from "./tooltip-
|
|
2
|
-
import { t as icon_default } from "./icon-
|
|
1
|
+
import { t as tooltip_default } from "./tooltip-CWv9skVu.js";
|
|
2
|
+
import { t as icon_default } from "./icon-BJa4ovUe.js";
|
|
3
3
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
|
|
4
4
|
import { createReusableTemplate } from "@vueuse/core";
|
|
5
5
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./previewers-
|
|
2
|
-
import { r as useShiki } from "./composables-
|
|
3
|
-
import "./tooltip-
|
|
4
|
-
import "./button-
|
|
5
|
-
import "./icon-
|
|
6
|
-
import "./modal-
|
|
7
|
-
import { t as code_block_default } from "./code-block-
|
|
8
|
-
import "./segmented-
|
|
1
|
+
import "./previewers-DB2HHDGb.js";
|
|
2
|
+
import { r as useShiki } from "./composables-BvaSMf02.js";
|
|
3
|
+
import "./tooltip-CWv9skVu.js";
|
|
4
|
+
import "./button-B7H9jKmU.js";
|
|
5
|
+
import "./icon-BJa4ovUe.js";
|
|
6
|
+
import "./modal-Bhe0iSs6.js";
|
|
7
|
+
import { t as code_block_default } from "./code-block-DPC1FZT3.js";
|
|
8
|
+
import "./segmented-B-kjIOkd.js";
|
|
9
9
|
import { computed, createBlock, createCommentVNode, defineAsyncComponent, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, resolveDynamicComponent, withCtx } from "vue";
|
|
10
10
|
|
|
11
11
|
//#region src/components/renderers/code/index.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -79,8 +79,8 @@ var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
79
79
|
const languageClass = computed(() => `language-${props.node.lang}`);
|
|
80
80
|
const { installed: hasShiki } = useShiki();
|
|
81
81
|
const components = {
|
|
82
|
-
vanilla: defineAsyncComponent(() => import("./vanilla-
|
|
83
|
-
shiki: defineAsyncComponent(() => import("./shiki-
|
|
82
|
+
vanilla: defineAsyncComponent(() => import("./vanilla-DV7fYrnj.js")),
|
|
83
|
+
shiki: defineAsyncComponent(() => import("./shiki-DAu2_FTG.js"))
|
|
84
84
|
};
|
|
85
85
|
const component = computed(() => {
|
|
86
86
|
if (hasShiki.value) return components.shiki;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as CODE_PREVIEWERS } from "./previewers-
|
|
2
|
-
import { G as useControls, K as useContext, V as save, b as useI18n, d as LANGUAGE_ALIAS, f as LANGUAGE_EXTENSIONS, m as useMermaid, p as LANGUAGE_ICONS, q as useCodeOptions } from "./composables-
|
|
3
|
-
import { t as button_default } from "./button-
|
|
4
|
-
import { t as modal_default } from "./modal-
|
|
5
|
-
import { t as segmented_default } from "./segmented-
|
|
1
|
+
import { t as CODE_PREVIEWERS } from "./previewers-DB2HHDGb.js";
|
|
2
|
+
import { G as useControls, K as useContext, V as save, b as useI18n, d as LANGUAGE_ALIAS, f as LANGUAGE_EXTENSIONS, m as useMermaid, p as LANGUAGE_ICONS, q as useCodeOptions } from "./composables-BvaSMf02.js";
|
|
3
|
+
import { t as button_default } from "./button-B7H9jKmU.js";
|
|
4
|
+
import { t as modal_default } from "./modal-Bhe0iSs6.js";
|
|
5
|
+
import { t as segmented_default } from "./segmented-B-kjIOkd.js";
|
|
6
6
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineAsyncComponent, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, toRefs, unref, useModel, vShow, watch, withCtx, withDirectives } from "vue";
|
|
7
7
|
import { createReusableTemplate, useClipboard } from "@vueuse/core";
|
|
8
8
|
|
|
@@ -190,13 +190,13 @@ var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
190
190
|
},
|
|
191
191
|
setup(__props) {
|
|
192
192
|
const props = __props;
|
|
193
|
-
const CodeNode = defineAsyncComponent(() => import("./code-
|
|
193
|
+
const CodeNode = defineAsyncComponent(() => import("./code-DC7KVCvB.js"));
|
|
194
194
|
const { controls, previewers, codeOptions } = toRefs(props);
|
|
195
195
|
const [DefineTemplate, ReuseTemplate] = createReusableTemplate();
|
|
196
196
|
const { t } = useI18n();
|
|
197
197
|
const { isControlEnabled, getControlValue, resolveControls } = useControls({ controls });
|
|
198
198
|
const { installed: hasMermaid } = useMermaid();
|
|
199
|
-
const { onCopied } = useContext();
|
|
199
|
+
const { beforeDownload, onCopied } = useContext();
|
|
200
200
|
const { copy, copied } = useClipboard({ legacy: true });
|
|
201
201
|
const { saveMermaid } = useMermaid();
|
|
202
202
|
const collapsed = ref(false);
|
|
@@ -327,14 +327,22 @@ var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
327
327
|
icon: "download",
|
|
328
328
|
options: downloadOptions.value.length > 0 ? downloadOptions.value : void 0,
|
|
329
329
|
visible: () => showDownload.value && !!LANGUAGE_EXTENSIONS[language.value],
|
|
330
|
-
onClick: (_event, item) => {
|
|
330
|
+
onClick: async (_event, item) => {
|
|
331
331
|
if (props.node.loading) return;
|
|
332
332
|
if (!item || item.value === "code") {
|
|
333
333
|
const extension = LANGUAGE_EXTENSIONS[language.value];
|
|
334
|
-
|
|
334
|
+
if (await beforeDownload({
|
|
335
|
+
type: "code",
|
|
336
|
+
content: props.node.value
|
|
337
|
+
})) save(`file.${extension}`, props.node.value, "text/plain");
|
|
335
338
|
return;
|
|
336
339
|
}
|
|
337
|
-
if ((item === null || item === void 0 ? void 0 : item.value) === "svg" || (item === null || item === void 0 ? void 0 : item.value) === "png")
|
|
340
|
+
if ((item === null || item === void 0 ? void 0 : item.value) === "svg" || (item === null || item === void 0 ? void 0 : item.value) === "png") {
|
|
341
|
+
if (await beforeDownload({
|
|
342
|
+
type: "mermaid",
|
|
343
|
+
content: props.node.value
|
|
344
|
+
})) saveMermaid(item === null || item === void 0 ? void 0 : item.value, props.node.value);
|
|
345
|
+
}
|
|
338
346
|
}
|
|
339
347
|
},
|
|
340
348
|
{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./previewers-DB2HHDGb.js";
|
|
2
|
+
import "./composables-BvaSMf02.js";
|
|
3
|
+
import "./tooltip-CWv9skVu.js";
|
|
4
|
+
import "./button-B7H9jKmU.js";
|
|
5
|
+
import "./icon-BJa4ovUe.js";
|
|
6
|
+
import "./modal-Bhe0iSs6.js";
|
|
7
|
+
import { t as code_block_default } from "./code-block-DPC1FZT3.js";
|
|
8
|
+
import "./segmented-B-kjIOkd.js";
|
|
9
|
+
|
|
10
|
+
export { code_block_default as default };
|
|
@@ -68,6 +68,9 @@ function useContext() {
|
|
|
68
68
|
get getOverlayContainer() {
|
|
69
69
|
return context.getOverlayContainer || (() => null);
|
|
70
70
|
},
|
|
71
|
+
get beforeDownload() {
|
|
72
|
+
return context.beforeDownload || (() => true);
|
|
73
|
+
},
|
|
71
74
|
get onCopied() {
|
|
72
75
|
return context.onCopied || (() => {});
|
|
73
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./composables-
|
|
2
|
-
import { t as node_list_default } from "./node-list-
|
|
1
|
+
import "./composables-BvaSMf02.js";
|
|
2
|
+
import { t as node_list_default } from "./node-list-CWy--Gin.js";
|
|
3
3
|
import { createElementBlock, createVNode, defineComponent, mergeProps, openBlock } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/components/renderers/delete.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./composables-
|
|
2
|
-
import { t as node_list_default } from "./node-list-
|
|
1
|
+
import "./composables-BvaSMf02.js";
|
|
2
|
+
import { t as node_list_default } from "./node-list-CWy--Gin.js";
|
|
3
3
|
import { createElementBlock, createVNode, defineComponent, mergeProps, openBlock } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/components/renderers/emphasis.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as useContext, b as useI18n } from "./composables-
|
|
2
|
-
import { t as icon_default } from "./icon-
|
|
1
|
+
import { K as useContext, b as useI18n } from "./composables-BvaSMf02.js";
|
|
2
|
+
import { t as icon_default } from "./icon-BJa4ovUe.js";
|
|
3
3
|
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, defineComponent, openBlock, renderSlot, resolveDynamicComponent, toDisplayString } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/components/error-component.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { K as useContext, b as useI18n } from "./composables-
|
|
2
|
-
import { t as node_list_default } from "./node-list-
|
|
3
|
-
import "./tooltip-
|
|
4
|
-
import { t as button_default } from "./button-
|
|
5
|
-
import "./icon-
|
|
1
|
+
import { K as useContext, b as useI18n } from "./composables-BvaSMf02.js";
|
|
2
|
+
import { t as node_list_default } from "./node-list-CWy--Gin.js";
|
|
3
|
+
import "./tooltip-CWv9skVu.js";
|
|
4
|
+
import { t as button_default } from "./button-B7H9jKmU.js";
|
|
5
|
+
import "./icon-BJa4ovUe.js";
|
|
6
6
|
import { computed, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, openBlock, toDisplayString, unref } from "vue";
|
|
7
7
|
|
|
8
8
|
//#region src/components/renderers/footnote-definition.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as useContext } from "./composables-
|
|
1
|
+
import { K as useContext } from "./composables-BvaSMf02.js";
|
|
2
2
|
import { computed, createElementBlock, createElementVNode, defineComponent, openBlock, toDisplayString } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/renderers/footnote-reference.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./composables-
|
|
2
|
-
import { t as node_list_default } from "./node-list-
|
|
1
|
+
import "./composables-BvaSMf02.js";
|
|
2
|
+
import { t as node_list_default } from "./node-list-CWy--Gin.js";
|
|
3
3
|
import { computed, createBlock, createVNode, defineComponent, mergeProps, openBlock, resolveDynamicComponent, withCtx } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/components/renderers/heading.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as useContext } from "./composables-
|
|
1
|
+
import { K as useContext } from "./composables-BvaSMf02.js";
|
|
2
2
|
import { computed, createElementBlock, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, unref } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/icon.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { G as useControls,
|
|
1
|
+
import { G as useControls, K as useContext, b as useI18n, h as useMediumZoom } from "./composables-BvaSMf02.js";
|
|
2
2
|
import { n as treeFlatFilter } from "./dist-CYkm26BF.js";
|
|
3
|
-
import { t as button_default } from "./button-
|
|
4
|
-
import { t as modal_default } from "./modal-
|
|
5
|
-
import { t as zoom_container_default } from "./zoom-container-
|
|
3
|
+
import { t as button_default } from "./button-B7H9jKmU.js";
|
|
4
|
+
import { t as modal_default } from "./modal-Bhe0iSs6.js";
|
|
5
|
+
import { t as zoom_container_default } from "./zoom-container-DbeN8U39.js";
|
|
6
6
|
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, normalizeStyle, openBlock, ref, renderList, toRefs, unref, watch, withCtx } from "vue";
|
|
7
7
|
import { useCycleList } from "@vueuse/core";
|
|
8
8
|
|
|
@@ -54,6 +54,10 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
54
54
|
nodeProps: {
|
|
55
55
|
type: Object,
|
|
56
56
|
required: true
|
|
57
|
+
},
|
|
58
|
+
handleDownload: {
|
|
59
|
+
type: Function,
|
|
60
|
+
required: false
|
|
57
61
|
}
|
|
58
62
|
},
|
|
59
63
|
emits: ["load", "error"],
|
|
@@ -72,7 +76,7 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
72
76
|
initialValue: props.src,
|
|
73
77
|
fallbackIndex: 0
|
|
74
78
|
});
|
|
75
|
-
const enableDownload = computed(() => isControlEnabled("image.download"));
|
|
79
|
+
const enableDownload = computed(() => isControlEnabled("image.download") && !!props.handleDownload);
|
|
76
80
|
const enableCarousel = computed(() => isControlEnabled("image.carousel"));
|
|
77
81
|
const enableFlip = computed(() => isControlEnabled("image.flip"));
|
|
78
82
|
const enableRotate = computed(() => isControlEnabled("image.rotate"));
|
|
@@ -105,7 +109,10 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
105
109
|
key: "download",
|
|
106
110
|
icon: "download",
|
|
107
111
|
name: t("button.download"),
|
|
108
|
-
onClick:
|
|
112
|
+
onClick: () => {
|
|
113
|
+
var _props$handleDownload;
|
|
114
|
+
return (_props$handleDownload = props.handleDownload) === null || _props$handleDownload === void 0 ? void 0 : _props$handleDownload.call(props, imageSrc.value);
|
|
115
|
+
},
|
|
109
116
|
visible: () => !!imageSrc.value && enableDownload.value
|
|
110
117
|
},
|
|
111
118
|
{
|
|
@@ -170,10 +177,6 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
170
177
|
if (isAnimating.value) return;
|
|
171
178
|
zoomOut();
|
|
172
179
|
}
|
|
173
|
-
function download() {
|
|
174
|
-
if (!imageSrc.value) return;
|
|
175
|
-
saveImage(imageSrc.value, props.alt);
|
|
176
|
-
}
|
|
177
180
|
function flipHorizontal() {
|
|
178
181
|
scaleX.value *= -1;
|
|
179
182
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./composables-BvaSMf02.js";
|
|
2
|
+
import "./tooltip-CWv9skVu.js";
|
|
3
|
+
import "./button-B7H9jKmU.js";
|
|
4
|
+
import "./icon-BJa4ovUe.js";
|
|
5
|
+
import "./modal-Bhe0iSs6.js";
|
|
6
|
+
import "./zoom-container-DbeN8U39.js";
|
|
7
|
+
import { t as image_default } from "./image-DXu2WF2r.js";
|
|
8
|
+
|
|
9
|
+
export { image_default as default };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { G as useControls, H as saveImage, b as useI18n, i as useSanitizers } from "./composables-
|
|
2
|
-
import "./tooltip-
|
|
3
|
-
import { t as button_default } from "./button-
|
|
4
|
-
import "./icon-
|
|
5
|
-
import "./modal-
|
|
6
|
-
import { t as error_component_default } from "./error-component-
|
|
7
|
-
import "./zoom-container-
|
|
8
|
-
import { t as image_default$1 } from "./image-
|
|
1
|
+
import { G as useControls, H as saveImage, K as useContext, b as useI18n, i as useSanitizers } from "./composables-BvaSMf02.js";
|
|
2
|
+
import "./tooltip-CWv9skVu.js";
|
|
3
|
+
import { t as button_default } from "./button-B7H9jKmU.js";
|
|
4
|
+
import "./icon-BJa4ovUe.js";
|
|
5
|
+
import "./modal-Bhe0iSs6.js";
|
|
6
|
+
import { t as error_component_default } from "./error-component-DFBWdaYB.js";
|
|
7
|
+
import "./zoom-container-DbeN8U39.js";
|
|
8
|
+
import { t as image_default$1 } from "./image-DXu2WF2r.js";
|
|
9
9
|
import { t as spin_default } from "./spin-DzERwGWy.js";
|
|
10
10
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeProps, normalizeStyle, openBlock, ref, resolveDynamicComponent, toDisplayString, toRefs, unref, withCtx } from "vue";
|
|
11
11
|
|
|
@@ -79,6 +79,7 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
79
79
|
const props = __props;
|
|
80
80
|
const { t } = useI18n();
|
|
81
81
|
const { controls, hardenOptions } = toRefs(props);
|
|
82
|
+
const { beforeDownload } = useContext();
|
|
82
83
|
const { isControlEnabled } = useControls({ controls });
|
|
83
84
|
const maskRef = ref();
|
|
84
85
|
const loadError = ref(false);
|
|
@@ -118,9 +119,12 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
118
119
|
}
|
|
119
120
|
loadError.value = true;
|
|
120
121
|
}
|
|
121
|
-
async function handleDownload() {
|
|
122
|
-
if (!
|
|
123
|
-
|
|
122
|
+
async function handleDownload(url = imageSrc.value) {
|
|
123
|
+
if (!url) return;
|
|
124
|
+
if (await beforeDownload({
|
|
125
|
+
type: "image",
|
|
126
|
+
url
|
|
127
|
+
})) saveImage(url, alt.value);
|
|
124
128
|
}
|
|
125
129
|
function handleMouseEnter() {
|
|
126
130
|
if (maskRef.value) maskRef.value.style.opacity = 1;
|
|
@@ -149,7 +153,7 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
149
153
|
"icon-width": 16,
|
|
150
154
|
"icon-height": 16,
|
|
151
155
|
"button-style": { backgroundColor: "color-mix(in oklab, var(--background) 90%, transparent)" },
|
|
152
|
-
onClick: handleDownload
|
|
156
|
+
onClick: _cache[0] || (_cache[0] = () => handleDownload(imageSrc.value))
|
|
153
157
|
}, null, 8, ["name"])) : createCommentVNode("v-if", true)], 512)) : createCommentVNode("v-if", true),
|
|
154
158
|
(isLoading.value || !imageLoaded.value) && !unref(isHardenUrl) ? (openBlock(), createBlock(spin_default, { key: 1 })) : createCommentVNode("v-if", true),
|
|
155
159
|
!isLoading.value && !unref(isHardenUrl) && typeof unref(transformedUrl) === "string" ? (openBlock(), createBlock(image_default$1, {
|
|
@@ -161,6 +165,7 @@ var image_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
161
165
|
controls: unref(controls),
|
|
162
166
|
"transform-harden-url": unref(transformHardenUrl),
|
|
163
167
|
"node-props": props,
|
|
168
|
+
"handle-download": handleDownload,
|
|
164
169
|
onLoad: handleLoaded,
|
|
165
170
|
onError: handleError
|
|
166
171
|
}, null, 8, [
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,7 @@ import * as vue210 from "vue";
|
|
|
2
2
|
import { CSSProperties, Component, MaybeRef, MaybeRefOrGetter } from "vue";
|
|
3
3
|
import * as _floating_ui_dom0 from "@floating-ui/dom";
|
|
4
4
|
import { Placement } from "@floating-ui/dom";
|
|
5
|
-
import { MarkdownItAsync } from "markdown-it-async";
|
|
6
5
|
import { KatexOptions as KatexOptions$1 } from "katex";
|
|
7
|
-
import remend from "remend";
|
|
8
6
|
import { BuiltinLanguage, BuiltinTheme, BundledLanguage, BundledTheme, CodeToTokensOptions, Highlighter, SpecialLanguage, TokensResult } from "shiki";
|
|
9
7
|
import { Mermaid, MermaidConfig } from "mermaid";
|
|
10
8
|
import { Extension, fromMarkdown } from "mdast-util-from-markdown";
|
|
@@ -103,6 +101,17 @@ type InlineMathNode = Extract<ParsedNode, {
|
|
|
103
101
|
type: 'inlineMath';
|
|
104
102
|
}>;
|
|
105
103
|
//#endregion
|
|
104
|
+
//#region src/types/events.d.ts
|
|
105
|
+
type DownloadEvent = UrlDownloadEvent | ContentDownloadEvent;
|
|
106
|
+
interface UrlDownloadEvent {
|
|
107
|
+
type: 'image';
|
|
108
|
+
url: string;
|
|
109
|
+
}
|
|
110
|
+
interface ContentDownloadEvent {
|
|
111
|
+
type: 'code' | 'mermaid' | 'table';
|
|
112
|
+
content: string;
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
106
115
|
//#region src/types/locale.d.ts
|
|
107
116
|
interface LocaleConfig {
|
|
108
117
|
button: {
|
|
@@ -139,7 +148,6 @@ interface Options extends MarkdownParserOptions {
|
|
|
139
148
|
}
|
|
140
149
|
declare class MarkdownParser {
|
|
141
150
|
private mode;
|
|
142
|
-
private md;
|
|
143
151
|
private content;
|
|
144
152
|
private syntaxTree;
|
|
145
153
|
private options;
|
|
@@ -150,7 +158,6 @@ declare class MarkdownParser {
|
|
|
150
158
|
content: string;
|
|
151
159
|
nodes: ParsedNode[];
|
|
152
160
|
};
|
|
153
|
-
markdownToHtml(content: string): string;
|
|
154
161
|
markdownToAst(content: string, loading?: boolean): SyntaxTree;
|
|
155
162
|
astToMarkdown(data: SyntaxTree | ParsedNode): string;
|
|
156
163
|
hasLoadingNode(nodes?: ParsedNode[]): boolean;
|
|
@@ -288,6 +295,7 @@ declare const PRELOAD_NODE_RENDERER: BuiltinNodeRenderers[];
|
|
|
288
295
|
declare const SHADCN_SCHEMAS: readonly ["background", "foreground", "card", "card-foreground", "popover", "popover-foreground", "primary", "primary-foreground", "secondary", "secondary-foreground", "muted", "muted-foreground", "accent", "accent-foreground", "destructive", "border", "input", "ring", "chart-1", "chart-2", "chart-3", "chart-4", "chart-5", "sidebar", "sidebar-foreground", "sidebar-primary", "sidebar-primary-foreground", "sidebar-accent", "sidebar-accent-foreground", "sidebar-border", "sidebar-ring"];
|
|
289
296
|
//#endregion
|
|
290
297
|
//#region src/types/shared.d.ts
|
|
298
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
291
299
|
type BuiltinNodeRenderers = keyof typeof NODE_RENDERERS;
|
|
292
300
|
type BuiltinPreviewers = 'mermaid' | 'html';
|
|
293
301
|
type BuiltinUIComponents = keyof typeof UI;
|
|
@@ -327,6 +335,7 @@ interface StreamMarkdownProps extends StreamMarkdownContext, MarkdownParserOptio
|
|
|
327
335
|
preload?: PreloadConfig;
|
|
328
336
|
locale?: string | LocaleConfig;
|
|
329
337
|
enableAnimate?: boolean;
|
|
338
|
+
beforeDownload?: (event: DownloadEvent) => MaybePromise<boolean>;
|
|
330
339
|
}
|
|
331
340
|
interface PreloadConfig {
|
|
332
341
|
nodeRenderers?: BuiltinNodeRenderers[];
|
|
@@ -337,7 +346,6 @@ interface MarkdownParserOptions {
|
|
|
337
346
|
postNormalize?: (data: SyntaxTree) => SyntaxTree;
|
|
338
347
|
preprocess?: (content: string) => string;
|
|
339
348
|
postprocess?: (data: SyntaxTree) => SyntaxTree;
|
|
340
|
-
extendMarkdownIt?: (md: MarkdownItAsync) => void;
|
|
341
349
|
}
|
|
342
350
|
interface MdastOptions {
|
|
343
351
|
from?: Extension[];
|
|
@@ -609,6 +617,7 @@ declare const UI: {
|
|
|
609
617
|
controls?: ControlsConfig;
|
|
610
618
|
transformHardenUrl?: (url: string) => string | null;
|
|
611
619
|
nodeProps: ImageNodeRendererProps;
|
|
620
|
+
handleDownload?: (url: string) => Promise<void>;
|
|
612
621
|
}, {}, {}, {}, {}, vue210.ComponentOptionsMixin, vue210.ComponentOptionsMixin, {} & {
|
|
613
622
|
load: (event: Event) => any;
|
|
614
623
|
error: (event: Event) => any;
|
|
@@ -621,6 +630,7 @@ declare const UI: {
|
|
|
621
630
|
controls?: ControlsConfig;
|
|
622
631
|
transformHardenUrl?: (url: string) => string | null;
|
|
623
632
|
nodeProps: ImageNodeRendererProps;
|
|
633
|
+
handleDownload?: (url: string) => Promise<void>;
|
|
624
634
|
}> & Readonly<{
|
|
625
635
|
onLoad?: ((event: Event) => any) | undefined;
|
|
626
636
|
onError?: ((event: Event) => any) | undefined;
|
|
@@ -917,6 +927,7 @@ interface Context {
|
|
|
917
927
|
parsedNodes?: MaybeRef<ParsedNode[]>;
|
|
918
928
|
getContainer?: () => HTMLElement | undefined;
|
|
919
929
|
getOverlayContainer?: () => Element | null;
|
|
930
|
+
beforeDownload?: StreamMarkdownProps['beforeDownload'];
|
|
920
931
|
onCopied?: (content: string) => void;
|
|
921
932
|
}
|
|
922
933
|
declare function useContext(): {
|
|
@@ -931,6 +942,7 @@ declare function useContext(): {
|
|
|
931
942
|
parsedNodes: vue210.ComputedRef<ParsedNode[]>;
|
|
932
943
|
readonly getContainer: () => HTMLElement | undefined;
|
|
933
944
|
readonly getOverlayContainer: () => Element | null;
|
|
945
|
+
readonly beforeDownload: (event: DownloadEvent) => MaybePromise<boolean>;
|
|
934
946
|
readonly onCopied: (content: string) => void;
|
|
935
947
|
};
|
|
936
948
|
//#endregion
|
|
@@ -1297,6 +1309,31 @@ declare function fixFootnote(content: string): string;
|
|
|
1297
1309
|
*/
|
|
1298
1310
|
declare function fixLink(content: string): string;
|
|
1299
1311
|
//#endregion
|
|
1312
|
+
//#region src/preprocess/math.d.ts
|
|
1313
|
+
/**
|
|
1314
|
+
* Fix unclosed block math ($$) syntax in streaming markdown
|
|
1315
|
+
*
|
|
1316
|
+
* Block math is defined as $$ delimiters on separate lines:
|
|
1317
|
+
* $$
|
|
1318
|
+
* E = mc^2
|
|
1319
|
+
* $$
|
|
1320
|
+
*
|
|
1321
|
+
* This function processes the entire content (not just last paragraph)
|
|
1322
|
+
* because block math can span multiple paragraphs.
|
|
1323
|
+
*
|
|
1324
|
+
* @param content - Markdown content (potentially incomplete in stream mode)
|
|
1325
|
+
* @returns Content with auto-completed block math if needed
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* fixMath('$$\nE = mc^2')
|
|
1329
|
+
* // Returns: '$$\nE = mc^2\n$$'
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* fixMath('$$\nE = mc^2\n$$')
|
|
1333
|
+
* // Returns: '$$\nE = mc^2\n$$' (no change)
|
|
1334
|
+
*/
|
|
1335
|
+
declare function fixMath(content: string): string;
|
|
1336
|
+
//#endregion
|
|
1300
1337
|
//#region src/preprocess/strong.d.ts
|
|
1301
1338
|
/**
|
|
1302
1339
|
* Fix unclosed strong (** or __) syntax in streaming markdown
|
|
@@ -1396,7 +1433,7 @@ declare const trailingStandaloneDashWithNewlinesPattern: RegExp;
|
|
|
1396
1433
|
//#region src/preprocess/index.d.ts
|
|
1397
1434
|
declare function proprocessContent(content: string): string;
|
|
1398
1435
|
declare function normalize(content: string): string;
|
|
1399
|
-
declare function preprocess(content: string
|
|
1436
|
+
declare function preprocess(content: string): string;
|
|
1400
1437
|
//#endregion
|
|
1401
1438
|
//#region src/utils/harden.d.ts
|
|
1402
1439
|
declare function transformUrl(url: unknown, allowedPrefixes: string[], defaultOrigin: string, allowDataImages?: boolean, isImage?: boolean, allowedProtocols?: string[]): string | null;
|
|
@@ -1443,4 +1480,4 @@ declare function tableDataToTSV(data: TableData): string;
|
|
|
1443
1480
|
declare function escapeMarkdownTableCell(cell: string): string;
|
|
1444
1481
|
declare function tableDataToMarkdown(data: TableData): string;
|
|
1445
1482
|
//#endregion
|
|
1446
|
-
export { BlockquoteNode, BlockquoteNodeRendererProps, BreakNode, BreakNodeRendererProps, BuiltinNodeRenderers, BuiltinPreviewers, BuiltinUIComponents, ButtonProps, CODE_PREVIEWERS, CodeControlsConfig, CodeNode, CodeNodeRendererProps, CodeOptions, CodeOptionsLanguage, Control, ControlTransformer, ControlsConfig, DEFAULT_DARK_THEME, DEFAULT_HARDEN_OPTIONS, DEFAULT_LIGHT_THEME, DefinitionNode, DefinitionNodeRendererProps, DeleteNode, DeleteNodeRendererProps, EmphasisNode, EmphasisNodeRendererProps, FootnoteDefinitionNode, FootnoteDefinitionNodeRendererProps, FootnoteReferenceNode, FootnoteReferenceNodeRendererProps, HardenOptions, HeadingNode, HeadingNodeRendererProps, HtmlNode, HtmlNodeRendererProps, ICONS, IconName, Icons, ImageControlsConfig, ImageNode, ImageNodeRendererProps, ImageOptions, ImageReferenceNode, ImageReferenceNodeRendererProps, InlineCodeNode, InlineCodeNodeRendererProps, InlineMathNode, InlineMathNodeRendererProps, KatexOptions, LANGUAGE_ALIAS, LANGUAGE_EXTENSIONS, LANGUAGE_ICONS, LinkNode, LinkNodeRendererProps, LinkReferenceNode, LinkReferenceNodeRendererProps, ListItemNode, ListItemNodeRendererProps, ListNode, ListNodeRendererProps, LocaleConfig, _default as Markdown, MarkdownParser, MarkdownParserOptions, MathNode, MathNodeRendererProps, MdastOptions, MermaidControlsConfig, MermaidOptions, NODE_RENDERERS, NodeRendererListProps, NodeRendererProps, NodeRenderers, NodeType, OptionalIconName, Options, PRELOAD_NODE_RENDERER, ParagraphNode, ParagraphNodeRendererProps, ParsedNode, PreloadConfig, PreviewSegmentedPlacement, PreviewerConfig, SHADCN_SCHEMAS, SUPPORT_LANGUAGES, SelectOption, ShikiOptions, StreamMarkdownContext, StreamMarkdownProps, StrongNode, StrongNodeRendererProps, SyntaxTree, TableCellNode, TableCellNodeRendererProps, TableControlsConfig, TableData, TableNode, TableNodeRendererProps, TableRowNode, TableRowNodeRendererProps, TextNode, TextNodeRendererProps, ThematicBreakNode, ThematicBreakNodeRendererProps, UI, UIOptions, YamlNode, YamlNodeRendererProps, ZoomControlPosition, codeBlockPattern, crlfPattern, currentLocale, doubleAsteriskPattern, doubleDollarPattern, doubleTildePattern, doubleUnderscorePattern, escapeMarkdownTableCell, extractTableDataFromElement, findLastLeafNode, findNodeParent, fixCode, fixDelete, fixEmphasis, fixFootnote, fixLink, fixStrong, fixTable, fixTaskList, flow, footnoteDefLabelPattern, footnoteDefLinePattern, footnoteDefPattern, footnoteRefLabelPattern, footnoteRefPattern, hasKatex, hasMermaid, hasShiki, incompleteBracketPattern, incompleteFootnoteRefPattern, incompleteLinkTextPattern, incompleteTaskListPattern, incompleteUrlPattern, isClient, isServer, loadLocaleMessages, localeMessages, localesGlob, normalize, postFixFootnote, postFixText, postNormalize, postprocess, preloadAsyncComponents, preprocess, preprocessLaTeX, proprocessContent, quoteIncompleteTaskListPattern, quoteStandaloneDashPattern, quoteTaskListPattern,
|
|
1483
|
+
export { BlockquoteNode, BlockquoteNodeRendererProps, BreakNode, BreakNodeRendererProps, BuiltinNodeRenderers, BuiltinPreviewers, BuiltinUIComponents, ButtonProps, CODE_PREVIEWERS, CodeControlsConfig, CodeNode, CodeNodeRendererProps, CodeOptions, CodeOptionsLanguage, ContentDownloadEvent, Control, ControlTransformer, ControlsConfig, DEFAULT_DARK_THEME, DEFAULT_HARDEN_OPTIONS, DEFAULT_LIGHT_THEME, DefinitionNode, DefinitionNodeRendererProps, DeleteNode, DeleteNodeRendererProps, DownloadEvent, EmphasisNode, EmphasisNodeRendererProps, FootnoteDefinitionNode, FootnoteDefinitionNodeRendererProps, FootnoteReferenceNode, FootnoteReferenceNodeRendererProps, HardenOptions, HeadingNode, HeadingNodeRendererProps, HtmlNode, HtmlNodeRendererProps, ICONS, IconName, Icons, ImageControlsConfig, ImageNode, ImageNodeRendererProps, ImageOptions, ImageReferenceNode, ImageReferenceNodeRendererProps, InlineCodeNode, InlineCodeNodeRendererProps, InlineMathNode, InlineMathNodeRendererProps, KatexOptions, LANGUAGE_ALIAS, LANGUAGE_EXTENSIONS, LANGUAGE_ICONS, LinkNode, LinkNodeRendererProps, LinkReferenceNode, LinkReferenceNodeRendererProps, ListItemNode, ListItemNodeRendererProps, ListNode, ListNodeRendererProps, LocaleConfig, _default as Markdown, MarkdownParser, MarkdownParserOptions, MathNode, MathNodeRendererProps, MaybePromise, MdastOptions, MermaidControlsConfig, MermaidOptions, NODE_RENDERERS, NodeRendererListProps, NodeRendererProps, NodeRenderers, NodeType, OptionalIconName, Options, PRELOAD_NODE_RENDERER, ParagraphNode, ParagraphNodeRendererProps, ParsedNode, PreloadConfig, PreviewSegmentedPlacement, PreviewerConfig, SHADCN_SCHEMAS, SUPPORT_LANGUAGES, SelectOption, ShikiOptions, StreamMarkdownContext, StreamMarkdownProps, StrongNode, StrongNodeRendererProps, SyntaxTree, TableCellNode, TableCellNodeRendererProps, TableControlsConfig, TableData, TableNode, TableNodeRendererProps, TableRowNode, TableRowNodeRendererProps, TextNode, TextNodeRendererProps, ThematicBreakNode, ThematicBreakNodeRendererProps, UI, UIOptions, UrlDownloadEvent, YamlNode, YamlNodeRendererProps, ZoomControlPosition, codeBlockPattern, crlfPattern, currentLocale, doubleAsteriskPattern, doubleDollarPattern, doubleTildePattern, doubleUnderscorePattern, escapeMarkdownTableCell, extractTableDataFromElement, findLastLeafNode, findNodeParent, fixCode, fixDelete, fixEmphasis, fixFootnote, fixLink, fixMath, fixStrong, fixTable, fixTaskList, flow, footnoteDefLabelPattern, footnoteDefLinePattern, footnoteDefPattern, footnoteRefLabelPattern, footnoteRefPattern, hasKatex, hasMermaid, hasShiki, incompleteBracketPattern, incompleteFootnoteRefPattern, incompleteLinkTextPattern, incompleteTaskListPattern, incompleteUrlPattern, isClient, isServer, loadLocaleMessages, localeMessages, localesGlob, normalize, postFixFootnote, postFixText, postNormalize, postprocess, preloadAsyncComponents, preprocess, preprocessLaTeX, proprocessContent, quoteIncompleteTaskListPattern, quoteStandaloneDashPattern, quoteTaskListPattern, save, saveImage, separatorPattern, singleAsteriskPattern, singleBacktickPattern, singleUnderscorePattern, standaloneDashPattern, svgToPngBlob, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, tableRowPattern, taskListPattern, trailingBackticksPattern, trailingStandaloneBracketPattern, trailingStandaloneDashWithNewlinesPattern, trailingWhitespacePattern, transformUrl, tripleBacktickPattern, useCodeOptions, useContext, useControls, useFloating, useI18n, useKatex, useMathRenderer, useMediumZoom, useMermaid, useSanitizers, useShiki, useTailwindV3Theme, useZoom };
|