@noirmd/previewer 1.2.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/NReditor.cjs +928 -895
  2. package/dist/NReditor.cjs.map +1 -1
  3. package/dist/NReditor.d.cts +1 -1
  4. package/dist/NReditor.d.ts +1 -1
  5. package/dist/NReditor.js +929 -896
  6. package/dist/NReditor.js.map +1 -1
  7. package/dist/admonition.css +55 -0
  8. package/dist/{markdown.css → base.css} +96 -126
  9. package/dist/blockquote.css +16 -0
  10. package/dist/button.css +32 -0
  11. package/dist/card.css +143 -0
  12. package/dist/codeblock.css +59 -0
  13. package/dist/core.cjs +9 -1
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.js +9 -1
  16. package/dist/core.js.map +1 -1
  17. package/dist/details.css +45 -0
  18. package/dist/editor.css +56 -9
  19. package/dist/fonts/material-icons-round.woff2 +0 -0
  20. package/dist/index.cjs +929 -882
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +41 -70
  23. package/dist/index.d.ts +41 -70
  24. package/dist/index.js +928 -876
  25. package/dist/index.js.map +1 -1
  26. package/dist/list.css +18 -0
  27. package/dist/modal.css +82 -0
  28. package/dist/react.cjs +929 -885
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +44 -73
  31. package/dist/react.d.ts +44 -73
  32. package/dist/react.js +928 -879
  33. package/dist/react.js.map +1 -1
  34. package/dist/slide.css +21 -0
  35. package/dist/table.css +36 -0
  36. package/dist/toc.css +45 -0
  37. package/dist/vanilla.cjs +123 -31
  38. package/dist/vanilla.cjs.map +1 -1
  39. package/dist/vanilla.css +32 -677
  40. package/dist/vanilla.d.cts +24 -2
  41. package/dist/vanilla.d.ts +24 -2
  42. package/dist/vanilla.js +119 -31
  43. package/dist/vanilla.js.map +1 -1
  44. package/dist/variables.css +90 -0
  45. package/dist/vue.cjs +1007 -1120
  46. package/dist/vue.cjs.map +1 -1
  47. package/dist/vue.d.cts +63 -214
  48. package/dist/vue.d.ts +63 -214
  49. package/dist/vue.js +1006 -1119
  50. package/dist/vue.js.map +1 -1
  51. package/editor.css +56 -9
  52. package/package.json +5 -10
  53. package/markdown.css +0 -344
package/dist/vue.js CHANGED
@@ -1564,10 +1564,10 @@ var require_core = __commonJS({
1564
1564
  });
1565
1565
 
1566
1566
  // vue/NRpreviewer.ts
1567
- import { defineComponent as defineComponent12, h as h13, ref as ref6 } from "vue";
1567
+ import { defineComponent as defineComponent3, h as h3, ref as ref3 } from "vue";
1568
1568
 
1569
1569
  // vue/CustomMarkdownRenderer.ts
1570
- import { defineComponent as defineComponent11, h as h12, ref as ref5, computed, onMounted as onMounted4, onUnmounted as onUnmounted3, provide } from "vue";
1570
+ import { defineComponent, h, onMounted as onMounted2, onUnmounted as onUnmounted2, ref, watch as watch2 } from "vue";
1571
1571
 
1572
1572
  // core/utils.ts
1573
1573
  function parseCssString(cssText) {
@@ -1613,9 +1613,6 @@ function extractAttributes(text) {
1613
1613
  return { text: cleanedText, classes: classList.join(" "), id };
1614
1614
  }
1615
1615
  var _scopeCounter = 0;
1616
- function resetScopeCounter() {
1617
- _scopeCounter = 0;
1618
- }
1619
1616
  function generateScopeId() {
1620
1617
  return `scope-${++_scopeCounter}`;
1621
1618
  }
@@ -1663,6 +1660,7 @@ function parseMarkdown(markdown2) {
1663
1660
  if (!markdown2) return [];
1664
1661
  const lines = markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "").split("\n");
1665
1662
  const result = [];
1663
+ const usedIds = /* @__PURE__ */ new Set();
1666
1664
  let i = 0;
1667
1665
  while (i < lines.length) {
1668
1666
  const line = lines[i];
@@ -1672,7 +1670,14 @@ function parseMarkdown(markdown2) {
1672
1670
  const level = match[1].length;
1673
1671
  const rawText = match[2];
1674
1672
  const { text: text2, classes: classes2, id: customId } = extractAttributes(rawText);
1675
- const id2 = customId || generateId(text2.replace(/->|<-/g, ""));
1673
+ const baseId = customId || generateId(text2.replace(/->|<-/g, ""));
1674
+ let id2 = baseId;
1675
+ let n = 1;
1676
+ while (usedIds.has(id2)) {
1677
+ n++;
1678
+ id2 = `${baseId}-${n}`;
1679
+ }
1680
+ usedIds.add(id2);
1676
1681
  result.push({ type: "header", level, text: text2, id: id2, classes: classes2 || void 0 });
1677
1682
  i++;
1678
1683
  continue;
@@ -1987,156 +1992,6 @@ function splitSlots(rawContent) {
1987
1992
  return slots;
1988
1993
  }
1989
1994
 
1990
- // vue/renderers.ts
1991
- import { h } from "vue";
1992
- function renderInline(text) {
1993
- if (!text) return [];
1994
- const parsePart = (part, key) => {
1995
- let match2;
1996
- if (match2 = part.match(/^\|\[([^\]]+)\]\|$/)) {
1997
- return h("span", {
1998
- class: "nr-icon material-symbols-rounded",
1999
- "aria-hidden": "true",
2000
- innerHTML: /^[eE][0-9a-fA-F]{3,4}$/.test(match2[1]) ? `&#x${match2[1]};` : void 0,
2001
- key
2002
- }, /^[eE][0-9a-fA-F]{3,4}$/.test(match2[1]) ? void 0 : match2[1]);
2003
- }
2004
- if (match2 = part.match(/^!~(.+?)~!$/)) {
2005
- const content = match2[1];
2006
- const parts = content.split(";");
2007
- let color = "currentColor";
2008
- let decorationStyle = "solid";
2009
- let type = "underline";
2010
- let textIndex = 0;
2011
- if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
2012
- color = parts[textIndex++];
2013
- }
2014
- if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
2015
- decorationStyle = parts[textIndex++];
2016
- }
2017
- if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
2018
- type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
2019
- }
2020
- const innerText = parts.slice(textIndex).join(";");
2021
- return h("span", {
2022
- key,
2023
- style: { textDecoration: `${type} ${decorationStyle} ${color}`, textDecorationThickness: "auto" }
2024
- }, renderInline(innerText));
2025
- }
2026
- if (match2 = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
2027
- return h("span", { key, style: { color: match2[1] } }, renderInline(match2[2]));
2028
- }
2029
- if (match2 = part.match(/^!>([^<]+?)<!$/)) {
2030
- return h("span", {
2031
- key,
2032
- class: "bg-text-primary text-bg-primary px-1 rounded hover:bg-transparent transition-colors cursor-pointer"
2033
- }, renderInline(match2[1]));
2034
- }
2035
- if (match2 = part.match(/^==(.+?)==$/)) {
2036
- return h("mark", {
2037
- key,
2038
- class: "bg-yellow-500/20 text-inherit px-0.5 rounded"
2039
- }, renderInline(match2[1]));
2040
- }
2041
- if (match2 = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
2042
- return h("strong", { key }, h("em", renderInline(match2[1])));
2043
- }
2044
- if (match2 = part.match(/^\*\*(.+?)\*\*$/)) {
2045
- return h("strong", { key }, renderInline(match2[1]));
2046
- }
2047
- if (match2 = part.match(/^_(.+?)_$/)) {
2048
- return h("em", { key }, renderInline(match2[1]));
2049
- }
2050
- if (match2 = part.match(/^~~(.+?)~~$/)) {
2051
- return h("del", { key }, renderInline(match2[1]));
2052
- }
2053
- if (match2 = part.match(/^`([^`]+)`$/)) {
2054
- return h("code", {
2055
- key,
2056
- class: "text-[0.875em] font-mono bg-background-secondary/50 px-1.5 py-0.5 rounded text-text-primary"
2057
- }, match2[1]);
2058
- }
2059
- if (match2 = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
2060
- return h("a", {
2061
- key,
2062
- href: match2[2],
2063
- class: "text-accent-primary underline decoration-accent-primary/40 hover:decoration-accent-primary transition-colors",
2064
- target: "_blank",
2065
- rel: "noopener noreferrer"
2066
- }, renderInline(match2[1]));
2067
- }
2068
- if (part.startsWith("<") && part.endsWith(">")) {
2069
- return h("span", { key, innerHTML: part });
2070
- }
2071
- return h("span", { key }, part);
2072
- };
2073
- const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
2074
- const elements = [];
2075
- let lastIndex = 0;
2076
- let match;
2077
- let keyCounter = 0;
2078
- while ((match = regex.exec(text)) !== null) {
2079
- if (match.index > lastIndex) {
2080
- elements.push(h("span", { key: `text-${keyCounter++}` }, text.slice(lastIndex, match.index)));
2081
- }
2082
- elements.push(parsePart(match[0], `inline-${keyCounter++}`));
2083
- lastIndex = regex.lastIndex;
2084
- }
2085
- if (lastIndex < text.length) {
2086
- elements.push(h("span", { key: `text-${keyCounter++}` }, text.slice(lastIndex)));
2087
- }
2088
- return elements;
2089
- }
2090
- function renderTable(content) {
2091
- const rows = content.split("\n").filter((r) => r.trim());
2092
- if (rows.length < 2) return h("p", content);
2093
- const parseRow = (row) => row.split("|").map((c) => c.trim()).filter(Boolean);
2094
- const headerCells = parseRow(rows[0]);
2095
- const bodyRows = rows.slice(2).map(parseRow);
2096
- return h("div", { class: "overflow-x-auto" }, [
2097
- h("table", { class: "w-full text-sm sm:text-base border-collapse my-4" }, [
2098
- h("thead", [
2099
- h("tr", headerCells.map(
2100
- (cell, ci) => h("th", {
2101
- key: ci,
2102
- class: "border border-border px-3 py-2 bg-background-secondary-solid/10 text-left font-bold"
2103
- }, renderInline(cell))
2104
- ))
2105
- ]),
2106
- h("tbody", bodyRows.map(
2107
- (cells, ri) => h("tr", { key: ri }, cells.map(
2108
- (cell, ci) => h("td", { key: ci, class: "border border-border px-3 py-2" }, renderInline(cell))
2109
- ))
2110
- ))
2111
- ])
2112
- ]);
2113
- }
2114
- function renderList(content) {
2115
- const lines = content.split("\n");
2116
- const items = [];
2117
- for (const line of lines) {
2118
- if (!line.trim()) continue;
2119
- const match = line.match(/^(\s*)([-*+]|\d+\.)\s+(.+)$/);
2120
- if (match) {
2121
- items.push({ indent: match[1].length, marker: match[2], text: match[3] });
2122
- }
2123
- }
2124
- if (items.length === 0) return h("p", content);
2125
- const isOrdered = /^\d+\.$/.test(items[0].marker);
2126
- const tag = isOrdered ? "ol" : "ul";
2127
- return h(tag, {
2128
- class: `${isOrdered ? "list-decimal" : "list-disc"} pl-6 my-3 space-y-1 text-sm sm:text-base`
2129
- }, items.map(
2130
- (item, index) => h("li", { key: index, class: "leading-relaxed" }, renderInline(item.text))
2131
- ));
2132
- }
2133
- function extractHeaders(elements) {
2134
- return elements.filter((el) => el.type === "header");
2135
- }
2136
-
2137
- // vue/ui-components.ts
2138
- import { h as h2, ref, defineComponent } from "vue";
2139
-
2140
1995
  // node_modules/highlight.js/es/core.js
2141
1996
  var import_core = __toESM(require_core(), 1);
2142
1997
  var core_default = import_core.default;
@@ -11033,7 +10888,7 @@ function shell(hljs) {
11033
10888
  };
11034
10889
  }
11035
10890
 
11036
- // vue/highlightSetup.ts
10891
+ // vanilla/highlightSetup.ts
11037
10892
  core_default.registerLanguage("javascript", javascript);
11038
10893
  core_default.registerLanguage("js", javascript);
11039
10894
  core_default.registerLanguage("jsx", javascript);
@@ -11071,754 +10926,982 @@ core_default.registerLanguage("diff", diff);
11071
10926
  core_default.registerLanguage("shell", shell);
11072
10927
  var highlightSetup_default = core_default;
11073
10928
 
11074
- // vue/ui-components.ts
11075
- var IconRenderer = defineComponent({
11076
- name: "IconRenderer",
11077
- props: {
11078
- iconName: { type: String, required: true },
11079
- extraClasses: { type: String, default: "" }
11080
- },
11081
- setup(props) {
11082
- return () => {
11083
- if (!props.iconName) return null;
11084
- const baseClass = `material-symbols-rounded !text-[1em] leading-none align-top ${props.extraClasses}`;
11085
- const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(props.iconName);
11086
- if (isCodepoint) {
11087
- return h2("span", {
11088
- class: baseClass,
11089
- innerHTML: `&#x${props.iconName};`,
11090
- "aria-hidden": "true"
11091
- });
11092
- }
11093
- return h2("span", { class: baseClass, "aria-hidden": "true" }, props.iconName);
11094
- };
10929
+ // vanilla/components.ts
10930
+ function createIcon(iconName, extraClasses) {
10931
+ const span = document.createElement("span");
10932
+ const cls = `nr-icon material-icons-round${extraClasses ? ` ${extraClasses}` : ""}`;
10933
+ span.className = cls;
10934
+ span.setAttribute("aria-hidden", "true");
10935
+ const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(iconName);
10936
+ if (isCodepoint) {
10937
+ span.innerHTML = `&#x${iconName};`;
10938
+ } else {
10939
+ span.textContent = iconName;
11095
10940
  }
11096
- });
11097
- var CodeBlock = defineComponent({
11098
- name: "CodeBlock",
11099
- props: {
11100
- code: { type: String, required: true },
11101
- language: { type: String, default: "" },
11102
- title: { type: String, default: void 0 }
11103
- },
11104
- setup(props) {
11105
- const copied = ref(false);
11106
- let timer = null;
11107
- const lang = () => props.language?.split(/[\s{]/)[0]?.trim() || "";
11108
- const html = () => {
11109
- try {
11110
- if (lang() && highlightSetup_default.getLanguage(lang())) {
11111
- return highlightSetup_default.highlight(props.code, { language: lang() }).value;
11112
- }
11113
- return highlightSetup_default.highlightAuto(props.code).value;
11114
- } catch {
11115
- return "";
11116
- }
11117
- };
11118
- const handleCopy = () => {
11119
- navigator.clipboard.writeText(props.code);
11120
- copied.value = true;
11121
- if (timer) clearTimeout(timer);
11122
- timer = setTimeout(() => {
11123
- copied.value = false;
11124
- }, 1800);
11125
- };
11126
- return () => h2("div", { class: "not-prose my-4 rounded-2xl border border-border overflow-hidden bg-background-secondary-solid/5 relative" }, [
11127
- props.title && h2("div", { class: "flex items-center gap-2 px-4 py-2 border-b border-border bg-background-secondary-solid/10 text-xs sm:text-sm font-mono text-text-secondary" }, [
11128
- h2("span", { class: "material-symbols-rounded text-base" }, "description"),
11129
- props.title
11130
- ]),
11131
- h2("div", { class: "overflow-auto [&_pre]:m-0 [&_pre]:p-4 [&_pre]:text-xs sm:[&_pre]:text-sm" }, [
11132
- h2("pre", { class: "m-0" }, [
11133
- h2("code", {
11134
- class: `language-${lang() || "plaintext"}`,
11135
- innerHTML: html()
11136
- })
11137
- ])
11138
- ]),
11139
- h2("button", {
11140
- class: "absolute top-2 right-2 p-1.5 rounded-lg bg-background-secondary-solid/20 hover:bg-background-secondary-solid/40 transition-colors cursor-pointer border-none text-text-secondary hover:text-text-primary",
11141
- onClick: handleCopy,
11142
- title: "Copy code"
11143
- }, [
11144
- h2(
11145
- "span",
11146
- { class: "material-symbols-rounded", style: { fontSize: "1rem" } },
11147
- copied.value ? "check" : "content_copy"
11148
- )
11149
- ])
11150
- ]);
10941
+ return span;
10942
+ }
10943
+ function createCodeBlock(code, language, title) {
10944
+ const wrapper = document.createElement("div");
10945
+ wrapper.className = "nr-codeblock";
10946
+ const lang = language?.split(/[\s{]/)[0]?.trim() || "";
10947
+ if (title) {
10948
+ const header = document.createElement("div");
10949
+ header.className = "nr-codeblock__header";
10950
+ header.appendChild(createIcon("description"));
10951
+ const titleSpan = document.createElement("span");
10952
+ titleSpan.textContent = title;
10953
+ header.appendChild(titleSpan);
10954
+ wrapper.appendChild(header);
11151
10955
  }
11152
- });
11153
- var defaultIcons = {
10956
+ const pre = document.createElement("pre");
10957
+ pre.className = "nr-codeblock__pre";
10958
+ const codeEl = document.createElement("code");
10959
+ codeEl.className = `language-${lang || "plaintext"}`;
10960
+ try {
10961
+ if (lang && highlightSetup_default.getLanguage(lang)) {
10962
+ codeEl.innerHTML = highlightSetup_default.highlight(code, { language: lang }).value;
10963
+ } else {
10964
+ codeEl.innerHTML = highlightSetup_default.highlightAuto(code).value;
10965
+ }
10966
+ } catch {
10967
+ codeEl.textContent = code;
10968
+ }
10969
+ pre.appendChild(codeEl);
10970
+ wrapper.appendChild(pre);
10971
+ const copyBtn = document.createElement("button");
10972
+ copyBtn.className = "nr-codeblock__copy";
10973
+ copyBtn.title = "Copy code";
10974
+ const copyIcon = createIcon("content_copy");
10975
+ copyIcon.style.fontSize = "1rem";
10976
+ copyBtn.appendChild(copyIcon);
10977
+ let timer = null;
10978
+ copyBtn.addEventListener("click", () => {
10979
+ navigator.clipboard.writeText(code);
10980
+ copyIcon.textContent = "check";
10981
+ if (timer) clearTimeout(timer);
10982
+ timer = setTimeout(() => {
10983
+ copyIcon.textContent = "content_copy";
10984
+ }, 1800);
10985
+ });
10986
+ wrapper.appendChild(copyBtn);
10987
+ return wrapper;
10988
+ }
10989
+ var DEFAULT_ADMONITION_ICONS = {
11154
10990
  note: "info",
11155
10991
  info: "lightbulb",
11156
10992
  warning: "warning",
11157
10993
  danger: "report",
11158
- greentext: "subdirectory_play_arrow"
11159
- };
11160
- var typeClasses = {
11161
- note: "border-info/20 bg-info/5 text-info",
11162
- info: "border-info/30 bg-info/10 text-info",
11163
- warning: "border-amber-500/30 bg-amber-500/10 text-amber-500",
11164
- danger: "border-danger/30 bg-danger/10 text-danger",
11165
- greentext: "border-success/30 bg-success/10 text-success"
10994
+ greentext: "subdirectory_arrow_right"
11166
10995
  };
11167
- var Admonition = defineComponent({
11168
- name: "Admonition",
11169
- props: {
11170
- type: { type: String, default: "note" },
11171
- title: { type: String, default: void 0 },
11172
- icon: { type: String, default: void 0 },
11173
- class: { type: String, default: "" },
11174
- style: { type: Object, default: void 0 }
11175
- },
11176
- setup(props, { slots }) {
11177
- return () => {
11178
- const iconToRender = props.icon || defaultIcons[props.type] || "info";
11179
- const cls = `not-prose rounded-2xl mb-6 border shadow-xs p-4 ${typeClasses[props.type] || typeClasses.note} ${props.class}`;
11180
- return h2("div", { class: cls, style: props.style }, [
11181
- props.title && h2("h5", { class: "font-bold text-base mb-2 m-0 flex items-center gap-2" }, [
11182
- h2(IconRenderer, { iconName: iconToRender, extraClasses: "shrink-0" }),
11183
- h2("span", props.title)
11184
- ]),
11185
- h2("div", { class: "text-sm leading-relaxed opacity-90" }, slots.default?.())
11186
- ]);
11187
- };
10996
+ function createAdmonition(type, title, icon) {
10997
+ const el = document.createElement("div");
10998
+ el.className = `nr-admonition nr-admonition--${type || "note"}`;
10999
+ if (title) {
11000
+ const header = document.createElement("h5");
11001
+ header.className = "nr-admonition__title";
11002
+ const iconToRender = icon || DEFAULT_ADMONITION_ICONS[type] || "info";
11003
+ header.appendChild(createIcon(iconToRender, "nr-admonition__icon"));
11004
+ const titleSpan = document.createElement("span");
11005
+ titleSpan.textContent = title;
11006
+ header.appendChild(titleSpan);
11007
+ el.appendChild(header);
11188
11008
  }
11189
- });
11190
- var Details = defineComponent({
11191
- name: "Details",
11192
- props: {
11193
- title: { type: String, required: true },
11194
- icon: { type: String, default: void 0 },
11195
- defaultOpen: { type: Boolean, default: false },
11196
- class: { type: String, default: "" },
11197
- style: { type: Object, default: void 0 }
11198
- },
11199
- setup(props, { slots }) {
11200
- const isOpen = ref(props.defaultOpen);
11201
- const iconToRender = props.icon || "play_arrow";
11202
- return () => h2("details", {
11203
- class: `not-prose rounded-2xl border border-border mb-4 bg-background-primary/5 ${props.class}`,
11204
- open: isOpen.value,
11205
- style: props.style
11206
- }, [
11207
- h2("summary", {
11208
- class: "cursor-pointer p-4 font-bold flex items-center gap-2 list-none [&::-webkit-details-marker]:hidden hover:text-accent-primary transition-colors",
11209
- onClick: (e) => {
11210
- e.preventDefault();
11211
- isOpen.value = !isOpen.value;
11212
- }
11213
- }, [
11214
- h2(IconRenderer, {
11215
- iconName: iconToRender,
11216
- extraClasses: `transition-transform ${isOpen.value ? "rotate-90" : ""}`
11217
- }),
11218
- h2("span", props.title)
11219
- ]),
11220
- isOpen.value && h2("div", {
11221
- class: "px-4 pb-4 border-t border-border pt-3 text-sm leading-relaxed opacity-90 overflow-hidden min-w-0"
11222
- }, slots.default?.())
11223
- ]);
11009
+ const body = document.createElement("div");
11010
+ body.className = "nr-admonition__body";
11011
+ el.appendChild(body);
11012
+ return el;
11013
+ }
11014
+ function createDetails(title, icon, defaultOpen) {
11015
+ const details = document.createElement("details");
11016
+ details.className = "nr-details";
11017
+ if (defaultOpen) details.open = true;
11018
+ const summary = document.createElement("summary");
11019
+ summary.className = "nr-details__summary";
11020
+ const iconToRender = icon || "play_arrow";
11021
+ const iconEl = createIcon(iconToRender, "nr-details__icon");
11022
+ summary.appendChild(iconEl);
11023
+ const titleSpan = document.createElement("span");
11024
+ titleSpan.textContent = title || "Details";
11025
+ summary.appendChild(titleSpan);
11026
+ details.addEventListener("toggle", () => {
11027
+ iconEl.classList.toggle("nr-details__icon--open", details.open);
11028
+ });
11029
+ details.appendChild(summary);
11030
+ const body = document.createElement("div");
11031
+ body.className = "nr-details__body";
11032
+ details.appendChild(body);
11033
+ return details;
11034
+ }
11035
+ function createModal(title) {
11036
+ const dialog = document.createElement("dialog");
11037
+ dialog.className = "nr-modal";
11038
+ dialog.addEventListener("click", (e) => {
11039
+ if (e.target === dialog) {
11040
+ dialog.close();
11041
+ }
11042
+ });
11043
+ const popup = document.createElement("div");
11044
+ popup.className = "nr-modal__popup";
11045
+ const header = document.createElement("div");
11046
+ header.className = "nr-modal__header";
11047
+ const titleEl = document.createElement("h2");
11048
+ titleEl.className = "nr-modal__title";
11049
+ titleEl.textContent = title;
11050
+ header.appendChild(titleEl);
11051
+ const closeBtn = document.createElement("button");
11052
+ closeBtn.className = "nr-modal__close";
11053
+ closeBtn.appendChild(createIcon("close"));
11054
+ closeBtn.addEventListener("click", () => dialog.close());
11055
+ header.appendChild(closeBtn);
11056
+ popup.appendChild(header);
11057
+ const body = document.createElement("div");
11058
+ body.className = "nr-modal__body";
11059
+ popup.appendChild(body);
11060
+ dialog.appendChild(popup);
11061
+ return dialog;
11062
+ }
11063
+ function createTable(content, renderInline2) {
11064
+ const rows = content.split("\n").filter((r) => r.trim());
11065
+ if (rows.length < 2) {
11066
+ const p = document.createElement("p");
11067
+ p.textContent = content;
11068
+ return p;
11224
11069
  }
11225
- });
11226
- var Modal = defineComponent({
11227
- name: "Modal",
11228
- props: {
11229
- title: { type: String, required: true },
11230
- isOpen: { type: Boolean, required: true },
11231
- onClose: { type: Function, required: true }
11232
- },
11233
- setup(props, { slots }) {
11234
- let dialogEl = null;
11235
- const showDialog = () => {
11236
- if (dialogEl && !dialogEl.open) {
11237
- document.body.appendChild(dialogEl);
11238
- dialogEl.showModal();
11239
- }
11240
- };
11241
- const closeDialog = () => {
11242
- if (dialogEl) {
11243
- dialogEl.close();
11244
- }
11245
- };
11246
- return () => {
11247
- const dialog = h2("dialog", {
11248
- ref: (el) => {
11249
- dialogEl = el?.$el || el;
11250
- },
11251
- class: "nr-modal",
11252
- onClick: (e) => {
11253
- if (e.target === dialogEl) closeDialog();
11254
- },
11255
- onClosed: () => {
11256
- dialogEl?.remove();
11257
- props.onClose();
11258
- }
11259
- }, [
11260
- h2("div", { class: "nr-modal__popup" }, [
11261
- h2("div", { class: "nr-modal__header" }, [
11262
- h2("h2", { class: "nr-modal__title" }, props.title),
11263
- h2("button", {
11264
- class: "nr-modal__close",
11265
- onClick: closeDialog
11266
- }, [
11267
- h2("span", { class: "material-symbols-rounded" }, "close")
11268
- ])
11269
- ]),
11270
- h2("div", { class: "nr-modal__body" }, slots.default?.())
11271
- ])
11272
- ]);
11273
- if (props.isOpen) {
11274
- Promise.resolve().then(showDialog);
11275
- }
11276
- return dialog;
11277
- };
11070
+ const parseRow = (row) => row.split("|").map((c) => c.trim()).filter(Boolean);
11071
+ const headerCells = parseRow(rows[0]);
11072
+ const bodyRows = rows.slice(2).map(parseRow);
11073
+ const wrapper = document.createElement("div");
11074
+ wrapper.className = "nr-table-wrap";
11075
+ const table = document.createElement("table");
11076
+ table.className = "nr-table";
11077
+ const thead = document.createElement("thead");
11078
+ const tr = document.createElement("tr");
11079
+ for (const cell of headerCells) {
11080
+ const th = document.createElement("th");
11081
+ th.className = "nr-table__th";
11082
+ th.appendChild(renderInline2(cell));
11083
+ tr.appendChild(th);
11278
11084
  }
11279
- });
11280
-
11281
- // vue/DirectiveRenderer.ts
11282
- import { defineComponent as defineComponent9, h as h10 } from "vue";
11283
-
11284
- // vue/directives/AdmonitionDirective.ts
11285
- import { defineComponent as defineComponent2, h as h3 } from "vue";
11286
- var AdmonitionDirective = defineComponent2({
11287
- name: "AdmonitionDirective",
11288
- props: {
11289
- directiveType: String,
11290
- props: Object,
11291
- slots: Object,
11292
- renderSlot: Function,
11293
- context: Object,
11294
- index: [String, Number],
11295
- allElements: Array,
11296
- options: Object
11297
- },
11298
- setup(props) {
11299
- return () => {
11300
- const p = props;
11301
- return h3(Admonition, {
11302
- type: p.directiveType,
11303
- title: p.props.title,
11304
- icon: p.props.icon,
11305
- class: p.props.class,
11306
- style: p.props.style ? parseCssString(p.props.style) : void 0
11307
- }, p.renderSlot("default"));
11308
- };
11085
+ thead.appendChild(tr);
11086
+ table.appendChild(thead);
11087
+ const tbody = document.createElement("tbody");
11088
+ for (const cells of bodyRows) {
11089
+ const tr2 = document.createElement("tr");
11090
+ for (const cell of cells) {
11091
+ const td = document.createElement("td");
11092
+ td.className = "nr-table__td";
11093
+ td.appendChild(renderInline2(cell));
11094
+ tr2.appendChild(td);
11095
+ }
11096
+ tbody.appendChild(tr2);
11309
11097
  }
11310
- });
11311
- var AdmonitionDirective_default = AdmonitionDirective;
11312
-
11313
- // vue/directives/CardDirective.ts
11314
- import { defineComponent as defineComponent3, h as h4 } from "vue";
11098
+ table.appendChild(tbody);
11099
+ wrapper.appendChild(table);
11100
+ return wrapper;
11101
+ }
11102
+ function createList(content, renderInline2) {
11103
+ const lines = content.split("\n");
11104
+ const items = [];
11105
+ for (const line of lines) {
11106
+ if (!line.trim()) continue;
11107
+ const match = line.match(/^(\s*)([-*+]|\d+\.)\s+(.+)$/);
11108
+ if (match) {
11109
+ items.push({ indent: match[1].length, marker: match[2], text: match[3] });
11110
+ }
11111
+ }
11112
+ if (items.length === 0) {
11113
+ const p = document.createElement("p");
11114
+ p.textContent = content;
11115
+ return p;
11116
+ }
11117
+ const isOrdered = /^\d+\.$/.test(items[0].marker);
11118
+ const list = document.createElement(isOrdered ? "ol" : "ul");
11119
+ list.className = "nr-list";
11120
+ for (const item of items) {
11121
+ const li = document.createElement("li");
11122
+ li.className = "nr-list__item";
11123
+ li.appendChild(renderInline2(item.text));
11124
+ list.appendChild(li);
11125
+ }
11126
+ return list;
11127
+ }
11128
+ function createTOC(headers, renderInline2) {
11129
+ const nav = document.createElement("nav");
11130
+ nav.className = "nr-toc";
11131
+ const title = document.createElement("div");
11132
+ title.className = "nr-toc__title";
11133
+ title.textContent = "Table of Contents";
11134
+ nav.appendChild(title);
11135
+ const ul = document.createElement("ul");
11136
+ ul.className = "nr-toc__list";
11137
+ for (const h4 of headers) {
11138
+ const li = document.createElement("li");
11139
+ li.className = `nr-toc__item nr-toc__item--h${h4.level}`;
11140
+ const a = document.createElement("a");
11141
+ a.className = "nr-toc__link";
11142
+ a.href = `#${h4.id}`;
11143
+ a.appendChild(renderInline2(h4.text.replace(/->|<-/g, "").trim()));
11144
+ a.addEventListener("click", (e) => {
11145
+ e.preventDefault();
11146
+ const target = document.getElementById(h4.id);
11147
+ if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
11148
+ });
11149
+ li.appendChild(a);
11150
+ ul.appendChild(li);
11151
+ }
11152
+ nav.appendChild(ul);
11153
+ return nav;
11154
+ }
11155
+ function createBlockquote(content, classes, renderInline2) {
11156
+ const el = document.createElement("blockquote");
11157
+ el.className = `nr-blockquote${classes ? ` ${classes}` : ""}`;
11158
+ el.appendChild(renderInline2(content));
11159
+ return el;
11160
+ }
11315
11161
 
11316
- // vue/context.ts
11317
- import { inject } from "vue";
11318
- var RenderContextKey = /* @__PURE__ */ Symbol("RenderContext");
11319
- function useRenderContext() {
11320
- const ctx = inject(RenderContextKey);
11321
- if (!ctx) {
11322
- throw new Error("useRenderContext must be used within a RenderContextProvider");
11162
+ // vanilla/inline.ts
11163
+ function renderInline(text) {
11164
+ const fragment = document.createDocumentFragment();
11165
+ if (!text) return fragment;
11166
+ const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
11167
+ let lastIndex = 0;
11168
+ let match;
11169
+ while ((match = regex.exec(text)) !== null) {
11170
+ if (match.index > lastIndex) {
11171
+ fragment.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
11172
+ }
11173
+ fragment.appendChild(parseInlinePart(match[0]));
11174
+ lastIndex = regex.lastIndex;
11175
+ }
11176
+ if (lastIndex < text.length) {
11177
+ fragment.appendChild(document.createTextNode(text.slice(lastIndex)));
11323
11178
  }
11324
- return ctx;
11179
+ return fragment;
11180
+ }
11181
+ function parseInlinePart(part) {
11182
+ let match;
11183
+ if (match = part.match(/^\|\[([^\]]+)\]\|$/)) {
11184
+ return createIcon(match[1]);
11185
+ }
11186
+ if (match = part.match(/^!~(.+?)~!$/)) {
11187
+ const content = match[1];
11188
+ const parts = content.split(";");
11189
+ let color = "currentColor";
11190
+ let decorationStyle = "solid";
11191
+ let type = "underline";
11192
+ let textIndex = 0;
11193
+ if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
11194
+ color = parts[textIndex++];
11195
+ }
11196
+ if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
11197
+ decorationStyle = parts[textIndex++];
11198
+ }
11199
+ if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
11200
+ type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
11201
+ }
11202
+ const innerText = parts.slice(textIndex).join(";");
11203
+ const span = document.createElement("span");
11204
+ span.className = "nr-underline";
11205
+ span.style.textDecoration = `${type} ${decorationStyle} ${color}`;
11206
+ span.style.textDecorationThickness = "auto";
11207
+ span.appendChild(renderInline(innerText));
11208
+ return span;
11209
+ }
11210
+ if (match = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
11211
+ const span = document.createElement("span");
11212
+ span.style.color = match[1];
11213
+ span.appendChild(renderInline(match[2]));
11214
+ return span;
11215
+ }
11216
+ if (match = part.match(/^!>([^<]+?)<!$/)) {
11217
+ const span = document.createElement("span");
11218
+ span.className = "nr-spoiler";
11219
+ span.appendChild(renderInline(match[1]));
11220
+ return span;
11221
+ }
11222
+ if (match = part.match(/^==(.+?)==$/)) {
11223
+ const mark = document.createElement("mark");
11224
+ mark.className = "nr-highlight";
11225
+ mark.appendChild(renderInline(match[1]));
11226
+ return mark;
11227
+ }
11228
+ if (match = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
11229
+ const strong = document.createElement("strong");
11230
+ const em = document.createElement("em");
11231
+ em.appendChild(renderInline(match[1]));
11232
+ strong.appendChild(em);
11233
+ return strong;
11234
+ }
11235
+ if (match = part.match(/^\*\*(.+?)\*\*$/)) {
11236
+ const strong = document.createElement("strong");
11237
+ strong.appendChild(renderInline(match[1]));
11238
+ return strong;
11239
+ }
11240
+ if (match = part.match(/^_(.+?)_$/)) {
11241
+ const em = document.createElement("em");
11242
+ em.appendChild(renderInline(match[1]));
11243
+ return em;
11244
+ }
11245
+ if (match = part.match(/^~~(.+?)~~$/)) {
11246
+ const del = document.createElement("del");
11247
+ del.appendChild(renderInline(match[1]));
11248
+ return del;
11249
+ }
11250
+ if (match = part.match(/^`([^`]+)`$/)) {
11251
+ const code = document.createElement("code");
11252
+ code.className = "nr-inline-code";
11253
+ code.textContent = match[1];
11254
+ return code;
11255
+ }
11256
+ if (match = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
11257
+ const a = document.createElement("a");
11258
+ a.className = "nr-link";
11259
+ a.href = match[2];
11260
+ a.target = "_blank";
11261
+ a.rel = "noopener noreferrer";
11262
+ a.appendChild(renderInline(match[1]));
11263
+ return a;
11264
+ }
11265
+ if (part.startsWith("<") && part.endsWith(">")) {
11266
+ const span = document.createElement("span");
11267
+ span.innerHTML = part;
11268
+ return span;
11269
+ }
11270
+ return document.createTextNode(part);
11325
11271
  }
11326
11272
 
11327
- // vue/directives/CardDirective.ts
11328
- var CardDirective = defineComponent3({
11329
- name: "CardDirective",
11330
- props: {
11331
- directiveType: String,
11332
- props: Object,
11333
- slots: Object,
11334
- renderSlot: Function,
11335
- context: Object,
11336
- index: [String, Number],
11337
- allElements: Array,
11338
- options: { type: Object, default: () => ({}) }
11339
- },
11340
- setup(props) {
11341
- return () => {
11342
- const p = props;
11343
- const ctx = useRenderContext();
11344
- const { title, image, icon, class: customClass, url, target } = p.props;
11345
- const hasDescription = !!p.slots.description;
11346
- const { isSingleCard } = p.options || {};
11347
- const isModal = p.directiveType === "card-m";
11348
- const isLink = p.directiveType === "card-b";
11349
- const modalId = `modal-card-${p.props.id || Math.random().toString(36).slice(2, 9)}`;
11350
- const inlineStyles = p.props.style ? parseCssString(p.props.style) : {};
11351
- const description = hasDescription ? p.renderSlot("description") : null;
11352
- const content = p.renderSlot("content") || p.renderSlot("default");
11353
- const handleClick = isModal ? (e) => {
11354
- e.preventDefault();
11355
- e.stopPropagation();
11356
- ctx.setModals((prev) => ({ ...prev, [modalId]: true }));
11357
- } : isLink && url ? () => window.open(url, "_blank") : void 0;
11358
- const card = h4("div", {
11359
- class: `flex flex-col h-full rounded-3xl transition-all relative overflow-hidden group border min-w-[18rem] w-[18rem] max-w-[20rem] ${isModal || isLink ? "cursor-pointer !border-accent-primary/10 hover:border-accent-primary/50" : "border-border"} ${customClass || ""}`.trim(),
11360
- style: inlineStyles,
11361
- onClick: handleClick,
11362
- role: isModal ? "button" : void 0,
11363
- tabIndex: isModal ? 0 : void 0,
11364
- onKeyDown: isModal ? (e) => {
11365
- if (e.key === "Enter" || e.key === " ") {
11366
- ctx.setModals((prev) => ({ ...prev, [modalId]: true }));
11367
- }
11368
- } : void 0
11369
- }, [
11370
- // Image banner
11371
- image && h4("div", {
11372
- class: `w-full ${isSingleCard ? "h-[240px]" : "h-[160px]"} overflow-hidden relative transition-all duration-500`
11373
- }, [
11374
- h4("img", { src: image, alt: title || "", class: "w-full h-full object-cover !m-0" }),
11375
- h4("div", { class: "absolute inset-0 bg-gradient-to-t from-background-primary/40 to-transparent" })
11376
- ]),
11377
- // Content body
11378
- h4("div", {
11379
- class: `flex flex-col flex-1 bg-background-primary/80 rounded-t-xl p-6 relative ${image ? "-mt-10" : ""} border-t border-white/5 shadow-2xl`
11380
- }, [
11381
- // Header: Icon + Title
11382
- (icon || title) && h4("div", { class: "flex items-center gap-3 mb-3" }, [
11383
- icon && h4("div", {
11384
- class: "w-10 h-10 text-[1.6em] rounded-xl bg-accent-primary/20 flex items-center justify-center shrink-0 text-accent-primary"
11385
- }, h4(IconRenderer, { iconName: icon })),
11386
- h4("h3", { class: "text-base font-black tracking-tight leading-tight !m-0" }, title)
11387
- ]),
11388
- // Content Body
11389
- h4("div", { class: "flex-1 flex flex-col gap-2" }, [
11390
- description && h4("div", { class: "text-sm opacity-80 leading-relaxed font-medium" }, description),
11391
- p.directiveType === "card" && content && content.length > 0 ? h4("div", { class: "mt-2" }, content) : null
11392
- ]),
11393
- // Bottom: Action Link
11394
- (isModal || isLink) && h4("div", { class: "mt-6 flex justify-end" }, [
11395
- isLink && url ? h4("a", {
11396
- href: url,
11397
- target: "_blank",
11398
- rel: "noopener noreferrer",
11399
- class: "bg-accent-primary/20 hover:bg-accent-primary/30 px-4 py-2 rounded-xl flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest opacity-50 group-hover:opacity-100 group-hover:text-accent-primary transition-all no-underline",
11400
- onClick: (e) => e.stopPropagation()
11401
- }, [h4(IconRenderer, { iconName: "open_in_new" }), " Link"]) : isModal ? h4("div", {
11402
- class: "bg-accent-primary/20 hover:bg-accent-primary/30 px-4 py-2 cursor-pointer rounded-xl flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest opacity-50 group-hover:opacity-100 group-hover:text-accent-primary transition-all"
11403
- }, [h4(IconRenderer, { iconName: "arrow_forward" }), " Abrir"]) : null
11404
- ])
11405
- ])
11406
- ]);
11407
- if (isModal) {
11408
- const modalContent = p.renderSlot("content") || p.renderSlot("default");
11409
- return h4("div", null, [
11410
- card,
11411
- h4(Modal, {
11412
- title: title || "Detalles",
11413
- isOpen: !!ctx.modals.value[modalId],
11414
- onClose: () => ctx.setModals((prev) => ({ ...prev, [modalId]: false }))
11415
- }, [
11416
- h4("div", { class: "prose prose-sm max-w-none" }, modalContent)
11417
- ])
11418
- ]);
11419
- }
11420
- return card;
11421
- };
11273
+ // vanilla/directives/admonition.ts
11274
+ var admonitionDirective = ({ directiveType, props, renderSlot }) => {
11275
+ const el = createAdmonition(directiveType, props.title, props.icon);
11276
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
11277
+ if (props.style) el.setAttribute("style", props.style);
11278
+ const body = el.querySelector(".nr-admonition__body");
11279
+ if (body) {
11280
+ body.appendChild(renderSlot("default"));
11422
11281
  }
11423
- });
11424
- var CardDirective_default = CardDirective;
11282
+ return el;
11283
+ };
11284
+ var admonition_default = admonitionDirective;
11425
11285
 
11426
- // vue/directives/DetailsDirective.ts
11427
- import { defineComponent as defineComponent4, h as h5 } from "vue";
11428
- var DetailsDirective = defineComponent4({
11429
- name: "DetailsDirective",
11430
- props: {
11431
- directiveType: String,
11432
- props: Object,
11433
- slots: Object,
11434
- renderSlot: Function,
11435
- context: Object,
11436
- index: [String, Number],
11437
- allElements: Array,
11438
- options: Object
11439
- },
11440
- setup(props) {
11441
- return () => {
11442
- const p = props;
11443
- return h5(Details, {
11444
- title: p.props.title || "Details",
11445
- icon: p.props.icon,
11446
- defaultOpen: p.props.defaultOpen === "true",
11447
- class: p.props.class,
11448
- style: p.props.style ? parseCssString(p.props.style) : void 0
11449
- }, p.renderSlot("default"));
11450
- };
11286
+ // vanilla/directives/details.ts
11287
+ var detailsDirective = ({ props, renderSlot }) => {
11288
+ const el = createDetails(
11289
+ props.title || "Details",
11290
+ props.icon,
11291
+ props.defaultOpen === "true"
11292
+ );
11293
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
11294
+ if (props.style) el.setAttribute("style", props.style);
11295
+ const body = el.querySelector(".nr-details__body");
11296
+ if (body) {
11297
+ body.appendChild(renderSlot("default"));
11451
11298
  }
11452
- });
11453
- var DetailsDirective_default = DetailsDirective;
11299
+ return el;
11300
+ };
11301
+ var details_default = detailsDirective;
11454
11302
 
11455
- // vue/directives/ModalDirective.ts
11456
- import { defineComponent as defineComponent5, h as h6 } from "vue";
11457
- var ModalDirective = defineComponent5({
11458
- name: "ModalDirective",
11459
- props: {
11460
- directiveType: String,
11461
- props: Object,
11462
- slots: Object,
11463
- renderSlot: Function,
11464
- context: Object,
11465
- index: [String, Number],
11466
- allElements: Array,
11467
- options: Object
11468
- },
11469
- setup(props) {
11470
- return () => {
11471
- const p = props;
11472
- const ctx = useRenderContext();
11473
- const modalId = `modal-${p.props.id || Math.random().toString(36).slice(2, 9)}`;
11474
- const label = p.props.label || p.props.title || "Open";
11475
- const modalTitle = p.props.title || "Modal";
11476
- const customClass = p.props.class || "";
11477
- const hasSizeClass = /\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/.test(customClass);
11478
- const sizeClass = hasSizeClass ? "" : "text-sm";
11479
- const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
11480
- const displayClass = hasDisplayClass ? "" : "inline-flex";
11481
- const isInlineFlex = /\binline-flex\b/.test(customClass);
11482
- const marginClass = isInlineFlex ? "my-1 mx-1" : "my-4";
11483
- const btnBase = `${displayClass} items-center w-fit ${marginClass} ${sizeClass} px-4 py-2 rounded-xl font-bold no-underline gap-2 transition-all hover:scale-105 active:scale-95 border border-border bg-background-primary/5 hover:bg-background-primary/10 text-text-primary hover:text-text-primary`.replace(/\s+/g, " ");
11484
- const btnClass = `${btnBase} ${customClass}`.trim();
11485
- const positionMap = {
11486
- "#left": "text-left",
11487
- "#center": "text-center",
11488
- "#right": "text-right"
11489
- };
11490
- const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
11491
- const handleOpen = () => {
11492
- ctx.setModals((prev) => ({ ...prev, [modalId]: true }));
11493
- };
11494
- const handleClose = () => {
11495
- ctx.setModals((prev) => ({ ...prev, [modalId]: false }));
11496
- };
11497
- return h6("div", { class: `not-prose ${wrapperClass}`.trim() }, [
11498
- h6("button", { class: btnClass, onClick: handleOpen }, [
11499
- p.props.icon && h6(IconRenderer, { iconName: p.props.icon }),
11500
- label
11501
- ]),
11502
- h6(Modal, {
11503
- title: modalTitle,
11504
- isOpen: !!ctx.modals.value[modalId],
11505
- onClose: handleClose
11506
- }, p.renderSlot("default"))
11507
- ]);
11508
- };
11303
+ // vanilla/directives/modal.ts
11304
+ var modalDirective = ({ props, renderSlot }) => {
11305
+ const label = props.label || props.title || "Open";
11306
+ const modalTitle = props.title || "Modal";
11307
+ const customClass = props.class || "";
11308
+ const wrapper = document.createElement("div");
11309
+ wrapper.className = "nr-modal-trigger";
11310
+ const btn = document.createElement("button");
11311
+ btn.className = `nr-button nr-button--default`;
11312
+ if (customClass) btn.classList.add(...customClass.split(/\s+/).filter(Boolean));
11313
+ const icon = props.icon || "open_in_new";
11314
+ if (icon) btn.appendChild(createIcon(icon));
11315
+ btn.appendChild(document.createTextNode(label));
11316
+ const dialog = createModal(modalTitle);
11317
+ const body = dialog.querySelector(".nr-modal__body");
11318
+ if (body) {
11319
+ const prose = document.createElement("div");
11320
+ prose.className = "nr-prose";
11321
+ prose.appendChild(renderSlot("default"));
11322
+ body.appendChild(prose);
11509
11323
  }
11510
- });
11511
- var ModalDirective_default = ModalDirective;
11324
+ btn.addEventListener("click", () => {
11325
+ if (!dialog.open) {
11326
+ document.body.appendChild(dialog);
11327
+ dialog.showModal();
11328
+ dialog.addEventListener("close", () => {
11329
+ dialog.remove();
11330
+ }, { once: true });
11331
+ }
11332
+ });
11333
+ wrapper.appendChild(btn);
11334
+ wrapper.appendChild(dialog);
11335
+ return wrapper;
11336
+ };
11337
+ var modal_default = modalDirective;
11512
11338
 
11513
- // vue/directives/ButtonDirective.ts
11514
- import { defineComponent as defineComponent6, h as h7 } from "vue";
11515
- var ButtonDirective = defineComponent6({
11516
- name: "ButtonDirective",
11517
- props: {
11518
- directiveType: String,
11519
- props: Object,
11520
- slots: Object,
11521
- renderSlot: Function,
11522
- context: Object,
11523
- index: [String, Number],
11524
- allElements: Array,
11525
- options: Object
11526
- },
11527
- setup(props) {
11528
- return () => {
11529
- const p = props;
11530
- const url = p.props.url || p.props.href || "#";
11531
- const label = p.props.label;
11532
- const icon = p.props.icon || "near_me";
11533
- const target = p.props.target || "_blank";
11534
- const customClass = p.props.class || "";
11535
- const hasSizeClass = /\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/.test(customClass);
11536
- const sizeClass = hasSizeClass ? "" : "text-sm";
11537
- const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
11538
- const displayClass = hasDisplayClass ? "" : "inline-flex";
11539
- const isInline = !customClass || !/\b(flex|block|grid)\b/.test(customClass) || /\binline-flex\b/.test(customClass);
11540
- const marginClass = isInline ? "my-1 mx-1" : "my-4";
11541
- const btnBase = `${displayClass} items-center w-fit ${marginClass} ${sizeClass} px-4 py-2 rounded-xl font-bold no-underline gap-2 transition-all hover:scale-105 active:scale-95 border border-border bg-background-primary/5 hover:bg-background-primary/10 text-text-primary hover:text-text-primary`.replace(/\s+/g, " ");
11542
- const btnClass = `${btnBase} ${customClass}`.trim();
11543
- const positionMap = {
11544
- "#left": "flex justify-start",
11545
- "#center": "flex justify-center",
11546
- "#right": "flex justify-end"
11547
- };
11548
- const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
11549
- if (label) {
11550
- return h7("div", { class: `not-prose ${wrapperClass}`.trim() }, [
11551
- h7("a", {
11552
- href: url,
11553
- target,
11554
- rel: "noopener noreferrer",
11555
- class: btnClass
11556
- }, [
11557
- h7(IconRenderer, { iconName: icon }),
11558
- label
11559
- ])
11560
- ]);
11561
- }
11562
- const slotContent = p.renderSlot("default");
11563
- const findLinks = (vnodes) => {
11564
- const links2 = [];
11565
- for (const vnode of vnodes) {
11566
- if (!vnode) continue;
11567
- if (typeof vnode.type === "string" && vnode.type === "a") {
11568
- links2.push(vnode);
11569
- }
11570
- if (vnode.children && Array.isArray(vnode.children)) {
11571
- links2.push(...findLinks(vnode.children));
11572
- }
11573
- }
11574
- return links2;
11575
- };
11576
- const links = findLinks(Array.isArray(slotContent) ? slotContent : [slotContent]);
11577
- if (links.length > 0) {
11578
- return h7("div", { class: `not-prose ${wrapperClass}`.trim() }, links.map((link, i) => {
11579
- const linkChildren = Array.isArray(link.children) ? link.children : link.children != null ? [link.children] : [];
11580
- return h7("a", {
11581
- key: i,
11582
- ...link.props || {},
11583
- class: `${link.props?.class || ""} ${btnClass}`.trim(),
11584
- target,
11585
- rel: "noopener noreferrer"
11586
- }, [
11587
- h7(IconRenderer, { iconName: icon }),
11588
- ...linkChildren
11589
- ]);
11590
- }));
11591
- }
11592
- return h7("div", { class: `not-prose ${wrapperClass}`.trim() }, [
11593
- h7("a", {
11594
- href: url,
11595
- target,
11596
- rel: "noopener noreferrer",
11597
- class: btnClass
11598
- }, [
11599
- h7(IconRenderer, { iconName: icon }),
11600
- slotContent
11601
- ])
11602
- ]);
11603
- };
11339
+ // vanilla/directives/button.ts
11340
+ var buttonDirective = ({ props, renderSlot }) => {
11341
+ const url = props.url || props.href || "#";
11342
+ const label = props.label;
11343
+ const icon = props.icon || "near_me";
11344
+ const target = props.target || "_blank";
11345
+ const customClass = props.class || "";
11346
+ const wrapper = document.createElement("div");
11347
+ wrapper.className = "nr-button-wrap";
11348
+ if (label) {
11349
+ const a = document.createElement("a");
11350
+ a.href = url;
11351
+ a.target = target;
11352
+ a.rel = "noopener noreferrer";
11353
+ a.className = "nr-button nr-button--default";
11354
+ if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
11355
+ a.appendChild(createIcon(icon));
11356
+ a.appendChild(document.createTextNode(label));
11357
+ wrapper.appendChild(a);
11358
+ return wrapper;
11604
11359
  }
11605
- });
11606
- var ButtonDirective_default = ButtonDirective;
11360
+ const slotContent = renderSlot("default");
11361
+ const links = slotContent.querySelectorAll("a");
11362
+ if (links.length > 0) {
11363
+ links.forEach((link) => {
11364
+ link.classList.add("nr-button", "nr-button--default");
11365
+ if (customClass) link.classList.add(...customClass.split(/\s+/).filter(Boolean));
11366
+ });
11367
+ wrapper.appendChild(slotContent);
11368
+ } else {
11369
+ const a = document.createElement("a");
11370
+ a.href = url;
11371
+ a.target = target;
11372
+ a.rel = "noopener noreferrer";
11373
+ a.className = "nr-button nr-button--default";
11374
+ if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
11375
+ a.appendChild(createIcon(icon));
11376
+ a.appendChild(slotContent);
11377
+ wrapper.appendChild(a);
11378
+ }
11379
+ return wrapper;
11380
+ };
11381
+ var button_default = buttonDirective;
11607
11382
 
11608
- // vue/directives/WrapperDirective.ts
11609
- import { defineComponent as defineComponent7, h as h8 } from "vue";
11610
- var WrapperDirective = defineComponent7({
11611
- name: "WrapperDirective",
11612
- props: {
11613
- directiveType: String,
11614
- props: Object,
11615
- slots: Object,
11616
- renderSlot: Function,
11617
- context: Object,
11618
- index: [String, Number],
11619
- allElements: Array,
11620
- options: Object
11621
- },
11622
- setup(props) {
11623
- return () => {
11624
- const p = props;
11625
- const className = p.props.class || "";
11626
- const id = p.props.id || "";
11627
- const inlineStyle = p.props.style ? parseCssString(p.props.style) : {};
11628
- const wrapperProps = {};
11629
- if (className) wrapperProps.class = className;
11630
- if (id) wrapperProps.id = id;
11631
- if (Object.keys(inlineStyle).length > 0) wrapperProps.style = inlineStyle;
11632
- for (const [key, value] of Object.entries(p.props)) {
11633
- if (key.startsWith("data-")) {
11634
- wrapperProps[key] = value;
11635
- }
11383
+ // vanilla/directives/card.ts
11384
+ var cardDirective = ({
11385
+ directiveType,
11386
+ props,
11387
+ slots,
11388
+ renderSlot,
11389
+ options
11390
+ }) => {
11391
+ const { title, image, icon, url, target } = props;
11392
+ const customClass = props.class || "";
11393
+ const hasDescription = !!slots.description;
11394
+ const { isSingleCard } = options || {};
11395
+ const isModal = directiveType === "card-m";
11396
+ const isLink = directiveType === "card-b";
11397
+ const inlineStyles = props.style ? parseCssString(props.style) : {};
11398
+ const card = document.createElement("div");
11399
+ card.className = `nr-card${isModal || isLink ? " nr-card--interactive" : ""} ${customClass}`.trim();
11400
+ for (const [key, value] of Object.entries(inlineStyles)) {
11401
+ card.style.setProperty(key, String(value));
11402
+ }
11403
+ if (image) {
11404
+ const imgWrap = document.createElement("div");
11405
+ imgWrap.className = `nr-card__image${isSingleCard ? " nr-card__image--tall" : ""}`;
11406
+ const img = document.createElement("img");
11407
+ img.src = image;
11408
+ img.alt = title || "";
11409
+ img.className = "nr-card__img";
11410
+ imgWrap.appendChild(img);
11411
+ const gradient = document.createElement("div");
11412
+ gradient.className = "nr-card__gradient";
11413
+ imgWrap.appendChild(gradient);
11414
+ card.appendChild(imgWrap);
11415
+ }
11416
+ const body = document.createElement("div");
11417
+ body.className = `nr-card__body${image ? " nr-card__body--overlap" : ""}`;
11418
+ if (icon || title) {
11419
+ const header = document.createElement("div");
11420
+ header.className = "nr-card__header";
11421
+ if (icon) {
11422
+ const iconWrap = document.createElement("div");
11423
+ iconWrap.className = "nr-card__icon-wrap";
11424
+ iconWrap.appendChild(createIcon(icon));
11425
+ header.appendChild(iconWrap);
11426
+ }
11427
+ if (title) {
11428
+ const h32 = document.createElement("h3");
11429
+ h32.className = "nr-card__title";
11430
+ h32.textContent = title;
11431
+ header.appendChild(h32);
11432
+ }
11433
+ body.appendChild(header);
11434
+ }
11435
+ if (hasDescription) {
11436
+ const desc = document.createElement("div");
11437
+ desc.className = "nr-card__description";
11438
+ desc.appendChild(renderSlot("description"));
11439
+ body.appendChild(desc);
11440
+ }
11441
+ if (directiveType === "card") {
11442
+ const contentSlot = renderSlot("content") || renderSlot("default");
11443
+ if (contentSlot.childNodes.length > 0) {
11444
+ const contentDiv = document.createElement("div");
11445
+ contentDiv.className = "nr-card__content";
11446
+ contentDiv.appendChild(contentSlot);
11447
+ body.appendChild(contentDiv);
11448
+ }
11449
+ }
11450
+ if (isModal || isLink) {
11451
+ const action = document.createElement("div");
11452
+ action.className = "nr-card__action";
11453
+ if (isLink && url) {
11454
+ const a = document.createElement("a");
11455
+ a.href = url;
11456
+ a.target = target || "_blank";
11457
+ a.rel = "noopener noreferrer";
11458
+ a.className = "nr-card__action-link";
11459
+ a.appendChild(createIcon("open_in_new"));
11460
+ a.appendChild(document.createTextNode(" Link"));
11461
+ action.appendChild(a);
11462
+ } else if (isModal) {
11463
+ const modalBtn = document.createElement("div");
11464
+ modalBtn.className = "nr-card__action-link";
11465
+ modalBtn.appendChild(createIcon("arrow_forward"));
11466
+ modalBtn.appendChild(document.createTextNode(" Abrir"));
11467
+ action.appendChild(modalBtn);
11468
+ }
11469
+ body.appendChild(action);
11470
+ }
11471
+ card.appendChild(body);
11472
+ if (isModal) {
11473
+ const dialog = createModal(title || "Detalles");
11474
+ const modalBody = dialog.querySelector(".nr-modal__body");
11475
+ if (modalBody) {
11476
+ const prose = document.createElement("div");
11477
+ prose.className = "nr-prose";
11478
+ prose.appendChild(renderSlot("content") || renderSlot("default"));
11479
+ modalBody.appendChild(prose);
11480
+ }
11481
+ card.addEventListener("click", () => {
11482
+ if (!dialog.open) {
11483
+ document.body.appendChild(dialog);
11484
+ dialog.showModal();
11485
+ dialog.addEventListener("close", () => dialog.remove(), { once: true });
11636
11486
  }
11637
- return h8("div", wrapperProps, p.renderSlot("default"));
11638
- };
11487
+ });
11488
+ const frag = document.createDocumentFragment();
11489
+ frag.appendChild(card);
11490
+ frag.appendChild(dialog);
11491
+ return frag;
11639
11492
  }
11640
- });
11641
- var WrapperDirective_default = WrapperDirective;
11493
+ if (isLink && url) {
11494
+ card.addEventListener("click", () => window.open(url, target || "_blank"));
11495
+ }
11496
+ return card;
11497
+ };
11498
+ var card_default = cardDirective;
11642
11499
 
11643
- // vue/directives/SlideDirective.ts
11644
- import { defineComponent as defineComponent8, h as h9, ref as ref3, onMounted, onUnmounted, nextTick } from "vue";
11500
+ // vanilla/directives/wrapper.ts
11501
+ var wrapperDirective = ({ props, renderSlot }) => {
11502
+ const el = document.createElement("div");
11503
+ el.className = "nr-wrapper";
11504
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
11505
+ if (props.id) el.id = props.id;
11506
+ if (props.style) {
11507
+ const styles = parseCssString(props.style);
11508
+ for (const [key, value] of Object.entries(styles)) {
11509
+ el.style.setProperty(key, String(value));
11510
+ }
11511
+ }
11512
+ for (const [key, value] of Object.entries(props)) {
11513
+ if (key.startsWith("data-")) {
11514
+ el.setAttribute(key, value);
11515
+ }
11516
+ }
11517
+ el.appendChild(renderSlot("default"));
11518
+ return el;
11519
+ };
11520
+ var wrapper_default = wrapperDirective;
11521
+
11522
+ // vanilla/directives/slide.ts
11645
11523
  var slideCounter = 0;
11646
- var SlideDirective = defineComponent8({
11647
- name: "SlideDirective",
11648
- props: {
11649
- directiveType: String,
11650
- props: Object,
11651
- slots: Object,
11652
- renderSlot: Function,
11653
- context: Object,
11654
- index: [String, Number],
11655
- allElements: Array,
11656
- options: Object
11657
- },
11658
- setup(props) {
11659
- const current = ref3(0);
11660
- const maxH = ref3(0);
11661
- let intervalId = null;
11662
- let slideEls = [];
11663
- const measureAndSetHeight = () => {
11664
- let h14 = 0;
11524
+ var slideDirective = ({
11525
+ props,
11526
+ slots,
11527
+ renderInline: renderInline2,
11528
+ renderMarkdown
11529
+ }) => {
11530
+ const rawContent = slots.default || "";
11531
+ const lines = rawContent.split("\n").map((l) => l.trim()).filter(Boolean);
11532
+ if (lines.length === 0) {
11533
+ return document.createDocumentFragment();
11534
+ }
11535
+ const interval = parseInt(props.interval || "3000", 10);
11536
+ const speed = parseInt(props.speed || "500", 10);
11537
+ const rawClass = props.class || "";
11538
+ const inlineStyle = props.style ? parseCssString(props.style) : {};
11539
+ const scopeClass = `sld-${++slideCounter}`;
11540
+ const container = document.createElement("div");
11541
+ container.className = "nr-slide";
11542
+ Object.assign(container.style, {
11543
+ position: "relative",
11544
+ overflow: "hidden",
11545
+ ...inlineStyle
11546
+ });
11547
+ const track = document.createElement("div");
11548
+ track.className = "nr-slide__track";
11549
+ track.style.transition = `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`;
11550
+ const slideEls = [];
11551
+ for (const line of lines) {
11552
+ const slideEl = document.createElement("div");
11553
+ slideEl.className = `nr-slide__item ${scopeClass} ${rawClass}`.trim();
11554
+ slideEl.style.display = "flex";
11555
+ slideEl.style.alignItems = "center";
11556
+ if (renderMarkdown) {
11557
+ const tokens = renderMarkdown(line);
11558
+ slideEl.appendChild(tokens);
11559
+ } else if (renderInline2) {
11560
+ slideEl.appendChild(renderInline2(line));
11561
+ }
11562
+ track.appendChild(slideEl);
11563
+ slideEls.push(slideEl);
11564
+ }
11565
+ container.appendChild(track);
11566
+ let current = 0;
11567
+ let maxH = 0;
11568
+ const measureAndSetHeight = () => {
11569
+ maxH = 0;
11570
+ for (const el of slideEls) {
11571
+ maxH = Math.max(maxH, el.offsetHeight);
11572
+ }
11573
+ if (maxH > 0) {
11574
+ container.style.height = `${maxH}px`;
11665
11575
  for (const el of slideEls) {
11666
- h14 = Math.max(h14, el.offsetHeight);
11576
+ el.style.height = `${maxH}px`;
11667
11577
  }
11668
- if (h14 > 0) maxH.value = h14;
11669
- };
11670
- onMounted(() => {
11671
- nextTick(() => {
11672
- measureAndSetHeight();
11673
- if (document.fonts?.ready) {
11674
- document.fonts.ready.then(measureAndSetHeight);
11675
- }
11676
- });
11677
- });
11678
- onUnmounted(() => {
11679
- if (intervalId) clearInterval(intervalId);
11680
- });
11681
- return () => {
11682
- const p = props;
11683
- const ctx = p.context;
11684
- const rawContent = p.slots.default || "";
11685
- const lines = rawContent.split("\n").map((l) => l.trim()).filter(Boolean);
11686
- if (lines.length === 0) return h9("div");
11687
- const elements = lines.map((line) => ctx.parseMarkdown(line));
11688
- const interval = parseInt(p.props.interval || "3000", 10);
11689
- const speed = parseInt(p.props.speed || "500", 10);
11690
- const rawClass = p.props.class || "";
11691
- const inlineStyle = p.props.style ? parseCssString(p.props.style) : {};
11692
- const scopeClass = `sld-${++slideCounter}`;
11693
- if (lines.length > 1 && !intervalId) {
11694
- intervalId = setInterval(() => {
11695
- current.value = (current.value + 1) % elements.length;
11696
- }, interval);
11697
- }
11698
- const textSizeMap = {
11699
- "text-xs": "0.75rem",
11700
- "text-sm": "0.875rem",
11701
- "text-base": "1rem",
11702
- "text-lg": "1.125rem",
11703
- "text-xl": "1.25rem",
11704
- "text-2xl": "1.5rem",
11705
- "text-3xl": "1.875rem",
11706
- "text-4xl": "2.25rem",
11707
- "text-5xl": "3rem",
11708
- "text-6xl": "3.75rem",
11709
- "text-7xl": "4.5rem",
11710
- "text-8xl": "6rem",
11711
- "text-9xl": "8rem"
11712
- };
11713
- const textSizeMatch = rawClass.match(/\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/);
11714
- const forcedFontSize = textSizeMatch ? textSizeMap[textSizeMatch[0]] : null;
11715
- const className = textSizeMatch ? rawClass.replace(textSizeMatch[0], "").replace(/\s+/g, " ").trim() : rawClass;
11716
- return h9("div", {
11717
- class: "not-prose",
11718
- style: { height: maxH.value || "auto", position: "relative", overflow: "hidden", ...inlineStyle }
11719
- }, [
11720
- forcedFontSize && h9("style", `.${scopeClass} * { font-size: ${forcedFontSize} !important; line-height: normal !important; }`),
11721
- h9("div", {
11722
- style: {
11723
- position: "absolute",
11724
- left: 0,
11725
- right: 0,
11726
- top: 0,
11727
- transition: `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`,
11728
- transform: `translateY(${-current.value * maxH.value}px)`
11729
- }
11730
- }, elements.map(
11731
- (tokens, i) => h9("div", {
11732
- key: i,
11733
- ref: (el) => {
11734
- slideEls[i] = el?.$el || el;
11735
- },
11736
- style: maxH.value ? { height: maxH.value, display: "flex", alignItems: "center", overflow: "hidden" } : { display: "flex", alignItems: "center" }
11737
- }, [
11738
- h9("div", {
11739
- class: `${scopeClass} ${className}`.trim(),
11740
- style: { width: "100%" }
11741
- }, ctx.processAndRenderElements(tokens))
11742
- ])
11743
- ))
11744
- ]);
11745
- };
11578
+ }
11579
+ };
11580
+ requestAnimationFrame(() => {
11581
+ measureAndSetHeight();
11582
+ if (document.fonts?.ready) {
11583
+ document.fonts.ready.then(measureAndSetHeight);
11584
+ }
11585
+ });
11586
+ if (lines.length > 1) {
11587
+ setInterval(() => {
11588
+ current = (current + 1) % lines.length;
11589
+ track.style.transform = `translateY(${-current * maxH}px)`;
11590
+ }, interval);
11746
11591
  }
11747
- });
11748
- var SlideDirective_default = SlideDirective;
11592
+ return container;
11593
+ };
11594
+ var slide_default = slideDirective;
11749
11595
 
11750
- // vue/directives/index.ts
11596
+ // vanilla/directives/index.ts
11751
11597
  var directiveRegistry = {
11752
11598
  // Admonitions
11753
- note: AdmonitionDirective_default,
11754
- info: AdmonitionDirective_default,
11755
- warning: AdmonitionDirective_default,
11756
- danger: AdmonitionDirective_default,
11757
- greentext: AdmonitionDirective_default,
11599
+ note: admonition_default,
11600
+ info: admonition_default,
11601
+ warning: admonition_default,
11602
+ danger: admonition_default,
11603
+ greentext: admonition_default,
11758
11604
  // Cards
11759
- card: CardDirective_default,
11760
- "card-m": CardDirective_default,
11761
- "card-b": CardDirective_default,
11605
+ card: card_default,
11606
+ "card-m": card_default,
11607
+ "card-b": card_default,
11762
11608
  // Interactive
11763
- details: DetailsDirective_default,
11764
- modal: ModalDirective_default,
11765
- button: ButtonDirective_default,
11609
+ details: details_default,
11610
+ modal: modal_default,
11611
+ button: button_default,
11766
11612
  // Layout / generic wrappers
11767
- div: WrapperDirective_default,
11768
- style: WrapperDirective_default,
11769
- custom: WrapperDirective_default,
11770
- raw: WrapperDirective_default,
11613
+ div: wrapper_default,
11614
+ style: wrapper_default,
11615
+ custom: wrapper_default,
11616
+ raw: wrapper_default,
11771
11617
  // Animation
11772
- slide: SlideDirective_default
11618
+ slide: slide_default
11773
11619
  };
11774
11620
  var directives_default = directiveRegistry;
11775
11621
 
11776
- // vue/DirectiveRenderer.ts
11777
- var DirectiveRenderer = defineComponent9({
11778
- name: "DirectiveRenderer",
11779
- props: {
11780
- element: { type: Object, required: true },
11781
- context: { type: Object, required: true },
11782
- index: { type: Number, required: true },
11783
- allElements: { type: Array, required: true }
11784
- },
11785
- setup(props) {
11786
- return () => {
11787
- const { element, context, index, allElements } = props;
11788
- const { directiveType, props: directiveProps, slots, scopeId } = element;
11789
- const Component = directives_default[directiveType];
11790
- const renderSlot = (name) => {
11791
- const slotContent = slots[name];
11792
- if (!slotContent) return [];
11793
- const parsed = context.parseMarkdown(slotContent);
11794
- return context.processAndRenderElements(parsed);
11795
- };
11796
- const componentProps = {
11797
- directiveType,
11798
- props: directiveProps,
11799
- slots,
11800
- renderSlot,
11801
- context,
11802
- index,
11803
- allElements
11804
- };
11805
- if (Component) {
11806
- return h10(Component, componentProps);
11622
+ // vanilla/renderer.ts
11623
+ function renderTokens(tokens) {
11624
+ const article = document.createElement("article");
11625
+ article.className = "nr-prose";
11626
+ const ctx = {
11627
+ parseMarkdown,
11628
+ renderElements: (tks) => renderTokensInner(tks, ctx),
11629
+ renderInline,
11630
+ renderMarkdown: (md) => renderTokensInner(parseMarkdown(md), ctx)
11631
+ };
11632
+ article.appendChild(processElements(tokens, ctx, tokens));
11633
+ return article;
11634
+ }
11635
+ function renderMarkdownString(markdown2) {
11636
+ const tokens = parseMarkdown(markdown2);
11637
+ return renderTokens(tokens);
11638
+ }
11639
+ function renderHtmlString(html) {
11640
+ let processedContent = html;
11641
+ processedContent = processedContent.replace(
11642
+ /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
11643
+ (_match, cssContent) => {
11644
+ const styleEl = document.createElement("style");
11645
+ styleEl.setAttribute("data-nr-global", "");
11646
+ styleEl.textContent = cssContent;
11647
+ document.head.appendChild(styleEl);
11648
+ return "";
11649
+ }
11650
+ );
11651
+ const wrapper = document.createElement("div");
11652
+ wrapper.className = "nr-raw-html";
11653
+ wrapper.innerHTML = processedContent;
11654
+ const scripts = wrapper.querySelectorAll("script");
11655
+ scripts.forEach((oldScript) => {
11656
+ const newScript = document.createElement("script");
11657
+ Array.from(oldScript.attributes).forEach(
11658
+ (attr) => newScript.setAttribute(attr.name, attr.value)
11659
+ );
11660
+ newScript.textContent = oldScript.textContent;
11661
+ oldScript.parentNode?.replaceChild(newScript, oldScript);
11662
+ });
11663
+ return wrapper;
11664
+ }
11665
+ function renderTokensInner(tokens, ctx) {
11666
+ const container = document.createElement("div");
11667
+ container.appendChild(processElements(tokens, ctx, tokens));
11668
+ return container;
11669
+ }
11670
+ function processElements(elements, ctx, allElements) {
11671
+ const fragment = document.createDocumentFragment();
11672
+ let i = 0;
11673
+ while (i < elements.length) {
11674
+ const el = elements[i];
11675
+ if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
11676
+ const cards = [];
11677
+ while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
11678
+ cards.push(elements[i]);
11679
+ i++;
11807
11680
  }
11808
- return h10("div", {
11809
- key: index,
11810
- class: "my-4 p-4 rounded-2xl border border-border bg-background-primary/5"
11811
- }, renderSlot("default"));
11812
- };
11681
+ if (cards.length === 1 || cards[0].props?.batch === "off") {
11682
+ for (const card of cards) {
11683
+ const rendered = renderElement(card, ctx, allElements);
11684
+ if (rendered) fragment.appendChild(rendered);
11685
+ }
11686
+ } else {
11687
+ const grid = document.createElement("div");
11688
+ grid.className = "nr-card-grid";
11689
+ for (const card of cards) {
11690
+ const rendered = renderElement(card, ctx, allElements);
11691
+ if (rendered) grid.appendChild(rendered);
11692
+ }
11693
+ fragment.appendChild(grid);
11694
+ }
11695
+ } else {
11696
+ const rendered = renderElement(el, ctx, allElements);
11697
+ if (rendered) fragment.appendChild(rendered);
11698
+ i++;
11699
+ }
11813
11700
  }
11814
- });
11815
- var DirectiveRenderer_default = DirectiveRenderer;
11701
+ return fragment;
11702
+ }
11703
+ function renderElement(element, ctx, allElements) {
11704
+ switch (element.type) {
11705
+ case "header": {
11706
+ const tag = `h${element.level}`;
11707
+ let text = element.text;
11708
+ const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
11709
+ const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
11710
+ if (alignCenter) text = alignCenter[1];
11711
+ else if (alignRight) text = alignRight[1];
11712
+ const h4 = document.createElement(tag);
11713
+ h4.id = element.id;
11714
+ let cls = `md-h${element.level}`;
11715
+ if (alignCenter) cls += " text-center";
11716
+ if (alignRight) cls += " text-right";
11717
+ if (element.classes) cls += ` ${element.classes}`;
11718
+ h4.className = cls;
11719
+ h4.appendChild(renderInline(text));
11720
+ return h4;
11721
+ }
11722
+ case "paragraph": {
11723
+ const p = document.createElement("p");
11724
+ let cls = "md-p";
11725
+ if (element.classes) cls += ` ${element.classes}`;
11726
+ if (element.align) cls += ` text-${element.align}`;
11727
+ p.className = cls;
11728
+ if (element.id) p.id = element.id;
11729
+ const lines = element.content.split("\n");
11730
+ for (let li = 0; li < lines.length; li++) {
11731
+ const line = lines[li];
11732
+ const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
11733
+ if (hardBreakMatch) {
11734
+ p.appendChild(renderInline(hardBreakMatch[1]));
11735
+ p.appendChild(document.createElement("br"));
11736
+ } else {
11737
+ p.appendChild(renderInline(line));
11738
+ if (li < lines.length - 1) {
11739
+ p.appendChild(document.createTextNode(" "));
11740
+ }
11741
+ }
11742
+ }
11743
+ return p;
11744
+ }
11745
+ case "codeblock":
11746
+ return createCodeBlock(element.content, element.language, element.title);
11747
+ case "directive":
11748
+ return renderDirective(element, ctx, allElements);
11749
+ case "html": {
11750
+ const el = element;
11751
+ return renderHtmlString(el.content);
11752
+ }
11753
+ case "html-block": {
11754
+ const htmlBlock = element;
11755
+ const rawProps = parseHtmlAttrs(htmlBlock.attrs);
11756
+ const el = document.createElement(htmlBlock.tag);
11757
+ for (const [key, value] of Object.entries(rawProps)) {
11758
+ if (key === "style" && typeof value === "object") {
11759
+ for (const [prop, val] of Object.entries(value)) {
11760
+ el.style.setProperty(prop, String(val));
11761
+ }
11762
+ } else if (value === true) {
11763
+ el.setAttribute(key, "");
11764
+ } else {
11765
+ el.setAttribute(key, String(value));
11766
+ }
11767
+ }
11768
+ const childFrag = processElements(htmlBlock.children, ctx, allElements);
11769
+ el.appendChild(childFrag);
11770
+ return el;
11771
+ }
11772
+ case "image": {
11773
+ const img = document.createElement("img");
11774
+ img.src = element.src;
11775
+ img.alt = element.alt;
11776
+ img.className = "nr-image";
11777
+ if (element.style) {
11778
+ for (const [key, value] of Object.entries(element.style)) {
11779
+ img.style.setProperty(key, String(value));
11780
+ }
11781
+ }
11782
+ return img;
11783
+ }
11784
+ case "table":
11785
+ return createTable(element.content, renderInline);
11786
+ case "list":
11787
+ return createList(element.content, renderInline);
11788
+ case "blockquote":
11789
+ return createBlockquote(element.content, element.classes, renderInline);
11790
+ case "hr": {
11791
+ const hr = document.createElement("hr");
11792
+ hr.className = "nr-hr";
11793
+ return hr;
11794
+ }
11795
+ case "toc": {
11796
+ const headers = allElements.filter((e) => e.type === "header");
11797
+ return createTOC(headers.map((h4) => ({ level: h4.level, text: h4.text, id: h4.id })), renderInline);
11798
+ }
11799
+ default:
11800
+ return null;
11801
+ }
11802
+ }
11803
+ function renderDirective(element, ctx, allElements) {
11804
+ const { directiveType, props, slots, scopeId } = element;
11805
+ const renderer = directives_default[directiveType];
11806
+ const renderSlot = (name) => {
11807
+ const frag = document.createDocumentFragment();
11808
+ const slotContent = slots[name];
11809
+ if (!slotContent) return frag;
11810
+ const tokens = ctx.parseMarkdown(slotContent);
11811
+ frag.appendChild(ctx.renderElements(tokens));
11812
+ return frag;
11813
+ };
11814
+ const directiveProps = {
11815
+ directiveType,
11816
+ props,
11817
+ slots,
11818
+ renderSlot,
11819
+ context: ctx,
11820
+ index: 0,
11821
+ allElements,
11822
+ renderInline,
11823
+ renderMarkdown: ctx.renderMarkdown
11824
+ };
11825
+ if (renderer) {
11826
+ return renderer(directiveProps);
11827
+ }
11828
+ const fallback = document.createElement("div");
11829
+ fallback.className = "nr-unknown-directive";
11830
+ fallback.appendChild(renderSlot("default"));
11831
+ return fallback;
11832
+ }
11816
11833
 
11817
- // vue/RawHtmlRenderer.ts
11818
- import { defineComponent as defineComponent10, h as h11, ref as ref4, onMounted as onMounted3 } from "vue";
11834
+ // vue/useTailwindCDN.ts
11835
+ import { onMounted, onUnmounted, watch } from "vue";
11836
+
11837
+ // vanilla/tailwindTheme.ts
11838
+ var THEME_STYLE_ID = "nr-tailwind-theme";
11839
+ var NR_THEME_CSS = `
11840
+ @theme {
11841
+ --color-primary: var(--color-accent-primary, oklch(var(--p, 55% 0.3 240) / 1));
11842
+ --color-primary-content: #ffffff;
11843
+ --color-secondary: oklch(var(--s, 55% 0.25 200) / 1);
11844
+ --color-secondary-content: #ffffff;
11845
+ --color-accent: var(--color-accent-primary, oklch(var(--a, 65% 0.25 160) / 1));
11846
+ --color-accent-content: #ffffff;
11847
+ --color-neutral: oklch(var(--n, 50% 0.05 240) / 1);
11848
+ --color-neutral-content: var(--color-text-primary, oklch(var(--nc, 92% 0.02 240) / 1));
11849
+ --color-base-100: var(--color-background-primary, oklch(var(--b1, 15% 0.01 260) / 1));
11850
+ --color-base-200: var(--color-background-secondary-solid, oklch(var(--b2, 20% 0.02 260) / 1));
11851
+ --color-base-300: var(--color-border, oklch(var(--b3, 25% 0.03 260) / 1));
11852
+ --color-base-content: var(--color-text-primary, oklch(var(--bc, 92% 0.02 260) / 1));
11853
+ --color-info: oklch(var(--in, 70% 0.2 220) / 1);
11854
+ --color-info-content: #ffffff;
11855
+ --color-success: oklch(var(--su, 65% 0.25 140) / 1);
11856
+ --color-success-content: #ffffff;
11857
+ --color-warning: oklch(var(--wa, 80% 0.25 80) / 1);
11858
+ --color-warning-content: #1f2937;
11859
+ --color-error: oklch(var(--er, 65% 0.3 30) / 1);
11860
+ --color-error-content: #ffffff;
11861
+ }
11862
+ `;
11863
+ function getVar(root, name) {
11864
+ return getComputedStyle(root).getPropertyValue(name).trim();
11865
+ }
11866
+ function stylesheetHasTheme() {
11867
+ for (const sheet of Array.from(document.styleSheets)) {
11868
+ let rules = null;
11869
+ try {
11870
+ rules = sheet.cssRules;
11871
+ } catch {
11872
+ continue;
11873
+ }
11874
+ if (!rules) continue;
11875
+ for (const rule of Array.from(rules)) {
11876
+ const css2 = rule.cssText || "";
11877
+ if (css2.includes("@theme") || css2.includes('@plugin "daisyui"')) return true;
11878
+ }
11879
+ }
11880
+ return false;
11881
+ }
11882
+ function hasHostTheme() {
11883
+ if (typeof window === "undefined" || typeof document === "undefined") return true;
11884
+ if (getVar(document.documentElement, "--color-primary")) return true;
11885
+ if (getVar(document.documentElement, "--color-base-100")) return true;
11886
+ if (document.body && (getVar(document.body, "--color-primary") || getVar(document.body, "--color-base-100"))) return true;
11887
+ return stylesheetHasTheme();
11888
+ }
11889
+ function injectNRTailwindTheme() {
11890
+ if (typeof document === "undefined") return;
11891
+ if (document.getElementById(THEME_STYLE_ID)) return;
11892
+ if (hasHostTheme()) return;
11893
+ const style = document.createElement("style");
11894
+ style.id = THEME_STYLE_ID;
11895
+ style.setAttribute("type", "text/tailwindcss");
11896
+ style.textContent = NR_THEME_CSS;
11897
+ document.head.appendChild(style);
11898
+ }
11899
+ function removeNRTailwindTheme() {
11900
+ if (typeof document === "undefined") return;
11901
+ document.getElementById(THEME_STYLE_ID)?.remove();
11902
+ }
11819
11903
 
11820
11904
  // vue/useTailwindCDN.ts
11821
- import { onMounted as onMounted2, onUnmounted as onUnmounted2, watch } from "vue";
11822
11905
  var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
11823
11906
  var SCRIPT_ID = "tailwind-cdn-v4-runtime";
11824
11907
  var CONFIG_ID = "tailwind-cdn-v4-config";
@@ -11841,6 +11924,7 @@ function useLazyTailwindCDN(enabled) {
11841
11924
  configScript.textContent = TAILWIND_CDN_CONFIG;
11842
11925
  document.head.appendChild(configScript);
11843
11926
  }
11927
+ injectNRTailwindTheme();
11844
11928
  if (!document.getElementById(SCRIPT_ID)) {
11845
11929
  const script = document.createElement("script");
11846
11930
  script.id = SCRIPT_ID;
@@ -11854,14 +11938,15 @@ function useLazyTailwindCDN(enabled) {
11854
11938
  if ((window.__twCDNRefs ?? 0) <= 0) {
11855
11939
  document.getElementById(SCRIPT_ID)?.remove();
11856
11940
  document.getElementById(CONFIG_ID)?.remove();
11941
+ removeNRTailwindTheme();
11857
11942
  window.__twCDNRefs = 0;
11858
11943
  }
11859
11944
  };
11860
11945
  if (typeof enabled === "boolean") {
11861
- onMounted2(() => {
11946
+ onMounted(() => {
11862
11947
  if (enabled) injectCDN();
11863
11948
  });
11864
- onUnmounted2(() => {
11949
+ onUnmounted(() => {
11865
11950
  if (enabled) removeCDN();
11866
11951
  });
11867
11952
  } else {
@@ -11869,7 +11954,7 @@ function useLazyTailwindCDN(enabled) {
11869
11954
  if (newVal && !oldVal) injectCDN();
11870
11955
  if (!newVal && oldVal) removeCDN();
11871
11956
  }, { immediate: true });
11872
- onUnmounted2(() => {
11957
+ onUnmounted(() => {
11873
11958
  if (enabled.value) removeCDN();
11874
11959
  });
11875
11960
  }
@@ -11882,7 +11967,7 @@ function scanTailwindCDN() {
11882
11967
  function preloadTailwindCDN() {
11883
11968
  if (typeof window === "undefined" || typeof document === "undefined") return;
11884
11969
  if (document.getElementById(SCRIPT_ID)) return;
11885
- const inject2 = () => {
11970
+ const inject = () => {
11886
11971
  if (document.getElementById(SCRIPT_ID)) return;
11887
11972
  if (!document.getElementById(CONFIG_ID)) {
11888
11973
  const configScript = document.createElement("script");
@@ -11890,6 +11975,7 @@ function preloadTailwindCDN() {
11890
11975
  configScript.textContent = TAILWIND_CDN_CONFIG;
11891
11976
  document.head.appendChild(configScript);
11892
11977
  }
11978
+ injectNRTailwindTheme();
11893
11979
  const script = document.createElement("script");
11894
11980
  script.id = SCRIPT_ID;
11895
11981
  script.src = CDN_URL;
@@ -11897,267 +11983,76 @@ function preloadTailwindCDN() {
11897
11983
  window.__twCDNRefs = (window.__twCDNRefs ?? 0) + 1;
11898
11984
  };
11899
11985
  if ("requestIdleCallback" in window) {
11900
- window.requestIdleCallback(inject2, { timeout: 2e3 });
11986
+ window.requestIdleCallback(inject, { timeout: 2e3 });
11901
11987
  } else {
11902
- setTimeout(inject2, 200);
11988
+ setTimeout(inject, 200);
11903
11989
  }
11904
11990
  }
11905
11991
 
11906
- // vue/RawHtmlRenderer.ts
11907
- var RawHtmlRenderer = defineComponent10({
11908
- name: "RawHtmlRenderer",
11909
- props: {
11910
- content: { type: String, required: true },
11911
- globalStyles: { type: String, default: void 0 },
11912
- wrapperClassName: { type: String, required: true }
11913
- },
11914
- setup(props) {
11915
- const containerRef = ref4(null);
11916
- onMounted3(() => {
11917
- if (!containerRef.value) return;
11918
- const scripts = containerRef.value.querySelectorAll("script");
11919
- scripts.forEach((oldScript) => {
11920
- const newScript = document.createElement("script");
11921
- Array.from(oldScript.attributes).forEach(
11922
- (attr) => newScript.setAttribute(attr.name, attr.value)
11923
- );
11924
- newScript.textContent = oldScript.textContent;
11925
- oldScript.parentNode?.replaceChild(newScript, oldScript);
11926
- });
11927
- scanTailwindCDN();
11928
- });
11929
- return () => {
11930
- const children = [
11931
- h11("div", { innerHTML: props.content })
11932
- ];
11933
- return h11("div", { ref: containerRef, class: props.wrapperClassName }, children);
11934
- };
11935
- }
11936
- });
11937
- var RawHtmlRenderer_default = RawHtmlRenderer;
11938
-
11939
11992
  // vue/CustomMarkdownRenderer.ts
11940
- var CustomMarkdownRenderer = defineComponent11({
11993
+ var CustomMarkdownRenderer = defineComponent({
11941
11994
  name: "CustomMarkdownRenderer",
11942
11995
  props: {
11943
11996
  content: { type: String, required: true }
11944
11997
  },
11945
11998
  setup(props) {
11946
- const modals = ref5({});
11947
- const baseId = Math.random().toString(36).slice(2, 9);
11948
- const articleClass = `scope-${baseId}`;
11949
- resetScopeCounter();
11950
- const allElements = computed(() => parseMarkdown(props.content));
11951
- const handleHashChange = () => {
11952
- const hash = window.location.hash;
11953
- if (hash) {
11954
- const parts = hash.split("#");
11955
- const id = parts[parts.length - 1];
11956
- scrollToId(id);
11957
- }
11999
+ const container = ref(null);
12000
+ const render = () => {
12001
+ const el = container.value;
12002
+ if (!el) return;
12003
+ el.replaceChildren();
12004
+ el.appendChild(renderMarkdownString(props.content));
12005
+ scanTailwindCDN();
11958
12006
  };
11959
- onMounted4(() => {
12007
+ let cleanupHash = null;
12008
+ onMounted2(() => {
12009
+ render();
12010
+ const handleHashChange = () => {
12011
+ const hash = window.location.hash;
12012
+ if (hash) {
12013
+ const parts = hash.split("#");
12014
+ scrollToId(parts[parts.length - 1]);
12015
+ }
12016
+ };
11960
12017
  handleHashChange();
11961
12018
  window.addEventListener("hashchange", handleHashChange);
12019
+ cleanupHash = () => window.removeEventListener("hashchange", handleHashChange);
11962
12020
  });
11963
- onUnmounted3(() => {
11964
- window.removeEventListener("hashchange", handleHashChange);
12021
+ watch2(() => props.content, render);
12022
+ onUnmounted2(() => {
12023
+ cleanupHash?.();
11965
12024
  });
11966
- const generateToc = (elements) => {
11967
- const headers = extractHeaders(elements);
11968
- if (headers.length === 0) return null;
11969
- return h12("nav", { class: "not-prose my-6 p-4 rounded-2xl border border-border bg-background-primary/5" }, [
11970
- h12("div", { class: "text-base font-bold mb-3" }, "Table of Contents"),
11971
- h12("ul", { class: "space-y-1 list-none p-0 m-0" }, headers.map((h_token, i) => {
11972
- if (h_token.type !== "header") return null;
11973
- const indentClass = h_token.level <= 2 ? "pl-0" : h_token.level === 3 ? "pl-4" : h_token.level === 4 ? "pl-8" : "pl-12";
11974
- return h12("li", { key: i, class: `${indentClass} text-sm sm:text-base` }, [
11975
- h12("a", {
11976
- href: `#${h_token.id}`,
11977
- class: "text-accent-primary hover:text-accent-primary/80 no-underline hover:underline transition-colors",
11978
- onClick: (e) => {
11979
- e.preventDefault();
11980
- scrollToId(h_token.id);
11981
- }
11982
- }, renderInline(h_token.text.replace(/->|<-/g, "").trim()))
11983
- ]);
11984
- }))
11985
- ]);
11986
- };
11987
- const renderElement = (element, index, _depth = 0) => {
11988
- switch (element.type) {
11989
- case "header": {
11990
- const tag = `h${element.level}`;
11991
- let text = element.text;
11992
- const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
11993
- const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
11994
- if (alignCenter) text = alignCenter[1];
11995
- else if (alignRight) text = alignRight[1];
11996
- const userClasses = element.classes || "";
11997
- let headerClasses = `md-h${element.level}`;
11998
- if (alignCenter) headerClasses += " text-center";
11999
- if (alignRight) headerClasses += " text-right";
12000
- if (userClasses) headerClasses += ` ${userClasses}`;
12001
- return h12(tag, { key: index, id: element.id, class: headerClasses }, renderInline(text));
12002
- }
12003
- case "paragraph": {
12004
- const lines = element.content.split("\n");
12005
- const processedContent = lines.map((line, lineIndex) => {
12006
- const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
12007
- if (hardBreakMatch) {
12008
- return h12("span", { key: lineIndex }, [
12009
- renderInline(hardBreakMatch[1]),
12010
- h12("br")
12011
- ]);
12012
- }
12013
- const isLastLine = lineIndex === lines.length - 1;
12014
- return h12("span", { key: lineIndex }, [
12015
- renderInline(line),
12016
- !isLastLine && " "
12017
- ]);
12018
- });
12019
- const pUserClasses = element.classes || "";
12020
- let pClasses = "md-p";
12021
- if (pUserClasses) pClasses += ` ${pUserClasses}`;
12022
- if (element.align) pClasses += ` text-${element.align}`;
12023
- return h12("p", { key: index, id: element.id, class: pClasses }, processedContent);
12024
- }
12025
- case "codeblock":
12026
- return h12(CodeBlock, {
12027
- key: index,
12028
- code: element.content,
12029
- language: element.language,
12030
- title: element.title
12031
- });
12032
- case "directive":
12033
- return h12(DirectiveRenderer_default, {
12034
- key: index,
12035
- element,
12036
- context: contextForDirectives,
12037
- index,
12038
- allElements: allElements.value
12039
- });
12040
- case "html": {
12041
- let processedContent = element.content;
12042
- let globalStyles = "";
12043
- processedContent = processedContent.replace(
12044
- /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
12045
- (_match, cssContent) => {
12046
- globalStyles += cssContent + "\n";
12047
- return "";
12048
- }
12049
- );
12050
- return h12(RawHtmlRenderer_default, {
12051
- key: index,
12052
- content: processedContent,
12053
- globalStyles: globalStyles || void 0,
12054
- wrapperClassName: "w-full my-4"
12055
- });
12056
- }
12057
- case "html-block": {
12058
- const htmlBlock = element;
12059
- const rawProps = parseHtmlAttrs(htmlBlock.attrs);
12060
- const props2 = {};
12061
- for (const [key, value] of Object.entries(rawProps)) {
12062
- if (key === "class") props2["class"] = value;
12063
- else props2[key] = value;
12064
- }
12065
- return h12(
12066
- htmlBlock.tag,
12067
- { key: index, ...props2 },
12068
- processAndRenderElements(htmlBlock.children, _depth + 1)
12069
- );
12070
- }
12071
- case "image":
12072
- return h12("img", {
12073
- key: index,
12074
- alt: element.alt,
12075
- src: element.src,
12076
- style: element.style,
12077
- class: "max-w-full h-auto"
12078
- });
12079
- case "table":
12080
- return h12("div", { key: index }, renderTable(element.content));
12081
- case "list":
12082
- return h12("div", { key: index }, renderList(element.content));
12083
- case "blockquote":
12084
- return h12("blockquote", {
12085
- key: index,
12086
- class: `border-l-4 border-accent-primary/30 pl-4 italic text-text-secondary my-4 text-sm sm:text-base${element.classes ? ` ${element.classes}` : ""}`
12087
- }, renderInline(element.content));
12088
- case "hr":
12089
- return h12("hr", { key: index, class: "my-8 border-border" });
12090
- case "toc": {
12091
- const toc = generateToc(allElements.value);
12092
- return toc ? h12("div", { key: index }, toc) : null;
12093
- }
12094
- default:
12095
- return null;
12096
- }
12097
- };
12098
- const processAndRenderElements = (elements, depth = 0) => {
12099
- const result = [];
12100
- let i = 0;
12101
- while (i < elements.length) {
12102
- const el = elements[i];
12103
- if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
12104
- const cards = [];
12105
- while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
12106
- cards.push(elements[i]);
12107
- i++;
12108
- }
12109
- if (cards.length === 1 || cards[0].props?.batch === "off") {
12110
- for (let c = 0; c < cards.length; c++) {
12111
- result.push(renderElement(cards[c], result.length, depth));
12112
- }
12113
- } else {
12114
- const firstCardClass = cards[0].props?.["class"] || "";
12115
- const justifyClasses = firstCardClass.match(/\bjustify-\S+/g) || [];
12116
- const wrapperJustify = justifyClasses.length > 0 ? justifyClasses.join(" ") : "";
12117
- result.push(h12("div", {
12118
- key: `card-grid-${result.length}`,
12119
- class: `not-prose flex flex-wrap gap-6 my-6 ${wrapperJustify}`
12120
- }, cards.map((card, ci) => {
12121
- const rendered = renderElement(card, ci, depth);
12122
- return rendered ? h12("span", { key: ci }, rendered) : null;
12123
- })));
12124
- }
12125
- } else {
12126
- result.push(renderElement(el, result.length, depth));
12127
- i++;
12128
- }
12129
- }
12130
- return result;
12131
- };
12132
- const setModals = (value) => {
12133
- if (typeof value === "function") {
12134
- modals.value = value(modals.value);
12135
- } else {
12136
- modals.value = value;
12137
- }
12138
- };
12139
- const contextForDirectives = {
12140
- modals,
12141
- setModals,
12142
- articleClass,
12143
- allElements: allElements.value,
12144
- parseMarkdown,
12145
- renderElement,
12146
- renderInline,
12147
- processAndRenderElements
12148
- };
12149
- provide(RenderContextKey, contextForDirectives);
12150
- return () => h12(
12151
- "div",
12152
- { class: articleClass },
12153
- processAndRenderElements(allElements.value)
12154
- );
12025
+ return () => h("div", { ref: container });
12155
12026
  }
12156
12027
  });
12157
12028
  var CustomMarkdownRenderer_default = CustomMarkdownRenderer;
12158
12029
 
12030
+ // vue/RawHtmlRenderer.ts
12031
+ import { defineComponent as defineComponent2, h as h2, onMounted as onMounted3, ref as ref2, watch as watch3 } from "vue";
12032
+ var RawHtmlRenderer = defineComponent2({
12033
+ name: "RawHtmlRenderer",
12034
+ props: {
12035
+ content: { type: String, required: true },
12036
+ wrapperClassName: { type: String, default: "nr-raw-html" }
12037
+ },
12038
+ setup(props) {
12039
+ const container = ref2(null);
12040
+ const render = () => {
12041
+ const el = container.value;
12042
+ if (!el) return;
12043
+ el.replaceChildren();
12044
+ el.appendChild(renderHtmlString(props.content));
12045
+ scanTailwindCDN();
12046
+ };
12047
+ onMounted3(render);
12048
+ watch3(() => props.content, render);
12049
+ return () => h2("div", { ref: container, class: props.wrapperClassName });
12050
+ }
12051
+ });
12052
+ var RawHtmlRenderer_default = RawHtmlRenderer;
12053
+
12159
12054
  // vue/NRpreviewer.ts
12160
- var NRpreviewer = defineComponent12({
12055
+ var NRpreviewer = defineComponent3({
12161
12056
  name: "NRpreviewer",
12162
12057
  props: {
12163
12058
  content: { type: String, default: void 0 },
@@ -12167,23 +12062,20 @@ var NRpreviewer = defineComponent12({
12167
12062
  style: { type: Object, default: void 0 }
12168
12063
  },
12169
12064
  setup(props) {
12170
- const tailwindEnabled = ref6(props.tailwindCDN);
12065
+ const tailwindEnabled = ref3(props.tailwindCDN);
12171
12066
  if (typeof window !== "undefined") {
12172
12067
  useLazyTailwindCDN(tailwindEnabled);
12173
12068
  }
12174
12069
  return () => {
12175
12070
  const wrapperClass = `nr-prose${props.className ? ` ${props.className}` : ""}`;
12176
12071
  if (props.content) {
12177
- return h13("div", { class: wrapperClass, style: props.style }, [
12178
- h13(CustomMarkdownRenderer_default, { content: props.content })
12072
+ return h3("div", { class: wrapperClass, style: props.style }, [
12073
+ h3(CustomMarkdownRenderer_default, { content: props.content })
12179
12074
  ]);
12180
12075
  }
12181
12076
  if (props.html) {
12182
- return h13("div", { class: wrapperClass, style: props.style }, [
12183
- h13(RawHtmlRenderer_default, {
12184
- content: props.html,
12185
- wrapperClassName: "nr-preview-html"
12186
- })
12077
+ return h3("div", { class: wrapperClass, style: props.style }, [
12078
+ h3(RawHtmlRenderer_default, { content: props.html })
12187
12079
  ]);
12188
12080
  }
12189
12081
  return null;
@@ -12192,14 +12084,9 @@ var NRpreviewer = defineComponent12({
12192
12084
  });
12193
12085
  var NRpreviewer_default = NRpreviewer;
12194
12086
  export {
12195
- Admonition,
12196
- CodeBlock,
12197
12087
  CustomMarkdownRenderer_default as CustomMarkdownRenderer,
12198
- Details,
12199
- IconRenderer,
12200
- Modal,
12201
12088
  NRpreviewer_default as NRpreviewer,
12202
- extractHeaders,
12089
+ RawHtmlRenderer_default as RawHtmlRenderer,
12203
12090
  parseMarkdown,
12204
12091
  preloadTailwindCDN,
12205
12092
  scanTailwindCDN,