@readme/markdown 13.6.3 → 13.7.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/components/Image/index.tsx +60 -39
- package/components/Image/style.scss +1 -0
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +160 -45
- package/dist/main.node.js +145 -40
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/mdxish-jsx-to-mdast.d.ts +2 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(require("@readme/syntax-highlighter"), require("@readme/variable"), require("@tippyjs/react"), require("acorn"), require("mermaid"), require("react"));
|
|
3
|
+
module.exports = factory(require("@readme/syntax-highlighter"), require("@readme/variable"), require("@tippyjs/react"), require("acorn"), require("mermaid"), require("react"), require("react-dom"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define(["@readme/syntax-highlighter", "@readme/variable", "@tippyjs/react", "acorn", "mermaid", "react"], factory);
|
|
5
|
+
define(["@readme/syntax-highlighter", "@readme/variable", "@tippyjs/react", "acorn", "mermaid", "react", "react-dom"], factory);
|
|
6
6
|
else {
|
|
7
|
-
var a = typeof exports === 'object' ? factory(require("@readme/syntax-highlighter"), require("@readme/variable"), require("@tippyjs/react"), require("acorn"), require("mermaid"), require("react")) : factory(root["@readme/syntax-highlighter"], root["@readme/variable"], root["@tippyjs/react"], root["acorn"], root["mermaid"], root["React"]);
|
|
7
|
+
var a = typeof exports === 'object' ? factory(require("@readme/syntax-highlighter"), require("@readme/variable"), require("@tippyjs/react"), require("acorn"), require("mermaid"), require("react"), require("react-dom")) : factory(root["@readme/syntax-highlighter"], root["@readme/variable"], root["@tippyjs/react"], root["acorn"], root["mermaid"], root["React"], root["ReactDOM"]);
|
|
8
8
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
9
9
|
}
|
|
10
|
-
})(self, (__WEBPACK_EXTERNAL_MODULE__3966__, __WEBPACK_EXTERNAL_MODULE__8167__, __WEBPACK_EXTERNAL_MODULE__4189__, __WEBPACK_EXTERNAL_MODULE__6473__, __WEBPACK_EXTERNAL_MODULE__1387__, __WEBPACK_EXTERNAL_MODULE__1307__) => {
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__3966__, __WEBPACK_EXTERNAL_MODULE__8167__, __WEBPACK_EXTERNAL_MODULE__4189__, __WEBPACK_EXTERNAL_MODULE__6473__, __WEBPACK_EXTERNAL_MODULE__1387__, __WEBPACK_EXTERNAL_MODULE__1307__, __WEBPACK_EXTERNAL_MODULE__8759__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
@@ -11149,6 +11149,14 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__1307__;
|
|
|
11149
11149
|
|
|
11150
11150
|
/***/ }),
|
|
11151
11151
|
|
|
11152
|
+
/***/ 8759:
|
|
11153
|
+
/***/ ((module) => {
|
|
11154
|
+
|
|
11155
|
+
"use strict";
|
|
11156
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__8759__;
|
|
11157
|
+
|
|
11158
|
+
/***/ }),
|
|
11159
|
+
|
|
11152
11160
|
/***/ 9746:
|
|
11153
11161
|
/***/ (() => {
|
|
11154
11162
|
|
|
@@ -11906,8 +11914,20 @@ const CreateHeading = (depth) => {
|
|
|
11906
11914
|
};
|
|
11907
11915
|
/* harmony default export */ const components_Heading = (CreateHeading);
|
|
11908
11916
|
|
|
11917
|
+
// EXTERNAL MODULE: external {"amd":"react-dom","commonjs2":"react-dom","commonjs":"react-dom","root":"ReactDOM","umd":"react-dom"}
|
|
11918
|
+
var external_amd_react_dom_commonjs2_react_dom_commonjs_react_dom_root_ReactDOM_umd_react_dom_ = __webpack_require__(8759);
|
|
11909
11919
|
;// ./components/Image/index.tsx
|
|
11910
11920
|
|
|
11921
|
+
|
|
11922
|
+
/**
|
|
11923
|
+
* Renders lightbox overlay via a React portal to document.body so it escapes
|
|
11924
|
+
* any intermediate CSS stacking contexts and reliably covers all UI chrome.
|
|
11925
|
+
*/
|
|
11926
|
+
const LightboxPortal = ({ children }) => {
|
|
11927
|
+
if (typeof document === 'undefined')
|
|
11928
|
+
return null;
|
|
11929
|
+
return (0,external_amd_react_dom_commonjs2_react_dom_commonjs_react_dom_root_ReactDOM_umd_react_dom_.createPortal)(children, document.body);
|
|
11930
|
+
};
|
|
11911
11931
|
const Image = (Props) => {
|
|
11912
11932
|
const { align = '', alt = '', border: borderProp = false, caption, className = '', height = 'auto', src, title = '', width = 'auto', lazy = true, children, } = Props;
|
|
11913
11933
|
// Normalize border: MDXish passes {false} as the string "false", not a boolean
|
|
@@ -11940,20 +11960,27 @@ const Image = (Props) => {
|
|
|
11940
11960
|
return;
|
|
11941
11961
|
setLightbox(!lightbox);
|
|
11942
11962
|
};
|
|
11963
|
+
const imgElement = (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { alt: alt, className: `img ${caption || children ? 'img-align-center' : align ? `img-align-${align}` : ''} ${border ? 'border' : ''}`, height: height, loading: lazy ? 'lazy' : 'eager', src: src, title: title, width: width }));
|
|
11964
|
+
const lightboxOverlay = lightbox ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement(LightboxPortal, null,
|
|
11965
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("div", { className: "markdown-body" },
|
|
11966
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt || 'Collapse image', className: "img lightbox open", onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
11967
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
|
|
11968
|
+
imgElement,
|
|
11969
|
+
(children || caption) && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, children || caption))),
|
|
11970
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("button", { "aria-label": "Minimize image", className: "lightbox-close", onClick: toggle, type: "button" },
|
|
11971
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("i", { "aria-hidden": "true", className: "fa-solid fa-xmark" }))))) : null;
|
|
11943
11972
|
if (children || caption) {
|
|
11944
11973
|
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
|
|
11945
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className:
|
|
11974
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: "img lightbox closed", onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
11946
11975
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
|
|
11947
|
-
|
|
11976
|
+
imgElement,
|
|
11948
11977
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, children || caption))),
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
lightbox && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("button", { "aria-label": "Minimize image", className: "lightbox-close", type: "button" },
|
|
11956
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("i", { "aria-hidden": "true", className: "fa-solid fa-xmark" })))));
|
|
11978
|
+
lightboxOverlay));
|
|
11979
|
+
}
|
|
11980
|
+
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement(external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Fragment, null,
|
|
11981
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": "Expand image", className: "img lightbox closed", onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
11982
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" }, imgElement)),
|
|
11983
|
+
lightboxOverlay));
|
|
11957
11984
|
};
|
|
11958
11985
|
/* harmony default export */ const components_Image = (Image);
|
|
11959
11986
|
|
|
@@ -95461,7 +95488,7 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
|
|
|
95461
95488
|
data: {
|
|
95462
95489
|
hProperties: {
|
|
95463
95490
|
...(imgData.align && { align: imgData.align }),
|
|
95464
|
-
...(imgData.border && { border: imgData.border
|
|
95491
|
+
...(imgData.border !== undefined && { border: String(imgData.border) !== 'false' }),
|
|
95465
95492
|
...(imgData.sizing && { width: imgWidthBySize[imgData.sizing] }),
|
|
95466
95493
|
},
|
|
95467
95494
|
},
|
|
@@ -95740,7 +95767,7 @@ const constants_INLINE_COMPONENT_TAGS = new Set(['Anchor']);
|
|
|
95740
95767
|
|
|
95741
95768
|
|
|
95742
95769
|
|
|
95743
|
-
const pascalCaseTagPattern = /^<([A-Z][A-Za-z0-9_]*)([^>]*?)(\/?)>([\s\S]*)?$/;
|
|
95770
|
+
const pascalCaseTagPattern = /^<([A-Z][A-Za-z0-9_]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>([\s\S]*)?$/;
|
|
95744
95771
|
const tagAttributePattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+))?/g;
|
|
95745
95772
|
/**
|
|
95746
95773
|
* Maximum number of siblings to scan forward when looking for a closing tag
|
|
@@ -96464,6 +96491,30 @@ const mdxishInlineComponents = () => tree => {
|
|
|
96464
96491
|
|
|
96465
96492
|
|
|
96466
96493
|
|
|
96494
|
+
function toImageAlign(value) {
|
|
96495
|
+
if (value === 'left' || value === 'center' || value === 'right') {
|
|
96496
|
+
return value;
|
|
96497
|
+
}
|
|
96498
|
+
return undefined;
|
|
96499
|
+
}
|
|
96500
|
+
function toBool(value) {
|
|
96501
|
+
if (value === undefined)
|
|
96502
|
+
return undefined;
|
|
96503
|
+
if (typeof value === 'boolean')
|
|
96504
|
+
return value;
|
|
96505
|
+
return value !== '' && value !== 'false';
|
|
96506
|
+
}
|
|
96507
|
+
function mdxish_jsx_to_mdast_extractText(nodes) {
|
|
96508
|
+
return nodes
|
|
96509
|
+
.map(n => {
|
|
96510
|
+
if ('value' in n && typeof n.value === 'string')
|
|
96511
|
+
return n.value;
|
|
96512
|
+
if ('children' in n)
|
|
96513
|
+
return mdxish_jsx_to_mdast_extractText(n.children);
|
|
96514
|
+
return '';
|
|
96515
|
+
})
|
|
96516
|
+
.join('');
|
|
96517
|
+
}
|
|
96467
96518
|
const transformAnchor = (jsx) => {
|
|
96468
96519
|
const attrs = getAttrs(jsx);
|
|
96469
96520
|
const { href = '', label, target, title } = attrs;
|
|
@@ -96485,31 +96536,35 @@ const transformAnchor = (jsx) => {
|
|
|
96485
96536
|
const transformImage = (jsx) => {
|
|
96486
96537
|
const attrs = getAttrs(jsx);
|
|
96487
96538
|
const { align, alt = '', border, caption, className, height, lazy, src = '', title = '', width } = attrs;
|
|
96539
|
+
const validAlign = toImageAlign(align);
|
|
96540
|
+
const sizing = width !== undefined ? String(width) : undefined;
|
|
96488
96541
|
const hProperties = {
|
|
96489
96542
|
alt,
|
|
96490
96543
|
src,
|
|
96491
96544
|
title,
|
|
96492
|
-
...(
|
|
96493
|
-
...(border !== undefined && { border:
|
|
96545
|
+
...(validAlign && { align: validAlign }),
|
|
96546
|
+
...(border !== undefined && { border: toBool(border) }),
|
|
96494
96547
|
...(caption && { caption }),
|
|
96495
96548
|
...(className && { className }),
|
|
96496
96549
|
...(height !== undefined && { height: String(height) }),
|
|
96497
|
-
...(lazy !== undefined && { lazy }),
|
|
96498
|
-
...(
|
|
96550
|
+
...(lazy !== undefined && { lazy: toBool(lazy) }),
|
|
96551
|
+
...(sizing && { sizing }),
|
|
96552
|
+
...(sizing && { width: sizing }),
|
|
96499
96553
|
};
|
|
96500
96554
|
return {
|
|
96501
96555
|
type: NodeTypes.imageBlock,
|
|
96502
|
-
align,
|
|
96556
|
+
align: validAlign,
|
|
96503
96557
|
alt,
|
|
96504
|
-
border:
|
|
96558
|
+
border: toBool(border),
|
|
96505
96559
|
caption,
|
|
96506
96560
|
children: caption ? lib_mdast(caption).children : [],
|
|
96507
96561
|
className,
|
|
96508
96562
|
height: height !== undefined ? String(height) : undefined,
|
|
96509
|
-
lazy,
|
|
96563
|
+
lazy: toBool(lazy),
|
|
96564
|
+
sizing,
|
|
96510
96565
|
src,
|
|
96511
96566
|
title,
|
|
96512
|
-
width:
|
|
96567
|
+
width: sizing,
|
|
96513
96568
|
data: {
|
|
96514
96569
|
hName: 'img',
|
|
96515
96570
|
hProperties,
|
|
@@ -96536,7 +96591,7 @@ const transformCallout = (jsx) => {
|
|
|
96536
96591
|
};
|
|
96537
96592
|
const transformEmbed = (jsx) => {
|
|
96538
96593
|
const attrs = getAttrs(jsx);
|
|
96539
|
-
const { favicon, height, html, iframe, image, providerName, providerUrl, title = '', typeOfEmbed, url = '', width } = attrs;
|
|
96594
|
+
const { favicon, height, html, iframe, image, providerName, providerUrl, title = '', typeOfEmbed, url = '', width, } = attrs;
|
|
96540
96595
|
return {
|
|
96541
96596
|
type: NodeTypes.embedBlock,
|
|
96542
96597
|
title,
|
|
@@ -96582,22 +96637,26 @@ const transformMagicBlockImage = (node) => {
|
|
|
96582
96637
|
const { alt = '', data, position, title = '', url = '' } = node;
|
|
96583
96638
|
const hProps = data?.hProperties || {};
|
|
96584
96639
|
const { align, border, width } = hProps;
|
|
96640
|
+
const validAlign = toImageAlign(align);
|
|
96641
|
+
const sizing = width || undefined;
|
|
96585
96642
|
const hProperties = {
|
|
96586
96643
|
alt,
|
|
96587
96644
|
src: url,
|
|
96588
96645
|
title,
|
|
96589
|
-
...(
|
|
96590
|
-
...(border && { border }),
|
|
96591
|
-
...(
|
|
96646
|
+
...(validAlign && { align: validAlign }),
|
|
96647
|
+
...(border !== undefined && { border: toBool(border) }),
|
|
96648
|
+
...(sizing && { sizing }),
|
|
96649
|
+
...(sizing && { width: sizing }),
|
|
96592
96650
|
};
|
|
96593
96651
|
return {
|
|
96594
96652
|
type: NodeTypes.imageBlock,
|
|
96595
|
-
align,
|
|
96653
|
+
align: validAlign,
|
|
96596
96654
|
alt,
|
|
96597
|
-
border,
|
|
96655
|
+
border: toBool(border),
|
|
96656
|
+
sizing,
|
|
96598
96657
|
src: url,
|
|
96599
96658
|
title,
|
|
96600
|
-
width,
|
|
96659
|
+
width: sizing,
|
|
96601
96660
|
data: {
|
|
96602
96661
|
hName: 'img',
|
|
96603
96662
|
hProperties,
|
|
@@ -96645,7 +96704,8 @@ const COMPONENT_MAP = {
|
|
|
96645
96704
|
* - JSX component elements (Image, Callout, Embed, Recipe) into their corresponding MDAST types
|
|
96646
96705
|
* - Magic block image nodes (type: 'image') into image-block
|
|
96647
96706
|
* - Magic block embed nodes (type: 'embed') into embed-block
|
|
96648
|
-
* - Figure nodes
|
|
96707
|
+
* - Figure nodes (magic blocks with captions) into flat image-block with caption string
|
|
96708
|
+
* - Normalizes all image-block attrs (border, align, sizing, caption) to a consistent shape
|
|
96649
96709
|
*
|
|
96650
96710
|
* This is controlled by the `newEditorTypes` flag to maintain backwards compatibility.
|
|
96651
96711
|
*/
|
|
@@ -96671,12 +96731,10 @@ const mdxishJsxToMdast = () => tree => {
|
|
|
96671
96731
|
}
|
|
96672
96732
|
});
|
|
96673
96733
|
// Transform magic block images (type: 'image') to image-block
|
|
96674
|
-
//
|
|
96675
|
-
// Magic block images are direct children of root, so we handle them here
|
|
96734
|
+
// Images inside paragraphs are standard markdown — handled by imageTransformer, normalized below
|
|
96676
96735
|
visit(tree, 'image', (node, index, parent) => {
|
|
96677
96736
|
if (!parent || index === undefined)
|
|
96678
96737
|
return SKIP;
|
|
96679
|
-
// Skip images inside paragraphs (those are standard markdown images handled by imageTransformer)
|
|
96680
96738
|
if (parent.type === 'paragraph')
|
|
96681
96739
|
return SKIP;
|
|
96682
96740
|
const newNode = transformMagicBlockImage(node);
|
|
@@ -96691,16 +96749,74 @@ const mdxishJsxToMdast = () => tree => {
|
|
|
96691
96749
|
parent.children[index] = newNode;
|
|
96692
96750
|
return SKIP;
|
|
96693
96751
|
});
|
|
96694
|
-
//
|
|
96752
|
+
// Flatten figure nodes (magic blocks with captions) into image-block nodes
|
|
96695
96753
|
const isFigure = (node) => node.type === 'figure';
|
|
96696
|
-
visit(tree, isFigure, node => {
|
|
96697
|
-
|
|
96698
|
-
|
|
96699
|
-
|
|
96700
|
-
|
|
96701
|
-
|
|
96702
|
-
|
|
96703
|
-
|
|
96754
|
+
visit(tree, isFigure, (node, index, parent) => {
|
|
96755
|
+
if (!parent || index === undefined)
|
|
96756
|
+
return;
|
|
96757
|
+
const imageChild = node.children.find(child => child.type === 'image' || child.type === NodeTypes.imageBlock);
|
|
96758
|
+
if (!imageChild)
|
|
96759
|
+
return;
|
|
96760
|
+
const figcaptionChild = node.children.find(child => child.type === 'figcaption');
|
|
96761
|
+
// If the image was already transformed to image-block by the earlier visitor, use it directly
|
|
96762
|
+
const imageBlock = imageChild.type === NodeTypes.imageBlock
|
|
96763
|
+
? imageChild
|
|
96764
|
+
: transformMagicBlockImage(imageChild);
|
|
96765
|
+
if (figcaptionChild?.children) {
|
|
96766
|
+
const caption = mdxish_jsx_to_mdast_extractText(figcaptionChild.children);
|
|
96767
|
+
if (caption) {
|
|
96768
|
+
imageBlock.caption = caption;
|
|
96769
|
+
imageBlock.data.hProperties.caption = caption;
|
|
96770
|
+
}
|
|
96771
|
+
}
|
|
96772
|
+
parent.children[index] = imageBlock;
|
|
96773
|
+
});
|
|
96774
|
+
// Final normalization pass across all image-block nodes
|
|
96775
|
+
// Ensures consistent types (border→boolean, align→ImageAlign, width→sizing) and cleans up artifacts
|
|
96776
|
+
const isImageBlock = (node) => node.type === NodeTypes.imageBlock;
|
|
96777
|
+
visit(tree, isImageBlock, _node => {
|
|
96778
|
+
const node = _node;
|
|
96779
|
+
const hProps = (node.data?.hProperties || {});
|
|
96780
|
+
// Normalize boolean attrs
|
|
96781
|
+
if (hProps.border !== undefined) {
|
|
96782
|
+
const val = toBool(hProps.border);
|
|
96783
|
+
node.border = val;
|
|
96784
|
+
hProps.border = val;
|
|
96785
|
+
}
|
|
96786
|
+
else if (node.border !== undefined) {
|
|
96787
|
+
node.border = toBool(node.border);
|
|
96788
|
+
}
|
|
96789
|
+
// Validate align
|
|
96790
|
+
const validAlign = toImageAlign(hProps.align) || toImageAlign(node.align);
|
|
96791
|
+
node.align = validAlign;
|
|
96792
|
+
if (validAlign) {
|
|
96793
|
+
hProps.align = validAlign;
|
|
96794
|
+
}
|
|
96795
|
+
else {
|
|
96796
|
+
delete hProps.align;
|
|
96797
|
+
}
|
|
96798
|
+
// Map width → sizing
|
|
96799
|
+
const width = hProps.width || node.width;
|
|
96800
|
+
if (width) {
|
|
96801
|
+
node.sizing = width;
|
|
96802
|
+
node.width = width;
|
|
96803
|
+
hProps.sizing = width;
|
|
96804
|
+
hProps.width = width;
|
|
96805
|
+
}
|
|
96806
|
+
// Normalize caption
|
|
96807
|
+
const caption = hProps.caption || node.caption;
|
|
96808
|
+
if (caption) {
|
|
96809
|
+
node.caption = caption;
|
|
96810
|
+
hProps.caption = caption;
|
|
96811
|
+
}
|
|
96812
|
+
// Normalize src (url → src)
|
|
96813
|
+
node.src = hProps.src || node.src;
|
|
96814
|
+
hProps.src = node.src;
|
|
96815
|
+
// Remove stray children array from imageTransformer, but preserve caption children
|
|
96816
|
+
if (!caption) {
|
|
96817
|
+
delete node.children;
|
|
96818
|
+
}
|
|
96819
|
+
delete hProps.children;
|
|
96704
96820
|
});
|
|
96705
96821
|
return tree;
|
|
96706
96822
|
};
|
|
@@ -99063,7 +99179,6 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
99063
99179
|
.use(mdxish_html_blocks)
|
|
99064
99180
|
.use(newEditorTypes ? mdxish_inline_components : undefined) // Merge inline html components (e.g. <Anchor>) into MDAST nodes
|
|
99065
99181
|
.use(newEditorTypes ? mdxish_jsx_to_mdast : undefined) // Convert block JSX elements to MDAST types
|
|
99066
|
-
.use(safeMode ? undefined : evaluate_expressions, { context: jsxContext }) // Evaluate MDX expressions using jsxContext
|
|
99067
99182
|
.use(variables_text) // Parse {user.*} patterns from text nodes
|
|
99068
99183
|
.use(useTailwind ? transform_tailwind : undefined, { components: tempComponentsMap })
|
|
99069
99184
|
.use(remarkGfm);
|
package/dist/main.node.js
CHANGED
|
@@ -24514,6 +24514,16 @@ const CreateHeading = (depth) => {
|
|
|
24514
24514
|
|
|
24515
24515
|
;// ./components/Image/index.tsx
|
|
24516
24516
|
|
|
24517
|
+
|
|
24518
|
+
/**
|
|
24519
|
+
* Renders lightbox overlay via a React portal to document.body so it escapes
|
|
24520
|
+
* any intermediate CSS stacking contexts and reliably covers all UI chrome.
|
|
24521
|
+
*/
|
|
24522
|
+
const LightboxPortal = ({ children }) => {
|
|
24523
|
+
if (typeof document === 'undefined')
|
|
24524
|
+
return null;
|
|
24525
|
+
return (0,external_react_dom_namespaceObject.createPortal)(children, document.body);
|
|
24526
|
+
};
|
|
24517
24527
|
const Image = (Props) => {
|
|
24518
24528
|
const { align = '', alt = '', border: borderProp = false, caption, className = '', height = 'auto', src, title = '', width = 'auto', lazy = true, children, } = Props;
|
|
24519
24529
|
// Normalize border: MDXish passes {false} as the string "false", not a boolean
|
|
@@ -24546,20 +24556,27 @@ const Image = (Props) => {
|
|
|
24546
24556
|
return;
|
|
24547
24557
|
setLightbox(!lightbox);
|
|
24548
24558
|
};
|
|
24559
|
+
const imgElement = (external_react_.createElement("img", { alt: alt, className: `img ${caption || children ? 'img-align-center' : align ? `img-align-${align}` : ''} ${border ? 'border' : ''}`, height: height, loading: lazy ? 'lazy' : 'eager', src: src, title: title, width: width }));
|
|
24560
|
+
const lightboxOverlay = lightbox ? (external_react_.createElement(LightboxPortal, null,
|
|
24561
|
+
external_react_.createElement("div", { className: "markdown-body" },
|
|
24562
|
+
external_react_.createElement("span", { "aria-label": alt || 'Collapse image', className: "img lightbox open", onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
24563
|
+
external_react_.createElement("span", { className: "lightbox-inner" },
|
|
24564
|
+
imgElement,
|
|
24565
|
+
(children || caption) && external_react_.createElement("figcaption", null, children || caption))),
|
|
24566
|
+
external_react_.createElement("button", { "aria-label": "Minimize image", className: "lightbox-close", onClick: toggle, type: "button" },
|
|
24567
|
+
external_react_.createElement("i", { "aria-hidden": "true", className: "fa-solid fa-xmark" }))))) : null;
|
|
24549
24568
|
if (children || caption) {
|
|
24550
24569
|
return (external_react_.createElement("figure", null,
|
|
24551
|
-
external_react_.createElement("span", { "aria-label": alt, className:
|
|
24570
|
+
external_react_.createElement("span", { "aria-label": alt, className: "img lightbox closed", onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
24552
24571
|
external_react_.createElement("span", { className: "lightbox-inner" },
|
|
24553
|
-
|
|
24572
|
+
imgElement,
|
|
24554
24573
|
external_react_.createElement("figcaption", null, children || caption))),
|
|
24555
|
-
|
|
24556
|
-
external_react_.createElement("i", { "aria-hidden": "true", className: "fa-solid fa-xmark" })))));
|
|
24574
|
+
lightboxOverlay));
|
|
24557
24575
|
}
|
|
24558
|
-
return (external_react_.createElement(
|
|
24559
|
-
external_react_.createElement("span", { className: "lightbox
|
|
24560
|
-
external_react_.createElement("
|
|
24561
|
-
|
|
24562
|
-
external_react_.createElement("i", { "aria-hidden": "true", className: "fa-solid fa-xmark" })))));
|
|
24576
|
+
return (external_react_.createElement(external_react_.Fragment, null,
|
|
24577
|
+
external_react_.createElement("span", { "aria-label": "Expand image", className: "img lightbox closed", onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
24578
|
+
external_react_.createElement("span", { className: "lightbox-inner" }, imgElement)),
|
|
24579
|
+
lightboxOverlay));
|
|
24563
24580
|
};
|
|
24564
24581
|
/* harmony default export */ const components_Image = (Image);
|
|
24565
24582
|
|
|
@@ -115665,7 +115682,7 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
|
|
|
115665
115682
|
data: {
|
|
115666
115683
|
hProperties: {
|
|
115667
115684
|
...(imgData.align && { align: imgData.align }),
|
|
115668
|
-
...(imgData.border && { border: imgData.border
|
|
115685
|
+
...(imgData.border !== undefined && { border: String(imgData.border) !== 'false' }),
|
|
115669
115686
|
...(imgData.sizing && { width: imgWidthBySize[imgData.sizing] }),
|
|
115670
115687
|
},
|
|
115671
115688
|
},
|
|
@@ -115944,7 +115961,7 @@ const constants_INLINE_COMPONENT_TAGS = new Set(['Anchor']);
|
|
|
115944
115961
|
|
|
115945
115962
|
|
|
115946
115963
|
|
|
115947
|
-
const pascalCaseTagPattern = /^<([A-Z][A-Za-z0-9_]*)([^>]*?)(\/?)>([\s\S]*)?$/;
|
|
115964
|
+
const pascalCaseTagPattern = /^<([A-Z][A-Za-z0-9_]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>([\s\S]*)?$/;
|
|
115948
115965
|
const tagAttributePattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+))?/g;
|
|
115949
115966
|
/**
|
|
115950
115967
|
* Maximum number of siblings to scan forward when looking for a closing tag
|
|
@@ -116668,6 +116685,30 @@ const mdxishInlineComponents = () => tree => {
|
|
|
116668
116685
|
|
|
116669
116686
|
|
|
116670
116687
|
|
|
116688
|
+
function toImageAlign(value) {
|
|
116689
|
+
if (value === 'left' || value === 'center' || value === 'right') {
|
|
116690
|
+
return value;
|
|
116691
|
+
}
|
|
116692
|
+
return undefined;
|
|
116693
|
+
}
|
|
116694
|
+
function toBool(value) {
|
|
116695
|
+
if (value === undefined)
|
|
116696
|
+
return undefined;
|
|
116697
|
+
if (typeof value === 'boolean')
|
|
116698
|
+
return value;
|
|
116699
|
+
return value !== '' && value !== 'false';
|
|
116700
|
+
}
|
|
116701
|
+
function mdxish_jsx_to_mdast_extractText(nodes) {
|
|
116702
|
+
return nodes
|
|
116703
|
+
.map(n => {
|
|
116704
|
+
if ('value' in n && typeof n.value === 'string')
|
|
116705
|
+
return n.value;
|
|
116706
|
+
if ('children' in n)
|
|
116707
|
+
return mdxish_jsx_to_mdast_extractText(n.children);
|
|
116708
|
+
return '';
|
|
116709
|
+
})
|
|
116710
|
+
.join('');
|
|
116711
|
+
}
|
|
116671
116712
|
const transformAnchor = (jsx) => {
|
|
116672
116713
|
const attrs = getAttrs(jsx);
|
|
116673
116714
|
const { href = '', label, target, title } = attrs;
|
|
@@ -116689,31 +116730,35 @@ const transformAnchor = (jsx) => {
|
|
|
116689
116730
|
const transformImage = (jsx) => {
|
|
116690
116731
|
const attrs = getAttrs(jsx);
|
|
116691
116732
|
const { align, alt = '', border, caption, className, height, lazy, src = '', title = '', width } = attrs;
|
|
116733
|
+
const validAlign = toImageAlign(align);
|
|
116734
|
+
const sizing = width !== undefined ? String(width) : undefined;
|
|
116692
116735
|
const hProperties = {
|
|
116693
116736
|
alt,
|
|
116694
116737
|
src,
|
|
116695
116738
|
title,
|
|
116696
|
-
...(
|
|
116697
|
-
...(border !== undefined && { border:
|
|
116739
|
+
...(validAlign && { align: validAlign }),
|
|
116740
|
+
...(border !== undefined && { border: toBool(border) }),
|
|
116698
116741
|
...(caption && { caption }),
|
|
116699
116742
|
...(className && { className }),
|
|
116700
116743
|
...(height !== undefined && { height: String(height) }),
|
|
116701
|
-
...(lazy !== undefined && { lazy }),
|
|
116702
|
-
...(
|
|
116744
|
+
...(lazy !== undefined && { lazy: toBool(lazy) }),
|
|
116745
|
+
...(sizing && { sizing }),
|
|
116746
|
+
...(sizing && { width: sizing }),
|
|
116703
116747
|
};
|
|
116704
116748
|
return {
|
|
116705
116749
|
type: NodeTypes.imageBlock,
|
|
116706
|
-
align,
|
|
116750
|
+
align: validAlign,
|
|
116707
116751
|
alt,
|
|
116708
|
-
border:
|
|
116752
|
+
border: toBool(border),
|
|
116709
116753
|
caption,
|
|
116710
116754
|
children: caption ? lib_mdast(caption).children : [],
|
|
116711
116755
|
className,
|
|
116712
116756
|
height: height !== undefined ? String(height) : undefined,
|
|
116713
|
-
lazy,
|
|
116757
|
+
lazy: toBool(lazy),
|
|
116758
|
+
sizing,
|
|
116714
116759
|
src,
|
|
116715
116760
|
title,
|
|
116716
|
-
width:
|
|
116761
|
+
width: sizing,
|
|
116717
116762
|
data: {
|
|
116718
116763
|
hName: 'img',
|
|
116719
116764
|
hProperties,
|
|
@@ -116740,7 +116785,7 @@ const transformCallout = (jsx) => {
|
|
|
116740
116785
|
};
|
|
116741
116786
|
const transformEmbed = (jsx) => {
|
|
116742
116787
|
const attrs = getAttrs(jsx);
|
|
116743
|
-
const { favicon, height, html, iframe, image, providerName, providerUrl, title = '', typeOfEmbed, url = '', width } = attrs;
|
|
116788
|
+
const { favicon, height, html, iframe, image, providerName, providerUrl, title = '', typeOfEmbed, url = '', width, } = attrs;
|
|
116744
116789
|
return {
|
|
116745
116790
|
type: NodeTypes.embedBlock,
|
|
116746
116791
|
title,
|
|
@@ -116786,22 +116831,26 @@ const transformMagicBlockImage = (node) => {
|
|
|
116786
116831
|
const { alt = '', data, position, title = '', url = '' } = node;
|
|
116787
116832
|
const hProps = data?.hProperties || {};
|
|
116788
116833
|
const { align, border, width } = hProps;
|
|
116834
|
+
const validAlign = toImageAlign(align);
|
|
116835
|
+
const sizing = width || undefined;
|
|
116789
116836
|
const hProperties = {
|
|
116790
116837
|
alt,
|
|
116791
116838
|
src: url,
|
|
116792
116839
|
title,
|
|
116793
|
-
...(
|
|
116794
|
-
...(border && { border }),
|
|
116795
|
-
...(
|
|
116840
|
+
...(validAlign && { align: validAlign }),
|
|
116841
|
+
...(border !== undefined && { border: toBool(border) }),
|
|
116842
|
+
...(sizing && { sizing }),
|
|
116843
|
+
...(sizing && { width: sizing }),
|
|
116796
116844
|
};
|
|
116797
116845
|
return {
|
|
116798
116846
|
type: NodeTypes.imageBlock,
|
|
116799
|
-
align,
|
|
116847
|
+
align: validAlign,
|
|
116800
116848
|
alt,
|
|
116801
|
-
border,
|
|
116849
|
+
border: toBool(border),
|
|
116850
|
+
sizing,
|
|
116802
116851
|
src: url,
|
|
116803
116852
|
title,
|
|
116804
|
-
width,
|
|
116853
|
+
width: sizing,
|
|
116805
116854
|
data: {
|
|
116806
116855
|
hName: 'img',
|
|
116807
116856
|
hProperties,
|
|
@@ -116849,7 +116898,8 @@ const COMPONENT_MAP = {
|
|
|
116849
116898
|
* - JSX component elements (Image, Callout, Embed, Recipe) into their corresponding MDAST types
|
|
116850
116899
|
* - Magic block image nodes (type: 'image') into image-block
|
|
116851
116900
|
* - Magic block embed nodes (type: 'embed') into embed-block
|
|
116852
|
-
* - Figure nodes
|
|
116901
|
+
* - Figure nodes (magic blocks with captions) into flat image-block with caption string
|
|
116902
|
+
* - Normalizes all image-block attrs (border, align, sizing, caption) to a consistent shape
|
|
116853
116903
|
*
|
|
116854
116904
|
* This is controlled by the `newEditorTypes` flag to maintain backwards compatibility.
|
|
116855
116905
|
*/
|
|
@@ -116875,12 +116925,10 @@ const mdxishJsxToMdast = () => tree => {
|
|
|
116875
116925
|
}
|
|
116876
116926
|
});
|
|
116877
116927
|
// Transform magic block images (type: 'image') to image-block
|
|
116878
|
-
//
|
|
116879
|
-
// Magic block images are direct children of root, so we handle them here
|
|
116928
|
+
// Images inside paragraphs are standard markdown — handled by imageTransformer, normalized below
|
|
116880
116929
|
visit(tree, 'image', (node, index, parent) => {
|
|
116881
116930
|
if (!parent || index === undefined)
|
|
116882
116931
|
return SKIP;
|
|
116883
|
-
// Skip images inside paragraphs (those are standard markdown images handled by imageTransformer)
|
|
116884
116932
|
if (parent.type === 'paragraph')
|
|
116885
116933
|
return SKIP;
|
|
116886
116934
|
const newNode = transformMagicBlockImage(node);
|
|
@@ -116895,16 +116943,74 @@ const mdxishJsxToMdast = () => tree => {
|
|
|
116895
116943
|
parent.children[index] = newNode;
|
|
116896
116944
|
return SKIP;
|
|
116897
116945
|
});
|
|
116898
|
-
//
|
|
116946
|
+
// Flatten figure nodes (magic blocks with captions) into image-block nodes
|
|
116899
116947
|
const isFigure = (node) => node.type === 'figure';
|
|
116900
|
-
visit(tree, isFigure, node => {
|
|
116901
|
-
|
|
116902
|
-
|
|
116903
|
-
|
|
116904
|
-
|
|
116905
|
-
|
|
116906
|
-
|
|
116907
|
-
|
|
116948
|
+
visit(tree, isFigure, (node, index, parent) => {
|
|
116949
|
+
if (!parent || index === undefined)
|
|
116950
|
+
return;
|
|
116951
|
+
const imageChild = node.children.find(child => child.type === 'image' || child.type === NodeTypes.imageBlock);
|
|
116952
|
+
if (!imageChild)
|
|
116953
|
+
return;
|
|
116954
|
+
const figcaptionChild = node.children.find(child => child.type === 'figcaption');
|
|
116955
|
+
// If the image was already transformed to image-block by the earlier visitor, use it directly
|
|
116956
|
+
const imageBlock = imageChild.type === NodeTypes.imageBlock
|
|
116957
|
+
? imageChild
|
|
116958
|
+
: transformMagicBlockImage(imageChild);
|
|
116959
|
+
if (figcaptionChild?.children) {
|
|
116960
|
+
const caption = mdxish_jsx_to_mdast_extractText(figcaptionChild.children);
|
|
116961
|
+
if (caption) {
|
|
116962
|
+
imageBlock.caption = caption;
|
|
116963
|
+
imageBlock.data.hProperties.caption = caption;
|
|
116964
|
+
}
|
|
116965
|
+
}
|
|
116966
|
+
parent.children[index] = imageBlock;
|
|
116967
|
+
});
|
|
116968
|
+
// Final normalization pass across all image-block nodes
|
|
116969
|
+
// Ensures consistent types (border→boolean, align→ImageAlign, width→sizing) and cleans up artifacts
|
|
116970
|
+
const isImageBlock = (node) => node.type === NodeTypes.imageBlock;
|
|
116971
|
+
visit(tree, isImageBlock, _node => {
|
|
116972
|
+
const node = _node;
|
|
116973
|
+
const hProps = (node.data?.hProperties || {});
|
|
116974
|
+
// Normalize boolean attrs
|
|
116975
|
+
if (hProps.border !== undefined) {
|
|
116976
|
+
const val = toBool(hProps.border);
|
|
116977
|
+
node.border = val;
|
|
116978
|
+
hProps.border = val;
|
|
116979
|
+
}
|
|
116980
|
+
else if (node.border !== undefined) {
|
|
116981
|
+
node.border = toBool(node.border);
|
|
116982
|
+
}
|
|
116983
|
+
// Validate align
|
|
116984
|
+
const validAlign = toImageAlign(hProps.align) || toImageAlign(node.align);
|
|
116985
|
+
node.align = validAlign;
|
|
116986
|
+
if (validAlign) {
|
|
116987
|
+
hProps.align = validAlign;
|
|
116988
|
+
}
|
|
116989
|
+
else {
|
|
116990
|
+
delete hProps.align;
|
|
116991
|
+
}
|
|
116992
|
+
// Map width → sizing
|
|
116993
|
+
const width = hProps.width || node.width;
|
|
116994
|
+
if (width) {
|
|
116995
|
+
node.sizing = width;
|
|
116996
|
+
node.width = width;
|
|
116997
|
+
hProps.sizing = width;
|
|
116998
|
+
hProps.width = width;
|
|
116999
|
+
}
|
|
117000
|
+
// Normalize caption
|
|
117001
|
+
const caption = hProps.caption || node.caption;
|
|
117002
|
+
if (caption) {
|
|
117003
|
+
node.caption = caption;
|
|
117004
|
+
hProps.caption = caption;
|
|
117005
|
+
}
|
|
117006
|
+
// Normalize src (url → src)
|
|
117007
|
+
node.src = hProps.src || node.src;
|
|
117008
|
+
hProps.src = node.src;
|
|
117009
|
+
// Remove stray children array from imageTransformer, but preserve caption children
|
|
117010
|
+
if (!caption) {
|
|
117011
|
+
delete node.children;
|
|
117012
|
+
}
|
|
117013
|
+
delete hProps.children;
|
|
116908
117014
|
});
|
|
116909
117015
|
return tree;
|
|
116910
117016
|
};
|
|
@@ -119267,7 +119373,6 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
119267
119373
|
.use(mdxish_html_blocks)
|
|
119268
119374
|
.use(newEditorTypes ? mdxish_inline_components : undefined) // Merge inline html components (e.g. <Anchor>) into MDAST nodes
|
|
119269
119375
|
.use(newEditorTypes ? mdxish_jsx_to_mdast : undefined) // Convert block JSX elements to MDAST types
|
|
119270
|
-
.use(safeMode ? undefined : evaluate_expressions, { context: jsxContext }) // Evaluate MDX expressions using jsxContext
|
|
119271
119376
|
.use(variables_text) // Parse {user.*} patterns from text nodes
|
|
119272
119377
|
.use(useTailwind ? transform_tailwind : undefined, { components: tempComponentsMap })
|
|
119273
119378
|
.use(remarkGfm);
|