@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/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,7 @@ __export(vanilla_exports, {
|
|
|
1582
1582
|
createTOC: () => createTOC,
|
|
1583
1583
|
createTable: () => createTable,
|
|
1584
1584
|
directiveRegistry: () => directives_default,
|
|
1585
|
+
renderHtmlString: () => renderHtmlString,
|
|
1585
1586
|
renderInline: () => renderInline,
|
|
1586
1587
|
renderMarkdownString: () => renderMarkdownString,
|
|
1587
1588
|
renderTokens: () => renderTokens
|
|
@@ -1672,6 +1673,7 @@ function parseMarkdown(markdown2) {
|
|
|
1672
1673
|
if (!markdown2) return [];
|
|
1673
1674
|
const lines = markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "").split("\n");
|
|
1674
1675
|
const result = [];
|
|
1676
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
1675
1677
|
let i = 0;
|
|
1676
1678
|
while (i < lines.length) {
|
|
1677
1679
|
const line = lines[i];
|
|
@@ -1681,7 +1683,14 @@ function parseMarkdown(markdown2) {
|
|
|
1681
1683
|
const level = match[1].length;
|
|
1682
1684
|
const rawText = match[2];
|
|
1683
1685
|
const { text: text2, classes: classes2, id: customId } = extractAttributes(rawText);
|
|
1684
|
-
const
|
|
1686
|
+
const baseId = customId || generateId(text2.replace(/->|<-/g, ""));
|
|
1687
|
+
let id2 = baseId;
|
|
1688
|
+
let n = 1;
|
|
1689
|
+
while (usedIds.has(id2)) {
|
|
1690
|
+
n++;
|
|
1691
|
+
id2 = `${baseId}-${n}`;
|
|
1692
|
+
}
|
|
1693
|
+
usedIds.add(id2);
|
|
1685
1694
|
result.push({ type: "header", level, text: text2, id: id2, classes: classes2 || void 0 });
|
|
1686
1695
|
i++;
|
|
1687
1696
|
continue;
|
|
@@ -10933,7 +10942,7 @@ var highlightSetup_default = core_default;
|
|
|
10933
10942
|
// vanilla/components.ts
|
|
10934
10943
|
function createIcon(iconName, extraClasses) {
|
|
10935
10944
|
const span = document.createElement("span");
|
|
10936
|
-
const cls = `nr-icon material-
|
|
10945
|
+
const cls = `nr-icon material-icons-round${extraClasses ? ` ${extraClasses}` : ""}`;
|
|
10937
10946
|
span.className = cls;
|
|
10938
10947
|
span.setAttribute("aria-hidden", "true");
|
|
10939
10948
|
const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(iconName);
|
|
@@ -10995,7 +11004,7 @@ var DEFAULT_ADMONITION_ICONS = {
|
|
|
10995
11004
|
info: "lightbulb",
|
|
10996
11005
|
warning: "warning",
|
|
10997
11006
|
danger: "report",
|
|
10998
|
-
greentext: "
|
|
11007
|
+
greentext: "subdirectory_arrow_right"
|
|
10999
11008
|
};
|
|
11000
11009
|
function createAdmonition(type, title, icon) {
|
|
11001
11010
|
const el = document.createElement("div");
|
|
@@ -11314,7 +11323,8 @@ var modalDirective = ({ props, renderSlot }) => {
|
|
|
11314
11323
|
const btn = document.createElement("button");
|
|
11315
11324
|
btn.className = `nr-button nr-button--default`;
|
|
11316
11325
|
if (customClass) btn.classList.add(...customClass.split(/\s+/).filter(Boolean));
|
|
11317
|
-
|
|
11326
|
+
const icon = props.icon || "open_in_new";
|
|
11327
|
+
if (icon) btn.appendChild(createIcon(icon));
|
|
11318
11328
|
btn.appendChild(document.createTextNode(label));
|
|
11319
11329
|
const dialog = createModal(modalTitle);
|
|
11320
11330
|
const body = dialog.querySelector(".nr-modal__body");
|
|
@@ -11634,6 +11644,32 @@ function renderMarkdownString(markdown2) {
|
|
|
11634
11644
|
const tokens = parseMarkdown(markdown2);
|
|
11635
11645
|
return renderTokens(tokens);
|
|
11636
11646
|
}
|
|
11647
|
+
function renderHtmlString(html) {
|
|
11648
|
+
let processedContent = html;
|
|
11649
|
+
processedContent = processedContent.replace(
|
|
11650
|
+
/<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
|
|
11651
|
+
(_match, cssContent) => {
|
|
11652
|
+
const styleEl = document.createElement("style");
|
|
11653
|
+
styleEl.setAttribute("data-nr-global", "");
|
|
11654
|
+
styleEl.textContent = cssContent;
|
|
11655
|
+
document.head.appendChild(styleEl);
|
|
11656
|
+
return "";
|
|
11657
|
+
}
|
|
11658
|
+
);
|
|
11659
|
+
const wrapper = document.createElement("div");
|
|
11660
|
+
wrapper.className = "nr-raw-html";
|
|
11661
|
+
wrapper.innerHTML = processedContent;
|
|
11662
|
+
const scripts = wrapper.querySelectorAll("script");
|
|
11663
|
+
scripts.forEach((oldScript) => {
|
|
11664
|
+
const newScript = document.createElement("script");
|
|
11665
|
+
Array.from(oldScript.attributes).forEach(
|
|
11666
|
+
(attr) => newScript.setAttribute(attr.name, attr.value)
|
|
11667
|
+
);
|
|
11668
|
+
newScript.textContent = oldScript.textContent;
|
|
11669
|
+
oldScript.parentNode?.replaceChild(newScript, oldScript);
|
|
11670
|
+
});
|
|
11671
|
+
return wrapper;
|
|
11672
|
+
}
|
|
11637
11673
|
function renderTokensInner(tokens, ctx) {
|
|
11638
11674
|
const container = document.createElement("div");
|
|
11639
11675
|
container.appendChild(processElements(tokens, ctx, tokens));
|
|
@@ -11720,30 +11756,7 @@ function renderElement(element, ctx, allElements) {
|
|
|
11720
11756
|
return renderDirective(element, ctx, allElements);
|
|
11721
11757
|
case "html": {
|
|
11722
11758
|
const el = element;
|
|
11723
|
-
|
|
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;
|
|
11759
|
+
return renderHtmlString(el.content);
|
|
11747
11760
|
}
|
|
11748
11761
|
case "html-block": {
|
|
11749
11762
|
const htmlBlock = element;
|
|
@@ -11837,6 +11850,7 @@ function renderDirective(element, ctx, allElements) {
|
|
|
11837
11850
|
createTOC,
|
|
11838
11851
|
createTable,
|
|
11839
11852
|
directiveRegistry,
|
|
11853
|
+
renderHtmlString,
|
|
11840
11854
|
renderInline,
|
|
11841
11855
|
renderMarkdownString,
|
|
11842
11856
|
renderTokens
|