@noirmd/previewer 1.0.1 → 1.1.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 +41 -38
- package/dist/NReditor.cjs.map +1 -1
- package/dist/NReditor.js +41 -38
- package/dist/NReditor.js.map +1 -1
- package/dist/core.cjs +464 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +118 -0
- package/dist/core.d.ts +118 -0
- package/dist/core.js +429 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +56 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -73
- package/dist/index.d.ts +120 -73
- package/dist/index.js +48 -37
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +12044 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +225 -0
- package/dist/react.d.ts +225 -0
- package/dist/react.js +12018 -0
- package/dist/react.js.map +1 -0
- package/dist/vanilla.cjs +11844 -0
- package/dist/vanilla.cjs.map +1 -0
- package/dist/vanilla.css +677 -0
- package/dist/vanilla.d.cts +173 -0
- package/dist/vanilla.d.ts +173 -0
- package/dist/vanilla.js +11818 -0
- package/dist/vanilla.js.map +1 -0
- package/dist/vue.cjs +12227 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +389 -0
- package/dist/vue.d.ts +389 -0
- package/dist/vue.js +12202 -0
- package/dist/vue.js.map +1 -0
- package/package.json +45 -14
package/dist/NReditor.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// NReditor.tsx
|
|
30
|
+
// react/NReditor.tsx
|
|
31
31
|
var NReditor_exports = {};
|
|
32
32
|
__export(NReditor_exports, {
|
|
33
33
|
default: () => NReditor_default
|
|
@@ -37,7 +37,7 @@ var import_react11 = __toESM(require("react"), 1);
|
|
|
37
37
|
var import_react_codemirror = __toESM(require("@uiw/react-codemirror"), 1);
|
|
38
38
|
var import_view = require("@codemirror/view");
|
|
39
39
|
|
|
40
|
-
// custom-syntax.ts
|
|
40
|
+
// react/custom-syntax.ts
|
|
41
41
|
var import_language = require("@codemirror/language");
|
|
42
42
|
var import_highlight = require("@lezer/highlight");
|
|
43
43
|
var customStreamParserV2 = import_language.StreamLanguage.define({
|
|
@@ -331,12 +331,12 @@ var customStreamParserV2 = import_language.StreamLanguage.define({
|
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
|
|
334
|
-
// NReditor.tsx
|
|
334
|
+
// react/NReditor.tsx
|
|
335
335
|
var import_state = require("@codemirror/state");
|
|
336
336
|
var import_language2 = require("@codemirror/language");
|
|
337
337
|
var import_highlight2 = require("@lezer/highlight");
|
|
338
338
|
|
|
339
|
-
// useDebounce.ts
|
|
339
|
+
// react/useDebounce.ts
|
|
340
340
|
var import_react = require("react");
|
|
341
341
|
function useDebounce(value, delay) {
|
|
342
342
|
const [debouncedValue, setDebouncedValue] = (0, import_react.useState)(value);
|
|
@@ -347,10 +347,10 @@ function useDebounce(value, delay) {
|
|
|
347
347
|
return debouncedValue;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
// CustomMarkdownRenderer.tsx
|
|
350
|
+
// react/CustomMarkdownRenderer.tsx
|
|
351
351
|
var import_react10 = __toESM(require("react"), 1);
|
|
352
352
|
|
|
353
|
-
// utils.ts
|
|
353
|
+
// core/utils.ts
|
|
354
354
|
function parseCssString(cssText) {
|
|
355
355
|
if (!cssText) return {};
|
|
356
356
|
return cssText.split(";").filter(Boolean).reduce((styleObj, styleString) => {
|
|
@@ -366,6 +366,7 @@ function generateId(text) {
|
|
|
366
366
|
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
|
|
367
367
|
}
|
|
368
368
|
function scrollToId(id) {
|
|
369
|
+
if (typeof document === "undefined") return;
|
|
369
370
|
const element = document.getElementById(id);
|
|
370
371
|
if (element) {
|
|
371
372
|
element.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
@@ -427,11 +428,8 @@ function parseHtmlAttrs(attrsString) {
|
|
|
427
428
|
const pairRegex = /([a-zA-Z0-9_-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
428
429
|
let match;
|
|
429
430
|
while ((match = pairRegex.exec(attrsString)) !== null) {
|
|
430
|
-
|
|
431
|
+
const key = match[1];
|
|
431
432
|
const value = match[2] ?? match[3] ?? match[4] ?? true;
|
|
432
|
-
if (key === "class") key = "className";
|
|
433
|
-
else if (key === "for") key = "htmlFor";
|
|
434
|
-
else if (key === "tabindex") key = "tabIndex";
|
|
435
433
|
if (key === "style" && typeof value === "string") {
|
|
436
434
|
props[key] = parseCssString(value);
|
|
437
435
|
} else {
|
|
@@ -441,7 +439,7 @@ function parseHtmlAttrs(attrsString) {
|
|
|
441
439
|
return props;
|
|
442
440
|
}
|
|
443
441
|
|
|
444
|
-
// parser.ts
|
|
442
|
+
// core/parser.ts
|
|
445
443
|
function parseMarkdown(markdown2) {
|
|
446
444
|
if (!markdown2) return [];
|
|
447
445
|
const lines = markdown2.split("\n");
|
|
@@ -756,26 +754,24 @@ function splitSlots(rawContent) {
|
|
|
756
754
|
nestingDepth++;
|
|
757
755
|
}
|
|
758
756
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
757
|
+
if (nestingDepth === 0 && trimmed.match(/^#([\w-]+)$/)) {
|
|
758
|
+
if (buffer.length > 0 || currentSlot !== "default") {
|
|
759
|
+
slots[currentSlot] = buffer.join("\n").trim();
|
|
760
|
+
}
|
|
761
|
+
currentSlot = trimmed.slice(1);
|
|
762
762
|
buffer = [];
|
|
763
|
-
currentSlot = slotMatch[1];
|
|
764
763
|
} else {
|
|
765
764
|
buffer.push(line);
|
|
766
765
|
}
|
|
767
766
|
}
|
|
768
767
|
slots[currentSlot] = buffer.join("\n").trim();
|
|
769
|
-
for (const key of Object.keys(slots)) {
|
|
770
|
-
if (!slots[key]) delete slots[key];
|
|
771
|
-
}
|
|
772
768
|
return slots;
|
|
773
769
|
}
|
|
774
770
|
|
|
775
|
-
// ui-components.tsx
|
|
771
|
+
// react/ui-components.tsx
|
|
776
772
|
var import_react2 = require("react");
|
|
777
773
|
|
|
778
|
-
// highlightSetup.ts
|
|
774
|
+
// react/highlightSetup.ts
|
|
779
775
|
var import_core = __toESM(require("highlight.js/lib/core"), 1);
|
|
780
776
|
var import_javascript = __toESM(require("highlight.js/lib/languages/javascript"), 1);
|
|
781
777
|
var import_typescript = __toESM(require("highlight.js/lib/languages/typescript"), 1);
|
|
@@ -845,7 +841,7 @@ import_core.default.registerLanguage("diff", import_diff.default);
|
|
|
845
841
|
import_core.default.registerLanguage("shell", import_shell.default);
|
|
846
842
|
var highlightSetup_default = import_core.default;
|
|
847
843
|
|
|
848
|
-
// ui-components.tsx
|
|
844
|
+
// react/ui-components.tsx
|
|
849
845
|
var import_dialog = require("@base-ui/react/dialog");
|
|
850
846
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
851
847
|
var IconRenderer = ({ iconName, extraClasses = "" }) => {
|
|
@@ -981,7 +977,7 @@ var Modal = ({ title, isOpen, onClose, children }) => {
|
|
|
981
977
|
] }) });
|
|
982
978
|
};
|
|
983
979
|
|
|
984
|
-
// renderers.tsx
|
|
980
|
+
// react/renderers.tsx
|
|
985
981
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
986
982
|
function renderInline(text) {
|
|
987
983
|
if (!text) return text;
|
|
@@ -1112,7 +1108,7 @@ function extractHeaders(elements) {
|
|
|
1112
1108
|
return elements.filter((el) => el.type === "header");
|
|
1113
1109
|
}
|
|
1114
1110
|
|
|
1115
|
-
// directives/AdmonitionDirective.tsx
|
|
1111
|
+
// react/directives/AdmonitionDirective.tsx
|
|
1116
1112
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1117
1113
|
var AdmonitionDirective = ({
|
|
1118
1114
|
directiveType,
|
|
@@ -1133,7 +1129,7 @@ var AdmonitionDirective = ({
|
|
|
1133
1129
|
};
|
|
1134
1130
|
var AdmonitionDirective_default = AdmonitionDirective;
|
|
1135
1131
|
|
|
1136
|
-
// directives/CardDirective.tsx
|
|
1132
|
+
// react/directives/CardDirective.tsx
|
|
1137
1133
|
var import_react3 = __toESM(require("react"), 1);
|
|
1138
1134
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1139
1135
|
var CardDirective = ({
|
|
@@ -1219,7 +1215,7 @@ var CardDirective = ({
|
|
|
1219
1215
|
};
|
|
1220
1216
|
var CardDirective_default = CardDirective;
|
|
1221
1217
|
|
|
1222
|
-
// directives/DetailsDirective.tsx
|
|
1218
|
+
// react/directives/DetailsDirective.tsx
|
|
1223
1219
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1224
1220
|
var DetailsDirective = ({
|
|
1225
1221
|
props,
|
|
@@ -1239,7 +1235,7 @@ var DetailsDirective = ({
|
|
|
1239
1235
|
};
|
|
1240
1236
|
var DetailsDirective_default = DetailsDirective;
|
|
1241
1237
|
|
|
1242
|
-
// directives/ModalDirective.tsx
|
|
1238
|
+
// react/directives/ModalDirective.tsx
|
|
1243
1239
|
var import_react4 = require("react");
|
|
1244
1240
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1245
1241
|
var ModalDirective = ({
|
|
@@ -1290,7 +1286,7 @@ var ModalDirective = ({
|
|
|
1290
1286
|
};
|
|
1291
1287
|
var ModalDirective_default = ModalDirective;
|
|
1292
1288
|
|
|
1293
|
-
// directives/ButtonDirective.tsx
|
|
1289
|
+
// react/directives/ButtonDirective.tsx
|
|
1294
1290
|
var import_react5 = __toESM(require("react"), 1);
|
|
1295
1291
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1296
1292
|
var ButtonDirective = ({
|
|
@@ -1370,7 +1366,7 @@ var ButtonDirective = ({
|
|
|
1370
1366
|
};
|
|
1371
1367
|
var ButtonDirective_default = ButtonDirective;
|
|
1372
1368
|
|
|
1373
|
-
// directives/WrapperDirective.tsx
|
|
1369
|
+
// react/directives/WrapperDirective.tsx
|
|
1374
1370
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1375
1371
|
var WrapperDirective = ({
|
|
1376
1372
|
props,
|
|
@@ -1392,7 +1388,7 @@ var WrapperDirective = ({
|
|
|
1392
1388
|
};
|
|
1393
1389
|
var WrapperDirective_default = WrapperDirective;
|
|
1394
1390
|
|
|
1395
|
-
// directives/SlideDirective.tsx
|
|
1391
|
+
// react/directives/SlideDirective.tsx
|
|
1396
1392
|
var import_react6 = require("react");
|
|
1397
1393
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1398
1394
|
var slideCounter = 0;
|
|
@@ -1484,7 +1480,7 @@ var SlideDirective = ({
|
|
|
1484
1480
|
};
|
|
1485
1481
|
var SlideDirective_default = SlideDirective;
|
|
1486
1482
|
|
|
1487
|
-
// directives/index.ts
|
|
1483
|
+
// react/directives/index.ts
|
|
1488
1484
|
var directiveRegistry = {
|
|
1489
1485
|
// Admonitions
|
|
1490
1486
|
note: AdmonitionDirective_default,
|
|
@@ -1510,7 +1506,7 @@ var directiveRegistry = {
|
|
|
1510
1506
|
};
|
|
1511
1507
|
var directives_default = directiveRegistry;
|
|
1512
1508
|
|
|
1513
|
-
// DirectiveRenderer.tsx
|
|
1509
|
+
// react/DirectiveRenderer.tsx
|
|
1514
1510
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1515
1511
|
var DirectiveRenderer = ({
|
|
1516
1512
|
element,
|
|
@@ -1542,17 +1538,17 @@ var DirectiveRenderer = ({
|
|
|
1542
1538
|
};
|
|
1543
1539
|
var DirectiveRenderer_default = DirectiveRenderer;
|
|
1544
1540
|
|
|
1545
|
-
// RawHtmlRenderer.tsx
|
|
1541
|
+
// react/RawHtmlRenderer.tsx
|
|
1546
1542
|
var import_react8 = require("react");
|
|
1547
1543
|
|
|
1548
|
-
// useTailwindCDN.ts
|
|
1544
|
+
// react/useTailwindCDN.ts
|
|
1549
1545
|
var import_react7 = require("react");
|
|
1550
1546
|
function scanTailwindCDN() {
|
|
1551
1547
|
const tw = window.tailwind;
|
|
1552
1548
|
if (tw?.scan) tw.scan();
|
|
1553
1549
|
}
|
|
1554
1550
|
|
|
1555
|
-
// RawHtmlRenderer.tsx
|
|
1551
|
+
// react/RawHtmlRenderer.tsx
|
|
1556
1552
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1557
1553
|
var RawHtmlRenderer = ({
|
|
1558
1554
|
content,
|
|
@@ -1587,12 +1583,12 @@ var RawHtmlRenderer = ({
|
|
|
1587
1583
|
};
|
|
1588
1584
|
var RawHtmlRenderer_default = RawHtmlRenderer;
|
|
1589
1585
|
|
|
1590
|
-
// context.tsx
|
|
1586
|
+
// react/context.tsx
|
|
1591
1587
|
var import_react9 = require("react");
|
|
1592
1588
|
var RenderCtx = (0, import_react9.createContext)(null);
|
|
1593
1589
|
var RenderContextProvider = RenderCtx.Provider;
|
|
1594
1590
|
|
|
1595
|
-
// CustomMarkdownRenderer.tsx
|
|
1591
|
+
// react/CustomMarkdownRenderer.tsx
|
|
1596
1592
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1597
1593
|
var CustomMarkdownRenderer = ({ content: initialContent }) => {
|
|
1598
1594
|
const [modals, setModals] = (0, import_react10.useState)({});
|
|
@@ -1704,7 +1700,14 @@ var CustomMarkdownRenderer = ({ content: initialContent }) => {
|
|
|
1704
1700
|
}
|
|
1705
1701
|
case "html-block": {
|
|
1706
1702
|
const htmlBlock = element;
|
|
1707
|
-
const
|
|
1703
|
+
const rawProps = parseHtmlAttrs(htmlBlock.attrs);
|
|
1704
|
+
const props = {};
|
|
1705
|
+
for (const [key, value] of Object.entries(rawProps)) {
|
|
1706
|
+
if (key === "class") props["className"] = value;
|
|
1707
|
+
else if (key === "for") props["htmlFor"] = value;
|
|
1708
|
+
else if (key === "tabindex") props["tabIndex"] = value;
|
|
1709
|
+
else props[key] = value;
|
|
1710
|
+
}
|
|
1708
1711
|
return import_react10.default.createElement(
|
|
1709
1712
|
htmlBlock.tag,
|
|
1710
1713
|
{ key: index, ...props },
|
|
@@ -1809,7 +1812,7 @@ var CustomMarkdownRenderer = ({ content: initialContent }) => {
|
|
|
1809
1812
|
};
|
|
1810
1813
|
var CustomMarkdownRenderer_default = CustomMarkdownRenderer;
|
|
1811
1814
|
|
|
1812
|
-
// NReditor.tsx
|
|
1815
|
+
// react/NReditor.tsx
|
|
1813
1816
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1814
1817
|
var customSyntaxHighlighting = import_language2.HighlightStyle.define([
|
|
1815
1818
|
{ tag: import_highlight2.tags.heading, fontWeight: "bold", color: "var(--tc-heading, #e2e8f0)" },
|