@noirmd/previewer 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vanilla.cjs CHANGED
@@ -1582,6 +1582,9 @@ __export(vanilla_exports, {
1582
1582
  createTOC: () => createTOC,
1583
1583
  createTable: () => createTable,
1584
1584
  directiveRegistry: () => directives_default,
1585
+ hasHostTheme: () => hasHostTheme,
1586
+ injectNRTailwindTheme: () => injectNRTailwindTheme,
1587
+ removeNRTailwindTheme: () => removeNRTailwindTheme,
1585
1588
  renderHtmlString: () => renderHtmlString,
1586
1589
  renderInline: () => renderInline,
1587
1590
  renderMarkdownString: () => renderMarkdownString,
@@ -11329,7 +11332,10 @@ var modalDirective = ({ props, renderSlot }) => {
11329
11332
  const dialog = createModal(modalTitle);
11330
11333
  const body = dialog.querySelector(".nr-modal__body");
11331
11334
  if (body) {
11332
- body.appendChild(renderSlot("default"));
11335
+ const prose = document.createElement("div");
11336
+ prose.className = "nr-prose";
11337
+ prose.appendChild(renderSlot("default"));
11338
+ body.appendChild(prose);
11333
11339
  }
11334
11340
  btn.addEventListener("click", () => {
11335
11341
  if (!dialog.open) {
@@ -11483,8 +11489,10 @@ var cardDirective = ({
11483
11489
  const dialog = createModal(title || "Detalles");
11484
11490
  const modalBody = dialog.querySelector(".nr-modal__body");
11485
11491
  if (modalBody) {
11486
- const contentSlot = renderSlot("content") || renderSlot("default");
11487
- modalBody.appendChild(contentSlot);
11492
+ const prose = document.createElement("div");
11493
+ prose.className = "nr-prose";
11494
+ prose.appendChild(renderSlot("content") || renderSlot("default"));
11495
+ modalBody.appendChild(prose);
11488
11496
  }
11489
11497
  card.addEventListener("click", () => {
11490
11498
  if (!dialog.open) {
@@ -11838,6 +11846,73 @@ function renderDirective(element, ctx, allElements) {
11838
11846
  fallback.appendChild(renderSlot("default"));
11839
11847
  return fallback;
11840
11848
  }
11849
+
11850
+ // vanilla/tailwindTheme.ts
11851
+ var THEME_STYLE_ID = "nr-tailwind-theme";
11852
+ var NR_THEME_CSS = `
11853
+ @theme {
11854
+ --color-primary: var(--color-accent-primary, oklch(var(--p, 55% 0.3 240) / 1));
11855
+ --color-primary-content: #ffffff;
11856
+ --color-secondary: oklch(var(--s, 55% 0.25 200) / 1);
11857
+ --color-secondary-content: #ffffff;
11858
+ --color-accent: var(--color-accent-primary, oklch(var(--a, 65% 0.25 160) / 1));
11859
+ --color-accent-content: #ffffff;
11860
+ --color-neutral: oklch(var(--n, 50% 0.05 240) / 1);
11861
+ --color-neutral-content: var(--color-text-primary, oklch(var(--nc, 92% 0.02 240) / 1));
11862
+ --color-base-100: var(--color-background-primary, oklch(var(--b1, 15% 0.01 260) / 1));
11863
+ --color-base-200: var(--color-background-secondary-solid, oklch(var(--b2, 20% 0.02 260) / 1));
11864
+ --color-base-300: var(--color-border, oklch(var(--b3, 25% 0.03 260) / 1));
11865
+ --color-base-content: var(--color-text-primary, oklch(var(--bc, 92% 0.02 260) / 1));
11866
+ --color-info: oklch(var(--in, 70% 0.2 220) / 1);
11867
+ --color-info-content: #ffffff;
11868
+ --color-success: oklch(var(--su, 65% 0.25 140) / 1);
11869
+ --color-success-content: #ffffff;
11870
+ --color-warning: oklch(var(--wa, 80% 0.25 80) / 1);
11871
+ --color-warning-content: #1f2937;
11872
+ --color-error: oklch(var(--er, 65% 0.3 30) / 1);
11873
+ --color-error-content: #ffffff;
11874
+ }
11875
+ `;
11876
+ function getVar(root, name) {
11877
+ return getComputedStyle(root).getPropertyValue(name).trim();
11878
+ }
11879
+ function stylesheetHasTheme() {
11880
+ for (const sheet of Array.from(document.styleSheets)) {
11881
+ let rules = null;
11882
+ try {
11883
+ rules = sheet.cssRules;
11884
+ } catch {
11885
+ continue;
11886
+ }
11887
+ if (!rules) continue;
11888
+ for (const rule of Array.from(rules)) {
11889
+ const css2 = rule.cssText || "";
11890
+ if (css2.includes("@theme") || css2.includes('@plugin "daisyui"')) return true;
11891
+ }
11892
+ }
11893
+ return false;
11894
+ }
11895
+ function hasHostTheme() {
11896
+ if (typeof window === "undefined" || typeof document === "undefined") return true;
11897
+ if (getVar(document.documentElement, "--color-primary")) return true;
11898
+ if (getVar(document.documentElement, "--color-base-100")) return true;
11899
+ if (document.body && (getVar(document.body, "--color-primary") || getVar(document.body, "--color-base-100"))) return true;
11900
+ return stylesheetHasTheme();
11901
+ }
11902
+ function injectNRTailwindTheme() {
11903
+ if (typeof document === "undefined") return;
11904
+ if (document.getElementById(THEME_STYLE_ID)) return;
11905
+ if (hasHostTheme()) return;
11906
+ const style = document.createElement("style");
11907
+ style.id = THEME_STYLE_ID;
11908
+ style.setAttribute("type", "text/tailwindcss");
11909
+ style.textContent = NR_THEME_CSS;
11910
+ document.head.appendChild(style);
11911
+ }
11912
+ function removeNRTailwindTheme() {
11913
+ if (typeof document === "undefined") return;
11914
+ document.getElementById(THEME_STYLE_ID)?.remove();
11915
+ }
11841
11916
  // Annotate the CommonJS export names for ESM import in node:
11842
11917
  0 && (module.exports = {
11843
11918
  createAdmonition,
@@ -11850,6 +11925,9 @@ function renderDirective(element, ctx, allElements) {
11850
11925
  createTOC,
11851
11926
  createTable,
11852
11927
  directiveRegistry,
11928
+ hasHostTheme,
11929
+ injectNRTailwindTheme,
11930
+ removeNRTailwindTheme,
11853
11931
  renderHtmlString,
11854
11932
  renderInline,
11855
11933
  renderMarkdownString,