@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/NReditor.cjs CHANGED
@@ -349,6 +349,75 @@ function useDebounce(value, delay) {
349
349
 
350
350
  // react/useTailwindCDN.ts
351
351
  var import_react2 = require("react");
352
+
353
+ // vanilla/tailwindTheme.ts
354
+ var THEME_STYLE_ID = "nr-tailwind-theme";
355
+ var NR_THEME_CSS = `
356
+ @theme {
357
+ --color-primary: var(--color-accent-primary, oklch(var(--p, 55% 0.3 240) / 1));
358
+ --color-primary-content: #ffffff;
359
+ --color-secondary: oklch(var(--s, 55% 0.25 200) / 1);
360
+ --color-secondary-content: #ffffff;
361
+ --color-accent: var(--color-accent-primary, oklch(var(--a, 65% 0.25 160) / 1));
362
+ --color-accent-content: #ffffff;
363
+ --color-neutral: oklch(var(--n, 50% 0.05 240) / 1);
364
+ --color-neutral-content: var(--color-text-primary, oklch(var(--nc, 92% 0.02 240) / 1));
365
+ --color-base-100: var(--color-background-primary, oklch(var(--b1, 15% 0.01 260) / 1));
366
+ --color-base-200: var(--color-background-secondary-solid, oklch(var(--b2, 20% 0.02 260) / 1));
367
+ --color-base-300: var(--color-border, oklch(var(--b3, 25% 0.03 260) / 1));
368
+ --color-base-content: var(--color-text-primary, oklch(var(--bc, 92% 0.02 260) / 1));
369
+ --color-info: oklch(var(--in, 70% 0.2 220) / 1);
370
+ --color-info-content: #ffffff;
371
+ --color-success: oklch(var(--su, 65% 0.25 140) / 1);
372
+ --color-success-content: #ffffff;
373
+ --color-warning: oklch(var(--wa, 80% 0.25 80) / 1);
374
+ --color-warning-content: #1f2937;
375
+ --color-error: oklch(var(--er, 65% 0.3 30) / 1);
376
+ --color-error-content: #ffffff;
377
+ }
378
+ `;
379
+ function getVar(root, name) {
380
+ return getComputedStyle(root).getPropertyValue(name).trim();
381
+ }
382
+ function stylesheetHasTheme() {
383
+ for (const sheet of Array.from(document.styleSheets)) {
384
+ let rules = null;
385
+ try {
386
+ rules = sheet.cssRules;
387
+ } catch {
388
+ continue;
389
+ }
390
+ if (!rules) continue;
391
+ for (const rule of Array.from(rules)) {
392
+ const css2 = rule.cssText || "";
393
+ if (css2.includes("@theme") || css2.includes('@plugin "daisyui"')) return true;
394
+ }
395
+ }
396
+ return false;
397
+ }
398
+ function hasHostTheme() {
399
+ if (typeof window === "undefined" || typeof document === "undefined") return true;
400
+ if (getVar(document.documentElement, "--color-primary")) return true;
401
+ if (getVar(document.documentElement, "--color-base-100")) return true;
402
+ if (document.body && (getVar(document.body, "--color-primary") || getVar(document.body, "--color-base-100"))) return true;
403
+ return stylesheetHasTheme();
404
+ }
405
+ function injectNRTailwindTheme() {
406
+ if (typeof document === "undefined") return;
407
+ if (document.getElementById(THEME_STYLE_ID)) return;
408
+ if (hasHostTheme()) return;
409
+ const style = document.createElement("style");
410
+ style.id = THEME_STYLE_ID;
411
+ style.setAttribute("type", "text/tailwindcss");
412
+ style.textContent = NR_THEME_CSS;
413
+ document.head.appendChild(style);
414
+ }
415
+ function removeNRTailwindTheme() {
416
+ if (typeof document === "undefined") return;
417
+ document.getElementById(THEME_STYLE_ID)?.remove();
418
+ }
419
+
420
+ // react/useTailwindCDN.ts
352
421
  var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
353
422
  var SCRIPT_ID = "tailwind-cdn-v4-runtime";
354
423
  var CONFIG_ID = "tailwind-cdn-v4-config";
@@ -368,6 +437,7 @@ function useLazyTailwindCDN(enabled) {
368
437
  if ((window.__twCDNRefs ?? 0) <= 0) {
369
438
  document.getElementById(SCRIPT_ID)?.remove();
370
439
  document.getElementById(CONFIG_ID)?.remove();
440
+ removeNRTailwindTheme();
371
441
  window.__twCDNRefs = 0;
372
442
  loadedRef.current = false;
373
443
  }
@@ -380,6 +450,7 @@ function useLazyTailwindCDN(enabled) {
380
450
  configScript.textContent = TAILWIND_CDN_CONFIG;
381
451
  document.head.appendChild(configScript);
382
452
  }
453
+ injectNRTailwindTheme();
383
454
  if (!document.getElementById(SCRIPT_ID)) {
384
455
  const script = document.createElement("script");
385
456
  script.id = SCRIPT_ID;
@@ -392,6 +463,7 @@ function useLazyTailwindCDN(enabled) {
392
463
  if ((window.__twCDNRefs ?? 0) <= 0) {
393
464
  document.getElementById(SCRIPT_ID)?.remove();
394
465
  document.getElementById(CONFIG_ID)?.remove();
466
+ removeNRTailwindTheme();
395
467
  window.__twCDNRefs = 0;
396
468
  loadedRef.current = false;
397
469
  }
@@ -1282,7 +1354,10 @@ var modalDirective = ({ props, renderSlot }) => {
1282
1354
  const dialog = createModal(modalTitle);
1283
1355
  const body = dialog.querySelector(".nr-modal__body");
1284
1356
  if (body) {
1285
- body.appendChild(renderSlot("default"));
1357
+ const prose = document.createElement("div");
1358
+ prose.className = "nr-prose";
1359
+ prose.appendChild(renderSlot("default"));
1360
+ body.appendChild(prose);
1286
1361
  }
1287
1362
  btn.addEventListener("click", () => {
1288
1363
  if (!dialog.open) {
@@ -1436,8 +1511,10 @@ var cardDirective = ({
1436
1511
  const dialog = createModal(title || "Detalles");
1437
1512
  const modalBody = dialog.querySelector(".nr-modal__body");
1438
1513
  if (modalBody) {
1439
- const contentSlot = renderSlot("content") || renderSlot("default");
1440
- modalBody.appendChild(contentSlot);
1514
+ const prose = document.createElement("div");
1515
+ prose.className = "nr-prose";
1516
+ prose.appendChild(renderSlot("content") || renderSlot("default"));
1517
+ modalBody.appendChild(prose);
1441
1518
  }
1442
1519
  card.addEventListener("click", () => {
1443
1520
  if (!dialog.open) {