@elmethis/core 0.6.4 → 0.7.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/dist/components/code/ElmMermaid.vue.mjs +10 -0
- package/dist/components/code/ElmMermaid.vue2.mjs +59 -0
- package/dist/components/code/ElmMermaid.vue3.mjs +26 -0
- package/dist/components/others/ElmJsonComponentRenderer.vue.d.ts +1 -1
- package/dist/components/others/ElmJsonComponentRenderer.vue2.mjs +24 -9
- package/dist/components/others/ElmMarkdown.vue.d.ts +1 -1
- package/dist/components/others/ElmMarkdown.vue.mjs +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import _sfc_main from "./ElmMermaid.vue2.mjs";
|
|
2
|
+
import style0 from "./ElmMermaid.vue3.mjs";
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
4
|
+
const cssModules = {
|
|
5
|
+
"$style": style0
|
|
6
|
+
};
|
|
7
|
+
const ElmMermaid = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
|
|
8
|
+
export {
|
|
9
|
+
ElmMermaid as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineComponent, useCssModule, ref, useTemplateRef, watch, onMounted, createElementBlock, openBlock, normalizeClass } from "vue";
|
|
2
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3
|
+
__name: "ElmMermaid",
|
|
4
|
+
props: {
|
|
5
|
+
code: {}
|
|
6
|
+
},
|
|
7
|
+
setup(__props) {
|
|
8
|
+
const props = __props;
|
|
9
|
+
const classes = useCssModule();
|
|
10
|
+
const isRendered = ref(false);
|
|
11
|
+
const elementRef = useTemplateRef("svgRef");
|
|
12
|
+
const renderMermaid = async () => {
|
|
13
|
+
if (!elementRef.value) return;
|
|
14
|
+
isRendered.value = false;
|
|
15
|
+
const { default: mermaid } = await import("mermaid");
|
|
16
|
+
try {
|
|
17
|
+
mermaid.initialize({
|
|
18
|
+
startOnLoad: false,
|
|
19
|
+
theme: "base",
|
|
20
|
+
themeVariables: {
|
|
21
|
+
mainBkg: "#fbfcff",
|
|
22
|
+
lineColor: "#606875",
|
|
23
|
+
primaryColor: "#6c7483",
|
|
24
|
+
secondaryColor: "#e9dec5",
|
|
25
|
+
tertiaryColor: "#f5f6f8",
|
|
26
|
+
tertiaryBorderColor: "#e2d4b2",
|
|
27
|
+
tertiaryTextColor: "#b69545",
|
|
28
|
+
// Sequence Diagram
|
|
29
|
+
signalColor: "#949ba7"
|
|
30
|
+
// default: textColor
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const { svg } = await mermaid.render(classes.mermaid, props.code);
|
|
34
|
+
elementRef.value.innerHTML = svg;
|
|
35
|
+
isRendered.value = true;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error("Mermaid render error:", error);
|
|
38
|
+
elementRef.value.innerHTML = `<pre>${props.code}</pre>`;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
watch(() => props.code, renderMermaid);
|
|
42
|
+
onMounted(renderMermaid);
|
|
43
|
+
return (_ctx, _cache) => {
|
|
44
|
+
return openBlock(), createElementBlock("div", {
|
|
45
|
+
ref: "svgRef",
|
|
46
|
+
class: normalizeClass([
|
|
47
|
+
_ctx.$style.mermaid,
|
|
48
|
+
{
|
|
49
|
+
[_ctx.$style.raw]: !isRendered.value,
|
|
50
|
+
[_ctx.$style.rendered]: isRendered.value
|
|
51
|
+
}
|
|
52
|
+
])
|
|
53
|
+
}, null, 2);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export {
|
|
58
|
+
_sfc_main as default
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
"use strict";
|
|
3
|
+
try {
|
|
4
|
+
if (typeof document != "undefined") {
|
|
5
|
+
var elementStyle = document.createElement("style");
|
|
6
|
+
elementStyle.appendChild(document.createTextNode("._mermaid_1r2yy_1{display:block}._mermaid_1r2yy_1::-moz-selection{color:#cccfd5;background-color:#494f59}._mermaid_1r2yy_1::selection{color:#cccfd5;background-color:#494f59}._raw_1r2yy_9{opacity:0}._rendered_1r2yy_13{opacity:1}"));
|
|
7
|
+
document.head.appendChild(elementStyle);
|
|
8
|
+
}
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error("vite-plugin-css-injected-by-js", e);
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
13
|
+
const mermaid = "_mermaid_1r2yy_1";
|
|
14
|
+
const raw = "_raw_1r2yy_9";
|
|
15
|
+
const rendered = "_rendered_1r2yy_13";
|
|
16
|
+
const style0 = {
|
|
17
|
+
mermaid,
|
|
18
|
+
raw,
|
|
19
|
+
rendered
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
style0 as default,
|
|
23
|
+
mermaid,
|
|
24
|
+
raw,
|
|
25
|
+
rendered
|
|
26
|
+
};
|
|
@@ -2,5 +2,5 @@ import { Component } from 'jarkup-ts';
|
|
|
2
2
|
export interface ElmJsonComponentRendererProps {
|
|
3
3
|
jsonComponents: Component[];
|
|
4
4
|
}
|
|
5
|
-
declare const _default: import('vue').DefineComponent<ElmJsonComponentRendererProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ElmJsonComponentRendererProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {},
|
|
5
|
+
declare const _default: import('vue').DefineComponent<ElmJsonComponentRendererProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ElmJsonComponentRendererProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
6
6
|
export default _default;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
console.error("vite-plugin-css-injected-by-js", e);
|
|
11
11
|
}
|
|
12
12
|
})();
|
|
13
|
-
import { defineComponent, useCssModule, defineAsyncComponent,
|
|
13
|
+
import { defineComponent, useCssModule, defineAsyncComponent, ref, computed, watch, createElementBlock, openBlock, createBlock, resolveDynamicComponent, h } from "vue";
|
|
14
14
|
import "@mdi/js";
|
|
15
15
|
import "polished";
|
|
16
16
|
import "@vueuse/core";
|
|
@@ -38,6 +38,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
38
38
|
const AsyncElmKatex = defineAsyncComponent({
|
|
39
39
|
loader: () => import("../code/ElmKatex.vue.mjs")
|
|
40
40
|
});
|
|
41
|
+
const AsyncElmMermaid = defineAsyncComponent({
|
|
42
|
+
loader: () => import("../code/ElmMermaid.vue.mjs")
|
|
43
|
+
});
|
|
41
44
|
const AsyncElmInlineIcon = defineAsyncComponent({
|
|
42
45
|
loader: () => import("../icon/ElmInlineIcon.vue.mjs")
|
|
43
46
|
});
|
|
@@ -110,9 +113,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
110
113
|
loadingComponent: ElmBlockFallback
|
|
111
114
|
});
|
|
112
115
|
const convertInlineComponentsToPlainText = (inlineComponents) => {
|
|
113
|
-
return inlineComponents.map((
|
|
114
|
-
if (
|
|
115
|
-
return
|
|
116
|
+
return inlineComponents.map((component2) => {
|
|
117
|
+
if (component2.type === "Text") {
|
|
118
|
+
return component2.props.text;
|
|
116
119
|
} else {
|
|
117
120
|
return "";
|
|
118
121
|
}
|
|
@@ -195,6 +198,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
195
198
|
{ default: () => render2(slots.default) }
|
|
196
199
|
) : h(AsyncElmCodeBlock, { code: props2.code, language: props2.language }),
|
|
197
200
|
Katex: ({ props: props2 }) => h(AsyncElmKatex, { expression: props2.expression, block: true }),
|
|
201
|
+
Mermaid: ({ props: props2 }) => h(AsyncElmMermaid, { code: props2.code }),
|
|
198
202
|
Table: ({ props: props2, slots }) => {
|
|
199
203
|
let header = void 0;
|
|
200
204
|
if (slots.header != null) {
|
|
@@ -231,15 +235,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
231
235
|
};
|
|
232
236
|
const render = (jsonComponents) => {
|
|
233
237
|
const results = [];
|
|
234
|
-
for (const
|
|
235
|
-
const renderFunction = defaultRenderFunctionMap(render)[
|
|
236
|
-
results.push(renderFunction(
|
|
238
|
+
for (const component2 of jsonComponents) {
|
|
239
|
+
const renderFunction = defaultRenderFunctionMap(render)[component2.type];
|
|
240
|
+
results.push(renderFunction(component2));
|
|
237
241
|
}
|
|
238
242
|
return results;
|
|
239
243
|
};
|
|
240
|
-
const renderResult = render(props.jsonComponents);
|
|
244
|
+
const renderResult = ref(render(props.jsonComponents));
|
|
245
|
+
const component = computed(() => ({
|
|
246
|
+
render: () => renderResult.value
|
|
247
|
+
}));
|
|
248
|
+
watch(
|
|
249
|
+
() => props.jsonComponents,
|
|
250
|
+
(newComponents) => {
|
|
251
|
+
renderResult.value = render(newComponents);
|
|
252
|
+
}
|
|
253
|
+
);
|
|
241
254
|
return (_ctx, _cache) => {
|
|
242
|
-
return openBlock(),
|
|
255
|
+
return openBlock(), createElementBlock("div", null, [
|
|
256
|
+
(openBlock(), createBlock(resolveDynamicComponent(component.value)))
|
|
257
|
+
]);
|
|
243
258
|
};
|
|
244
259
|
}
|
|
245
260
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface ElmMarkdownProps {
|
|
2
2
|
markdown: string;
|
|
3
3
|
}
|
|
4
|
-
declare const _default: import('vue').DefineComponent<ElmMarkdownProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ElmMarkdownProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {},
|
|
4
|
+
declare const _default: import('vue').DefineComponent<ElmMarkdownProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ElmMarkdownProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
5
5
|
export default _default;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
console.error("vite-plugin-css-injected-by-js", e);
|
|
11
11
|
}
|
|
12
12
|
})();
|
|
13
|
-
import { defineComponent, defineAsyncComponent, ref, computed, watch,
|
|
13
|
+
import { defineComponent, defineAsyncComponent, ref, computed, watch, createElementBlock, openBlock, createBlock, resolveDynamicComponent, h } from "vue";
|
|
14
14
|
import { marked as k } from "../../node_modules/.pnpm/marked@16.4.0/node_modules/marked/lib/marked.esm.mjs";
|
|
15
15
|
import "@mdi/js";
|
|
16
16
|
import "polished";
|
|
@@ -293,7 +293,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
293
293
|
}
|
|
294
294
|
);
|
|
295
295
|
return (_ctx, _cache) => {
|
|
296
|
-
return openBlock(),
|
|
296
|
+
return openBlock(), createElementBlock("div", null, [
|
|
297
|
+
(openBlock(), createBlock(resolveDynamicComponent(component.value)))
|
|
298
|
+
]);
|
|
297
299
|
};
|
|
298
300
|
}
|
|
299
301
|
});
|