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