@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/index.js
CHANGED
|
@@ -1563,10 +1563,7 @@ var require_core = __commonJS({
|
|
|
1563
1563
|
}
|
|
1564
1564
|
});
|
|
1565
1565
|
|
|
1566
|
-
//
|
|
1567
|
-
import React8, { useState as useState3, useEffect as useEffect4, useCallback as useCallback2, useMemo, useId as useId3, useRef as useRef5 } from "react";
|
|
1568
|
-
|
|
1569
|
-
// utils.ts
|
|
1566
|
+
// core/utils.ts
|
|
1570
1567
|
function parseCssString(cssText) {
|
|
1571
1568
|
if (!cssText) return {};
|
|
1572
1569
|
return cssText.split(";").filter(Boolean).reduce((styleObj, styleString) => {
|
|
@@ -1582,6 +1579,7 @@ function generateId(text) {
|
|
|
1582
1579
|
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
|
|
1583
1580
|
}
|
|
1584
1581
|
function scrollToId(id) {
|
|
1582
|
+
if (typeof document === "undefined") return;
|
|
1585
1583
|
const element = document.getElementById(id);
|
|
1586
1584
|
if (element) {
|
|
1587
1585
|
element.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
@@ -1643,11 +1641,8 @@ function parseHtmlAttrs(attrsString) {
|
|
|
1643
1641
|
const pairRegex = /([a-zA-Z0-9_-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
1644
1642
|
let match;
|
|
1645
1643
|
while ((match = pairRegex.exec(attrsString)) !== null) {
|
|
1646
|
-
|
|
1644
|
+
const key = match[1];
|
|
1647
1645
|
const value = match[2] ?? match[3] ?? match[4] ?? true;
|
|
1648
|
-
if (key === "class") key = "className";
|
|
1649
|
-
else if (key === "for") key = "htmlFor";
|
|
1650
|
-
else if (key === "tabindex") key = "tabIndex";
|
|
1651
1646
|
if (key === "style" && typeof value === "string") {
|
|
1652
1647
|
props[key] = parseCssString(value);
|
|
1653
1648
|
} else {
|
|
@@ -1657,7 +1652,7 @@ function parseHtmlAttrs(attrsString) {
|
|
|
1657
1652
|
return props;
|
|
1658
1653
|
}
|
|
1659
1654
|
|
|
1660
|
-
// parser.ts
|
|
1655
|
+
// core/parser.ts
|
|
1661
1656
|
function parseMarkdown(markdown2) {
|
|
1662
1657
|
if (!markdown2) return [];
|
|
1663
1658
|
const lines = markdown2.split("\n");
|
|
@@ -1972,23 +1967,24 @@ function splitSlots(rawContent) {
|
|
|
1972
1967
|
nestingDepth++;
|
|
1973
1968
|
}
|
|
1974
1969
|
}
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1970
|
+
if (nestingDepth === 0 && trimmed.match(/^#([\w-]+)$/)) {
|
|
1971
|
+
if (buffer.length > 0 || currentSlot !== "default") {
|
|
1972
|
+
slots[currentSlot] = buffer.join("\n").trim();
|
|
1973
|
+
}
|
|
1974
|
+
currentSlot = trimmed.slice(1);
|
|
1978
1975
|
buffer = [];
|
|
1979
|
-
currentSlot = slotMatch[1];
|
|
1980
1976
|
} else {
|
|
1981
1977
|
buffer.push(line);
|
|
1982
1978
|
}
|
|
1983
1979
|
}
|
|
1984
1980
|
slots[currentSlot] = buffer.join("\n").trim();
|
|
1985
|
-
for (const key of Object.keys(slots)) {
|
|
1986
|
-
if (!slots[key]) delete slots[key];
|
|
1987
|
-
}
|
|
1988
1981
|
return slots;
|
|
1989
1982
|
}
|
|
1990
1983
|
|
|
1991
|
-
//
|
|
1984
|
+
// react/CustomMarkdownRenderer.tsx
|
|
1985
|
+
import React8, { useState as useState3, useEffect as useEffect4, useCallback as useCallback2, useMemo, useId as useId3, useRef as useRef5 } from "react";
|
|
1986
|
+
|
|
1987
|
+
// react/ui-components.tsx
|
|
1992
1988
|
import { useState, useRef } from "react";
|
|
1993
1989
|
|
|
1994
1990
|
// node_modules/highlight.js/es/core.js
|
|
@@ -10887,7 +10883,7 @@ function shell(hljs) {
|
|
|
10887
10883
|
};
|
|
10888
10884
|
}
|
|
10889
10885
|
|
|
10890
|
-
// highlightSetup.ts
|
|
10886
|
+
// react/highlightSetup.ts
|
|
10891
10887
|
core_default.registerLanguage("javascript", javascript);
|
|
10892
10888
|
core_default.registerLanguage("js", javascript);
|
|
10893
10889
|
core_default.registerLanguage("jsx", javascript);
|
|
@@ -10932,7 +10928,7 @@ core_default.registerLanguage("diff", diff);
|
|
|
10932
10928
|
core_default.registerLanguage("shell", shell);
|
|
10933
10929
|
var highlightSetup_default = core_default;
|
|
10934
10930
|
|
|
10935
|
-
// ui-components.tsx
|
|
10931
|
+
// react/ui-components.tsx
|
|
10936
10932
|
import { Dialog } from "@base-ui/react/dialog";
|
|
10937
10933
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10938
10934
|
var IconRenderer = ({ iconName, extraClasses = "" }) => {
|
|
@@ -11068,7 +11064,7 @@ var Modal = ({ title, isOpen, onClose, children }) => {
|
|
|
11068
11064
|
] }) });
|
|
11069
11065
|
};
|
|
11070
11066
|
|
|
11071
|
-
// renderers.tsx
|
|
11067
|
+
// react/renderers.tsx
|
|
11072
11068
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
11073
11069
|
function renderInline(text) {
|
|
11074
11070
|
if (!text) return text;
|
|
@@ -11199,7 +11195,7 @@ function extractHeaders(elements) {
|
|
|
11199
11195
|
return elements.filter((el) => el.type === "header");
|
|
11200
11196
|
}
|
|
11201
11197
|
|
|
11202
|
-
// directives/AdmonitionDirective.tsx
|
|
11198
|
+
// react/directives/AdmonitionDirective.tsx
|
|
11203
11199
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
11204
11200
|
var AdmonitionDirective = ({
|
|
11205
11201
|
directiveType,
|
|
@@ -11220,7 +11216,7 @@ var AdmonitionDirective = ({
|
|
|
11220
11216
|
};
|
|
11221
11217
|
var AdmonitionDirective_default = AdmonitionDirective;
|
|
11222
11218
|
|
|
11223
|
-
// directives/CardDirective.tsx
|
|
11219
|
+
// react/directives/CardDirective.tsx
|
|
11224
11220
|
import React2, { useId } from "react";
|
|
11225
11221
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
11226
11222
|
var CardDirective = ({
|
|
@@ -11306,7 +11302,7 @@ var CardDirective = ({
|
|
|
11306
11302
|
};
|
|
11307
11303
|
var CardDirective_default = CardDirective;
|
|
11308
11304
|
|
|
11309
|
-
// directives/DetailsDirective.tsx
|
|
11305
|
+
// react/directives/DetailsDirective.tsx
|
|
11310
11306
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
11311
11307
|
var DetailsDirective = ({
|
|
11312
11308
|
props,
|
|
@@ -11326,7 +11322,7 @@ var DetailsDirective = ({
|
|
|
11326
11322
|
};
|
|
11327
11323
|
var DetailsDirective_default = DetailsDirective;
|
|
11328
11324
|
|
|
11329
|
-
// directives/ModalDirective.tsx
|
|
11325
|
+
// react/directives/ModalDirective.tsx
|
|
11330
11326
|
import { useId as useId2 } from "react";
|
|
11331
11327
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
11332
11328
|
var ModalDirective = ({
|
|
@@ -11377,7 +11373,7 @@ var ModalDirective = ({
|
|
|
11377
11373
|
};
|
|
11378
11374
|
var ModalDirective_default = ModalDirective;
|
|
11379
11375
|
|
|
11380
|
-
// directives/ButtonDirective.tsx
|
|
11376
|
+
// react/directives/ButtonDirective.tsx
|
|
11381
11377
|
import React4 from "react";
|
|
11382
11378
|
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
11383
11379
|
var ButtonDirective = ({
|
|
@@ -11457,7 +11453,7 @@ var ButtonDirective = ({
|
|
|
11457
11453
|
};
|
|
11458
11454
|
var ButtonDirective_default = ButtonDirective;
|
|
11459
11455
|
|
|
11460
|
-
// directives/WrapperDirective.tsx
|
|
11456
|
+
// react/directives/WrapperDirective.tsx
|
|
11461
11457
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
11462
11458
|
var WrapperDirective = ({
|
|
11463
11459
|
props,
|
|
@@ -11479,7 +11475,7 @@ var WrapperDirective = ({
|
|
|
11479
11475
|
};
|
|
11480
11476
|
var WrapperDirective_default = WrapperDirective;
|
|
11481
11477
|
|
|
11482
|
-
// directives/SlideDirective.tsx
|
|
11478
|
+
// react/directives/SlideDirective.tsx
|
|
11483
11479
|
import { useState as useState2, useEffect, useCallback, useRef as useRef2, useLayoutEffect } from "react";
|
|
11484
11480
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
11485
11481
|
var slideCounter = 0;
|
|
@@ -11571,7 +11567,7 @@ var SlideDirective = ({
|
|
|
11571
11567
|
};
|
|
11572
11568
|
var SlideDirective_default = SlideDirective;
|
|
11573
11569
|
|
|
11574
|
-
// directives/index.ts
|
|
11570
|
+
// react/directives/index.ts
|
|
11575
11571
|
var directiveRegistry = {
|
|
11576
11572
|
// Admonitions
|
|
11577
11573
|
note: AdmonitionDirective_default,
|
|
@@ -11597,7 +11593,7 @@ var directiveRegistry = {
|
|
|
11597
11593
|
};
|
|
11598
11594
|
var directives_default = directiveRegistry;
|
|
11599
11595
|
|
|
11600
|
-
// DirectiveRenderer.tsx
|
|
11596
|
+
// react/DirectiveRenderer.tsx
|
|
11601
11597
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
11602
11598
|
var DirectiveRenderer = ({
|
|
11603
11599
|
element,
|
|
@@ -11629,10 +11625,10 @@ var DirectiveRenderer = ({
|
|
|
11629
11625
|
};
|
|
11630
11626
|
var DirectiveRenderer_default = DirectiveRenderer;
|
|
11631
11627
|
|
|
11632
|
-
// RawHtmlRenderer.tsx
|
|
11628
|
+
// react/RawHtmlRenderer.tsx
|
|
11633
11629
|
import { useRef as useRef4, useEffect as useEffect3 } from "react";
|
|
11634
11630
|
|
|
11635
|
-
// useTailwindCDN.ts
|
|
11631
|
+
// react/useTailwindCDN.ts
|
|
11636
11632
|
import { useEffect as useEffect2, useRef as useRef3 } from "react";
|
|
11637
11633
|
var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
|
|
11638
11634
|
var SCRIPT_ID = "tailwind-cdn-v4-runtime";
|
|
@@ -11710,7 +11706,7 @@ function preloadTailwindCDN() {
|
|
|
11710
11706
|
}
|
|
11711
11707
|
}
|
|
11712
11708
|
|
|
11713
|
-
// RawHtmlRenderer.tsx
|
|
11709
|
+
// react/RawHtmlRenderer.tsx
|
|
11714
11710
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
11715
11711
|
var RawHtmlRenderer = ({
|
|
11716
11712
|
content,
|
|
@@ -11745,12 +11741,12 @@ var RawHtmlRenderer = ({
|
|
|
11745
11741
|
};
|
|
11746
11742
|
var RawHtmlRenderer_default = RawHtmlRenderer;
|
|
11747
11743
|
|
|
11748
|
-
// context.tsx
|
|
11744
|
+
// react/context.tsx
|
|
11749
11745
|
import { createContext, useContext } from "react";
|
|
11750
11746
|
var RenderCtx = createContext(null);
|
|
11751
11747
|
var RenderContextProvider = RenderCtx.Provider;
|
|
11752
11748
|
|
|
11753
|
-
// CustomMarkdownRenderer.tsx
|
|
11749
|
+
// react/CustomMarkdownRenderer.tsx
|
|
11754
11750
|
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
11755
11751
|
var CustomMarkdownRenderer = ({ content: initialContent }) => {
|
|
11756
11752
|
const [modals, setModals] = useState3({});
|
|
@@ -11862,7 +11858,14 @@ var CustomMarkdownRenderer = ({ content: initialContent }) => {
|
|
|
11862
11858
|
}
|
|
11863
11859
|
case "html-block": {
|
|
11864
11860
|
const htmlBlock = element;
|
|
11865
|
-
const
|
|
11861
|
+
const rawProps = parseHtmlAttrs(htmlBlock.attrs);
|
|
11862
|
+
const props = {};
|
|
11863
|
+
for (const [key, value] of Object.entries(rawProps)) {
|
|
11864
|
+
if (key === "class") props["className"] = value;
|
|
11865
|
+
else if (key === "for") props["htmlFor"] = value;
|
|
11866
|
+
else if (key === "tabindex") props["tabIndex"] = value;
|
|
11867
|
+
else props[key] = value;
|
|
11868
|
+
}
|
|
11866
11869
|
return React8.createElement(
|
|
11867
11870
|
htmlBlock.tag,
|
|
11868
11871
|
{ key: index, ...props },
|
|
@@ -11967,7 +11970,7 @@ var CustomMarkdownRenderer = ({ content: initialContent }) => {
|
|
|
11967
11970
|
};
|
|
11968
11971
|
var CustomMarkdownRenderer_default = CustomMarkdownRenderer;
|
|
11969
11972
|
|
|
11970
|
-
// NRpreviewer.tsx
|
|
11973
|
+
// react/NRpreviewer.tsx
|
|
11971
11974
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
11972
11975
|
var NRpreviewer = ({
|
|
11973
11976
|
content,
|
|
@@ -11987,7 +11990,7 @@ var NRpreviewer = ({
|
|
|
11987
11990
|
};
|
|
11988
11991
|
var NRpreviewer_default = NRpreviewer;
|
|
11989
11992
|
|
|
11990
|
-
// useDebounce.ts
|
|
11993
|
+
// react/useDebounce.ts
|
|
11991
11994
|
import { useState as useState4, useEffect as useEffect5 } from "react";
|
|
11992
11995
|
function useDebounce(value, delay) {
|
|
11993
11996
|
const [debouncedValue, setDebouncedValue] = useState4(value);
|
|
@@ -12005,10 +12008,18 @@ export {
|
|
|
12005
12008
|
IconRenderer,
|
|
12006
12009
|
Modal,
|
|
12007
12010
|
NRpreviewer_default as NRpreviewer,
|
|
12011
|
+
extractAttributes,
|
|
12008
12012
|
extractHeaders,
|
|
12013
|
+
generateId,
|
|
12014
|
+
generateScopeId,
|
|
12015
|
+
parseCssString,
|
|
12016
|
+
parseHtmlAttrs,
|
|
12009
12017
|
parseMarkdown,
|
|
12018
|
+
parseProps,
|
|
12010
12019
|
preloadTailwindCDN,
|
|
12020
|
+
resetScopeCounter,
|
|
12011
12021
|
scanTailwindCDN,
|
|
12022
|
+
scrollToId,
|
|
12012
12023
|
useDebounce,
|
|
12013
12024
|
useLazyTailwindCDN
|
|
12014
12025
|
};
|