@noirmd/previewer 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NReditor.cjs +851 -895
- package/dist/NReditor.cjs.map +1 -1
- package/dist/NReditor.d.cts +1 -1
- package/dist/NReditor.d.ts +1 -1
- package/dist/NReditor.js +852 -896
- package/dist/NReditor.js.map +1 -1
- package/dist/admonition.css +55 -0
- package/dist/{markdown.css → base.css} +96 -126
- package/dist/blockquote.css +16 -0
- package/dist/button.css +32 -0
- package/dist/card.css +143 -0
- package/dist/codeblock.css +59 -0
- package/dist/core.cjs +9 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +9 -1
- package/dist/core.js.map +1 -1
- package/dist/details.css +45 -0
- package/dist/editor.css +56 -9
- package/dist/fonts/material-icons-round.woff2 +0 -0
- package/dist/index.cjs +852 -883
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -70
- package/dist/index.d.ts +41 -70
- package/dist/index.js +851 -877
- package/dist/index.js.map +1 -1
- package/dist/list.css +18 -0
- package/dist/modal.css +82 -0
- package/dist/react.cjs +852 -886
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +44 -73
- package/dist/react.d.ts +44 -73
- package/dist/react.js +851 -880
- package/dist/react.js.map +1 -1
- package/dist/slide.css +21 -0
- package/dist/table.css +36 -0
- package/dist/toc.css +45 -0
- package/dist/vanilla.cjs +42 -28
- package/dist/vanilla.cjs.map +1 -1
- package/dist/vanilla.css +32 -677
- package/dist/vanilla.d.cts +8 -2
- package/dist/vanilla.d.ts +8 -2
- package/dist/vanilla.js +41 -28
- package/dist/vanilla.js.map +1 -1
- package/dist/variables.css +53 -0
- package/dist/vue.cjs +931 -1121
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +63 -214
- package/dist/vue.d.ts +63 -214
- package/dist/vue.js +930 -1120
- package/dist/vue.js.map +1 -1
- package/editor.css +56 -9
- package/package.json +5 -10
- package/markdown.css +0 -344
package/dist/index.cjs
CHANGED
|
@@ -1572,15 +1572,10 @@ var require_core = __commonJS({
|
|
|
1572
1572
|
// index.ts
|
|
1573
1573
|
var index_exports = {};
|
|
1574
1574
|
__export(index_exports, {
|
|
1575
|
-
Admonition: () => Admonition,
|
|
1576
|
-
CodeBlock: () => CodeBlock,
|
|
1577
1575
|
CustomMarkdownRenderer: () => CustomMarkdownRenderer_default,
|
|
1578
|
-
Details: () => Details,
|
|
1579
|
-
IconRenderer: () => IconRenderer,
|
|
1580
|
-
Modal: () => Modal,
|
|
1581
1576
|
NRpreviewer: () => NRpreviewer_default,
|
|
1577
|
+
RawHtmlRenderer: () => RawHtmlRenderer_default,
|
|
1582
1578
|
extractAttributes: () => extractAttributes,
|
|
1583
|
-
extractHeaders: () => extractHeaders,
|
|
1584
1579
|
generateId: () => generateId,
|
|
1585
1580
|
generateScopeId: () => generateScopeId,
|
|
1586
1581
|
parseCssString: () => parseCssString,
|
|
@@ -1690,6 +1685,7 @@ function parseMarkdown(markdown2) {
|
|
|
1690
1685
|
if (!markdown2) return [];
|
|
1691
1686
|
const lines = markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "").split("\n");
|
|
1692
1687
|
const result = [];
|
|
1688
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
1693
1689
|
let i = 0;
|
|
1694
1690
|
while (i < lines.length) {
|
|
1695
1691
|
const line = lines[i];
|
|
@@ -1699,7 +1695,14 @@ function parseMarkdown(markdown2) {
|
|
|
1699
1695
|
const level = match[1].length;
|
|
1700
1696
|
const rawText = match[2];
|
|
1701
1697
|
const { text: text2, classes: classes2, id: customId } = extractAttributes(rawText);
|
|
1702
|
-
const
|
|
1698
|
+
const baseId = customId || generateId(text2.replace(/->|<-/g, ""));
|
|
1699
|
+
let id2 = baseId;
|
|
1700
|
+
let n = 1;
|
|
1701
|
+
while (usedIds.has(id2)) {
|
|
1702
|
+
n++;
|
|
1703
|
+
id2 = `${baseId}-${n}`;
|
|
1704
|
+
}
|
|
1705
|
+
usedIds.add(id2);
|
|
1703
1706
|
result.push({ type: "header", level, text: text2, id: id2, classes: classes2 || void 0 });
|
|
1704
1707
|
i++;
|
|
1705
1708
|
continue;
|
|
@@ -2015,10 +2018,7 @@ function splitSlots(rawContent) {
|
|
|
2015
2018
|
}
|
|
2016
2019
|
|
|
2017
2020
|
// react/CustomMarkdownRenderer.tsx
|
|
2018
|
-
var
|
|
2019
|
-
|
|
2020
|
-
// react/ui-components.tsx
|
|
2021
|
-
var import_react = require("react");
|
|
2021
|
+
var import_react2 = require("react");
|
|
2022
2022
|
|
|
2023
2023
|
// node_modules/highlight.js/es/core.js
|
|
2024
2024
|
var import_core = __toESM(require_core(), 1);
|
|
@@ -10916,7 +10916,7 @@ function shell(hljs) {
|
|
|
10916
10916
|
};
|
|
10917
10917
|
}
|
|
10918
10918
|
|
|
10919
|
-
//
|
|
10919
|
+
// vanilla/highlightSetup.ts
|
|
10920
10920
|
core_default.registerLanguage("javascript", javascript);
|
|
10921
10921
|
core_default.registerLanguage("js", javascript);
|
|
10922
10922
|
core_default.registerLanguage("jsx", javascript);
|
|
@@ -10940,729 +10940,922 @@ core_default.registerLanguage("java", java);
|
|
|
10940
10940
|
core_default.registerLanguage("csharp", csharp);
|
|
10941
10941
|
core_default.registerLanguage("cs", csharp);
|
|
10942
10942
|
core_default.registerLanguage("cpp", cpp);
|
|
10943
|
-
core_default.registerLanguage("c", cpp);
|
|
10944
10943
|
core_default.registerLanguage("go", go);
|
|
10945
10944
|
core_default.registerLanguage("rust", rust);
|
|
10946
|
-
core_default.registerLanguage("rs", rust);
|
|
10947
10945
|
core_default.registerLanguage("php", php);
|
|
10948
10946
|
core_default.registerLanguage("ruby", ruby);
|
|
10949
|
-
core_default.registerLanguage("rb", ruby);
|
|
10950
10947
|
core_default.registerLanguage("swift", swift);
|
|
10951
10948
|
core_default.registerLanguage("kotlin", kotlin);
|
|
10952
|
-
core_default.registerLanguage("kt", kotlin);
|
|
10953
10949
|
core_default.registerLanguage("dart", dart);
|
|
10954
10950
|
core_default.registerLanguage("yaml", yaml);
|
|
10955
|
-
core_default.registerLanguage("yml", yaml);
|
|
10956
10951
|
core_default.registerLanguage("toml", ini);
|
|
10957
|
-
core_default.registerLanguage("ini", ini);
|
|
10958
10952
|
core_default.registerLanguage("dockerfile", dockerfile);
|
|
10959
|
-
core_default.registerLanguage("docker", dockerfile);
|
|
10960
10953
|
core_default.registerLanguage("diff", diff);
|
|
10961
10954
|
core_default.registerLanguage("shell", shell);
|
|
10962
10955
|
var highlightSetup_default = core_default;
|
|
10963
10956
|
|
|
10964
|
-
//
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10957
|
+
// vanilla/components.ts
|
|
10958
|
+
function createIcon(iconName, extraClasses) {
|
|
10959
|
+
const span = document.createElement("span");
|
|
10960
|
+
const cls = `nr-icon material-icons-round${extraClasses ? ` ${extraClasses}` : ""}`;
|
|
10961
|
+
span.className = cls;
|
|
10962
|
+
span.setAttribute("aria-hidden", "true");
|
|
10970
10963
|
const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(iconName);
|
|
10971
10964
|
if (isCodepoint) {
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
className: baseClass,
|
|
10976
|
-
dangerouslySetInnerHTML: { __html: `&#x${iconName};` },
|
|
10977
|
-
"aria-hidden": "true"
|
|
10978
|
-
}
|
|
10979
|
-
);
|
|
10965
|
+
span.innerHTML = `&#x${iconName};`;
|
|
10966
|
+
} else {
|
|
10967
|
+
span.textContent = iconName;
|
|
10980
10968
|
}
|
|
10981
|
-
return
|
|
10982
|
-
}
|
|
10983
|
-
|
|
10984
|
-
const
|
|
10985
|
-
|
|
10969
|
+
return span;
|
|
10970
|
+
}
|
|
10971
|
+
function createCodeBlock(code, language, title) {
|
|
10972
|
+
const wrapper = document.createElement("div");
|
|
10973
|
+
wrapper.className = "nr-codeblock";
|
|
10986
10974
|
const lang = language?.split(/[\s{]/)[0]?.trim() || "";
|
|
10987
|
-
|
|
10975
|
+
if (title) {
|
|
10976
|
+
const header = document.createElement("div");
|
|
10977
|
+
header.className = "nr-codeblock__header";
|
|
10978
|
+
header.appendChild(createIcon("description"));
|
|
10979
|
+
const titleSpan = document.createElement("span");
|
|
10980
|
+
titleSpan.textContent = title;
|
|
10981
|
+
header.appendChild(titleSpan);
|
|
10982
|
+
wrapper.appendChild(header);
|
|
10983
|
+
}
|
|
10984
|
+
const pre = document.createElement("pre");
|
|
10985
|
+
pre.className = "nr-codeblock__pre";
|
|
10986
|
+
const codeEl = document.createElement("code");
|
|
10987
|
+
codeEl.className = `language-${lang || "plaintext"}`;
|
|
10988
10988
|
try {
|
|
10989
10989
|
if (lang && highlightSetup_default.getLanguage(lang)) {
|
|
10990
|
-
|
|
10990
|
+
codeEl.innerHTML = highlightSetup_default.highlight(code, { language: lang }).value;
|
|
10991
10991
|
} else {
|
|
10992
|
-
|
|
10992
|
+
codeEl.innerHTML = highlightSetup_default.highlightAuto(code).value;
|
|
10993
10993
|
}
|
|
10994
10994
|
} catch {
|
|
10995
|
-
|
|
10995
|
+
codeEl.textContent = code;
|
|
10996
10996
|
}
|
|
10997
|
-
|
|
10997
|
+
pre.appendChild(codeEl);
|
|
10998
|
+
wrapper.appendChild(pre);
|
|
10999
|
+
const copyBtn = document.createElement("button");
|
|
11000
|
+
copyBtn.className = "nr-codeblock__copy";
|
|
11001
|
+
copyBtn.title = "Copy code";
|
|
11002
|
+
const copyIcon = createIcon("content_copy");
|
|
11003
|
+
copyIcon.style.fontSize = "1rem";
|
|
11004
|
+
copyBtn.appendChild(copyIcon);
|
|
11005
|
+
let timer = null;
|
|
11006
|
+
copyBtn.addEventListener("click", () => {
|
|
10998
11007
|
navigator.clipboard.writeText(code);
|
|
10999
|
-
|
|
11000
|
-
if (
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "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", onClick: handleCopy, title: "Copy code", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "material-symbols-rounded", style: { fontSize: "1rem" }, children: copied ? "check" : "content_copy" }) })
|
|
11010
|
-
] });
|
|
11011
|
-
};
|
|
11012
|
-
var defaultIcons = {
|
|
11008
|
+
copyIcon.textContent = "check";
|
|
11009
|
+
if (timer) clearTimeout(timer);
|
|
11010
|
+
timer = setTimeout(() => {
|
|
11011
|
+
copyIcon.textContent = "content_copy";
|
|
11012
|
+
}, 1800);
|
|
11013
|
+
});
|
|
11014
|
+
wrapper.appendChild(copyBtn);
|
|
11015
|
+
return wrapper;
|
|
11016
|
+
}
|
|
11017
|
+
var DEFAULT_ADMONITION_ICONS = {
|
|
11013
11018
|
note: "info",
|
|
11014
11019
|
info: "lightbulb",
|
|
11015
11020
|
warning: "warning",
|
|
11016
11021
|
danger: "report",
|
|
11017
|
-
greentext: "
|
|
11022
|
+
greentext: "subdirectory_arrow_right"
|
|
11018
11023
|
};
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
);
|
|
11042
|
-
|
|
11043
|
-
var Details = ({
|
|
11044
|
-
title,
|
|
11045
|
-
icon,
|
|
11046
|
-
defaultOpen = false,
|
|
11047
|
-
className = "",
|
|
11048
|
-
style,
|
|
11049
|
-
children
|
|
11050
|
-
}) => {
|
|
11051
|
-
const [isOpen, setIsOpen] = (0, import_react.useState)(defaultOpen);
|
|
11024
|
+
function createAdmonition(type, title, icon) {
|
|
11025
|
+
const el = document.createElement("div");
|
|
11026
|
+
el.className = `nr-admonition nr-admonition--${type || "note"}`;
|
|
11027
|
+
if (title) {
|
|
11028
|
+
const header = document.createElement("h5");
|
|
11029
|
+
header.className = "nr-admonition__title";
|
|
11030
|
+
const iconToRender = icon || DEFAULT_ADMONITION_ICONS[type] || "info";
|
|
11031
|
+
header.appendChild(createIcon(iconToRender, "nr-admonition__icon"));
|
|
11032
|
+
const titleSpan = document.createElement("span");
|
|
11033
|
+
titleSpan.textContent = title;
|
|
11034
|
+
header.appendChild(titleSpan);
|
|
11035
|
+
el.appendChild(header);
|
|
11036
|
+
}
|
|
11037
|
+
const body = document.createElement("div");
|
|
11038
|
+
body.className = "nr-admonition__body";
|
|
11039
|
+
el.appendChild(body);
|
|
11040
|
+
return el;
|
|
11041
|
+
}
|
|
11042
|
+
function createDetails(title, icon, defaultOpen) {
|
|
11043
|
+
const details = document.createElement("details");
|
|
11044
|
+
details.className = "nr-details";
|
|
11045
|
+
if (defaultOpen) details.open = true;
|
|
11046
|
+
const summary = document.createElement("summary");
|
|
11047
|
+
summary.className = "nr-details__summary";
|
|
11052
11048
|
const iconToRender = icon || "play_arrow";
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
|
|
11073
|
-
extraClasses: `transition-transform ${isOpen ? "rotate-90" : ""}`
|
|
11074
|
-
}
|
|
11075
|
-
),
|
|
11076
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: title })
|
|
11077
|
-
]
|
|
11078
|
-
}
|
|
11079
|
-
),
|
|
11080
|
-
isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pb-4 border-t border-border pt-3 text-sm leading-relaxed opacity-90 overflow-hidden min-w-0", children })
|
|
11081
|
-
]
|
|
11082
|
-
}
|
|
11083
|
-
);
|
|
11084
|
-
};
|
|
11085
|
-
var Modal = ({ title, isOpen, onClose, children }) => {
|
|
11086
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Root, { open: isOpen, onOpenChange: (open) => {
|
|
11087
|
-
if (!open) onClose();
|
|
11088
|
-
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Portal, { children: [
|
|
11089
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Backdrop, { className: "fixed inset-0 z-[9999] bg-black/60" }),
|
|
11090
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Viewport, { className: "fixed inset-0 z-[9999] flex items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Popup, { className: "bg-background-primary border border-border shadow-2xl rounded-3xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden", children: [
|
|
11091
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-between items-center p-4 border-b border-border bg-background-secondary-solid/20", children: [
|
|
11092
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Title, { className: "text-lg font-bold !m-0", children: title }),
|
|
11093
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Close, { className: "w-8 h-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors cursor-pointer border-none bg-transparent", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "material-symbols-rounded text-base", children: "close" }) })
|
|
11094
|
-
] }),
|
|
11095
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "p-6 overflow-auto min-h-0 text-text-primary [&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0 [&_h5:first-child]:mt-0 [&_h6:first-child]:mt-0", children })
|
|
11096
|
-
] }) })
|
|
11097
|
-
] }) });
|
|
11098
|
-
};
|
|
11099
|
-
|
|
11100
|
-
// react/renderers.tsx
|
|
11101
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
11102
|
-
function renderInline(text) {
|
|
11103
|
-
if (!text) return text;
|
|
11104
|
-
const parsePart = (part, key) => {
|
|
11105
|
-
let match2;
|
|
11106
|
-
if (match2 = part.match(/^\|\[([^\]]+)\]\|$/)) {
|
|
11107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconRenderer, { iconName: match2[1] }, key);
|
|
11108
|
-
}
|
|
11109
|
-
if (match2 = part.match(/^!~(.+?)~!$/)) {
|
|
11110
|
-
const content = match2[1];
|
|
11111
|
-
const parts = content.split(";");
|
|
11112
|
-
let color = "currentColor";
|
|
11113
|
-
let decorationStyle = "solid";
|
|
11114
|
-
let type = "underline";
|
|
11115
|
-
let textIndex = 0;
|
|
11116
|
-
if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
|
|
11117
|
-
color = parts[textIndex++];
|
|
11118
|
-
}
|
|
11119
|
-
if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
|
|
11120
|
-
decorationStyle = parts[textIndex++];
|
|
11121
|
-
}
|
|
11122
|
-
if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
|
|
11123
|
-
type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
|
|
11124
|
-
}
|
|
11125
|
-
const innerText = parts.slice(textIndex).join(";");
|
|
11126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
11127
|
-
"span",
|
|
11128
|
-
{
|
|
11129
|
-
style: {
|
|
11130
|
-
textDecoration: `${type} ${decorationStyle} ${color}`,
|
|
11131
|
-
textDecorationThickness: "auto"
|
|
11132
|
-
},
|
|
11133
|
-
children: renderInline(innerText)
|
|
11134
|
-
},
|
|
11135
|
-
key
|
|
11136
|
-
);
|
|
11137
|
-
}
|
|
11138
|
-
if (match2 = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
|
|
11139
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { color: match2[1] }, children: renderInline(match2[2]) }, key);
|
|
11140
|
-
}
|
|
11141
|
-
if (match2 = part.match(/^!>([^<]+?)<!$/)) {
|
|
11142
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "bg-text-primary text-bg-primary px-1 rounded hover:bg-transparent transition-colors cursor-pointer", children: renderInline(match2[1]) }, key);
|
|
11143
|
-
}
|
|
11144
|
-
if (match2 = part.match(/^==(.+?)==$/)) {
|
|
11145
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("mark", { className: "bg-yellow-500/20 text-inherit px-0.5 rounded", children: renderInline(match2[1]) }, key);
|
|
11146
|
-
}
|
|
11147
|
-
if (match2 = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
|
|
11148
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: renderInline(match2[1]) }) }, key);
|
|
11149
|
-
}
|
|
11150
|
-
if (match2 = part.match(/^\*\*(.+?)\*\*$/)) {
|
|
11151
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: renderInline(match2[1]) }, key);
|
|
11152
|
-
}
|
|
11153
|
-
if (match2 = part.match(/^_(.+?)_$/)) {
|
|
11154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: renderInline(match2[1]) }, key);
|
|
11155
|
-
}
|
|
11156
|
-
if (match2 = part.match(/^~~(.+?)~~$/)) {
|
|
11157
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("del", { children: renderInline(match2[1]) }, key);
|
|
11158
|
-
}
|
|
11159
|
-
if (match2 = part.match(/^`([^`]+)`$/)) {
|
|
11160
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { className: "text-[0.875em] font-mono bg-background-secondary/50 px-1.5 py-0.5 rounded text-text-primary", children: match2[1] }, key);
|
|
11161
|
-
}
|
|
11162
|
-
if (match2 = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
|
|
11163
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
11164
|
-
"a",
|
|
11165
|
-
{
|
|
11166
|
-
href: match2[2],
|
|
11167
|
-
className: "text-accent-primary underline decoration-accent-primary/40 hover:decoration-accent-primary transition-colors",
|
|
11168
|
-
target: "_blank",
|
|
11169
|
-
rel: "noopener noreferrer",
|
|
11170
|
-
children: renderInline(match2[1])
|
|
11171
|
-
},
|
|
11172
|
-
key
|
|
11173
|
-
);
|
|
11174
|
-
}
|
|
11175
|
-
if (part.startsWith("<") && part.endsWith(">")) {
|
|
11176
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { dangerouslySetInnerHTML: { __html: part } }, key);
|
|
11177
|
-
}
|
|
11178
|
-
return part;
|
|
11179
|
-
};
|
|
11180
|
-
const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
|
|
11181
|
-
const elements = [];
|
|
11182
|
-
let lastIndex = 0;
|
|
11183
|
-
let match;
|
|
11184
|
-
let keyCounter = 0;
|
|
11185
|
-
while ((match = regex.exec(text)) !== null) {
|
|
11186
|
-
if (match.index > lastIndex) {
|
|
11187
|
-
elements.push(text.slice(lastIndex, match.index));
|
|
11049
|
+
const iconEl = createIcon(iconToRender, "nr-details__icon");
|
|
11050
|
+
summary.appendChild(iconEl);
|
|
11051
|
+
const titleSpan = document.createElement("span");
|
|
11052
|
+
titleSpan.textContent = title || "Details";
|
|
11053
|
+
summary.appendChild(titleSpan);
|
|
11054
|
+
details.addEventListener("toggle", () => {
|
|
11055
|
+
iconEl.classList.toggle("nr-details__icon--open", details.open);
|
|
11056
|
+
});
|
|
11057
|
+
details.appendChild(summary);
|
|
11058
|
+
const body = document.createElement("div");
|
|
11059
|
+
body.className = "nr-details__body";
|
|
11060
|
+
details.appendChild(body);
|
|
11061
|
+
return details;
|
|
11062
|
+
}
|
|
11063
|
+
function createModal(title) {
|
|
11064
|
+
const dialog = document.createElement("dialog");
|
|
11065
|
+
dialog.className = "nr-modal";
|
|
11066
|
+
dialog.addEventListener("click", (e) => {
|
|
11067
|
+
if (e.target === dialog) {
|
|
11068
|
+
dialog.close();
|
|
11188
11069
|
}
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11070
|
+
});
|
|
11071
|
+
const popup = document.createElement("div");
|
|
11072
|
+
popup.className = "nr-modal__popup";
|
|
11073
|
+
const header = document.createElement("div");
|
|
11074
|
+
header.className = "nr-modal__header";
|
|
11075
|
+
const titleEl = document.createElement("h2");
|
|
11076
|
+
titleEl.className = "nr-modal__title";
|
|
11077
|
+
titleEl.textContent = title;
|
|
11078
|
+
header.appendChild(titleEl);
|
|
11079
|
+
const closeBtn = document.createElement("button");
|
|
11080
|
+
closeBtn.className = "nr-modal__close";
|
|
11081
|
+
closeBtn.appendChild(createIcon("close"));
|
|
11082
|
+
closeBtn.addEventListener("click", () => dialog.close());
|
|
11083
|
+
header.appendChild(closeBtn);
|
|
11084
|
+
popup.appendChild(header);
|
|
11085
|
+
const body = document.createElement("div");
|
|
11086
|
+
body.className = "nr-modal__body";
|
|
11087
|
+
popup.appendChild(body);
|
|
11088
|
+
dialog.appendChild(popup);
|
|
11089
|
+
return dialog;
|
|
11196
11090
|
}
|
|
11197
|
-
function
|
|
11091
|
+
function createTable(content, renderInline2) {
|
|
11198
11092
|
const rows = content.split("\n").filter((r) => r.trim());
|
|
11199
|
-
if (rows.length < 2)
|
|
11093
|
+
if (rows.length < 2) {
|
|
11094
|
+
const p = document.createElement("p");
|
|
11095
|
+
p.textContent = content;
|
|
11096
|
+
return p;
|
|
11097
|
+
}
|
|
11200
11098
|
const parseRow = (row) => row.split("|").map((c) => c.trim()).filter(Boolean);
|
|
11201
11099
|
const headerCells = parseRow(rows[0]);
|
|
11202
11100
|
const bodyRows = rows.slice(2).map(parseRow);
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11101
|
+
const wrapper = document.createElement("div");
|
|
11102
|
+
wrapper.className = "nr-table-wrap";
|
|
11103
|
+
const table = document.createElement("table");
|
|
11104
|
+
table.className = "nr-table";
|
|
11105
|
+
const thead = document.createElement("thead");
|
|
11106
|
+
const tr = document.createElement("tr");
|
|
11107
|
+
for (const cell of headerCells) {
|
|
11108
|
+
const th = document.createElement("th");
|
|
11109
|
+
th.className = "nr-table__th";
|
|
11110
|
+
th.appendChild(renderInline2(cell));
|
|
11111
|
+
tr.appendChild(th);
|
|
11112
|
+
}
|
|
11113
|
+
thead.appendChild(tr);
|
|
11114
|
+
table.appendChild(thead);
|
|
11115
|
+
const tbody = document.createElement("tbody");
|
|
11116
|
+
for (const cells of bodyRows) {
|
|
11117
|
+
const tr2 = document.createElement("tr");
|
|
11118
|
+
for (const cell of cells) {
|
|
11119
|
+
const td = document.createElement("td");
|
|
11120
|
+
td.className = "nr-table__td";
|
|
11121
|
+
td.appendChild(renderInline2(cell));
|
|
11122
|
+
tr2.appendChild(td);
|
|
11123
|
+
}
|
|
11124
|
+
tbody.appendChild(tr2);
|
|
11125
|
+
}
|
|
11126
|
+
table.appendChild(tbody);
|
|
11127
|
+
wrapper.appendChild(table);
|
|
11128
|
+
return wrapper;
|
|
11207
11129
|
}
|
|
11208
|
-
function
|
|
11130
|
+
function createList(content, renderInline2) {
|
|
11209
11131
|
const lines = content.split("\n");
|
|
11210
11132
|
const items = [];
|
|
11211
11133
|
for (const line of lines) {
|
|
11212
11134
|
if (!line.trim()) continue;
|
|
11213
11135
|
const match = line.match(/^(\s*)([-*+]|\d+\.)\s+(.+)$/);
|
|
11214
11136
|
if (match) {
|
|
11215
|
-
items.push({
|
|
11216
|
-
indent: match[1].length,
|
|
11217
|
-
marker: match[2],
|
|
11218
|
-
text: match[3]
|
|
11219
|
-
});
|
|
11137
|
+
items.push({ indent: match[1].length, marker: match[2], text: match[3] });
|
|
11220
11138
|
}
|
|
11221
11139
|
}
|
|
11222
|
-
if (items.length === 0)
|
|
11140
|
+
if (items.length === 0) {
|
|
11141
|
+
const p = document.createElement("p");
|
|
11142
|
+
p.textContent = content;
|
|
11143
|
+
return p;
|
|
11144
|
+
}
|
|
11223
11145
|
const isOrdered = /^\d+\.$/.test(items[0].marker);
|
|
11224
|
-
const
|
|
11225
|
-
|
|
11146
|
+
const list = document.createElement(isOrdered ? "ol" : "ul");
|
|
11147
|
+
list.className = "nr-list";
|
|
11148
|
+
for (const item of items) {
|
|
11149
|
+
const li = document.createElement("li");
|
|
11150
|
+
li.className = "nr-list__item";
|
|
11151
|
+
li.appendChild(renderInline2(item.text));
|
|
11152
|
+
list.appendChild(li);
|
|
11153
|
+
}
|
|
11154
|
+
return list;
|
|
11155
|
+
}
|
|
11156
|
+
function createTOC(headers, renderInline2) {
|
|
11157
|
+
const nav = document.createElement("nav");
|
|
11158
|
+
nav.className = "nr-toc";
|
|
11159
|
+
const title = document.createElement("div");
|
|
11160
|
+
title.className = "nr-toc__title";
|
|
11161
|
+
title.textContent = "Table of Contents";
|
|
11162
|
+
nav.appendChild(title);
|
|
11163
|
+
const ul = document.createElement("ul");
|
|
11164
|
+
ul.className = "nr-toc__list";
|
|
11165
|
+
for (const h of headers) {
|
|
11166
|
+
const li = document.createElement("li");
|
|
11167
|
+
li.className = `nr-toc__item nr-toc__item--h${h.level}`;
|
|
11168
|
+
const a = document.createElement("a");
|
|
11169
|
+
a.className = "nr-toc__link";
|
|
11170
|
+
a.href = `#${h.id}`;
|
|
11171
|
+
a.appendChild(renderInline2(h.text.replace(/->|<-/g, "").trim()));
|
|
11172
|
+
a.addEventListener("click", (e) => {
|
|
11173
|
+
e.preventDefault();
|
|
11174
|
+
const target = document.getElementById(h.id);
|
|
11175
|
+
if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
11176
|
+
});
|
|
11177
|
+
li.appendChild(a);
|
|
11178
|
+
ul.appendChild(li);
|
|
11179
|
+
}
|
|
11180
|
+
nav.appendChild(ul);
|
|
11181
|
+
return nav;
|
|
11226
11182
|
}
|
|
11227
|
-
function
|
|
11228
|
-
|
|
11183
|
+
function createBlockquote(content, classes, renderInline2) {
|
|
11184
|
+
const el = document.createElement("blockquote");
|
|
11185
|
+
el.className = `nr-blockquote${classes ? ` ${classes}` : ""}`;
|
|
11186
|
+
el.appendChild(renderInline2(content));
|
|
11187
|
+
return el;
|
|
11229
11188
|
}
|
|
11230
11189
|
|
|
11231
|
-
//
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
type: directiveType,
|
|
11242
|
-
title: props.title,
|
|
11243
|
-
icon: props.icon,
|
|
11244
|
-
className: props.class,
|
|
11245
|
-
style: props.style ? parseCssString(props.style) : void 0,
|
|
11246
|
-
children: renderSlot("default")
|
|
11190
|
+
// vanilla/inline.ts
|
|
11191
|
+
function renderInline(text) {
|
|
11192
|
+
const fragment = document.createDocumentFragment();
|
|
11193
|
+
if (!text) return fragment;
|
|
11194
|
+
const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
|
|
11195
|
+
let lastIndex = 0;
|
|
11196
|
+
let match;
|
|
11197
|
+
while ((match = regex.exec(text)) !== null) {
|
|
11198
|
+
if (match.index > lastIndex) {
|
|
11199
|
+
fragment.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
|
|
11247
11200
|
}
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11201
|
+
fragment.appendChild(parseInlinePart(match[0]));
|
|
11202
|
+
lastIndex = regex.lastIndex;
|
|
11203
|
+
}
|
|
11204
|
+
if (lastIndex < text.length) {
|
|
11205
|
+
fragment.appendChild(document.createTextNode(text.slice(lastIndex)));
|
|
11206
|
+
}
|
|
11207
|
+
return fragment;
|
|
11208
|
+
}
|
|
11209
|
+
function parseInlinePart(part) {
|
|
11210
|
+
let match;
|
|
11211
|
+
if (match = part.match(/^\|\[([^\]]+)\]\|$/)) {
|
|
11212
|
+
return createIcon(match[1]);
|
|
11213
|
+
}
|
|
11214
|
+
if (match = part.match(/^!~(.+?)~!$/)) {
|
|
11215
|
+
const content = match[1];
|
|
11216
|
+
const parts = content.split(";");
|
|
11217
|
+
let color = "currentColor";
|
|
11218
|
+
let decorationStyle = "solid";
|
|
11219
|
+
let type = "underline";
|
|
11220
|
+
let textIndex = 0;
|
|
11221
|
+
if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
|
|
11222
|
+
color = parts[textIndex++];
|
|
11223
|
+
}
|
|
11224
|
+
if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
|
|
11225
|
+
decorationStyle = parts[textIndex++];
|
|
11226
|
+
}
|
|
11227
|
+
if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
|
|
11228
|
+
type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
|
|
11229
|
+
}
|
|
11230
|
+
const innerText = parts.slice(textIndex).join(";");
|
|
11231
|
+
const span = document.createElement("span");
|
|
11232
|
+
span.className = "nr-underline";
|
|
11233
|
+
span.style.textDecoration = `${type} ${decorationStyle} ${color}`;
|
|
11234
|
+
span.style.textDecorationThickness = "auto";
|
|
11235
|
+
span.appendChild(renderInline(innerText));
|
|
11236
|
+
return span;
|
|
11237
|
+
}
|
|
11238
|
+
if (match = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
|
|
11239
|
+
const span = document.createElement("span");
|
|
11240
|
+
span.style.color = match[1];
|
|
11241
|
+
span.appendChild(renderInline(match[2]));
|
|
11242
|
+
return span;
|
|
11243
|
+
}
|
|
11244
|
+
if (match = part.match(/^!>([^<]+?)<!$/)) {
|
|
11245
|
+
const span = document.createElement("span");
|
|
11246
|
+
span.className = "nr-spoiler";
|
|
11247
|
+
span.appendChild(renderInline(match[1]));
|
|
11248
|
+
return span;
|
|
11249
|
+
}
|
|
11250
|
+
if (match = part.match(/^==(.+?)==$/)) {
|
|
11251
|
+
const mark = document.createElement("mark");
|
|
11252
|
+
mark.className = "nr-highlight";
|
|
11253
|
+
mark.appendChild(renderInline(match[1]));
|
|
11254
|
+
return mark;
|
|
11255
|
+
}
|
|
11256
|
+
if (match = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
|
|
11257
|
+
const strong = document.createElement("strong");
|
|
11258
|
+
const em = document.createElement("em");
|
|
11259
|
+
em.appendChild(renderInline(match[1]));
|
|
11260
|
+
strong.appendChild(em);
|
|
11261
|
+
return strong;
|
|
11262
|
+
}
|
|
11263
|
+
if (match = part.match(/^\*\*(.+?)\*\*$/)) {
|
|
11264
|
+
const strong = document.createElement("strong");
|
|
11265
|
+
strong.appendChild(renderInline(match[1]));
|
|
11266
|
+
return strong;
|
|
11267
|
+
}
|
|
11268
|
+
if (match = part.match(/^_(.+?)_$/)) {
|
|
11269
|
+
const em = document.createElement("em");
|
|
11270
|
+
em.appendChild(renderInline(match[1]));
|
|
11271
|
+
return em;
|
|
11272
|
+
}
|
|
11273
|
+
if (match = part.match(/^~~(.+?)~~$/)) {
|
|
11274
|
+
const del = document.createElement("del");
|
|
11275
|
+
del.appendChild(renderInline(match[1]));
|
|
11276
|
+
return del;
|
|
11277
|
+
}
|
|
11278
|
+
if (match = part.match(/^`([^`]+)`$/)) {
|
|
11279
|
+
const code = document.createElement("code");
|
|
11280
|
+
code.className = "nr-inline-code";
|
|
11281
|
+
code.textContent = match[1];
|
|
11282
|
+
return code;
|
|
11283
|
+
}
|
|
11284
|
+
if (match = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
|
|
11285
|
+
const a = document.createElement("a");
|
|
11286
|
+
a.className = "nr-link";
|
|
11287
|
+
a.href = match[2];
|
|
11288
|
+
a.target = "_blank";
|
|
11289
|
+
a.rel = "noopener noreferrer";
|
|
11290
|
+
a.appendChild(renderInline(match[1]));
|
|
11291
|
+
return a;
|
|
11292
|
+
}
|
|
11293
|
+
if (part.startsWith("<") && part.endsWith(">")) {
|
|
11294
|
+
const span = document.createElement("span");
|
|
11295
|
+
span.innerHTML = part;
|
|
11296
|
+
return span;
|
|
11297
|
+
}
|
|
11298
|
+
return document.createTextNode(part);
|
|
11299
|
+
}
|
|
11251
11300
|
|
|
11252
|
-
//
|
|
11253
|
-
var
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
}) => {
|
|
11263
|
-
const stableId = (0, import_react2.useId)();
|
|
11264
|
-
const { title, image, icon, class: customClass, url, target } = props;
|
|
11265
|
-
const hasDescription = !!slots.description;
|
|
11266
|
-
const { isSingleCard } = options;
|
|
11267
|
-
const isModal = directiveType === "card-m";
|
|
11268
|
-
const isLink = directiveType === "card-b";
|
|
11269
|
-
const modalId = `modal-card-${props.id || stableId}`;
|
|
11270
|
-
const wrapperClass = customClass || "";
|
|
11271
|
-
const inlineStyles = props.style ? parseCssString(props.style) : {};
|
|
11272
|
-
const description = hasDescription ? renderSlot("description") : null;
|
|
11273
|
-
const content = renderSlot("content") || renderSlot("default");
|
|
11274
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react2.default.Fragment, { children: [
|
|
11275
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
11276
|
-
"div",
|
|
11277
|
-
{
|
|
11278
|
-
className: `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"} ${wrapperClass}`,
|
|
11279
|
-
style: inlineStyles,
|
|
11280
|
-
onClick: isModal ? (e) => {
|
|
11281
|
-
e.preventDefault();
|
|
11282
|
-
e.stopPropagation();
|
|
11283
|
-
context.setModals((prev) => ({ ...prev, [modalId]: true }));
|
|
11284
|
-
} : isLink && url ? () => window.open(url, "_blank") : void 0,
|
|
11285
|
-
role: isModal ? "button" : void 0,
|
|
11286
|
-
tabIndex: isModal ? 0 : void 0,
|
|
11287
|
-
onKeyDown: isModal ? (e) => {
|
|
11288
|
-
if (e.key === "Enter" || e.key === " ") context.setModals((prev) => ({ ...prev, [modalId]: true }));
|
|
11289
|
-
} : void 0,
|
|
11290
|
-
children: [
|
|
11291
|
-
image && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `w-full ${isSingleCard ? "h-[240px]" : "h-[160px]"} overflow-hidden relative transition-all duration-500`, children: [
|
|
11292
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: image, alt: title || "", className: "w-full h-full object-cover !m-0" }),
|
|
11293
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "absolute inset-0 bg-gradient-to-t from-background-primary/40 to-transparent" })
|
|
11294
|
-
] }),
|
|
11295
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `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`, children: [
|
|
11296
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-3 mb-3", children: [
|
|
11297
|
-
icon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-10 h-10 text-[1.6em] rounded-xl bg-accent-primary/20 flex items-center justify-center shrink-0 text-accent-primary", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconRenderer, { iconName: icon }) }),
|
|
11298
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { className: "text-base font-black tracking-tight leading-tight !m-0", children: title })
|
|
11299
|
-
] }),
|
|
11300
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex-1 flex flex-col gap-2", children: [
|
|
11301
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-sm opacity-80 leading-relaxed font-medium", children: description }),
|
|
11302
|
-
directiveType === "card" && content && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mt-2", children: content })
|
|
11303
|
-
] }),
|
|
11304
|
-
(isModal || isLink) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mt-6 flex justify-end", children: isLink && url ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
11305
|
-
"a",
|
|
11306
|
-
{
|
|
11307
|
-
href: url,
|
|
11308
|
-
target: "_blank",
|
|
11309
|
-
rel: "noopener noreferrer",
|
|
11310
|
-
className: "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",
|
|
11311
|
-
onClick: (e) => e.stopPropagation(),
|
|
11312
|
-
children: [
|
|
11313
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconRenderer, { iconName: "open_in_new" }),
|
|
11314
|
-
" Link"
|
|
11315
|
-
]
|
|
11316
|
-
}
|
|
11317
|
-
) : isModal ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "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", children: [
|
|
11318
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconRenderer, { iconName: "arrow_forward" }),
|
|
11319
|
-
" Abrir"
|
|
11320
|
-
] }) : null })
|
|
11321
|
-
] })
|
|
11322
|
-
]
|
|
11323
|
-
}
|
|
11324
|
-
),
|
|
11325
|
-
isModal && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
11326
|
-
Modal,
|
|
11327
|
-
{
|
|
11328
|
-
title: title || "Detalles",
|
|
11329
|
-
isOpen: !!context.modals[modalId],
|
|
11330
|
-
onClose: () => context.setModals((prev) => ({ ...prev, [modalId]: false })),
|
|
11331
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "prose prose-sm max-w-none", children: content })
|
|
11332
|
-
}
|
|
11333
|
-
)
|
|
11334
|
-
] });
|
|
11301
|
+
// vanilla/directives/admonition.ts
|
|
11302
|
+
var admonitionDirective = ({ directiveType, props, renderSlot }) => {
|
|
11303
|
+
const el = createAdmonition(directiveType, props.title, props.icon);
|
|
11304
|
+
if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11305
|
+
if (props.style) el.setAttribute("style", props.style);
|
|
11306
|
+
const body = el.querySelector(".nr-admonition__body");
|
|
11307
|
+
if (body) {
|
|
11308
|
+
body.appendChild(renderSlot("default"));
|
|
11309
|
+
}
|
|
11310
|
+
return el;
|
|
11335
11311
|
};
|
|
11336
|
-
var
|
|
11312
|
+
var admonition_default = admonitionDirective;
|
|
11337
11313
|
|
|
11338
|
-
//
|
|
11339
|
-
var
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
11345
|
-
Details,
|
|
11346
|
-
{
|
|
11347
|
-
title: props.title || "Details",
|
|
11348
|
-
icon: props.icon,
|
|
11349
|
-
defaultOpen: props.defaultOpen === "true",
|
|
11350
|
-
className: props.class,
|
|
11351
|
-
style: props.style ? parseCssString(props.style) : void 0,
|
|
11352
|
-
children: renderSlot("default")
|
|
11353
|
-
}
|
|
11314
|
+
// vanilla/directives/details.ts
|
|
11315
|
+
var detailsDirective = ({ props, renderSlot }) => {
|
|
11316
|
+
const el = createDetails(
|
|
11317
|
+
props.title || "Details",
|
|
11318
|
+
props.icon,
|
|
11319
|
+
props.defaultOpen === "true"
|
|
11354
11320
|
);
|
|
11321
|
+
if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11322
|
+
if (props.style) el.setAttribute("style", props.style);
|
|
11323
|
+
const body = el.querySelector(".nr-details__body");
|
|
11324
|
+
if (body) {
|
|
11325
|
+
body.appendChild(renderSlot("default"));
|
|
11326
|
+
}
|
|
11327
|
+
return el;
|
|
11355
11328
|
};
|
|
11356
|
-
var
|
|
11329
|
+
var details_default = detailsDirective;
|
|
11357
11330
|
|
|
11358
|
-
//
|
|
11359
|
-
var
|
|
11360
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
11361
|
-
var ModalDirective = ({
|
|
11362
|
-
props,
|
|
11363
|
-
renderSlot,
|
|
11364
|
-
context
|
|
11365
|
-
}) => {
|
|
11366
|
-
const stableId = (0, import_react3.useId)();
|
|
11367
|
-
const modalId = `modal-${props.id || stableId}`;
|
|
11331
|
+
// vanilla/directives/modal.ts
|
|
11332
|
+
var modalDirective = ({ props, renderSlot }) => {
|
|
11368
11333
|
const label = props.label || props.title || "Open";
|
|
11369
11334
|
const modalTitle = props.title || "Modal";
|
|
11370
11335
|
const customClass = props.class || "";
|
|
11371
|
-
const
|
|
11372
|
-
|
|
11373
|
-
const
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
const
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
const
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
"
|
|
11383
|
-
}
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
11397
|
-
Modal,
|
|
11398
|
-
{
|
|
11399
|
-
title: modalTitle,
|
|
11400
|
-
isOpen: !!context.modals[modalId],
|
|
11401
|
-
onClose: handleClose,
|
|
11402
|
-
children: renderSlot("default")
|
|
11403
|
-
}
|
|
11404
|
-
)
|
|
11405
|
-
] });
|
|
11336
|
+
const wrapper = document.createElement("div");
|
|
11337
|
+
wrapper.className = "nr-modal-trigger";
|
|
11338
|
+
const btn = document.createElement("button");
|
|
11339
|
+
btn.className = `nr-button nr-button--default`;
|
|
11340
|
+
if (customClass) btn.classList.add(...customClass.split(/\s+/).filter(Boolean));
|
|
11341
|
+
const icon = props.icon || "open_in_new";
|
|
11342
|
+
if (icon) btn.appendChild(createIcon(icon));
|
|
11343
|
+
btn.appendChild(document.createTextNode(label));
|
|
11344
|
+
const dialog = createModal(modalTitle);
|
|
11345
|
+
const body = dialog.querySelector(".nr-modal__body");
|
|
11346
|
+
if (body) {
|
|
11347
|
+
body.appendChild(renderSlot("default"));
|
|
11348
|
+
}
|
|
11349
|
+
btn.addEventListener("click", () => {
|
|
11350
|
+
if (!dialog.open) {
|
|
11351
|
+
document.body.appendChild(dialog);
|
|
11352
|
+
dialog.showModal();
|
|
11353
|
+
dialog.addEventListener("close", () => {
|
|
11354
|
+
dialog.remove();
|
|
11355
|
+
}, { once: true });
|
|
11356
|
+
}
|
|
11357
|
+
});
|
|
11358
|
+
wrapper.appendChild(btn);
|
|
11359
|
+
wrapper.appendChild(dialog);
|
|
11360
|
+
return wrapper;
|
|
11406
11361
|
};
|
|
11407
|
-
var
|
|
11362
|
+
var modal_default = modalDirective;
|
|
11408
11363
|
|
|
11409
|
-
//
|
|
11410
|
-
var
|
|
11411
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
11412
|
-
var ButtonDirective = ({
|
|
11413
|
-
props,
|
|
11414
|
-
renderSlot
|
|
11415
|
-
}) => {
|
|
11364
|
+
// vanilla/directives/button.ts
|
|
11365
|
+
var buttonDirective = ({ props, renderSlot }) => {
|
|
11416
11366
|
const url = props.url || props.href || "#";
|
|
11417
11367
|
const label = props.label;
|
|
11418
11368
|
const icon = props.icon || "near_me";
|
|
11419
11369
|
const target = props.target || "_blank";
|
|
11420
11370
|
const customClass = props.class || "";
|
|
11421
|
-
const
|
|
11422
|
-
|
|
11423
|
-
const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
|
|
11424
|
-
const displayClass = hasDisplayClass ? "" : "inline-flex";
|
|
11425
|
-
const isInline = !customClass || !/\b(flex|block|grid)\b/.test(customClass) || /\binline-flex\b/.test(customClass);
|
|
11426
|
-
const marginClass = isInline ? "my-1 mx-1" : "my-4";
|
|
11427
|
-
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, " ");
|
|
11428
|
-
const btnClass = `${btnBase} ${customClass}`.trim();
|
|
11429
|
-
const positionMap = {
|
|
11430
|
-
"#left": "flex justify-start",
|
|
11431
|
-
"#center": "flex justify-center",
|
|
11432
|
-
"#right": "flex justify-end"
|
|
11433
|
-
};
|
|
11434
|
-
const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
|
|
11371
|
+
const wrapper = document.createElement("div");
|
|
11372
|
+
wrapper.className = "nr-button-wrap";
|
|
11435
11373
|
if (label) {
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
]
|
|
11447
|
-
}
|
|
11448
|
-
) });
|
|
11374
|
+
const a = document.createElement("a");
|
|
11375
|
+
a.href = url;
|
|
11376
|
+
a.target = target;
|
|
11377
|
+
a.rel = "noopener noreferrer";
|
|
11378
|
+
a.className = "nr-button nr-button--default";
|
|
11379
|
+
if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
|
|
11380
|
+
a.appendChild(createIcon(icon));
|
|
11381
|
+
a.appendChild(document.createTextNode(label));
|
|
11382
|
+
wrapper.appendChild(a);
|
|
11383
|
+
return wrapper;
|
|
11449
11384
|
}
|
|
11450
11385
|
const slotContent = renderSlot("default");
|
|
11451
|
-
const
|
|
11452
|
-
if (!element) return [];
|
|
11453
|
-
if (import_react4.default.isValidElement(element) && element.type === "a") {
|
|
11454
|
-
return [element];
|
|
11455
|
-
}
|
|
11456
|
-
if (Array.isArray(element)) {
|
|
11457
|
-
return element.flatMap(findLinks);
|
|
11458
|
-
}
|
|
11459
|
-
if (import_react4.default.isValidElement(element) && element.props.children) {
|
|
11460
|
-
return findLinks(element.props.children);
|
|
11461
|
-
}
|
|
11462
|
-
return [];
|
|
11463
|
-
};
|
|
11464
|
-
const links = findLinks(slotContent);
|
|
11386
|
+
const links = slotContent.querySelectorAll("a");
|
|
11465
11387
|
if (links.length > 0) {
|
|
11466
|
-
|
|
11467
|
-
(
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
)
|
|
11388
|
+
links.forEach((link) => {
|
|
11389
|
+
link.classList.add("nr-button", "nr-button--default");
|
|
11390
|
+
if (customClass) link.classList.add(...customClass.split(/\s+/).filter(Boolean));
|
|
11391
|
+
});
|
|
11392
|
+
wrapper.appendChild(slotContent);
|
|
11393
|
+
} else {
|
|
11394
|
+
const a = document.createElement("a");
|
|
11395
|
+
a.href = url;
|
|
11396
|
+
a.target = target;
|
|
11397
|
+
a.rel = "noopener noreferrer";
|
|
11398
|
+
a.className = "nr-button nr-button--default";
|
|
11399
|
+
if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
|
|
11400
|
+
a.appendChild(createIcon(icon));
|
|
11401
|
+
a.appendChild(slotContent);
|
|
11402
|
+
wrapper.appendChild(a);
|
|
11481
11403
|
}
|
|
11482
|
-
return
|
|
11483
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IconRenderer, { iconName: icon }),
|
|
11484
|
-
slotContent
|
|
11485
|
-
] }) });
|
|
11404
|
+
return wrapper;
|
|
11486
11405
|
};
|
|
11487
|
-
var
|
|
11406
|
+
var button_default = buttonDirective;
|
|
11488
11407
|
|
|
11489
|
-
//
|
|
11490
|
-
var
|
|
11491
|
-
|
|
11408
|
+
// vanilla/directives/card.ts
|
|
11409
|
+
var cardDirective = ({
|
|
11410
|
+
directiveType,
|
|
11492
11411
|
props,
|
|
11493
|
-
|
|
11412
|
+
slots,
|
|
11413
|
+
renderSlot,
|
|
11414
|
+
options
|
|
11494
11415
|
}) => {
|
|
11495
|
-
const
|
|
11496
|
-
const
|
|
11497
|
-
const
|
|
11498
|
-
const
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11416
|
+
const { title, image, icon, url, target } = props;
|
|
11417
|
+
const customClass = props.class || "";
|
|
11418
|
+
const hasDescription = !!slots.description;
|
|
11419
|
+
const { isSingleCard } = options || {};
|
|
11420
|
+
const isModal = directiveType === "card-m";
|
|
11421
|
+
const isLink = directiveType === "card-b";
|
|
11422
|
+
const inlineStyles = props.style ? parseCssString(props.style) : {};
|
|
11423
|
+
const card = document.createElement("div");
|
|
11424
|
+
card.className = `nr-card${isModal || isLink ? " nr-card--interactive" : ""} ${customClass}`.trim();
|
|
11425
|
+
for (const [key, value] of Object.entries(inlineStyles)) {
|
|
11426
|
+
card.style.setProperty(key, String(value));
|
|
11427
|
+
}
|
|
11428
|
+
if (image) {
|
|
11429
|
+
const imgWrap = document.createElement("div");
|
|
11430
|
+
imgWrap.className = `nr-card__image${isSingleCard ? " nr-card__image--tall" : ""}`;
|
|
11431
|
+
const img = document.createElement("img");
|
|
11432
|
+
img.src = image;
|
|
11433
|
+
img.alt = title || "";
|
|
11434
|
+
img.className = "nr-card__img";
|
|
11435
|
+
imgWrap.appendChild(img);
|
|
11436
|
+
const gradient = document.createElement("div");
|
|
11437
|
+
gradient.className = "nr-card__gradient";
|
|
11438
|
+
imgWrap.appendChild(gradient);
|
|
11439
|
+
card.appendChild(imgWrap);
|
|
11440
|
+
}
|
|
11441
|
+
const body = document.createElement("div");
|
|
11442
|
+
body.className = `nr-card__body${image ? " nr-card__body--overlap" : ""}`;
|
|
11443
|
+
if (icon || title) {
|
|
11444
|
+
const header = document.createElement("div");
|
|
11445
|
+
header.className = "nr-card__header";
|
|
11446
|
+
if (icon) {
|
|
11447
|
+
const iconWrap = document.createElement("div");
|
|
11448
|
+
iconWrap.className = "nr-card__icon-wrap";
|
|
11449
|
+
iconWrap.appendChild(createIcon(icon));
|
|
11450
|
+
header.appendChild(iconWrap);
|
|
11451
|
+
}
|
|
11452
|
+
if (title) {
|
|
11453
|
+
const h3 = document.createElement("h3");
|
|
11454
|
+
h3.className = "nr-card__title";
|
|
11455
|
+
h3.textContent = title;
|
|
11456
|
+
header.appendChild(h3);
|
|
11457
|
+
}
|
|
11458
|
+
body.appendChild(header);
|
|
11459
|
+
}
|
|
11460
|
+
if (hasDescription) {
|
|
11461
|
+
const desc = document.createElement("div");
|
|
11462
|
+
desc.className = "nr-card__description";
|
|
11463
|
+
desc.appendChild(renderSlot("description"));
|
|
11464
|
+
body.appendChild(desc);
|
|
11465
|
+
}
|
|
11466
|
+
if (directiveType === "card") {
|
|
11467
|
+
const contentSlot = renderSlot("content") || renderSlot("default");
|
|
11468
|
+
if (contentSlot.childNodes.length > 0) {
|
|
11469
|
+
const contentDiv = document.createElement("div");
|
|
11470
|
+
contentDiv.className = "nr-card__content";
|
|
11471
|
+
contentDiv.appendChild(contentSlot);
|
|
11472
|
+
body.appendChild(contentDiv);
|
|
11473
|
+
}
|
|
11474
|
+
}
|
|
11475
|
+
if (isModal || isLink) {
|
|
11476
|
+
const action = document.createElement("div");
|
|
11477
|
+
action.className = "nr-card__action";
|
|
11478
|
+
if (isLink && url) {
|
|
11479
|
+
const a = document.createElement("a");
|
|
11480
|
+
a.href = url;
|
|
11481
|
+
a.target = target || "_blank";
|
|
11482
|
+
a.rel = "noopener noreferrer";
|
|
11483
|
+
a.className = "nr-card__action-link";
|
|
11484
|
+
a.appendChild(createIcon("open_in_new"));
|
|
11485
|
+
a.appendChild(document.createTextNode(" Link"));
|
|
11486
|
+
action.appendChild(a);
|
|
11487
|
+
} else if (isModal) {
|
|
11488
|
+
const modalBtn = document.createElement("div");
|
|
11489
|
+
modalBtn.className = "nr-card__action-link";
|
|
11490
|
+
modalBtn.appendChild(createIcon("arrow_forward"));
|
|
11491
|
+
modalBtn.appendChild(document.createTextNode(" Abrir"));
|
|
11492
|
+
action.appendChild(modalBtn);
|
|
11493
|
+
}
|
|
11494
|
+
body.appendChild(action);
|
|
11495
|
+
}
|
|
11496
|
+
card.appendChild(body);
|
|
11497
|
+
if (isModal) {
|
|
11498
|
+
const dialog = createModal(title || "Detalles");
|
|
11499
|
+
const modalBody = dialog.querySelector(".nr-modal__body");
|
|
11500
|
+
if (modalBody) {
|
|
11501
|
+
const contentSlot = renderSlot("content") || renderSlot("default");
|
|
11502
|
+
modalBody.appendChild(contentSlot);
|
|
11503
|
+
}
|
|
11504
|
+
card.addEventListener("click", () => {
|
|
11505
|
+
if (!dialog.open) {
|
|
11506
|
+
document.body.appendChild(dialog);
|
|
11507
|
+
dialog.showModal();
|
|
11508
|
+
dialog.addEventListener("close", () => dialog.remove(), { once: true });
|
|
11509
|
+
}
|
|
11510
|
+
});
|
|
11511
|
+
const frag = document.createDocumentFragment();
|
|
11512
|
+
frag.appendChild(card);
|
|
11513
|
+
frag.appendChild(dialog);
|
|
11514
|
+
return frag;
|
|
11515
|
+
}
|
|
11516
|
+
if (isLink && url) {
|
|
11517
|
+
card.addEventListener("click", () => window.open(url, target || "_blank"));
|
|
11518
|
+
}
|
|
11519
|
+
return card;
|
|
11520
|
+
};
|
|
11521
|
+
var card_default = cardDirective;
|
|
11522
|
+
|
|
11523
|
+
// vanilla/directives/wrapper.ts
|
|
11524
|
+
var wrapperDirective = ({ props, renderSlot }) => {
|
|
11525
|
+
const el = document.createElement("div");
|
|
11526
|
+
el.className = "nr-wrapper";
|
|
11527
|
+
if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11528
|
+
if (props.id) el.id = props.id;
|
|
11529
|
+
if (props.style) {
|
|
11530
|
+
const styles = parseCssString(props.style);
|
|
11531
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
11532
|
+
el.style.setProperty(key, String(value));
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11502
11535
|
for (const [key, value] of Object.entries(props)) {
|
|
11503
11536
|
if (key.startsWith("data-")) {
|
|
11504
|
-
|
|
11537
|
+
el.setAttribute(key, value);
|
|
11505
11538
|
}
|
|
11506
11539
|
}
|
|
11507
|
-
|
|
11540
|
+
el.appendChild(renderSlot("default"));
|
|
11541
|
+
return el;
|
|
11508
11542
|
};
|
|
11509
|
-
var
|
|
11543
|
+
var wrapper_default = wrapperDirective;
|
|
11510
11544
|
|
|
11511
|
-
//
|
|
11512
|
-
var import_react5 = require("react");
|
|
11513
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
11545
|
+
// vanilla/directives/slide.ts
|
|
11514
11546
|
var slideCounter = 0;
|
|
11515
|
-
var
|
|
11547
|
+
var slideDirective = ({
|
|
11516
11548
|
props,
|
|
11517
|
-
|
|
11518
|
-
|
|
11549
|
+
slots,
|
|
11550
|
+
renderInline: renderInline2,
|
|
11551
|
+
renderMarkdown
|
|
11519
11552
|
}) => {
|
|
11520
11553
|
const rawContent = slots.default || "";
|
|
11521
11554
|
const lines = rawContent.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
11522
|
-
|
|
11523
|
-
|
|
11555
|
+
if (lines.length === 0) {
|
|
11556
|
+
return document.createDocumentFragment();
|
|
11557
|
+
}
|
|
11524
11558
|
const interval = parseInt(props.interval || "3000", 10);
|
|
11525
11559
|
const speed = parseInt(props.speed || "500", 10);
|
|
11526
|
-
const elRefs = (0, import_react5.useRef)([]);
|
|
11527
|
-
const [maxH, setMaxH] = (0, import_react5.useState)(0);
|
|
11528
|
-
(0, import_react5.useLayoutEffect)(() => {
|
|
11529
|
-
let h = 0;
|
|
11530
|
-
elRefs.current.forEach((el) => {
|
|
11531
|
-
if (el) h = Math.max(h, el.offsetHeight);
|
|
11532
|
-
});
|
|
11533
|
-
if (h > 0) setMaxH(h);
|
|
11534
|
-
}, [elements]);
|
|
11535
|
-
const cycle = (0, import_react5.useCallback)(() => {
|
|
11536
|
-
if (elements.length <= 1) return;
|
|
11537
|
-
setCurrent((prev) => (prev + 1) % elements.length);
|
|
11538
|
-
}, [elements.length]);
|
|
11539
|
-
(0, import_react5.useEffect)(() => {
|
|
11540
|
-
if (elements.length <= 1) return;
|
|
11541
|
-
const id = setInterval(cycle, interval);
|
|
11542
|
-
return () => clearInterval(id);
|
|
11543
|
-
}, [cycle, interval, elements.length]);
|
|
11544
|
-
if (elements.length === 0) return null;
|
|
11545
11560
|
const rawClass = props.class || "";
|
|
11546
11561
|
const inlineStyle = props.style ? parseCssString(props.style) : {};
|
|
11547
|
-
const textSizeMap = {
|
|
11548
|
-
"text-xs": "0.75rem",
|
|
11549
|
-
"text-sm": "0.875rem",
|
|
11550
|
-
"text-base": "1rem",
|
|
11551
|
-
"text-lg": "1.125rem",
|
|
11552
|
-
"text-xl": "1.25rem",
|
|
11553
|
-
"text-2xl": "1.5rem",
|
|
11554
|
-
"text-3xl": "1.875rem",
|
|
11555
|
-
"text-4xl": "2.25rem",
|
|
11556
|
-
"text-5xl": "3rem",
|
|
11557
|
-
"text-6xl": "3.75rem",
|
|
11558
|
-
"text-7xl": "4.5rem",
|
|
11559
|
-
"text-8xl": "6rem",
|
|
11560
|
-
"text-9xl": "8rem"
|
|
11561
|
-
};
|
|
11562
|
-
const textSizeMatch = rawClass.match(/\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/);
|
|
11563
|
-
const forcedFontSize = textSizeMatch ? textSizeMap[textSizeMatch[0]] : null;
|
|
11564
11562
|
const scopeClass = `sld-${++slideCounter}`;
|
|
11565
|
-
const
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
|
|
11586
|
-
{
|
|
11587
|
-
ref: (el) => {
|
|
11588
|
-
elRefs.current[i] = el;
|
|
11589
|
-
},
|
|
11590
|
-
style: maxH ? { height: maxH, display: "flex", alignItems: "center", overflow: "hidden" } : { display: "flex", alignItems: "center" },
|
|
11591
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${scopeClass} ${className}`, style: { width: "100%" }, children: context.processAndRenderElements(tokens) })
|
|
11592
|
-
},
|
|
11593
|
-
i
|
|
11594
|
-
))
|
|
11595
|
-
}
|
|
11596
|
-
)
|
|
11597
|
-
]
|
|
11563
|
+
const container = document.createElement("div");
|
|
11564
|
+
container.className = "nr-slide";
|
|
11565
|
+
Object.assign(container.style, {
|
|
11566
|
+
position: "relative",
|
|
11567
|
+
overflow: "hidden",
|
|
11568
|
+
...inlineStyle
|
|
11569
|
+
});
|
|
11570
|
+
const track = document.createElement("div");
|
|
11571
|
+
track.className = "nr-slide__track";
|
|
11572
|
+
track.style.transition = `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`;
|
|
11573
|
+
const slideEls = [];
|
|
11574
|
+
for (const line of lines) {
|
|
11575
|
+
const slideEl = document.createElement("div");
|
|
11576
|
+
slideEl.className = `nr-slide__item ${scopeClass} ${rawClass}`.trim();
|
|
11577
|
+
slideEl.style.display = "flex";
|
|
11578
|
+
slideEl.style.alignItems = "center";
|
|
11579
|
+
if (renderMarkdown) {
|
|
11580
|
+
const tokens = renderMarkdown(line);
|
|
11581
|
+
slideEl.appendChild(tokens);
|
|
11582
|
+
} else if (renderInline2) {
|
|
11583
|
+
slideEl.appendChild(renderInline2(line));
|
|
11598
11584
|
}
|
|
11599
|
-
|
|
11585
|
+
track.appendChild(slideEl);
|
|
11586
|
+
slideEls.push(slideEl);
|
|
11587
|
+
}
|
|
11588
|
+
container.appendChild(track);
|
|
11589
|
+
let current = 0;
|
|
11590
|
+
let maxH = 0;
|
|
11591
|
+
const measureAndSetHeight = () => {
|
|
11592
|
+
maxH = 0;
|
|
11593
|
+
for (const el of slideEls) {
|
|
11594
|
+
maxH = Math.max(maxH, el.offsetHeight);
|
|
11595
|
+
}
|
|
11596
|
+
if (maxH > 0) {
|
|
11597
|
+
container.style.height = `${maxH}px`;
|
|
11598
|
+
for (const el of slideEls) {
|
|
11599
|
+
el.style.height = `${maxH}px`;
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
};
|
|
11603
|
+
requestAnimationFrame(() => {
|
|
11604
|
+
measureAndSetHeight();
|
|
11605
|
+
if (document.fonts?.ready) {
|
|
11606
|
+
document.fonts.ready.then(measureAndSetHeight);
|
|
11607
|
+
}
|
|
11608
|
+
});
|
|
11609
|
+
if (lines.length > 1) {
|
|
11610
|
+
setInterval(() => {
|
|
11611
|
+
current = (current + 1) % lines.length;
|
|
11612
|
+
track.style.transform = `translateY(${-current * maxH}px)`;
|
|
11613
|
+
}, interval);
|
|
11614
|
+
}
|
|
11615
|
+
return container;
|
|
11600
11616
|
};
|
|
11601
|
-
var
|
|
11617
|
+
var slide_default = slideDirective;
|
|
11602
11618
|
|
|
11603
|
-
//
|
|
11619
|
+
// vanilla/directives/index.ts
|
|
11604
11620
|
var directiveRegistry = {
|
|
11605
11621
|
// Admonitions
|
|
11606
|
-
note:
|
|
11607
|
-
info:
|
|
11608
|
-
warning:
|
|
11609
|
-
danger:
|
|
11610
|
-
greentext:
|
|
11622
|
+
note: admonition_default,
|
|
11623
|
+
info: admonition_default,
|
|
11624
|
+
warning: admonition_default,
|
|
11625
|
+
danger: admonition_default,
|
|
11626
|
+
greentext: admonition_default,
|
|
11611
11627
|
// Cards
|
|
11612
|
-
card:
|
|
11613
|
-
"card-m":
|
|
11614
|
-
"card-b":
|
|
11628
|
+
card: card_default,
|
|
11629
|
+
"card-m": card_default,
|
|
11630
|
+
"card-b": card_default,
|
|
11615
11631
|
// Interactive
|
|
11616
|
-
details:
|
|
11617
|
-
modal:
|
|
11618
|
-
button:
|
|
11632
|
+
details: details_default,
|
|
11633
|
+
modal: modal_default,
|
|
11634
|
+
button: button_default,
|
|
11619
11635
|
// Layout / generic wrappers
|
|
11620
|
-
div:
|
|
11621
|
-
style:
|
|
11622
|
-
custom:
|
|
11623
|
-
raw:
|
|
11636
|
+
div: wrapper_default,
|
|
11637
|
+
style: wrapper_default,
|
|
11638
|
+
custom: wrapper_default,
|
|
11639
|
+
raw: wrapper_default,
|
|
11624
11640
|
// Animation
|
|
11625
|
-
slide:
|
|
11641
|
+
slide: slide_default
|
|
11626
11642
|
};
|
|
11627
11643
|
var directives_default = directiveRegistry;
|
|
11628
11644
|
|
|
11629
|
-
//
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11645
|
+
// vanilla/renderer.ts
|
|
11646
|
+
function renderTokens(tokens) {
|
|
11647
|
+
const article = document.createElement("article");
|
|
11648
|
+
article.className = "nr-prose";
|
|
11649
|
+
const ctx = {
|
|
11650
|
+
parseMarkdown,
|
|
11651
|
+
renderElements: (tks) => renderTokensInner(tks, ctx),
|
|
11652
|
+
renderInline,
|
|
11653
|
+
renderMarkdown: (md) => renderTokensInner(parseMarkdown(md), ctx)
|
|
11654
|
+
};
|
|
11655
|
+
article.appendChild(processElements(tokens, ctx, tokens));
|
|
11656
|
+
return article;
|
|
11657
|
+
}
|
|
11658
|
+
function renderMarkdownString(markdown2) {
|
|
11659
|
+
const tokens = parseMarkdown(markdown2);
|
|
11660
|
+
return renderTokens(tokens);
|
|
11661
|
+
}
|
|
11662
|
+
function renderHtmlString(html) {
|
|
11663
|
+
let processedContent = html;
|
|
11664
|
+
processedContent = processedContent.replace(
|
|
11665
|
+
/<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
|
|
11666
|
+
(_match, cssContent) => {
|
|
11667
|
+
const styleEl = document.createElement("style");
|
|
11668
|
+
styleEl.setAttribute("data-nr-global", "");
|
|
11669
|
+
styleEl.textContent = cssContent;
|
|
11670
|
+
document.head.appendChild(styleEl);
|
|
11671
|
+
return "";
|
|
11672
|
+
}
|
|
11673
|
+
);
|
|
11674
|
+
const wrapper = document.createElement("div");
|
|
11675
|
+
wrapper.className = "nr-raw-html";
|
|
11676
|
+
wrapper.innerHTML = processedContent;
|
|
11677
|
+
const scripts = wrapper.querySelectorAll("script");
|
|
11678
|
+
scripts.forEach((oldScript) => {
|
|
11679
|
+
const newScript = document.createElement("script");
|
|
11680
|
+
Array.from(oldScript.attributes).forEach(
|
|
11681
|
+
(attr) => newScript.setAttribute(attr.name, attr.value)
|
|
11682
|
+
);
|
|
11683
|
+
newScript.textContent = oldScript.textContent;
|
|
11684
|
+
oldScript.parentNode?.replaceChild(newScript, oldScript);
|
|
11685
|
+
});
|
|
11686
|
+
return wrapper;
|
|
11687
|
+
}
|
|
11688
|
+
function renderTokensInner(tokens, ctx) {
|
|
11689
|
+
const container = document.createElement("div");
|
|
11690
|
+
container.appendChild(processElements(tokens, ctx, tokens));
|
|
11691
|
+
return container;
|
|
11692
|
+
}
|
|
11693
|
+
function processElements(elements, ctx, allElements) {
|
|
11694
|
+
const fragment = document.createDocumentFragment();
|
|
11695
|
+
let i = 0;
|
|
11696
|
+
while (i < elements.length) {
|
|
11697
|
+
const el = elements[i];
|
|
11698
|
+
if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
|
|
11699
|
+
const cards = [];
|
|
11700
|
+
while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
|
|
11701
|
+
cards.push(elements[i]);
|
|
11702
|
+
i++;
|
|
11703
|
+
}
|
|
11704
|
+
if (cards.length === 1 || cards[0].props?.batch === "off") {
|
|
11705
|
+
for (const card of cards) {
|
|
11706
|
+
const rendered = renderElement(card, ctx, allElements);
|
|
11707
|
+
if (rendered) fragment.appendChild(rendered);
|
|
11708
|
+
}
|
|
11709
|
+
} else {
|
|
11710
|
+
const grid = document.createElement("div");
|
|
11711
|
+
grid.className = "nr-card-grid";
|
|
11712
|
+
for (const card of cards) {
|
|
11713
|
+
const rendered = renderElement(card, ctx, allElements);
|
|
11714
|
+
if (rendered) grid.appendChild(rendered);
|
|
11715
|
+
}
|
|
11716
|
+
fragment.appendChild(grid);
|
|
11717
|
+
}
|
|
11718
|
+
} else {
|
|
11719
|
+
const rendered = renderElement(el, ctx, allElements);
|
|
11720
|
+
if (rendered) fragment.appendChild(rendered);
|
|
11721
|
+
i++;
|
|
11722
|
+
}
|
|
11723
|
+
}
|
|
11724
|
+
return fragment;
|
|
11725
|
+
}
|
|
11726
|
+
function renderElement(element, ctx, allElements) {
|
|
11727
|
+
switch (element.type) {
|
|
11728
|
+
case "header": {
|
|
11729
|
+
const tag = `h${element.level}`;
|
|
11730
|
+
let text = element.text;
|
|
11731
|
+
const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
|
|
11732
|
+
const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
|
|
11733
|
+
if (alignCenter) text = alignCenter[1];
|
|
11734
|
+
else if (alignRight) text = alignRight[1];
|
|
11735
|
+
const h = document.createElement(tag);
|
|
11736
|
+
h.id = element.id;
|
|
11737
|
+
let cls = `md-h${element.level}`;
|
|
11738
|
+
if (alignCenter) cls += " text-center";
|
|
11739
|
+
if (alignRight) cls += " text-right";
|
|
11740
|
+
if (element.classes) cls += ` ${element.classes}`;
|
|
11741
|
+
h.className = cls;
|
|
11742
|
+
h.appendChild(renderInline(text));
|
|
11743
|
+
return h;
|
|
11744
|
+
}
|
|
11745
|
+
case "paragraph": {
|
|
11746
|
+
const p = document.createElement("p");
|
|
11747
|
+
let cls = "md-p";
|
|
11748
|
+
if (element.classes) cls += ` ${element.classes}`;
|
|
11749
|
+
if (element.align) cls += ` text-${element.align}`;
|
|
11750
|
+
p.className = cls;
|
|
11751
|
+
if (element.id) p.id = element.id;
|
|
11752
|
+
const lines = element.content.split("\n");
|
|
11753
|
+
for (let li = 0; li < lines.length; li++) {
|
|
11754
|
+
const line = lines[li];
|
|
11755
|
+
const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
|
|
11756
|
+
if (hardBreakMatch) {
|
|
11757
|
+
p.appendChild(renderInline(hardBreakMatch[1]));
|
|
11758
|
+
p.appendChild(document.createElement("br"));
|
|
11759
|
+
} else {
|
|
11760
|
+
p.appendChild(renderInline(line));
|
|
11761
|
+
if (li < lines.length - 1) {
|
|
11762
|
+
p.appendChild(document.createTextNode(" "));
|
|
11763
|
+
}
|
|
11764
|
+
}
|
|
11765
|
+
}
|
|
11766
|
+
return p;
|
|
11767
|
+
}
|
|
11768
|
+
case "codeblock":
|
|
11769
|
+
return createCodeBlock(element.content, element.language, element.title);
|
|
11770
|
+
case "directive":
|
|
11771
|
+
return renderDirective(element, ctx, allElements);
|
|
11772
|
+
case "html": {
|
|
11773
|
+
const el = element;
|
|
11774
|
+
return renderHtmlString(el.content);
|
|
11775
|
+
}
|
|
11776
|
+
case "html-block": {
|
|
11777
|
+
const htmlBlock = element;
|
|
11778
|
+
const rawProps = parseHtmlAttrs(htmlBlock.attrs);
|
|
11779
|
+
const el = document.createElement(htmlBlock.tag);
|
|
11780
|
+
for (const [key, value] of Object.entries(rawProps)) {
|
|
11781
|
+
if (key === "style" && typeof value === "object") {
|
|
11782
|
+
for (const [prop, val] of Object.entries(value)) {
|
|
11783
|
+
el.style.setProperty(prop, String(val));
|
|
11784
|
+
}
|
|
11785
|
+
} else if (value === true) {
|
|
11786
|
+
el.setAttribute(key, "");
|
|
11787
|
+
} else {
|
|
11788
|
+
el.setAttribute(key, String(value));
|
|
11789
|
+
}
|
|
11790
|
+
}
|
|
11791
|
+
const childFrag = processElements(htmlBlock.children, ctx, allElements);
|
|
11792
|
+
el.appendChild(childFrag);
|
|
11793
|
+
return el;
|
|
11794
|
+
}
|
|
11795
|
+
case "image": {
|
|
11796
|
+
const img = document.createElement("img");
|
|
11797
|
+
img.src = element.src;
|
|
11798
|
+
img.alt = element.alt;
|
|
11799
|
+
img.className = "nr-image";
|
|
11800
|
+
if (element.style) {
|
|
11801
|
+
for (const [key, value] of Object.entries(element.style)) {
|
|
11802
|
+
img.style.setProperty(key, String(value));
|
|
11803
|
+
}
|
|
11804
|
+
}
|
|
11805
|
+
return img;
|
|
11806
|
+
}
|
|
11807
|
+
case "table":
|
|
11808
|
+
return createTable(element.content, renderInline);
|
|
11809
|
+
case "list":
|
|
11810
|
+
return createList(element.content, renderInline);
|
|
11811
|
+
case "blockquote":
|
|
11812
|
+
return createBlockquote(element.content, element.classes, renderInline);
|
|
11813
|
+
case "hr": {
|
|
11814
|
+
const hr = document.createElement("hr");
|
|
11815
|
+
hr.className = "nr-hr";
|
|
11816
|
+
return hr;
|
|
11817
|
+
}
|
|
11818
|
+
case "toc": {
|
|
11819
|
+
const headers = allElements.filter((e) => e.type === "header");
|
|
11820
|
+
return createTOC(headers.map((h) => ({ level: h.level, text: h.text, id: h.id })), renderInline);
|
|
11821
|
+
}
|
|
11822
|
+
default:
|
|
11823
|
+
return null;
|
|
11824
|
+
}
|
|
11825
|
+
}
|
|
11826
|
+
function renderDirective(element, ctx, allElements) {
|
|
11637
11827
|
const { directiveType, props, slots, scopeId } = element;
|
|
11638
|
-
const
|
|
11828
|
+
const renderer = directives_default[directiveType];
|
|
11639
11829
|
const renderSlot = (name) => {
|
|
11830
|
+
const frag = document.createDocumentFragment();
|
|
11640
11831
|
const slotContent = slots[name];
|
|
11641
|
-
if (!slotContent) return
|
|
11642
|
-
const
|
|
11643
|
-
|
|
11832
|
+
if (!slotContent) return frag;
|
|
11833
|
+
const tokens = ctx.parseMarkdown(slotContent);
|
|
11834
|
+
frag.appendChild(ctx.renderElements(tokens));
|
|
11835
|
+
return frag;
|
|
11644
11836
|
};
|
|
11645
11837
|
const directiveProps = {
|
|
11646
11838
|
directiveType,
|
|
11647
11839
|
props,
|
|
11648
11840
|
slots,
|
|
11649
11841
|
renderSlot,
|
|
11650
|
-
context,
|
|
11651
|
-
index,
|
|
11652
|
-
allElements
|
|
11842
|
+
context: ctx,
|
|
11843
|
+
index: 0,
|
|
11844
|
+
allElements,
|
|
11845
|
+
renderInline,
|
|
11846
|
+
renderMarkdown: ctx.renderMarkdown
|
|
11653
11847
|
};
|
|
11654
|
-
if (
|
|
11655
|
-
return
|
|
11848
|
+
if (renderer) {
|
|
11849
|
+
return renderer(directiveProps);
|
|
11656
11850
|
}
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
var import_react7 = require("react");
|
|
11851
|
+
const fallback = document.createElement("div");
|
|
11852
|
+
fallback.className = "nr-unknown-directive";
|
|
11853
|
+
fallback.appendChild(renderSlot("default"));
|
|
11854
|
+
return fallback;
|
|
11855
|
+
}
|
|
11663
11856
|
|
|
11664
11857
|
// react/useTailwindCDN.ts
|
|
11665
|
-
var
|
|
11858
|
+
var import_react = require("react");
|
|
11666
11859
|
var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
|
|
11667
11860
|
var SCRIPT_ID = "tailwind-cdn-v4-runtime";
|
|
11668
11861
|
var CONFIG_ID = "tailwind-cdn-v4-config";
|
|
@@ -11675,8 +11868,8 @@ window.tailwind.config = {
|
|
|
11675
11868
|
};
|
|
11676
11869
|
`;
|
|
11677
11870
|
function useLazyTailwindCDN(enabled) {
|
|
11678
|
-
const loadedRef = (0,
|
|
11679
|
-
(0,
|
|
11871
|
+
const loadedRef = (0, import_react.useRef)(false);
|
|
11872
|
+
(0, import_react.useEffect)(() => {
|
|
11680
11873
|
if (!enabled) {
|
|
11681
11874
|
window.__twCDNRefs = (window.__twCDNRefs ?? 1) - 1;
|
|
11682
11875
|
if ((window.__twCDNRefs ?? 0) <= 0) {
|
|
@@ -11739,272 +11932,52 @@ function preloadTailwindCDN() {
|
|
|
11739
11932
|
}
|
|
11740
11933
|
}
|
|
11741
11934
|
|
|
11742
|
-
// react/RawHtmlRenderer.tsx
|
|
11743
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
11744
|
-
var RawHtmlRenderer = ({
|
|
11745
|
-
content,
|
|
11746
|
-
globalStyles,
|
|
11747
|
-
wrapperClassName
|
|
11748
|
-
}) => {
|
|
11749
|
-
const containerRef = (0, import_react7.useRef)(null);
|
|
11750
|
-
(0, import_react7.useEffect)(() => {
|
|
11751
|
-
if (!containerRef.current) return;
|
|
11752
|
-
const scripts = containerRef.current.querySelectorAll("script");
|
|
11753
|
-
scripts.forEach((oldScript) => {
|
|
11754
|
-
const newScript = document.createElement("script");
|
|
11755
|
-
Array.from(oldScript.attributes).forEach(
|
|
11756
|
-
(attr) => newScript.setAttribute(attr.name, attr.value)
|
|
11757
|
-
);
|
|
11758
|
-
newScript.textContent = oldScript.textContent;
|
|
11759
|
-
oldScript.parentNode?.replaceChild(newScript, oldScript);
|
|
11760
|
-
});
|
|
11761
|
-
scanTailwindCDN();
|
|
11762
|
-
}, [content]);
|
|
11763
|
-
(0, import_react7.useEffect)(() => {
|
|
11764
|
-
if (!globalStyles) return;
|
|
11765
|
-
const styleEl = document.createElement("style");
|
|
11766
|
-
styleEl.setAttribute("data-global", "");
|
|
11767
|
-
styleEl.textContent = globalStyles;
|
|
11768
|
-
document.head.appendChild(styleEl);
|
|
11769
|
-
return () => {
|
|
11770
|
-
if (styleEl.parentNode) document.head.removeChild(styleEl);
|
|
11771
|
-
};
|
|
11772
|
-
}, [globalStyles]);
|
|
11773
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: wrapperClassName, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { dangerouslySetInnerHTML: { __html: content } }) });
|
|
11774
|
-
};
|
|
11775
|
-
var RawHtmlRenderer_default = RawHtmlRenderer;
|
|
11776
|
-
|
|
11777
|
-
// react/context.tsx
|
|
11778
|
-
var import_react8 = require("react");
|
|
11779
|
-
var RenderCtx = (0, import_react8.createContext)(null);
|
|
11780
|
-
var RenderContextProvider = RenderCtx.Provider;
|
|
11781
|
-
|
|
11782
11935
|
// react/CustomMarkdownRenderer.tsx
|
|
11783
|
-
var
|
|
11784
|
-
var CustomMarkdownRenderer = ({ content
|
|
11785
|
-
const
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11936
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
11937
|
+
var CustomMarkdownRenderer = ({ content }) => {
|
|
11938
|
+
const containerRef = (0, import_react2.useRef)(null);
|
|
11939
|
+
(0, import_react2.useEffect)(() => {
|
|
11940
|
+
const container = containerRef.current;
|
|
11941
|
+
if (!container) return;
|
|
11942
|
+
container.replaceChildren();
|
|
11943
|
+
container.appendChild(renderMarkdownString(content));
|
|
11944
|
+
scanTailwindCDN();
|
|
11792
11945
|
const handleHashChange = () => {
|
|
11793
11946
|
const hash = window.location.hash;
|
|
11794
11947
|
if (hash) {
|
|
11795
11948
|
const parts = hash.split("#");
|
|
11796
|
-
|
|
11797
|
-
scrollToId(id);
|
|
11949
|
+
scrollToId(parts[parts.length - 1]);
|
|
11798
11950
|
}
|
|
11799
11951
|
};
|
|
11800
11952
|
handleHashChange();
|
|
11801
11953
|
window.addEventListener("hashchange", handleHashChange);
|
|
11802
11954
|
return () => window.removeEventListener("hashchange", handleHashChange);
|
|
11803
|
-
}, [
|
|
11804
|
-
|
|
11805
|
-
(element, index, _depth = 0) => {
|
|
11806
|
-
switch (element.type) {
|
|
11807
|
-
case "header": {
|
|
11808
|
-
const HeaderTag = `h${element.level}`;
|
|
11809
|
-
let text = element.text;
|
|
11810
|
-
const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
|
|
11811
|
-
const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
|
|
11812
|
-
if (alignCenter) {
|
|
11813
|
-
text = alignCenter[1];
|
|
11814
|
-
} else if (alignRight) {
|
|
11815
|
-
text = alignRight[1];
|
|
11816
|
-
}
|
|
11817
|
-
const userClasses = element.classes || "";
|
|
11818
|
-
let headerClasses = `md-h${element.level}`;
|
|
11819
|
-
if (alignCenter) headerClasses += " text-center";
|
|
11820
|
-
if (alignRight) headerClasses += " text-right";
|
|
11821
|
-
if (userClasses) headerClasses += ` ${userClasses}`;
|
|
11822
|
-
return import_react9.default.createElement(
|
|
11823
|
-
HeaderTag,
|
|
11824
|
-
{ key: index, id: element.id, className: headerClasses },
|
|
11825
|
-
renderInline(text)
|
|
11826
|
-
);
|
|
11827
|
-
}
|
|
11828
|
-
case "paragraph": {
|
|
11829
|
-
const lines = element.content.split("\n");
|
|
11830
|
-
const processedContent = lines.map((line, lineIndex) => {
|
|
11831
|
-
const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
|
|
11832
|
-
if (hardBreakMatch) {
|
|
11833
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react9.default.Fragment, { children: [
|
|
11834
|
-
renderInline(hardBreakMatch[1]),
|
|
11835
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("br", {})
|
|
11836
|
-
] }, lineIndex);
|
|
11837
|
-
}
|
|
11838
|
-
const isLastLine = lineIndex === lines.length - 1;
|
|
11839
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react9.default.Fragment, { children: [
|
|
11840
|
-
renderInline(line),
|
|
11841
|
-
!isLastLine && " "
|
|
11842
|
-
] }, lineIndex);
|
|
11843
|
-
});
|
|
11844
|
-
const pUserClasses = element.classes || "";
|
|
11845
|
-
let pClasses = "md-p";
|
|
11846
|
-
if (pUserClasses) pClasses += ` ${pUserClasses}`;
|
|
11847
|
-
if (element.align) pClasses += ` text-${element.align}`;
|
|
11848
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { id: element.id, className: pClasses, children: processedContent }, index);
|
|
11849
|
-
}
|
|
11850
|
-
case "codeblock":
|
|
11851
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
11852
|
-
CodeBlock,
|
|
11853
|
-
{
|
|
11854
|
-
code: element.content,
|
|
11855
|
-
language: element.language,
|
|
11856
|
-
title: element.title
|
|
11857
|
-
},
|
|
11858
|
-
index
|
|
11859
|
-
);
|
|
11860
|
-
case "directive":
|
|
11861
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
11862
|
-
DirectiveRenderer_default,
|
|
11863
|
-
{
|
|
11864
|
-
element,
|
|
11865
|
-
context: contextRef.current,
|
|
11866
|
-
index,
|
|
11867
|
-
allElements
|
|
11868
|
-
},
|
|
11869
|
-
index
|
|
11870
|
-
);
|
|
11871
|
-
case "html": {
|
|
11872
|
-
let processedContent = element.content;
|
|
11873
|
-
let globalStyles = "";
|
|
11874
|
-
processedContent = processedContent.replace(
|
|
11875
|
-
/<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
|
|
11876
|
-
(_match, cssContent) => {
|
|
11877
|
-
globalStyles += cssContent + "\n";
|
|
11878
|
-
return "";
|
|
11879
|
-
}
|
|
11880
|
-
);
|
|
11881
|
-
const wrapperClassName = "w-full my-4";
|
|
11882
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
11883
|
-
RawHtmlRenderer_default,
|
|
11884
|
-
{
|
|
11885
|
-
content: processedContent,
|
|
11886
|
-
globalStyles: globalStyles || void 0,
|
|
11887
|
-
wrapperClassName
|
|
11888
|
-
},
|
|
11889
|
-
index
|
|
11890
|
-
);
|
|
11891
|
-
}
|
|
11892
|
-
case "html-block": {
|
|
11893
|
-
const htmlBlock = element;
|
|
11894
|
-
const rawProps = parseHtmlAttrs(htmlBlock.attrs);
|
|
11895
|
-
const props = {};
|
|
11896
|
-
for (const [key, value] of Object.entries(rawProps)) {
|
|
11897
|
-
if (key === "class") props["className"] = value;
|
|
11898
|
-
else if (key === "for") props["htmlFor"] = value;
|
|
11899
|
-
else if (key === "tabindex") props["tabIndex"] = value;
|
|
11900
|
-
else props[key] = value;
|
|
11901
|
-
}
|
|
11902
|
-
return import_react9.default.createElement(
|
|
11903
|
-
htmlBlock.tag,
|
|
11904
|
-
{ key: index, ...props },
|
|
11905
|
-
...processAndRenderElements(htmlBlock.children, _depth + 1)
|
|
11906
|
-
);
|
|
11907
|
-
}
|
|
11908
|
-
case "image":
|
|
11909
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
11910
|
-
"img",
|
|
11911
|
-
{
|
|
11912
|
-
alt: element.alt,
|
|
11913
|
-
src: element.src,
|
|
11914
|
-
style: element.style,
|
|
11915
|
-
className: "max-w-full h-auto"
|
|
11916
|
-
},
|
|
11917
|
-
index
|
|
11918
|
-
);
|
|
11919
|
-
case "table":
|
|
11920
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: renderTable(element.content) }, index);
|
|
11921
|
-
case "list":
|
|
11922
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: renderList(element.content) }, index);
|
|
11923
|
-
case "blockquote":
|
|
11924
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("blockquote", { className: `border-l-4 border-accent-primary/30 pl-4 italic text-text-secondary my-4 text-sm sm:text-base${element.classes ? ` ${element.classes}` : ""}`, children: renderInline(element.content) }, index);
|
|
11925
|
-
case "hr":
|
|
11926
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("hr", { className: "my-8 border-border" }, index);
|
|
11927
|
-
case "toc":
|
|
11928
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: generateToc(allElements) }, index);
|
|
11929
|
-
default:
|
|
11930
|
-
return null;
|
|
11931
|
-
}
|
|
11932
|
-
},
|
|
11933
|
-
[allElements]
|
|
11934
|
-
);
|
|
11935
|
-
const processAndRenderElements = (0, import_react9.useCallback)(
|
|
11936
|
-
(elements, depth = 0) => {
|
|
11937
|
-
const result = [];
|
|
11938
|
-
let i = 0;
|
|
11939
|
-
while (i < elements.length) {
|
|
11940
|
-
const el = elements[i];
|
|
11941
|
-
if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
|
|
11942
|
-
const cards = [];
|
|
11943
|
-
while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
|
|
11944
|
-
cards.push(elements[i]);
|
|
11945
|
-
i++;
|
|
11946
|
-
}
|
|
11947
|
-
if (cards.length === 1 || cards[0].props?.batch === "off") {
|
|
11948
|
-
for (let c = 0; c < cards.length; c++) {
|
|
11949
|
-
result.push(renderElement(cards[c], result.length, depth));
|
|
11950
|
-
}
|
|
11951
|
-
} else {
|
|
11952
|
-
const firstCardClass = cards[0].props?.["class"] || "";
|
|
11953
|
-
const justifyClasses = firstCardClass.match(/\bjustify-\S+/g) || [];
|
|
11954
|
-
const wrapperJustify = justifyClasses.length > 0 ? justifyClasses.join(" ") : "";
|
|
11955
|
-
result.push(
|
|
11956
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `not-prose flex flex-wrap gap-6 my-6 ${wrapperJustify}`, children: cards.map((card, ci) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react9.default.Fragment, { children: renderElement(card, ci, depth) }, ci)) }, `card-grid-${result.length}`)
|
|
11957
|
-
);
|
|
11958
|
-
}
|
|
11959
|
-
} else {
|
|
11960
|
-
result.push(renderElement(el, result.length, depth));
|
|
11961
|
-
i++;
|
|
11962
|
-
}
|
|
11963
|
-
}
|
|
11964
|
-
return result;
|
|
11965
|
-
},
|
|
11966
|
-
[renderElement]
|
|
11967
|
-
);
|
|
11968
|
-
const generateToc = (elements) => {
|
|
11969
|
-
const headers = extractHeaders(elements);
|
|
11970
|
-
if (headers.length === 0) return null;
|
|
11971
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("nav", { className: "not-prose my-6 p-4 rounded-2xl border border-border bg-background-primary/5", children: [
|
|
11972
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-base font-bold mb-3", children: "Table of Contents" }),
|
|
11973
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: "space-y-1 list-none p-0 m-0", children: headers.map((h, i) => {
|
|
11974
|
-
if (h.type !== "header") return null;
|
|
11975
|
-
const indentClass = h.level <= 2 ? "pl-0" : h.level === 3 ? "pl-4" : h.level === 4 ? "pl-8" : "pl-12";
|
|
11976
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { className: `${indentClass} text-sm sm:text-base`, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
11977
|
-
"a",
|
|
11978
|
-
{
|
|
11979
|
-
href: `#${h.id}`,
|
|
11980
|
-
className: "text-accent-primary hover:text-accent-primary/80 no-underline hover:underline transition-colors",
|
|
11981
|
-
onClick: (e) => {
|
|
11982
|
-
e.preventDefault();
|
|
11983
|
-
scrollToId(h.id);
|
|
11984
|
-
},
|
|
11985
|
-
children: renderInline(h.text.replace(/->|<-/g, "").trim())
|
|
11986
|
-
}
|
|
11987
|
-
) }, i);
|
|
11988
|
-
}) })
|
|
11989
|
-
] });
|
|
11990
|
-
};
|
|
11991
|
-
const contextForDirectives = {
|
|
11992
|
-
modals,
|
|
11993
|
-
setModals,
|
|
11994
|
-
articleClass,
|
|
11995
|
-
allElements,
|
|
11996
|
-
parseMarkdown,
|
|
11997
|
-
renderElement,
|
|
11998
|
-
renderInline,
|
|
11999
|
-
processAndRenderElements
|
|
12000
|
-
};
|
|
12001
|
-
contextRef.current = contextForDirectives;
|
|
12002
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RenderContextProvider, { value: contextForDirectives, children: processAndRenderElements(allElements) });
|
|
11955
|
+
}, [content]);
|
|
11956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: containerRef });
|
|
12003
11957
|
};
|
|
12004
11958
|
var CustomMarkdownRenderer_default = CustomMarkdownRenderer;
|
|
12005
11959
|
|
|
11960
|
+
// react/RawHtmlRenderer.tsx
|
|
11961
|
+
var import_react3 = require("react");
|
|
11962
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
11963
|
+
var RawHtmlRenderer = ({
|
|
11964
|
+
content,
|
|
11965
|
+
wrapperClassName = "nr-raw-html"
|
|
11966
|
+
}) => {
|
|
11967
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
11968
|
+
(0, import_react3.useEffect)(() => {
|
|
11969
|
+
const container = containerRef.current;
|
|
11970
|
+
if (!container) return;
|
|
11971
|
+
container.replaceChildren();
|
|
11972
|
+
container.appendChild(renderHtmlString(content));
|
|
11973
|
+
scanTailwindCDN();
|
|
11974
|
+
}, [content]);
|
|
11975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: containerRef, className: wrapperClassName });
|
|
11976
|
+
};
|
|
11977
|
+
var RawHtmlRenderer_default = RawHtmlRenderer;
|
|
11978
|
+
|
|
12006
11979
|
// react/NRpreviewer.tsx
|
|
12007
|
-
var
|
|
11980
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
12008
11981
|
var NRpreviewer = ({
|
|
12009
11982
|
content,
|
|
12010
11983
|
html,
|
|
@@ -12013,21 +11986,22 @@ var NRpreviewer = ({
|
|
|
12013
11986
|
style
|
|
12014
11987
|
}) => {
|
|
12015
11988
|
useLazyTailwindCDN(tailwindCDN);
|
|
11989
|
+
const wrapperClass = `nr-prose${className ? ` ${className}` : ""}`;
|
|
12016
11990
|
if (content) {
|
|
12017
|
-
return /* @__PURE__ */ (0,
|
|
11991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: wrapperClass, style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CustomMarkdownRenderer_default, { content }) });
|
|
12018
11992
|
}
|
|
12019
11993
|
if (html) {
|
|
12020
|
-
return /* @__PURE__ */ (0,
|
|
11994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: wrapperClass, style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RawHtmlRenderer_default, { content: html }) });
|
|
12021
11995
|
}
|
|
12022
11996
|
return null;
|
|
12023
11997
|
};
|
|
12024
11998
|
var NRpreviewer_default = NRpreviewer;
|
|
12025
11999
|
|
|
12026
12000
|
// react/useDebounce.ts
|
|
12027
|
-
var
|
|
12001
|
+
var import_react4 = require("react");
|
|
12028
12002
|
function useDebounce(value, delay) {
|
|
12029
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
12030
|
-
(0,
|
|
12003
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react4.useState)(value);
|
|
12004
|
+
(0, import_react4.useEffect)(() => {
|
|
12031
12005
|
const timer = setTimeout(() => setDebouncedValue(value), delay);
|
|
12032
12006
|
return () => clearTimeout(timer);
|
|
12033
12007
|
}, [value, delay]);
|
|
@@ -12035,15 +12009,10 @@ function useDebounce(value, delay) {
|
|
|
12035
12009
|
}
|
|
12036
12010
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12037
12011
|
0 && (module.exports = {
|
|
12038
|
-
Admonition,
|
|
12039
|
-
CodeBlock,
|
|
12040
12012
|
CustomMarkdownRenderer,
|
|
12041
|
-
Details,
|
|
12042
|
-
IconRenderer,
|
|
12043
|
-
Modal,
|
|
12044
12013
|
NRpreviewer,
|
|
12014
|
+
RawHtmlRenderer,
|
|
12045
12015
|
extractAttributes,
|
|
12046
|
-
extractHeaders,
|
|
12047
12016
|
generateId,
|
|
12048
12017
|
generateScopeId,
|
|
12049
12018
|
parseCssString,
|