@elmethis/vue 0.2.11 → 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.
@@ -3,7 +3,7 @@
3
3
  try {
4
4
  if (typeof document != "undefined") {
5
5
  var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode(".v-enter-to[data-v-92929132],.v-leave-from[data-v-92929132]{opacity:1}.v-enter-active[data-v-92929132],.v-leave-active[data-v-92929132]{transition:opacity .15s}.v-enter-from[data-v-92929132],.v-leave-to[data-v-92929132]{opacity:0}"));
6
+ elementStyle.appendChild(document.createTextNode(".v-enter-to[data-v-514e4afd],.v-leave-from[data-v-514e4afd]{opacity:1}.v-enter-active[data-v-514e4afd],.v-leave-active[data-v-514e4afd]{transition:opacity .15s}.v-enter-from[data-v-514e4afd],.v-leave-to[data-v-514e4afd]{opacity:0}"));
7
7
  document.head.appendChild(elementStyle);
8
8
  }
9
9
  } catch (e) {
@@ -17,7 +17,7 @@ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
17
17
  const cssModules = {
18
18
  "$style": style0
19
19
  };
20
- const ElmCodeBlock = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-92929132"]]);
20
+ const ElmCodeBlock = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-514e4afd"]]);
21
21
  export {
22
22
  ElmCodeBlock as default
23
23
  };
@@ -3,7 +3,7 @@
3
3
  try {
4
4
  if (typeof document != "undefined") {
5
5
  var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode(".fade-enter-active[data-v-cbf6ab16],.fade-leave-active[data-v-cbf6ab16]{transition:all .1s ease}.fade-enter-from[data-v-cbf6ab16],.fade-leave-to[data-v-cbf6ab16]{opacity:0;transform:translate(.5rem)}"));
6
+ elementStyle.appendChild(document.createTextNode(".fade-enter-active[data-v-e975d67d],.fade-leave-active[data-v-e975d67d]{transition:all .1s ease}.fade-enter-from[data-v-e975d67d],.fade-leave-to[data-v-e975d67d]{opacity:0;transform:translate(.5rem)}"));
7
7
  document.head.appendChild(elementStyle);
8
8
  }
9
9
  } catch (e) {
@@ -17,7 +17,7 @@ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
17
17
  const cssModules = {
18
18
  "$style": style0
19
19
  };
20
- const ElmCommandPalette = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-cbf6ab16"]]);
20
+ const ElmCommandPalette = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-e975d67d"]]);
21
21
  export {
22
22
  ElmCommandPalette as default
23
23
  };
@@ -20,4 +20,6 @@ export declare const CodeBlock: Story;
20
20
  export declare const Katex: Story;
21
21
  export declare const Table: Story;
22
22
  export declare const ColumnList: Story;
23
+ export declare const ColumnListWithRatio: Story;
23
24
  export declare const Unsupported: Story;
25
+ export declare const Unified: Story;
@@ -10,7 +10,7 @@
10
10
  console.error("vite-plugin-css-injected-by-js", e);
11
11
  }
12
12
  })();
13
- import { defineComponent, useCssModule, ref, computed, watch, createElementBlock, openBlock, createBlock, resolveDynamicComponent, h } from "vue";
13
+ import { defineComponent, useCssModule, ref, computed, watch, createElementBlock, openBlock, normalizeClass, createBlock, resolveDynamicComponent, h } from "vue";
14
14
  import ElmInlineText from "../typography/ElmInlineText.vue.mjs";
15
15
  import ElmKatex from "../code/ElmKatex.vue.mjs";
16
16
  import ElmMermaid from "../code/ElmMermaid.vue.mjs";
@@ -151,9 +151,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
151
151
  { class: style["column-list"] },
152
152
  { default: () => render2(slots.default) }
153
153
  ),
154
- Column: ({ slots }) => h(
154
+ Column: ({ props: props2, slots }) => h(
155
155
  "div",
156
- { class: style.column },
156
+ {
157
+ class: style.column,
158
+ style: {
159
+ "--width-ratio": props2?.widthRatio ? props2.widthRatio : 1
160
+ }
161
+ },
157
162
  { default: () => render2(slots.default) }
158
163
  ),
159
164
  Unsupported: ({ props: props2 }) => h(ElmUnsupportedBlock, { details: props2?.details })
@@ -178,9 +183,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
178
183
  }
179
184
  );
180
185
  return (_ctx, _cache) => {
181
- return openBlock(), createElementBlock("div", null, [
186
+ return openBlock(), createElementBlock("div", {
187
+ class: normalizeClass(_ctx.$style["jarkup-body"])
188
+ }, [
182
189
  (openBlock(), createBlock(resolveDynamicComponent(components.value)))
183
- ]);
190
+ ], 2);
184
191
  };
185
192
  }
186
193
  });
@@ -3,16 +3,17 @@
3
3
  try {
4
4
  if (typeof document != "undefined") {
5
5
  var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode("._column-list_1at6s_1{box-sizing:content-box;padding-block:.25rem;width:100%;display:flex;flex-direction:row;gap:.5rem;justify-content:space-around;overflow:auto}._column_1at6s_1{flex:1}"));
6
+ elementStyle.appendChild(document.createTextNode("._jarkup-body_zpjoe_1>*+*{margin-block-start:2em}._column-list_zpjoe_5{box-sizing:content-box;padding-block:.25rem;width:100%;display:flex;flex-direction:row;gap:.5rem;justify-content:space-around;overflow:auto}._column_zpjoe_5{flex:1;flex:var(--width-ratio, 1)}"));
7
7
  document.head.appendChild(elementStyle);
8
8
  }
9
9
  } catch (e) {
10
10
  console.error("vite-plugin-css-injected-by-js", e);
11
11
  }
12
12
  })();
13
- const column = "_column_1at6s_1";
13
+ const column = "_column_zpjoe_5";
14
14
  const style0 = {
15
- "column-list": "_column-list_1at6s_1",
15
+ "jarkup-body": "_jarkup-body_zpjoe_1",
16
+ "column-list": "_column-list_zpjoe_5",
16
17
  column
17
18
  };
18
19
  export {
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof ElmMarkdown>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
6
  export declare const Primary: Story;
7
+ export declare const CodeBlock: Story;
@@ -1,255 +1,10 @@
1
- (function() {
2
- "use strict";
3
- try {
4
- if (typeof document != "undefined") {
5
- var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode(".elmethis-list-common{margin-block:1rem;opacity:var(--opacity);transition:opacity .8s;box-sizing:border-box;padding-left:1.25rem}.elmethis-bulleted-list li{box-sizing:border-box;padding-left:.5rem;margin-block:.75rem}.elmethis-bulleted-list li::marker{content:url(data:image/svg+xml;base64,ICA8c3ZnCiAgICB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnCiAgICB2aWV3Qm94PScwIDAgMTYgMTYnCiAgICB3aWR0aD0nMTJweCcKICAgIGhlaWdodD0nMTJweCcKICA+CiAgICA8cGF0aAogICAgICBmaWxsPScjNDQ5NzYzJwogICAgICBvcGFjaXR5PScwLjgnCiAgICAgIGQ9J00zIDMuNzMyYTEuNSAxLjUgMCAwIDEgMi4zMDUtMS4yNjVsNi43MDYgNC4yNjdhMS41IDEuNSAwIDAgMSAwIDIuNTMxbC02LjcwNiA0LjI2OEExLjUgMS41IDAgMCAxIDMgMTIuMjY3VjMuNzMyWicKICAgIC8+CiAgPC9zdmc+)}.elmethis-bulleted-list li ul li::marker{content:url(data:image/svg+xml;base64,ICA8c3ZnCiAgICB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnCiAgICB2aWV3Qm94PScwIDAgMjQgMjQnCiAgICB3aWR0aD0nMTJweCcKICAgIGhlaWdodD0nMTJweCcKICAgIHN0cm9rZT0nIzQ0OTc2MycKICAgIGZpbGw9J3RyYW5zcGFyZW50JwogID4KICAgIDxwYXRoCiAgICAgIHN0cm9rZUxpbmVjYXA9J3JvdW5kJwogICAgICBzdHJva2VMaW5lam9pbj0ncm91bmQnCiAgICAgIGQ9J001LjI1IDUuNjUzYzAtLjg1Ni45MTctMS4zOTggMS42NjctLjk4NmwxMS41NCA2LjM0N2ExLjEyNSAxLjEyNSAwIDAgMSAwIDEuOTcybC0xMS41NCA2LjM0N2ExLjEyNSAxLjEyNSAwIDAgMS0xLjY2Ny0uOTg2VjUuNjUzWicKICAgIC8+CiAgPC9zdmc+)}.elmethis-bulleted-list li ul li ul li::marker{content:url(data:image/svg+xml;base64,ICA8c3ZnCiAgICB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnCiAgICB2aWV3Qm94PScwIDAgMjAgMjAnCiAgICB3aWR0aD0nMTJweCcKICAgIGhlaWdodD0nMTJweCcKICAgIHN0cm9rZT0nIzQ0OTc2MycKICAgIGZpbGw9JyM0NDk3NjMnCiAgPgogICAgPHBhdGgKICAgICAgZmlsbFJ1bGU9J2V2ZW5vZGQnCiAgICAgIGQ9J004LjIyIDUuMjJhLjc1Ljc1IDAgMCAxIDEuMDYgMGw0LjI1IDQuMjVhLjc1Ljc1IDAgMCAxIDAgMS4wNmwtNC4yNSA0LjI1YS43NS43NSAwIDAgMS0xLjA2LTEuMDZMMTEuOTQgMTAgOC4yMiA2LjI4YS43NS43NSAwIDAgMSAwLTEuMDZaJwogICAgICBjbGlwUnVsZT0nZXZlbm9kZCcKICAgIC8+CiAgPC9zdmc+)}.elmethis-numbered-list li{box-sizing:border-box;padding-left:.25rem;margin-block:.75rem;margin-left:.25rem;list-style-type:decimal}.elmethis-numbered-list li::marker{font-weight:700;color:#9771bd}.elmethis-numbered-list li ol li{list-style-type:lower-alpha}.elmethis-numbered-list li ol li ol li{list-style-type:lower-roman}.elmethis-numbered-list li ol li ol li ol li{list-style-type:lower-greek}"));
7
- document.head.appendChild(elementStyle);
8
- }
9
- } catch (e) {
10
- console.error("vite-plugin-css-injected-by-js", e);
11
- }
12
- })();
13
- import { defineComponent, ref, computed, watch, createElementBlock, openBlock, Fragment, renderList, createBlock, resolveDynamicComponent, h } from "vue";
14
- import { marked } from "marked";
15
- import ElmInlineText from "../typography/ElmInlineText.vue.mjs";
16
- import ElmHeading from "../typography/ElmHeading.vue.mjs";
17
- import ElmParagraph from "../typography/ElmParagraph.vue.mjs";
18
- import _sfc_main$2 from "../typography/ElmList.vue.mjs";
19
-
20
- import ElmBlockQuote from "../typography/ElmBlockQuote.vue.mjs";
21
- import ElmDivider from "../typography/ElmDivider.vue.mjs";
22
- import ElmImage from "../media/ElmImage.vue.mjs";
23
- import ElmCodeBlock from "../code/ElmCodeBlock.vue.mjs";
24
- import ElmTable from "../table/ElmTable.vue.mjs";
25
- import ElmTableHeader from "../table/ElmTableHeader.vue.mjs";
26
- import _sfc_main$1 from "../table/ElmTableBody.vue.mjs";
27
- import ElmTableRow from "../table/ElmTableRow.vue.mjs";
28
- import ElmTableCell from "../table/ElmTableCell.vue.mjs";
29
- const _sfc_main = /* @__PURE__ */ defineComponent({
30
- __name: "ElmMarkdown",
31
- props: {
32
- markdown: {}
33
- },
34
- setup(__props) {
35
- const props = __props;
36
- const renderByToken = ({ tokens }) => {
37
- const results = [];
38
- for (const token of tokens) {
39
- switch (token.type) {
40
- case "blockquote":
41
- if (token.tokens != null && token.tokens.length !== 0) {
42
- results.push(
43
- h(
44
- ElmBlockQuote,
45
- {},
46
- {
47
- default: () => renderByToken({ tokens: token.tokens })
48
- }
49
- )
50
- );
51
- }
52
- break;
53
- case "br":
54
- results.push(h("br"));
55
- break;
56
- case "code":
57
- results.push(
58
- h(ElmCodeBlock, {
59
- code: token.text.trim(),
60
- language: token.lang
61
- })
62
- );
63
- break;
64
- case "codespan":
65
- results.push(h(ElmInlineText, { text: token.text, code: true }));
66
- break;
67
- case "def":
68
- h("span", "aaa");
69
- break;
70
- case "del":
71
- results.push(
72
- token.tokens != null && token.tokens.length !== 0 ? h(
73
- ElmInlineText,
74
- { strikethrough: true },
75
- {
76
- default: () => renderByToken({ tokens: token.tokens })
77
- }
78
- ) : h(ElmInlineText, { text: token.text, strikethrough: true })
79
- );
80
- break;
81
- case "em":
82
- results.push(
83
- token.tokens != null && token.tokens.length !== 0 ? h(
84
- ElmInlineText,
85
- { italic: true },
86
- {
87
- default: () => renderByToken({ tokens: token.tokens })
88
- }
89
- ) : h(ElmInlineText, { text: token.text, italic: true })
90
- );
91
- break;
92
- case "escape":
93
- break;
94
- case "heading":
95
- if (token.tokens && token.tokens.length !== 0) {
96
- results.push(
97
- h(
98
- ElmHeading,
99
- { level: token.depth },
100
- {
101
- default: () => renderByToken({ tokens: token.tokens })
102
- }
103
- )
104
- );
105
- } else {
106
- results.push(h(ElmHeading, { level: token.depth, text: token.text }));
107
- }
108
- break;
109
- case "hr":
110
- results.push(h(ElmDivider));
111
- break;
112
- case "html":
113
- break;
114
- case "image":
115
- results.push(
116
- h(ElmImage, {
117
- block: true,
118
- enableModal: true,
119
- src: token.href,
120
- alt: token.text
121
- })
122
- );
123
- break;
124
- case "link":
125
- results.push(
126
- token.tokens != null && token.tokens.length !== 0 ? h(ElmInlineText, {
127
- text: token.text,
128
- href: token.href
129
- }) : h(ElmInlineText, { text: token.text, href: token.href })
130
- );
131
- break;
132
- case "list":
133
- const listItems = token.items.map(
134
- (item) => h("li", {}, renderByToken({ tokens: item.tokens }))
135
- );
136
- results.push(
137
- h(
138
- _sfc_main$2,
139
- {
140
- listStyle: token.ordered ? "ordered" : "unordered"
141
- },
142
- { default: () => listItems }
143
- )
144
- );
145
- break;
146
- case "list_item":
147
- results.push(
148
- token.tokens != null && token.tokens.length !== 0 ? h(
149
- "li",
150
- {},
151
- {
152
- default: () => renderByToken({ tokens: token.tokens })
153
- }
154
- ) : h("li", { text: token.text })
155
- );
156
- break;
157
- case "paragraph":
158
- if (token.tokens && token.tokens.length !== 0) {
159
- results.push(
160
- h(
161
- ElmParagraph,
162
- {},
163
- {
164
- default: () => renderByToken({ tokens: token.tokens })
165
- }
166
- )
167
- );
168
- }
169
- break;
170
- case "space":
171
- break;
172
- case "strong":
173
- results.push(
174
- token.tokens != null && token.tokens.length !== 0 ? h(
175
- ElmInlineText,
176
- { bold: true },
177
- {
178
- default: () => renderByToken({ tokens: token.tokens })
179
- }
180
- ) : h(ElmInlineText, { text: token.text, bold: true })
181
- );
182
- break;
183
- case "table":
184
- const renderTableCells = ({
185
- cells
186
- }) => cells.map(
187
- (cell) => h(
188
- ElmTableCell,
189
- {},
190
- { default: () => renderByToken({ tokens: cell.tokens }) }
191
- )
192
- );
193
- const headerRow = h(
194
- ElmTableRow,
195
- {},
196
- { default: () => renderTableCells({ cells: token.header }) }
197
- );
198
- const bodyRows = token.rows.map(
199
- (row) => h(
200
- ElmTableRow,
201
- {},
202
- { default: () => renderTableCells({ cells: row }) }
203
- )
204
- );
205
- const table = h(
206
- ElmTable,
207
- {},
208
- {
209
- header: () => h(ElmTableHeader, {}, { default: () => headerRow }),
210
- body: () => h(_sfc_main$1, {}, { default: () => bodyRows })
211
- }
212
- );
213
- results.push(table);
214
- break;
215
- case "text":
216
- results.push(
217
- token.tokens != null && token.tokens.length !== 0 ? h(
218
- ElmInlineText,
219
- {},
220
- {
221
- default: () => renderByToken({ tokens: token.tokens })
222
- }
223
- ) : h(ElmInlineText, { text: token.text })
224
- );
225
- break;
226
- }
227
- }
228
- return results;
229
- };
230
- const renderMarkdown = ({ markdown }) => {
231
- const tokens = marked.setOptions({ gfm: true }).lexer(markdown);
232
- return renderByToken({ tokens });
233
- };
234
- const renderResult = ref(renderMarkdown({ markdown: props.markdown }));
235
- const components = computed(() => ({
236
- render: () => renderResult.value
237
- }));
238
- watch(
239
- () => props.markdown,
240
- (md) => {
241
- if (md != null) renderResult.value = renderMarkdown({ markdown: md });
242
- }
243
- );
244
- return (_ctx, _cache) => {
245
- return openBlock(), createElementBlock("div", null, [
246
- (openBlock(true), createElementBlock(Fragment, null, renderList(components.value, (component) => {
247
- return openBlock(), createBlock(resolveDynamicComponent(component));
248
- }), 256))
249
- ]);
250
- };
251
- }
252
- });
1
+ import _sfc_main from "./ElmMarkdown.vue2.mjs";
2
+ import style0 from "./ElmMarkdown.vue3.mjs";
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const cssModules = {
5
+ "$style": style0
6
+ };
7
+ const ElmMarkdown = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
253
8
  export {
254
- _sfc_main as default
9
+ ElmMarkdown as default
255
10
  };
@@ -1,4 +1,257 @@
1
- import _sfc_main from "./ElmMarkdown.vue.mjs";
1
+ (function() {
2
+ "use strict";
3
+ try {
4
+ if (typeof document != "undefined") {
5
+ var elementStyle = document.createElement("style");
6
+ elementStyle.appendChild(document.createTextNode(".elmethis-list-common{margin-block:1rem;opacity:var(--opacity);transition:opacity .8s;box-sizing:border-box;padding-left:1.25rem}.elmethis-bulleted-list li{box-sizing:border-box;padding-left:.5rem;margin-block:.75rem}.elmethis-bulleted-list li::marker{content:url(data:image/svg+xml;base64,ICA8c3ZnCiAgICB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnCiAgICB2aWV3Qm94PScwIDAgMTYgMTYnCiAgICB3aWR0aD0nMTJweCcKICAgIGhlaWdodD0nMTJweCcKICA+CiAgICA8cGF0aAogICAgICBmaWxsPScjNDQ5NzYzJwogICAgICBvcGFjaXR5PScwLjgnCiAgICAgIGQ9J00zIDMuNzMyYTEuNSAxLjUgMCAwIDEgMi4zMDUtMS4yNjVsNi43MDYgNC4yNjdhMS41IDEuNSAwIDAgMSAwIDIuNTMxbC02LjcwNiA0LjI2OEExLjUgMS41IDAgMCAxIDMgMTIuMjY3VjMuNzMyWicKICAgIC8+CiAgPC9zdmc+)}.elmethis-bulleted-list li ul li::marker{content:url(data:image/svg+xml;base64,ICA8c3ZnCiAgICB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnCiAgICB2aWV3Qm94PScwIDAgMjQgMjQnCiAgICB3aWR0aD0nMTJweCcKICAgIGhlaWdodD0nMTJweCcKICAgIHN0cm9rZT0nIzQ0OTc2MycKICAgIGZpbGw9J3RyYW5zcGFyZW50JwogID4KICAgIDxwYXRoCiAgICAgIHN0cm9rZUxpbmVjYXA9J3JvdW5kJwogICAgICBzdHJva2VMaW5lam9pbj0ncm91bmQnCiAgICAgIGQ9J001LjI1IDUuNjUzYzAtLjg1Ni45MTctMS4zOTggMS42NjctLjk4NmwxMS41NCA2LjM0N2ExLjEyNSAxLjEyNSAwIDAgMSAwIDEuOTcybC0xMS41NCA2LjM0N2ExLjEyNSAxLjEyNSAwIDAgMS0xLjY2Ny0uOTg2VjUuNjUzWicKICAgIC8+CiAgPC9zdmc+)}.elmethis-bulleted-list li ul li ul li::marker{content:url(data:image/svg+xml;base64,ICA8c3ZnCiAgICB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnCiAgICB2aWV3Qm94PScwIDAgMjAgMjAnCiAgICB3aWR0aD0nMTJweCcKICAgIGhlaWdodD0nMTJweCcKICAgIHN0cm9rZT0nIzQ0OTc2MycKICAgIGZpbGw9JyM0NDk3NjMnCiAgPgogICAgPHBhdGgKICAgICAgZmlsbFJ1bGU9J2V2ZW5vZGQnCiAgICAgIGQ9J004LjIyIDUuMjJhLjc1Ljc1IDAgMCAxIDEuMDYgMGw0LjI1IDQuMjVhLjc1Ljc1IDAgMCAxIDAgMS4wNmwtNC4yNSA0LjI1YS43NS43NSAwIDAgMS0xLjA2LTEuMDZMMTEuOTQgMTAgOC4yMiA2LjI4YS43NS43NSAwIDAgMSAwLTEuMDZaJwogICAgICBjbGlwUnVsZT0nZXZlbm9kZCcKICAgIC8+CiAgPC9zdmc+)}.elmethis-numbered-list li{box-sizing:border-box;padding-left:.25rem;margin-block:.75rem;margin-left:.25rem;list-style-type:decimal}.elmethis-numbered-list li::marker{font-weight:700;color:#9771bd}.elmethis-numbered-list li ol li{list-style-type:lower-alpha}.elmethis-numbered-list li ol li ol li{list-style-type:lower-roman}.elmethis-numbered-list li ol li ol li ol li{list-style-type:lower-greek}"));
7
+ document.head.appendChild(elementStyle);
8
+ }
9
+ } catch (e) {
10
+ console.error("vite-plugin-css-injected-by-js", e);
11
+ }
12
+ })();
13
+ import { defineComponent, ref, computed, watch, createElementBlock, openBlock, normalizeClass, Fragment, renderList, createBlock, resolveDynamicComponent, h } from "vue";
14
+ import { marked } from "marked";
15
+ import ElmInlineText from "../typography/ElmInlineText.vue.mjs";
16
+ import ElmHeading from "../typography/ElmHeading.vue.mjs";
17
+ import ElmParagraph from "../typography/ElmParagraph.vue.mjs";
18
+ import _sfc_main$2 from "../typography/ElmList.vue.mjs";
19
+
20
+ import ElmBlockQuote from "../typography/ElmBlockQuote.vue.mjs";
21
+ import ElmDivider from "../typography/ElmDivider.vue.mjs";
22
+ import ElmImage from "../media/ElmImage.vue.mjs";
23
+ import ElmCodeBlock from "../code/ElmCodeBlock.vue.mjs";
24
+ import ElmTable from "../table/ElmTable.vue.mjs";
25
+ import ElmTableHeader from "../table/ElmTableHeader.vue.mjs";
26
+ import _sfc_main$1 from "../table/ElmTableBody.vue.mjs";
27
+ import ElmTableRow from "../table/ElmTableRow.vue.mjs";
28
+ import ElmTableCell from "../table/ElmTableCell.vue.mjs";
29
+ const _sfc_main = /* @__PURE__ */ defineComponent({
30
+ __name: "ElmMarkdown",
31
+ props: {
32
+ markdown: {}
33
+ },
34
+ setup(__props) {
35
+ const props = __props;
36
+ const renderByToken = ({ tokens }) => {
37
+ const results = [];
38
+ for (const token of tokens) {
39
+ switch (token.type) {
40
+ case "blockquote":
41
+ if (token.tokens != null && token.tokens.length !== 0) {
42
+ results.push(
43
+ h(
44
+ ElmBlockQuote,
45
+ {},
46
+ {
47
+ default: () => renderByToken({ tokens: token.tokens })
48
+ }
49
+ )
50
+ );
51
+ }
52
+ break;
53
+ case "br":
54
+ results.push(h("br"));
55
+ break;
56
+ case "code":
57
+ results.push(
58
+ h(ElmCodeBlock, {
59
+ code: token.text.trim(),
60
+ language: token.lang
61
+ })
62
+ );
63
+ break;
64
+ case "codespan":
65
+ results.push(h(ElmInlineText, { text: token.text, code: true }));
66
+ break;
67
+ case "def":
68
+ h("span", "aaa");
69
+ break;
70
+ case "del":
71
+ results.push(
72
+ token.tokens != null && token.tokens.length !== 0 ? h(
73
+ ElmInlineText,
74
+ { strikethrough: true },
75
+ {
76
+ default: () => renderByToken({ tokens: token.tokens })
77
+ }
78
+ ) : h(ElmInlineText, { text: token.text, strikethrough: true })
79
+ );
80
+ break;
81
+ case "em":
82
+ results.push(
83
+ token.tokens != null && token.tokens.length !== 0 ? h(
84
+ ElmInlineText,
85
+ { italic: true },
86
+ {
87
+ default: () => renderByToken({ tokens: token.tokens })
88
+ }
89
+ ) : h(ElmInlineText, { text: token.text, italic: true })
90
+ );
91
+ break;
92
+ case "escape":
93
+ break;
94
+ case "heading":
95
+ if (token.tokens && token.tokens.length !== 0) {
96
+ results.push(
97
+ h(
98
+ ElmHeading,
99
+ { level: token.depth },
100
+ {
101
+ default: () => renderByToken({ tokens: token.tokens })
102
+ }
103
+ )
104
+ );
105
+ } else {
106
+ results.push(h(ElmHeading, { level: token.depth, text: token.text }));
107
+ }
108
+ break;
109
+ case "hr":
110
+ results.push(h(ElmDivider));
111
+ break;
112
+ case "html":
113
+ break;
114
+ case "image":
115
+ results.push(
116
+ h(ElmImage, {
117
+ block: true,
118
+ enableModal: true,
119
+ src: token.href,
120
+ alt: token.text
121
+ })
122
+ );
123
+ break;
124
+ case "link":
125
+ results.push(
126
+ token.tokens != null && token.tokens.length !== 0 ? h(ElmInlineText, {
127
+ text: token.text,
128
+ href: token.href
129
+ }) : h(ElmInlineText, { text: token.text, href: token.href })
130
+ );
131
+ break;
132
+ case "list":
133
+ const listItems = token.items.map(
134
+ (item) => h("li", {}, renderByToken({ tokens: item.tokens }))
135
+ );
136
+ results.push(
137
+ h(
138
+ _sfc_main$2,
139
+ {
140
+ listStyle: token.ordered ? "ordered" : "unordered"
141
+ },
142
+ { default: () => listItems }
143
+ )
144
+ );
145
+ break;
146
+ case "list_item":
147
+ results.push(
148
+ token.tokens != null && token.tokens.length !== 0 ? h(
149
+ "li",
150
+ {},
151
+ {
152
+ default: () => renderByToken({ tokens: token.tokens })
153
+ }
154
+ ) : h("li", { text: token.text })
155
+ );
156
+ break;
157
+ case "paragraph":
158
+ if (token.tokens && token.tokens.length !== 0) {
159
+ results.push(
160
+ h(
161
+ ElmParagraph,
162
+ {},
163
+ {
164
+ default: () => renderByToken({ tokens: token.tokens })
165
+ }
166
+ )
167
+ );
168
+ }
169
+ break;
170
+ case "space":
171
+ break;
172
+ case "strong":
173
+ results.push(
174
+ token.tokens != null && token.tokens.length !== 0 ? h(
175
+ ElmInlineText,
176
+ { bold: true },
177
+ {
178
+ default: () => renderByToken({ tokens: token.tokens })
179
+ }
180
+ ) : h(ElmInlineText, { text: token.text, bold: true })
181
+ );
182
+ break;
183
+ case "table":
184
+ const renderTableCells = ({
185
+ cells
186
+ }) => cells.map(
187
+ (cell) => h(
188
+ ElmTableCell,
189
+ {},
190
+ { default: () => renderByToken({ tokens: cell.tokens }) }
191
+ )
192
+ );
193
+ const headerRow = h(
194
+ ElmTableRow,
195
+ {},
196
+ { default: () => renderTableCells({ cells: token.header }) }
197
+ );
198
+ const bodyRows = token.rows.map(
199
+ (row) => h(
200
+ ElmTableRow,
201
+ {},
202
+ { default: () => renderTableCells({ cells: row }) }
203
+ )
204
+ );
205
+ const table = h(
206
+ ElmTable,
207
+ {},
208
+ {
209
+ header: () => h(ElmTableHeader, {}, { default: () => headerRow }),
210
+ body: () => h(_sfc_main$1, {}, { default: () => bodyRows })
211
+ }
212
+ );
213
+ results.push(table);
214
+ break;
215
+ case "text":
216
+ results.push(
217
+ token.tokens != null && token.tokens.length !== 0 ? h(
218
+ ElmInlineText,
219
+ {},
220
+ {
221
+ default: () => renderByToken({ tokens: token.tokens })
222
+ }
223
+ ) : h(ElmInlineText, { text: token.text })
224
+ );
225
+ break;
226
+ }
227
+ }
228
+ return results;
229
+ };
230
+ const renderMarkdown = ({ markdown }) => {
231
+ const tokens = marked.setOptions({ gfm: true }).lexer(markdown);
232
+ return renderByToken({ tokens });
233
+ };
234
+ const renderResult = ref(renderMarkdown({ markdown: props.markdown }));
235
+ const components = computed(() => ({
236
+ render: () => renderResult.value
237
+ }));
238
+ watch(
239
+ () => props.markdown,
240
+ (md) => {
241
+ if (md != null) renderResult.value = renderMarkdown({ markdown: md });
242
+ }
243
+ );
244
+ return (_ctx, _cache) => {
245
+ return openBlock(), createElementBlock("div", {
246
+ class: normalizeClass(_ctx.$style["markdown-body"])
247
+ }, [
248
+ (openBlock(true), createElementBlock(Fragment, null, renderList(components.value, (component) => {
249
+ return openBlock(), createBlock(resolveDynamicComponent(component));
250
+ }), 256))
251
+ ], 2);
252
+ };
253
+ }
254
+ });
2
255
  export {
3
256
  _sfc_main as default
4
257
  };
@@ -0,0 +1,18 @@
1
+ (function() {
2
+ "use strict";
3
+ try {
4
+ if (typeof document != "undefined") {
5
+ var elementStyle = document.createElement("style");
6
+ elementStyle.appendChild(document.createTextNode("._markdown-body_grhpg_1>*+*{margin-block-start:2em}"));
7
+ document.head.appendChild(elementStyle);
8
+ }
9
+ } catch (e) {
10
+ console.error("vite-plugin-css-injected-by-js", e);
11
+ }
12
+ })();
13
+ const style0 = {
14
+ "markdown-body": "_markdown-body_grhpg_1"
15
+ };
16
+ export {
17
+ style0 as default
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmethis/vue",
3
- "version": "0.2.11",
3
+ "version": "0.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,32 +24,32 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@mdi/js": "^7.4.47",
27
- "@vueuse/core": "^14.2.0",
27
+ "@vueuse/core": "^14.2.1",
28
28
  "fuse.js": "^7.1.0",
29
29
  "katex": "^0.16.28",
30
30
  "lodash-es": "^4.17.23",
31
- "marked": "^17.0.1",
32
- "mermaid": "^11.12.2",
31
+ "marked": "^17.0.3",
32
+ "mermaid": "^11.12.3",
33
33
  "nanoid": "^5.1.6",
34
34
  "polished": "^4.3.1",
35
- "shiki": "^3.21.0"
35
+ "shiki": "^3.22.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@ag-ui/core": "^0.0.43",
38
+ "@ag-ui/core": "^0.0.45",
39
39
  "@notionhq/client": "^5.9.0",
40
- "storybook": "^10.2.4",
41
- "@storybook/addon-docs": "^10.2.4",
42
- "@storybook/vue3-vite": "10.2.4",
40
+ "storybook": "^10.2.10",
41
+ "@storybook/addon-docs": "^10.2.10",
42
+ "@storybook/vue3-vite": "10.2.10",
43
43
  "@types/json-schema": "^7.0.15",
44
44
  "@types/katex": "^0.16.8",
45
45
  "@types/lodash-es": "^4.17.12",
46
- "@types/prismjs": "^1.26.5",
46
+ "@types/prismjs": "^1.26.6",
47
47
  "@vitejs/plugin-vue": "^6.0.4",
48
48
  "csstype": "^3.2.3",
49
- "jarkup-ts": "^0.6.0",
49
+ "jarkup-ts": "^0.7.0",
50
50
  "openapi-types": "^12.1.3",
51
51
  "postcss": "^8.5.6",
52
- "postcss-preset-env": "^11.1.2",
52
+ "postcss-preset-env": "^11.1.3",
53
53
  "sass": "^1.97.3",
54
54
  "vite": "^7.3.1",
55
55
  "vite-plugin-css-injected-by-js": "^3.5.2",