@noirmd/previewer 1.2.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.
Files changed (53) hide show
  1. package/dist/NReditor.cjs +928 -895
  2. package/dist/NReditor.cjs.map +1 -1
  3. package/dist/NReditor.d.cts +1 -1
  4. package/dist/NReditor.d.ts +1 -1
  5. package/dist/NReditor.js +929 -896
  6. package/dist/NReditor.js.map +1 -1
  7. package/dist/admonition.css +55 -0
  8. package/dist/{markdown.css → base.css} +96 -126
  9. package/dist/blockquote.css +16 -0
  10. package/dist/button.css +32 -0
  11. package/dist/card.css +143 -0
  12. package/dist/codeblock.css +59 -0
  13. package/dist/core.cjs +9 -1
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.js +9 -1
  16. package/dist/core.js.map +1 -1
  17. package/dist/details.css +45 -0
  18. package/dist/editor.css +56 -9
  19. package/dist/fonts/material-icons-round.woff2 +0 -0
  20. package/dist/index.cjs +929 -882
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +41 -70
  23. package/dist/index.d.ts +41 -70
  24. package/dist/index.js +928 -876
  25. package/dist/index.js.map +1 -1
  26. package/dist/list.css +18 -0
  27. package/dist/modal.css +82 -0
  28. package/dist/react.cjs +929 -885
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +44 -73
  31. package/dist/react.d.ts +44 -73
  32. package/dist/react.js +928 -879
  33. package/dist/react.js.map +1 -1
  34. package/dist/slide.css +21 -0
  35. package/dist/table.css +36 -0
  36. package/dist/toc.css +45 -0
  37. package/dist/vanilla.cjs +123 -31
  38. package/dist/vanilla.cjs.map +1 -1
  39. package/dist/vanilla.css +32 -677
  40. package/dist/vanilla.d.cts +24 -2
  41. package/dist/vanilla.d.ts +24 -2
  42. package/dist/vanilla.js +119 -31
  43. package/dist/vanilla.js.map +1 -1
  44. package/dist/variables.css +90 -0
  45. package/dist/vue.cjs +1007 -1120
  46. package/dist/vue.cjs.map +1 -1
  47. package/dist/vue.d.cts +63 -214
  48. package/dist/vue.d.ts +63 -214
  49. package/dist/vue.js +1006 -1119
  50. package/dist/vue.js.map +1 -1
  51. package/editor.css +56 -9
  52. package/package.json +5 -10
  53. package/markdown.css +0 -344
package/dist/slide.css ADDED
@@ -0,0 +1,21 @@
1
+ /* ============================================================
2
+ NoirMD Vanilla — Slide (Animation)
3
+ ============================================================ */
4
+
5
+ .nr-slide {
6
+ overflow: hidden;
7
+ position: relative;
8
+ }
9
+
10
+ .nr-slide__track {
11
+ position: absolute;
12
+ left: 0;
13
+ right: 0;
14
+ top: 0;
15
+ }
16
+
17
+ .nr-slide__item {
18
+ display: flex;
19
+ align-items: center;
20
+ overflow: hidden;
21
+ }
package/dist/table.css ADDED
@@ -0,0 +1,36 @@
1
+ /* ============================================================
2
+ NoirMD Vanilla — Table
3
+ ============================================================ */
4
+
5
+ .nr-table-wrap {
6
+ overflow-x: auto;
7
+ }
8
+
9
+ .nr-table {
10
+ width: 100%;
11
+ border-collapse: collapse;
12
+ margin: 1rem 0;
13
+ font-size: 0.875rem;
14
+ line-height: 1.5;
15
+ }
16
+ @media (min-width: 640px) {
17
+ .nr-table { font-size: 1rem; }
18
+ }
19
+
20
+ .nr-table__th {
21
+ padding: 0.5rem 0.75rem;
22
+ text-align: left;
23
+ font-weight: 700;
24
+ font-size: 0.75rem;
25
+ background: rgba(30, 41, 59, 0.1);
26
+ border-bottom: 1px solid var(--nr-border);
27
+ }
28
+
29
+ .nr-table__td {
30
+ padding: 0.5rem 0.75rem;
31
+ border-bottom: 1px solid var(--nr-border);
32
+ }
33
+
34
+ .nr-table tbody tr:last-child .nr-table__td {
35
+ border-bottom: none;
36
+ }
package/dist/toc.css ADDED
@@ -0,0 +1,45 @@
1
+ /* ============================================================
2
+ NoirMD Vanilla — TOC (Table of Contents)
3
+ ============================================================ */
4
+
5
+ .nr-toc {
6
+ margin: 1.5rem 0;
7
+ padding: 1rem;
8
+ border-radius: var(--nr-radius);
9
+ border: 1px solid var(--nr-border);
10
+ background: color-mix(in srgb, var(--nr-bg) 5%, transparent);
11
+ }
12
+
13
+ .nr-toc__title {
14
+ font-size: 1rem;
15
+ font-weight: 700;
16
+ margin-bottom: 0.75rem;
17
+ }
18
+
19
+ .nr-toc__list {
20
+ list-style: none;
21
+ padding: 0;
22
+ margin: 0;
23
+ }
24
+
25
+ .nr-toc__item {
26
+ margin: 0.25rem 0;
27
+ font-size: 0.875rem;
28
+ }
29
+ @media (min-width: 640px) {
30
+ .nr-toc__item { font-size: 1rem; }
31
+ }
32
+
33
+ .nr-toc__item--h3 { padding-left: 1rem; }
34
+ .nr-toc__item--h4 { padding-left: 2rem; }
35
+ .nr-toc__item--h5 { padding-left: 3rem; }
36
+
37
+ .nr-toc__link {
38
+ color: var(--nr-accent);
39
+ text-decoration: none;
40
+ transition: color 0.15s;
41
+ }
42
+ .nr-toc__link:hover {
43
+ color: var(--nr-accent-hover);
44
+ text-decoration: underline;
45
+ }
package/dist/vanilla.cjs CHANGED
@@ -1582,6 +1582,10 @@ __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,
1588
+ renderHtmlString: () => renderHtmlString,
1585
1589
  renderInline: () => renderInline,
1586
1590
  renderMarkdownString: () => renderMarkdownString,
1587
1591
  renderTokens: () => renderTokens
@@ -1672,6 +1676,7 @@ function parseMarkdown(markdown2) {
1672
1676
  if (!markdown2) return [];
1673
1677
  const lines = markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "").split("\n");
1674
1678
  const result = [];
1679
+ const usedIds = /* @__PURE__ */ new Set();
1675
1680
  let i = 0;
1676
1681
  while (i < lines.length) {
1677
1682
  const line = lines[i];
@@ -1681,7 +1686,14 @@ function parseMarkdown(markdown2) {
1681
1686
  const level = match[1].length;
1682
1687
  const rawText = match[2];
1683
1688
  const { text: text2, classes: classes2, id: customId } = extractAttributes(rawText);
1684
- const id2 = customId || generateId(text2.replace(/->|<-/g, ""));
1689
+ const baseId = customId || generateId(text2.replace(/->|<-/g, ""));
1690
+ let id2 = baseId;
1691
+ let n = 1;
1692
+ while (usedIds.has(id2)) {
1693
+ n++;
1694
+ id2 = `${baseId}-${n}`;
1695
+ }
1696
+ usedIds.add(id2);
1685
1697
  result.push({ type: "header", level, text: text2, id: id2, classes: classes2 || void 0 });
1686
1698
  i++;
1687
1699
  continue;
@@ -10933,7 +10945,7 @@ var highlightSetup_default = core_default;
10933
10945
  // vanilla/components.ts
10934
10946
  function createIcon(iconName, extraClasses) {
10935
10947
  const span = document.createElement("span");
10936
- const cls = `nr-icon material-symbols-rounded${extraClasses ? ` ${extraClasses}` : ""}`;
10948
+ const cls = `nr-icon material-icons-round${extraClasses ? ` ${extraClasses}` : ""}`;
10937
10949
  span.className = cls;
10938
10950
  span.setAttribute("aria-hidden", "true");
10939
10951
  const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(iconName);
@@ -10995,7 +11007,7 @@ var DEFAULT_ADMONITION_ICONS = {
10995
11007
  info: "lightbulb",
10996
11008
  warning: "warning",
10997
11009
  danger: "report",
10998
- greentext: "subdirectory_play_arrow"
11010
+ greentext: "subdirectory_arrow_right"
10999
11011
  };
11000
11012
  function createAdmonition(type, title, icon) {
11001
11013
  const el = document.createElement("div");
@@ -11314,12 +11326,16 @@ var modalDirective = ({ props, renderSlot }) => {
11314
11326
  const btn = document.createElement("button");
11315
11327
  btn.className = `nr-button nr-button--default`;
11316
11328
  if (customClass) btn.classList.add(...customClass.split(/\s+/).filter(Boolean));
11317
- if (props.icon) btn.appendChild(createIcon(props.icon));
11329
+ const icon = props.icon || "open_in_new";
11330
+ if (icon) btn.appendChild(createIcon(icon));
11318
11331
  btn.appendChild(document.createTextNode(label));
11319
11332
  const dialog = createModal(modalTitle);
11320
11333
  const body = dialog.querySelector(".nr-modal__body");
11321
11334
  if (body) {
11322
- body.appendChild(renderSlot("default"));
11335
+ const prose = document.createElement("div");
11336
+ prose.className = "nr-prose";
11337
+ prose.appendChild(renderSlot("default"));
11338
+ body.appendChild(prose);
11323
11339
  }
11324
11340
  btn.addEventListener("click", () => {
11325
11341
  if (!dialog.open) {
@@ -11473,8 +11489,10 @@ var cardDirective = ({
11473
11489
  const dialog = createModal(title || "Detalles");
11474
11490
  const modalBody = dialog.querySelector(".nr-modal__body");
11475
11491
  if (modalBody) {
11476
- const contentSlot = renderSlot("content") || renderSlot("default");
11477
- 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);
11478
11496
  }
11479
11497
  card.addEventListener("click", () => {
11480
11498
  if (!dialog.open) {
@@ -11634,6 +11652,32 @@ function renderMarkdownString(markdown2) {
11634
11652
  const tokens = parseMarkdown(markdown2);
11635
11653
  return renderTokens(tokens);
11636
11654
  }
11655
+ function renderHtmlString(html) {
11656
+ let processedContent = html;
11657
+ processedContent = processedContent.replace(
11658
+ /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
11659
+ (_match, cssContent) => {
11660
+ const styleEl = document.createElement("style");
11661
+ styleEl.setAttribute("data-nr-global", "");
11662
+ styleEl.textContent = cssContent;
11663
+ document.head.appendChild(styleEl);
11664
+ return "";
11665
+ }
11666
+ );
11667
+ const wrapper = document.createElement("div");
11668
+ wrapper.className = "nr-raw-html";
11669
+ wrapper.innerHTML = processedContent;
11670
+ const scripts = wrapper.querySelectorAll("script");
11671
+ scripts.forEach((oldScript) => {
11672
+ const newScript = document.createElement("script");
11673
+ Array.from(oldScript.attributes).forEach(
11674
+ (attr) => newScript.setAttribute(attr.name, attr.value)
11675
+ );
11676
+ newScript.textContent = oldScript.textContent;
11677
+ oldScript.parentNode?.replaceChild(newScript, oldScript);
11678
+ });
11679
+ return wrapper;
11680
+ }
11637
11681
  function renderTokensInner(tokens, ctx) {
11638
11682
  const container = document.createElement("div");
11639
11683
  container.appendChild(processElements(tokens, ctx, tokens));
@@ -11720,30 +11764,7 @@ function renderElement(element, ctx, allElements) {
11720
11764
  return renderDirective(element, ctx, allElements);
11721
11765
  case "html": {
11722
11766
  const el = element;
11723
- let processedContent = el.content;
11724
- processedContent = processedContent.replace(
11725
- /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
11726
- (_match, cssContent) => {
11727
- const styleEl = document.createElement("style");
11728
- styleEl.setAttribute("data-nr-global", "");
11729
- styleEl.textContent = cssContent;
11730
- document.head.appendChild(styleEl);
11731
- return "";
11732
- }
11733
- );
11734
- const wrapper = document.createElement("div");
11735
- wrapper.className = "nr-raw-html";
11736
- wrapper.innerHTML = processedContent;
11737
- const scripts = wrapper.querySelectorAll("script");
11738
- scripts.forEach((oldScript) => {
11739
- const newScript = document.createElement("script");
11740
- Array.from(oldScript.attributes).forEach(
11741
- (attr) => newScript.setAttribute(attr.name, attr.value)
11742
- );
11743
- newScript.textContent = oldScript.textContent;
11744
- oldScript.parentNode?.replaceChild(newScript, oldScript);
11745
- });
11746
- return wrapper;
11767
+ return renderHtmlString(el.content);
11747
11768
  }
11748
11769
  case "html-block": {
11749
11770
  const htmlBlock = element;
@@ -11825,6 +11846,73 @@ function renderDirective(element, ctx, allElements) {
11825
11846
  fallback.appendChild(renderSlot("default"));
11826
11847
  return fallback;
11827
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
+ }
11828
11916
  // Annotate the CommonJS export names for ESM import in node:
11829
11917
  0 && (module.exports = {
11830
11918
  createAdmonition,
@@ -11837,6 +11925,10 @@ function renderDirective(element, ctx, allElements) {
11837
11925
  createTOC,
11838
11926
  createTable,
11839
11927
  directiveRegistry,
11928
+ hasHostTheme,
11929
+ injectNRTailwindTheme,
11930
+ removeNRTailwindTheme,
11931
+ renderHtmlString,
11840
11932
  renderInline,
11841
11933
  renderMarkdownString,
11842
11934
  renderTokens