@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.js CHANGED
@@ -315,6 +315,75 @@ function useDebounce(value, delay) {
315
315
 
316
316
  // react/useTailwindCDN.ts
317
317
  import { useEffect as useEffect2, useRef } from "react";
318
+
319
+ // vanilla/tailwindTheme.ts
320
+ var THEME_STYLE_ID = "nr-tailwind-theme";
321
+ var NR_THEME_CSS = `
322
+ @theme {
323
+ --color-primary: var(--color-accent-primary, oklch(var(--p, 55% 0.3 240) / 1));
324
+ --color-primary-content: #ffffff;
325
+ --color-secondary: oklch(var(--s, 55% 0.25 200) / 1);
326
+ --color-secondary-content: #ffffff;
327
+ --color-accent: var(--color-accent-primary, oklch(var(--a, 65% 0.25 160) / 1));
328
+ --color-accent-content: #ffffff;
329
+ --color-neutral: oklch(var(--n, 50% 0.05 240) / 1);
330
+ --color-neutral-content: var(--color-text-primary, oklch(var(--nc, 92% 0.02 240) / 1));
331
+ --color-base-100: var(--color-background-primary, oklch(var(--b1, 15% 0.01 260) / 1));
332
+ --color-base-200: var(--color-background-secondary-solid, oklch(var(--b2, 20% 0.02 260) / 1));
333
+ --color-base-300: var(--color-border, oklch(var(--b3, 25% 0.03 260) / 1));
334
+ --color-base-content: var(--color-text-primary, oklch(var(--bc, 92% 0.02 260) / 1));
335
+ --color-info: oklch(var(--in, 70% 0.2 220) / 1);
336
+ --color-info-content: #ffffff;
337
+ --color-success: oklch(var(--su, 65% 0.25 140) / 1);
338
+ --color-success-content: #ffffff;
339
+ --color-warning: oklch(var(--wa, 80% 0.25 80) / 1);
340
+ --color-warning-content: #1f2937;
341
+ --color-error: oklch(var(--er, 65% 0.3 30) / 1);
342
+ --color-error-content: #ffffff;
343
+ }
344
+ `;
345
+ function getVar(root, name) {
346
+ return getComputedStyle(root).getPropertyValue(name).trim();
347
+ }
348
+ function stylesheetHasTheme() {
349
+ for (const sheet of Array.from(document.styleSheets)) {
350
+ let rules = null;
351
+ try {
352
+ rules = sheet.cssRules;
353
+ } catch {
354
+ continue;
355
+ }
356
+ if (!rules) continue;
357
+ for (const rule of Array.from(rules)) {
358
+ const css2 = rule.cssText || "";
359
+ if (css2.includes("@theme") || css2.includes('@plugin "daisyui"')) return true;
360
+ }
361
+ }
362
+ return false;
363
+ }
364
+ function hasHostTheme() {
365
+ if (typeof window === "undefined" || typeof document === "undefined") return true;
366
+ if (getVar(document.documentElement, "--color-primary")) return true;
367
+ if (getVar(document.documentElement, "--color-base-100")) return true;
368
+ if (document.body && (getVar(document.body, "--color-primary") || getVar(document.body, "--color-base-100"))) return true;
369
+ return stylesheetHasTheme();
370
+ }
371
+ function injectNRTailwindTheme() {
372
+ if (typeof document === "undefined") return;
373
+ if (document.getElementById(THEME_STYLE_ID)) return;
374
+ if (hasHostTheme()) return;
375
+ const style = document.createElement("style");
376
+ style.id = THEME_STYLE_ID;
377
+ style.setAttribute("type", "text/tailwindcss");
378
+ style.textContent = NR_THEME_CSS;
379
+ document.head.appendChild(style);
380
+ }
381
+ function removeNRTailwindTheme() {
382
+ if (typeof document === "undefined") return;
383
+ document.getElementById(THEME_STYLE_ID)?.remove();
384
+ }
385
+
386
+ // react/useTailwindCDN.ts
318
387
  var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
319
388
  var SCRIPT_ID = "tailwind-cdn-v4-runtime";
320
389
  var CONFIG_ID = "tailwind-cdn-v4-config";
@@ -334,6 +403,7 @@ function useLazyTailwindCDN(enabled) {
334
403
  if ((window.__twCDNRefs ?? 0) <= 0) {
335
404
  document.getElementById(SCRIPT_ID)?.remove();
336
405
  document.getElementById(CONFIG_ID)?.remove();
406
+ removeNRTailwindTheme();
337
407
  window.__twCDNRefs = 0;
338
408
  loadedRef.current = false;
339
409
  }
@@ -346,6 +416,7 @@ function useLazyTailwindCDN(enabled) {
346
416
  configScript.textContent = TAILWIND_CDN_CONFIG;
347
417
  document.head.appendChild(configScript);
348
418
  }
419
+ injectNRTailwindTheme();
349
420
  if (!document.getElementById(SCRIPT_ID)) {
350
421
  const script = document.createElement("script");
351
422
  script.id = SCRIPT_ID;
@@ -358,6 +429,7 @@ function useLazyTailwindCDN(enabled) {
358
429
  if ((window.__twCDNRefs ?? 0) <= 0) {
359
430
  document.getElementById(SCRIPT_ID)?.remove();
360
431
  document.getElementById(CONFIG_ID)?.remove();
432
+ removeNRTailwindTheme();
361
433
  window.__twCDNRefs = 0;
362
434
  loadedRef.current = false;
363
435
  }
@@ -1248,7 +1320,10 @@ var modalDirective = ({ props, renderSlot }) => {
1248
1320
  const dialog = createModal(modalTitle);
1249
1321
  const body = dialog.querySelector(".nr-modal__body");
1250
1322
  if (body) {
1251
- body.appendChild(renderSlot("default"));
1323
+ const prose = document.createElement("div");
1324
+ prose.className = "nr-prose";
1325
+ prose.appendChild(renderSlot("default"));
1326
+ body.appendChild(prose);
1252
1327
  }
1253
1328
  btn.addEventListener("click", () => {
1254
1329
  if (!dialog.open) {
@@ -1402,8 +1477,10 @@ var cardDirective = ({
1402
1477
  const dialog = createModal(title || "Detalles");
1403
1478
  const modalBody = dialog.querySelector(".nr-modal__body");
1404
1479
  if (modalBody) {
1405
- const contentSlot = renderSlot("content") || renderSlot("default");
1406
- modalBody.appendChild(contentSlot);
1480
+ const prose = document.createElement("div");
1481
+ prose.className = "nr-prose";
1482
+ prose.appendChild(renderSlot("content") || renderSlot("default"));
1483
+ modalBody.appendChild(prose);
1407
1484
  }
1408
1485
  card.addEventListener("click", () => {
1409
1486
  if (!dialog.open) {