@pagopa/io-app-design-system 6.0.6 → 6.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/lib/commonjs/components/badge/Badge.js +2 -2
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/badge/__test__/__snapshots__/badge.test.tsx.snap +2 -2
- package/lib/commonjs/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +3 -3
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -6
- package/lib/commonjs/components/index.js +30 -19
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/markdown/CodeBlock.js +36 -0
- package/lib/commonjs/components/markdown/CodeBlock.js.map +1 -0
- package/lib/commonjs/components/markdown/IOMarkdown.js +71 -0
- package/lib/commonjs/components/markdown/IOMarkdown.js.map +1 -0
- package/lib/commonjs/components/markdown/IOMarkdownLite.js +22 -0
- package/lib/commonjs/components/markdown/IOMarkdownLite.js.map +1 -0
- package/lib/commonjs/components/markdown/ImageRenderer.js +53 -0
- package/lib/commonjs/components/markdown/ImageRenderer.js.map +1 -0
- package/lib/commonjs/components/markdown/index.js +20 -0
- package/lib/commonjs/components/markdown/index.js.map +1 -0
- package/lib/commonjs/components/markdown/parser.js +253 -0
- package/lib/commonjs/components/markdown/parser.js.map +1 -0
- package/lib/commonjs/components/markdown/rules.js +324 -0
- package/lib/commonjs/components/markdown/rules.js.map +1 -0
- package/lib/commonjs/components/markdown/types.js +6 -0
- package/lib/commonjs/components/markdown/types.js.map +1 -0
- package/lib/commonjs/components/markdown/utils.js +113 -0
- package/lib/commonjs/components/markdown/utils.js.map +1 -0
- package/lib/commonjs/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +2 -2
- package/lib/commonjs/components/otpInput/OTPInput.js +41 -26
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/tag/Tag.js +2 -1
- package/lib/commonjs/components/tag/Tag.js.map +1 -1
- package/lib/commonjs/components/toast/ToastProvider.js +3 -3
- package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
- package/lib/commonjs/components/tooltip/Tooltip.js +3 -3
- package/lib/commonjs/components/tooltip/Tooltip.js.map +1 -1
- package/lib/commonjs/components/typography/BodySmall.js +6 -3
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/commonjs/components/typography/IOText.js +2 -3
- package/lib/commonjs/components/typography/IOText.js.map +1 -1
- package/lib/commonjs/utils/pipe.js +29 -0
- package/lib/commonjs/utils/pipe.js.map +1 -0
- package/lib/commonjs/utils/throttle.js +19 -0
- package/lib/commonjs/utils/throttle.js.map +1 -0
- package/lib/module/components/badge/Badge.js +2 -2
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/badge/__test__/__snapshots__/badge.test.tsx.snap +2 -2
- package/lib/module/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +3 -3
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -6
- package/lib/module/components/index.js +3 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/markdown/CodeBlock.js +31 -0
- package/lib/module/components/markdown/CodeBlock.js.map +1 -0
- package/lib/module/components/markdown/IOMarkdown.js +66 -0
- package/lib/module/components/markdown/IOMarkdown.js.map +1 -0
- package/lib/module/components/markdown/IOMarkdownLite.js +17 -0
- package/lib/module/components/markdown/IOMarkdownLite.js.map +1 -0
- package/lib/module/components/markdown/ImageRenderer.js +48 -0
- package/lib/module/components/markdown/ImageRenderer.js.map +1 -0
- package/lib/module/components/markdown/index.js +5 -0
- package/lib/module/components/markdown/index.js.map +1 -0
- package/lib/module/components/markdown/parser.js +246 -0
- package/lib/module/components/markdown/parser.js.map +1 -0
- package/lib/module/components/markdown/rules.js +319 -0
- package/lib/module/components/markdown/rules.js.map +1 -0
- package/lib/module/components/markdown/types.js +4 -0
- package/lib/module/components/markdown/types.js.map +1 -0
- package/lib/module/components/markdown/utils.js +103 -0
- package/lib/module/components/markdown/utils.js.map +1 -0
- package/lib/module/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +2 -2
- package/lib/module/components/otpInput/OTPInput.js +42 -27
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/tag/Tag.js +2 -1
- package/lib/module/components/tag/Tag.js.map +1 -1
- package/lib/module/components/toast/ToastProvider.js +1 -1
- package/lib/module/components/toast/ToastProvider.js.map +1 -1
- package/lib/module/components/tooltip/Tooltip.js +3 -3
- package/lib/module/components/tooltip/Tooltip.js.map +1 -1
- package/lib/module/components/typography/BodySmall.js +5 -2
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/typography/IOText.js +3 -4
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/utils/pipe.js +25 -0
- package/lib/module/utils/pipe.js.map +1 -0
- package/lib/module/utils/throttle.js +14 -0
- package/lib/module/utils/throttle.js.map +1 -0
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +3 -2
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/markdown/CodeBlock.d.ts +10 -0
- package/lib/typescript/components/markdown/CodeBlock.d.ts.map +1 -0
- package/lib/typescript/components/markdown/IOMarkdown.d.ts +34 -0
- package/lib/typescript/components/markdown/IOMarkdown.d.ts.map +1 -0
- package/lib/typescript/components/markdown/IOMarkdownLite.d.ts +22 -0
- package/lib/typescript/components/markdown/IOMarkdownLite.d.ts.map +1 -0
- package/lib/typescript/components/markdown/ImageRenderer.d.ts +12 -0
- package/lib/typescript/components/markdown/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/components/markdown/index.d.ts +6 -0
- package/lib/typescript/components/markdown/index.d.ts.map +1 -0
- package/lib/typescript/components/markdown/parser.d.ts +17 -0
- package/lib/typescript/components/markdown/parser.d.ts.map +1 -0
- package/lib/typescript/components/markdown/rules.d.ts +6 -0
- package/lib/typescript/components/markdown/rules.d.ts.map +1 -0
- package/lib/typescript/components/markdown/types.d.ts +41 -0
- package/lib/typescript/components/markdown/types.d.ts.map +1 -0
- package/lib/typescript/components/markdown/utils.d.ts +27 -0
- package/lib/typescript/components/markdown/utils.d.ts.map +1 -0
- package/lib/typescript/components/otpInput/OTPInput.d.ts +4 -0
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/tag/Tag.d.ts.map +1 -1
- package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts +2 -0
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/utils/pipe.d.ts +25 -0
- package/lib/typescript/utils/pipe.d.ts.map +1 -0
- package/lib/typescript/utils/throttle.d.ts +2 -0
- package/lib/typescript/utils/throttle.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/badge/Badge.tsx +2 -2
- package/src/components/badge/__test__/__snapshots__/badge.test.tsx.snap +2 -2
- package/src/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +3 -3
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -6
- package/src/components/index.tsx +3 -2
- package/src/components/markdown/CodeBlock.tsx +32 -0
- package/src/components/markdown/IOMarkdown.tsx +110 -0
- package/src/components/markdown/IOMarkdownLite.tsx +27 -0
- package/src/components/markdown/ImageRenderer.tsx +52 -0
- package/src/components/markdown/index.ts +7 -0
- package/src/components/markdown/parser.ts +334 -0
- package/src/components/markdown/rules.tsx +366 -0
- package/src/components/markdown/types.ts +81 -0
- package/src/components/markdown/utils.ts +127 -0
- package/src/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +2 -2
- package/src/components/otpInput/OTPInput.tsx +57 -32
- package/src/components/tag/Tag.tsx +2 -1
- package/src/components/toast/ToastProvider.tsx +1 -1
- package/src/components/tooltip/Tooltip.tsx +4 -3
- package/src/components/typography/BodySmall.tsx +5 -2
- package/src/components/typography/IOText.tsx +5 -15
- package/src/utils/pipe.ts +55 -0
- package/src/utils/throttle.ts +15 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.throttle = void 0;
|
|
7
|
+
const throttle = (fn, ms) => {
|
|
8
|
+
// eslint-disable-next-line functional/no-let
|
|
9
|
+
let lastCall = 0;
|
|
10
|
+
return (...args) => {
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
if (now - lastCall >= ms) {
|
|
13
|
+
lastCall = now;
|
|
14
|
+
fn(...args);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.throttle = throttle;
|
|
19
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["throttle","fn","ms","lastCall","args","now","Date","exports"],"sourceRoot":"../../../src","sources":["utils/throttle.ts"],"mappings":";;;;;;AAAO,MAAMA,QAAQ,GAAGA,CACtBC,EAAwB,EACxBC,EAAU,KACP;EACH;EACA,IAAIC,QAAQ,GAAG,CAAC;EAChB,OAAO,CAAC,GAAGC,IAAO,KAAK;IACrB,MAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAC,CAAC;IAEtB,IAAIA,GAAG,GAAGF,QAAQ,IAAID,EAAE,EAAE;MACxBC,QAAQ,GAAGE,GAAG;MACdJ,EAAE,CAAC,GAAGG,IAAI,CAAC;IACb;EACF,CAAC;AACH,CAAC;AAACG,OAAA,CAAAP,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -11,6 +11,7 @@ const styles = StyleSheet.create({
|
|
|
11
11
|
flexDirection: "row",
|
|
12
12
|
alignItems: "center",
|
|
13
13
|
justifyContent: "center",
|
|
14
|
+
overflow: "hidden",
|
|
14
15
|
borderCurve: "continuous",
|
|
15
16
|
...Platform.select({
|
|
16
17
|
android: {
|
|
@@ -167,8 +168,7 @@ export const Badge = ({
|
|
|
167
168
|
style: {
|
|
168
169
|
alignSelf: "center",
|
|
169
170
|
textTransform: "uppercase",
|
|
170
|
-
letterSpacing: 0.5
|
|
171
|
-
flexShrink: 1
|
|
171
|
+
letterSpacing: 0.5
|
|
172
172
|
},
|
|
173
173
|
children: text
|
|
174
174
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","StyleSheet","View","useIOThemeContext","hexToRgba","IOBadgeHSpacing","IOBadgeRadius","IOBadgeVSpacing","IOColors","useIOFontDynamicScale","IOText","jsx","_jsx","styles","create","badge","flexDirection","alignItems","justifyContent","borderCurve","select","android","textAlignVertical","badgeStaticStyle","borderRadius","paddingHorizontal","paddingVertical","Badge","text","outline","allowFontScaling","variant","accessible","testID","dynamicFontScale","themeType","bgOpacityDarkMode","mapVariantsLightMode","default","foreground","background","warning","success","error","cgn","highlight","mapVariantsDarkMode","mapOutlineVariantsLightMode","mapOutlineVariantsDarkMode","variantMap","dynamicStyle","style","borderWidth","borderColor","backgroundColor","undefined","children","weight","size","lineHeight","color","numberOfLines","ellipsizeMode","alignSelf","textTransform","letterSpacing"
|
|
1
|
+
{"version":3,"names":["Platform","StyleSheet","View","useIOThemeContext","hexToRgba","IOBadgeHSpacing","IOBadgeRadius","IOBadgeVSpacing","IOColors","useIOFontDynamicScale","IOText","jsx","_jsx","styles","create","badge","flexDirection","alignItems","justifyContent","overflow","borderCurve","select","android","textAlignVertical","badgeStaticStyle","borderRadius","paddingHorizontal","paddingVertical","Badge","text","outline","allowFontScaling","variant","accessible","testID","dynamicFontScale","themeType","bgOpacityDarkMode","mapVariantsLightMode","default","foreground","background","warning","success","error","cgn","highlight","mapVariantsDarkMode","mapOutlineVariantsLightMode","mapOutlineVariantsDarkMode","variantMap","dynamicStyle","style","borderWidth","borderColor","backgroundColor","undefined","children","weight","size","lineHeight","color","numberOfLines","ellipsizeMode","alignSelf","textTransform","letterSpacing"],"sourceRoot":"../../../../src","sources":["components/badge/Badge.tsx"],"mappings":";;AAAA,SAEEA,QAAQ,EACRC,UAAU,EACVC,IAAI,QAEC,cAAc;AACrB,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SACEC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,QAAQ,QACH,YAAY;AACnB,SAASC,qBAAqB,QAAQ,2BAA2B;AAEjE,SAASC,MAAM,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAoBvC,MAAMC,MAAM,GAAGZ,UAAU,CAACa,MAAM,CAAC;EAC/BC,KAAK,EAAE;IACLC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,QAAQ,EAAE,QAAQ;IAClBC,WAAW,EAAE,YAAY;IACzB,GAAGpB,QAAQ,CAACqB,MAAM,CAAC;MACjBC,OAAO,EAAE;QACPC,iBAAiB,EAAE;MACrB;IACF,CAAC;EACH,CAAC;EACDC,gBAAgB,EAAE;IAChBC,YAAY,EAAEnB,aAAa;IAC3BoB,iBAAiB,EAAErB,eAAe;IAClCsB,eAAe,EAAEpB;EACnB;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMqB,KAAK,GAAGA,CAAC;EACpBC,IAAI;EACJC,OAAO,GAAG,KAAK;EACfC,gBAAgB,GAAG,IAAI;EACvBC,OAAO;EACPC,UAAU,GAAG,IAAI;EACjBC;AACK,CAAC,KAAK;EACX,MAAM;IAAEC;EAAiB,CAAC,GAAG1B,qBAAqB,CAAC,CAAC;EACpD,MAAM;IAAE2B;EAAU,CAAC,GAAGjC,iBAAiB,CAAC,CAAC;EAEzC,MAAMkC,iBAAiB,GAAG,GAAG;EAE7B,MAAMC,oBAGL,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A,UAAW;IACvBC,MAAM,EAAEA,MAAO;IACfkB,KAAK,EAAE,CACLvC,MAAM,CAACE,KAAK,EACZgB,gBAAgB,GAAGoB,YAAY,GAAGtC,MAAM,CAACW,gBAAgB,EACzDM,OAAO,GACH;MACEuB,WAAW,EAAE,CAAC;MACdC,WAAW,EAAE9C,QAAQ,CAACgC,UAAU;IAClC,CAAC,GACD;MACEe,eAAe,EAAEd,UAAU,IAAIe;IACjC,CAAC,CACL;IAAAC,QAAA,eAEF7C,IAAA,CAACF,MAAM;MACLqB,gBAAgB,EAAEA,gBAAiB;MACnC2B,MAAM,EAAE,UAAW;MACnBC,IAAI,EAAE,EAAG;MACTC,UAAU,EAAE,EAAG;MACfC,KAAK,EAAErB,UAAW;MAClBsB,aAAa,EAAE,CAAE;MACjBC,aAAa,EAAC,MAAM;MACpBX,KAAK,EAAE;QACLY,SAAS,EAAE,QAAQ;QACnBC,aAAa,EAAE,WAAW;QAC1BC,aAAa,EAAE;MACjB,CAAE;MAAAT,QAAA,EAED5B;IAAI,CACC;EAAC,CACL,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ exports[`Test Badge Components - Experimental Enabled Badge Snapshot 1`] = `
|
|
|
10
10
|
"borderCurve": "continuous",
|
|
11
11
|
"flexDirection": "row",
|
|
12
12
|
"justifyContent": "center",
|
|
13
|
+
"overflow": "hidden",
|
|
13
14
|
},
|
|
14
15
|
{
|
|
15
16
|
"borderRadius": 24,
|
|
@@ -40,7 +41,6 @@ exports[`Test Badge Components - Experimental Enabled Badge Snapshot 1`] = `
|
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
43
|
"alignSelf": "center",
|
|
43
|
-
"flexShrink": 1,
|
|
44
44
|
"letterSpacing": 0.5,
|
|
45
45
|
"textTransform": "uppercase",
|
|
46
46
|
},
|
|
@@ -62,6 +62,7 @@ exports[`Test Badge Components Badge Snapshot 1`] = `
|
|
|
62
62
|
"borderCurve": "continuous",
|
|
63
63
|
"flexDirection": "row",
|
|
64
64
|
"justifyContent": "center",
|
|
65
|
+
"overflow": "hidden",
|
|
65
66
|
},
|
|
66
67
|
{
|
|
67
68
|
"borderRadius": 24,
|
|
@@ -92,7 +93,6 @@ exports[`Test Badge Components Badge Snapshot 1`] = `
|
|
|
92
93
|
},
|
|
93
94
|
{
|
|
94
95
|
"alignSelf": "center",
|
|
95
|
-
"flexShrink": 1,
|
|
96
96
|
"letterSpacing": 0.5,
|
|
97
97
|
"textTransform": "uppercase",
|
|
98
98
|
},
|
package/lib/module/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap
CHANGED
|
@@ -196,7 +196,7 @@ exports[`Test Buttons Components IOButton Snapshot · Link variant 1`] = `
|
|
|
196
196
|
[
|
|
197
197
|
{},
|
|
198
198
|
{
|
|
199
|
-
"color":
|
|
199
|
+
"color": undefined,
|
|
200
200
|
"fontFamily": "Titillio",
|
|
201
201
|
"fontSize": 16,
|
|
202
202
|
"fontStyle": "normal",
|
|
@@ -418,7 +418,7 @@ exports[`Test Buttons Components IOButton Snapshot · Outline variant 1`] = `
|
|
|
418
418
|
[
|
|
419
419
|
{},
|
|
420
420
|
{
|
|
421
|
-
"color":
|
|
421
|
+
"color": undefined,
|
|
422
422
|
"fontFamily": "Titillio",
|
|
423
423
|
"fontSize": 16,
|
|
424
424
|
"fontStyle": "normal",
|
|
@@ -638,7 +638,7 @@ exports[`Test Buttons Components IOButton Snapshot · Solid variant 1`] = `
|
|
|
638
638
|
[
|
|
639
639
|
{},
|
|
640
640
|
{
|
|
641
|
-
"color":
|
|
641
|
+
"color": undefined,
|
|
642
642
|
"fontFamily": "Titillio",
|
|
643
643
|
"fontSize": 16,
|
|
644
644
|
"fontStyle": "normal",
|
|
@@ -196,7 +196,7 @@ exports[`Test Buttons Components - Experimental Enabled ButtonLink Snapshot 1`]
|
|
|
196
196
|
[
|
|
197
197
|
{},
|
|
198
198
|
{
|
|
199
|
-
"color":
|
|
199
|
+
"color": undefined,
|
|
200
200
|
"fontFamily": "Titillio",
|
|
201
201
|
"fontSize": 16,
|
|
202
202
|
"fontStyle": "normal",
|
|
@@ -418,7 +418,7 @@ exports[`Test Buttons Components - Experimental Enabled ButtonOutline Snapshot 1
|
|
|
418
418
|
[
|
|
419
419
|
{},
|
|
420
420
|
{
|
|
421
|
-
"color":
|
|
421
|
+
"color": undefined,
|
|
422
422
|
"fontFamily": "Titillio",
|
|
423
423
|
"fontSize": 16,
|
|
424
424
|
"fontStyle": "normal",
|
|
@@ -638,7 +638,7 @@ exports[`Test Buttons Components - Experimental Enabled ButtonSolid Snapshot 1`]
|
|
|
638
638
|
[
|
|
639
639
|
{},
|
|
640
640
|
{
|
|
641
|
-
"color":
|
|
641
|
+
"color": undefined,
|
|
642
642
|
"fontFamily": "Titillio",
|
|
643
643
|
"fontSize": 16,
|
|
644
644
|
"fontStyle": "normal",
|
|
@@ -1352,7 +1352,7 @@ exports[`Test Buttons Components ButtonLink Snapshot 1`] = `
|
|
|
1352
1352
|
[
|
|
1353
1353
|
{},
|
|
1354
1354
|
{
|
|
1355
|
-
"color":
|
|
1355
|
+
"color": undefined,
|
|
1356
1356
|
"fontFamily": "Titillio",
|
|
1357
1357
|
"fontSize": 16,
|
|
1358
1358
|
"fontStyle": "normal",
|
|
@@ -1574,7 +1574,7 @@ exports[`Test Buttons Components ButtonOutline Snapshot 1`] = `
|
|
|
1574
1574
|
[
|
|
1575
1575
|
{},
|
|
1576
1576
|
{
|
|
1577
|
-
"color":
|
|
1577
|
+
"color": undefined,
|
|
1578
1578
|
"fontFamily": "Titillio",
|
|
1579
1579
|
"fontSize": 16,
|
|
1580
1580
|
"fontStyle": "normal",
|
|
@@ -1794,7 +1794,7 @@ exports[`Test Buttons Components ButtonSolid Snapshot 1`] = `
|
|
|
1794
1794
|
[
|
|
1795
1795
|
{},
|
|
1796
1796
|
{
|
|
1797
|
-
"color":
|
|
1797
|
+
"color": undefined,
|
|
1798
1798
|
"fontFamily": "Titillio",
|
|
1799
1799
|
"fontSize": 16,
|
|
1800
1800
|
"fontStyle": "normal",
|
|
@@ -10,13 +10,14 @@ export * from "./checkbox";
|
|
|
10
10
|
export * from "./claimsSelector";
|
|
11
11
|
export * from "./codeInput";
|
|
12
12
|
export * from "./featureInfo";
|
|
13
|
+
export * from "./headers";
|
|
13
14
|
export * from "./icons";
|
|
14
15
|
export * from "./image";
|
|
15
16
|
export * from "./layout";
|
|
16
|
-
export * from "./headers";
|
|
17
17
|
export * from "./listitems";
|
|
18
18
|
export * from "./loadingSpinner";
|
|
19
19
|
export * from "./logos";
|
|
20
|
+
export * from "./markdown";
|
|
20
21
|
export * from "./modules";
|
|
21
22
|
export * from "./numberpad";
|
|
22
23
|
export * from "./otpInput";
|
|
@@ -29,8 +30,8 @@ export * from "./stepper";
|
|
|
29
30
|
export * from "./switch";
|
|
30
31
|
export * from "./tabs";
|
|
31
32
|
export * from "./tag";
|
|
32
|
-
export * from "./textInput";
|
|
33
33
|
export * from "./templates";
|
|
34
|
+
export * from "./textInput";
|
|
34
35
|
export * from "./toast";
|
|
35
36
|
export * from "./tooltip";
|
|
36
37
|
export * from "./typography";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.tsx"],"mappings":";;AAAA,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.tsx"],"mappings":";;AAAA,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,SAAS;AACvB,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,kBAAkB;AAChC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { useIOTheme } from "../../context";
|
|
5
|
+
import { IOColors } from "../../core";
|
|
6
|
+
import { BodyMonospace } from "../typography/BodyMonospace";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* Theme-aware code block with a subtle background and border,
|
|
10
|
+
* similar to GitHub's fenced code block styling.
|
|
11
|
+
*/
|
|
12
|
+
export const CodeBlock = ({
|
|
13
|
+
content
|
|
14
|
+
}) => {
|
|
15
|
+
const theme = useIOTheme();
|
|
16
|
+
return /*#__PURE__*/_jsx(View, {
|
|
17
|
+
style: {
|
|
18
|
+
backgroundColor: IOColors[theme["appBackground-secondary"]],
|
|
19
|
+
borderColor: IOColors[theme["cardBorder-default"]],
|
|
20
|
+
borderWidth: 1,
|
|
21
|
+
borderRadius: 4,
|
|
22
|
+
borderCurve: "continuous",
|
|
23
|
+
paddingHorizontal: 16,
|
|
24
|
+
paddingVertical: 12
|
|
25
|
+
},
|
|
26
|
+
children: /*#__PURE__*/_jsx(BodyMonospace, {
|
|
27
|
+
children: content
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=CodeBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","useIOTheme","IOColors","BodyMonospace","jsx","_jsx","CodeBlock","content","theme","style","backgroundColor","borderColor","borderWidth","borderRadius","borderCurve","paddingHorizontal","paddingVertical","children"],"sourceRoot":"../../../../src","sources":["components/markdown/CodeBlock.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,cAAc;AACnC,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,aAAa,QAAQ,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAM5D;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGA,CAAC;EAAEC;AAAwB,CAAC,KAAK;EACxD,MAAMC,KAAK,GAAGP,UAAU,CAAC,CAAC;EAE1B,oBACEI,IAAA,CAACL,IAAI;IACHS,KAAK,EAAE;MACLC,eAAe,EAAER,QAAQ,CAACM,KAAK,CAAC,yBAAyB,CAAC,CAAC;MAC3DG,WAAW,EAAET,QAAQ,CAACM,KAAK,CAAC,oBAAoB,CAAC,CAAC;MAClDI,WAAW,EAAE,CAAC;MACdC,YAAY,EAAE,CAAC;MACfC,WAAW,EAAE,YAAY;MACzBC,iBAAiB,EAAE,EAAE;MACrBC,eAAe,EAAE;IACnB,CAAE;IAAAC,QAAA,eAEFZ,IAAA,CAACF,aAAa;MAAAc,QAAA,EAAEV;IAAO,CAAgB;EAAC,CACpC,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useMemo } from "react";
|
|
4
|
+
import { Linking, View } from "react-native";
|
|
5
|
+
import { useIOTheme } from "../../context";
|
|
6
|
+
import { bodyFontSize, bodyLineHeight, bodySmallFontSize, bodySmallLineHeight } from "../typography";
|
|
7
|
+
import { parse } from "./parser";
|
|
8
|
+
import { DEFAULT_RULES } from "./rules";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/**
|
|
11
|
+
* Full-featured markdown component that renders markdown content
|
|
12
|
+
* using design system primitives.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This component is still experimental. Check that it is correctly
|
|
16
|
+
* formatting your text before proceeding to use it.
|
|
17
|
+
*
|
|
18
|
+
* Supports headings, paragraphs, bold, italic, links, lists,
|
|
19
|
+
* blockquotes (as Banner), images, code, horizontal rules, and HTML breaks.
|
|
20
|
+
*
|
|
21
|
+
* Individual node types can be disabled via `disabledRules`, and
|
|
22
|
+
* render rules can be overridden via the `rules` prop.
|
|
23
|
+
*/
|
|
24
|
+
export const IOMarkdown = ({
|
|
25
|
+
content,
|
|
26
|
+
onLinkPress,
|
|
27
|
+
textAlign,
|
|
28
|
+
small,
|
|
29
|
+
testID,
|
|
30
|
+
disabledRules,
|
|
31
|
+
rules = {}
|
|
32
|
+
}) => {
|
|
33
|
+
const theme = useIOTheme();
|
|
34
|
+
const ast = useMemo(() => parse(content, disabledRules), [content, disabledRules]);
|
|
35
|
+
const handleLinkPress = useCallback(url => {
|
|
36
|
+
if (onLinkPress) {
|
|
37
|
+
onLinkPress(url);
|
|
38
|
+
} else {
|
|
39
|
+
Linking.openURL(url).catch(() => null);
|
|
40
|
+
}
|
|
41
|
+
}, [onLinkPress]);
|
|
42
|
+
const context = useMemo(() => ({
|
|
43
|
+
onLinkPress: handleLinkPress,
|
|
44
|
+
linkColor: theme["interactiveElem-default"],
|
|
45
|
+
textAlign: textAlign ?? "auto",
|
|
46
|
+
fontSize: small ? bodySmallFontSize : bodyFontSize,
|
|
47
|
+
lineHeight: small ? bodySmallLineHeight : bodyLineHeight
|
|
48
|
+
}), [handleLinkPress, textAlign, small, theme]);
|
|
49
|
+
const mergedRules = useMemo(() => ({
|
|
50
|
+
...DEFAULT_RULES,
|
|
51
|
+
...rules
|
|
52
|
+
}), [rules]);
|
|
53
|
+
const renderChildren = useCallback(nodes => nodes.map(node => {
|
|
54
|
+
const rule = mergedRules[node.type];
|
|
55
|
+
return rule ? rule(node, renderChildren, context) : null;
|
|
56
|
+
}), [mergedRules, context]);
|
|
57
|
+
const rendered = renderChildren(ast);
|
|
58
|
+
return /*#__PURE__*/_jsx(View, {
|
|
59
|
+
style: {
|
|
60
|
+
gap: 8
|
|
61
|
+
},
|
|
62
|
+
testID: testID,
|
|
63
|
+
children: rendered
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=IOMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useMemo","Linking","View","useIOTheme","bodyFontSize","bodyLineHeight","bodySmallFontSize","bodySmallLineHeight","parse","DEFAULT_RULES","jsx","_jsx","IOMarkdown","content","onLinkPress","textAlign","small","testID","disabledRules","rules","theme","ast","handleLinkPress","url","openURL","catch","context","linkColor","fontSize","lineHeight","mergedRules","renderChildren","nodes","map","node","rule","type","rendered","style","gap","children"],"sourceRoot":"../../../../src","sources":["components/markdown/IOMarkdown.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC5C,SAASC,OAAO,EAAkBC,IAAI,QAAQ,cAAc;AAC5D,SAASC,UAAU,QAAQ,eAAe;AAC1C,SACEC,YAAY,EACZC,cAAc,EACdC,iBAAiB,EACjBC,mBAAmB,QACd,eAAe;AACtB,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,aAAa,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA0BxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAGA,CAAC;EACzBC,OAAO;EACPC,WAAW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,GAAG,IAAI;EAC1D,CAAC,CAAC,EACJ,CAACI,WAAW,EAAEJ,OAAO,CACvB,CAAC;EAED,MAAMW,QAAQ,GAAGN,cAAc,CAACV,GAAG,CAAC;EAEpC,oBACEV,IAAA,CAACT,IAAI;IAACoC,KAAK,EAAE;MAAEC,GAAG,EAAE;IAAE,CAAE;IAACtB,MAAM,EAAEA,MAAO;IAAAuB,QAAA,EACrCH;EAAQ,CACL,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { IOMarkdown } from "./IOMarkdown";
|
|
4
|
+
import { LITE_DISABLED_TYPES } from "./parser";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* Lightweight markdown component supporting only paragraphs, bold, italic,
|
|
8
|
+
* links, and line breaks.
|
|
9
|
+
*
|
|
10
|
+
* This is a thin wrapper around `IOMarkdown` with extra node types (headings,
|
|
11
|
+
* lists, blockquotes, images, code, horizontal rules, and HTML) disabled.
|
|
12
|
+
*/
|
|
13
|
+
export const IOMarkdownLite = props => /*#__PURE__*/_jsx(IOMarkdown, {
|
|
14
|
+
...props,
|
|
15
|
+
disabledRules: LITE_DISABLED_TYPES
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=IOMarkdownLite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IOMarkdown","LITE_DISABLED_TYPES","jsx","_jsx","IOMarkdownLite","props","disabledRules"],"sourceRoot":"../../../../src","sources":["components/markdown/IOMarkdownLite.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,mBAAmB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAe/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,KAA0B,iBACvDF,IAAA,CAACH,UAAU;EAAA,GAAKK,KAAK;EAAEC,aAAa,EAAEL;AAAoB,CAAE,CAC7D","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useState } from "react";
|
|
4
|
+
import { Dimensions, Image } from "react-native";
|
|
5
|
+
import { IOVisualCostants } from "../../core";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* Stateful component that renders a remote image with auto-sizing.
|
|
9
|
+
* Uses `Image.getSize()` to determine intrinsic dimensions, then
|
|
10
|
+
* constrains width to the available screen width.
|
|
11
|
+
*/
|
|
12
|
+
export const ImageRenderer = ({
|
|
13
|
+
node
|
|
14
|
+
}) => {
|
|
15
|
+
const src = node.attributes?.src ?? "";
|
|
16
|
+
const alt = node.attributes?.alt ?? "";
|
|
17
|
+
const [imageSize, setImageSize] = useState({
|
|
18
|
+
width: 0,
|
|
19
|
+
aspectRatio: 1
|
|
20
|
+
});
|
|
21
|
+
const screenWidth = Dimensions.get("window").width - IOVisualCostants.appMarginDefault * 2;
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
if (!src) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
Image.getSize(src, (width, height) => {
|
|
27
|
+
const aspectRatio = width / height;
|
|
28
|
+
const constrainedWidth = Math.min(width, screenWidth);
|
|
29
|
+
setImageSize({
|
|
30
|
+
width: constrainedWidth,
|
|
31
|
+
aspectRatio
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}, [screenWidth, src]);
|
|
35
|
+
if (!src) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/_jsx(Image, {
|
|
39
|
+
accessibilityIgnoresInvertColors: true,
|
|
40
|
+
style: imageSize,
|
|
41
|
+
resizeMode: "contain",
|
|
42
|
+
accessibilityLabel: alt,
|
|
43
|
+
source: {
|
|
44
|
+
uri: src
|
|
45
|
+
}
|
|
46
|
+
}, node.key);
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=ImageRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useState","Dimensions","Image","IOVisualCostants","jsx","_jsx","ImageRenderer","node","src","attributes","alt","imageSize","setImageSize","width","aspectRatio","screenWidth","get","appMarginDefault","getSize","height","constrainedWidth","Math","min","accessibilityIgnoresInvertColors","style","resizeMode","accessibilityLabel","source","uri","key"],"sourceRoot":"../../../../src","sources":["components/markdown/ImageRenderer.tsx"],"mappings":";;AAAA,SAASA,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AACjD,SAASC,UAAU,EAAEC,KAAK,QAAQ,cAAc;AAChD,SAASC,gBAAgB,QAAQ,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO9C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC;AAAyB,CAAC,KAAK;EAC7D,MAAMC,GAAG,GAAGD,IAAI,CAACE,UAAU,EAAED,GAAG,IAAI,EAAE;EACtC,MAAME,GAAG,GAAGH,IAAI,CAACE,UAAU,EAAEC,GAAG,IAAI,EAAE;EAEtC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGZ,QAAQ,CAAC;IACzCa,KAAK,EAAE,CAAC;IACRC,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,WAAW,GACfd,UAAU,CAACe,GAAG,CAAC,QAAQ,CAAC,CAACH,KAAK,GAAGV,gBAAgB,CAACc,gBAAgB,GAAG,CAAC;EAExElB,eAAe,CAAC,MAAM;IACpB,IAAI,CAACS,GAAG,EAAE;MACR;IACF;IACAN,KAAK,CAACgB,OAAO,CAACV,GAAG,EAAE,CAACK,KAAK,EAAEM,MAAM,KAAK;MACpC,MAAML,WAAW,GAAGD,KAAK,GAAGM,MAAM;MAClC,MAAMC,gBAAgB,GAAGC,IAAI,CAACC,GAAG,CAACT,KAAK,EAAEE,WAAW,CAAC;MACrDH,YAAY,CAAC;QAAEC,KAAK,EAAEO,gBAAgB;QAAEN;MAAY,CAAC,CAAC;IACxD,CAAC,CAAC;EACJ,CAAC,EAAE,CAACC,WAAW,EAAEP,GAAG,CAAC,CAAC;EAEtB,IAAI,CAACA,GAAG,EAAE;IACR,OAAO,IAAI;EACb;EAEA,oBACEH,IAAA,CAACH,KAAK;IAEJqB,gCAAgC;IAChCC,KAAK,EAAEb,SAAU;IACjBc,UAAU,EAAC,SAAS;IACpBC,kBAAkB,EAAEhB,GAAI;IACxBiB,MAAM,EAAE;MAAEC,GAAG,EAAEpB;IAAI;EAAE,GALhBD,IAAI,CAACsB,GAMX,CAAC;AAEN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IOMarkdown","IOMarkdownLite"],"sourceRoot":"../../../../src","sources":["components/markdown/index.ts"],"mappings":";;AAEA,SAASA,UAAU,QAAQ,cAAc;AAGzC,SAASC,cAAc,QAAQ,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MarkdownIt from "markdown-it";
|
|
4
|
+
import { pipe } from "../../utils/pipe";
|
|
5
|
+
/* Two markdown-it instances: lite (no HTML) and full (HTML enabled) */
|
|
6
|
+
const mdLite = MarkdownIt({
|
|
7
|
+
html: false,
|
|
8
|
+
typographer: false,
|
|
9
|
+
linkify: false
|
|
10
|
+
});
|
|
11
|
+
const mdFull = MarkdownIt({
|
|
12
|
+
html: true,
|
|
13
|
+
typographer: false,
|
|
14
|
+
linkify: false
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a zero-dependency key generator for the markdown AST.
|
|
19
|
+
*
|
|
20
|
+
* These keys are only used as local React render keys, so they do not need
|
|
21
|
+
* cryptographic randomness or an external package: a per-parse incrementing
|
|
22
|
+
* counter is sufficient for our needs.
|
|
23
|
+
*/
|
|
24
|
+
const createKeyFactory = () => {
|
|
25
|
+
// eslint-disable-next-line functional/no-let
|
|
26
|
+
let keyCounter = 0;
|
|
27
|
+
return prefix => `md_${prefix}_${keyCounter++}`;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Complete set of all supported node types.
|
|
32
|
+
*/
|
|
33
|
+
const ALL_TYPES = new Set([/* lite types */
|
|
34
|
+
"heading1", "heading2", "heading3", "heading4", "heading5", "heading6", "paragraph", "text", "strong", "em", "link", "softbreak", "hardbreak", /* full types */
|
|
35
|
+
"bullet_list", "ordered_list", "list_item", "blockquote", "image", "code_inline", "fence", "hr", "html_block", "html_inline"]);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The types disabled when using IOMarkdownLite.
|
|
39
|
+
*/
|
|
40
|
+
export const LITE_DISABLED_TYPES = ["heading1", "heading2", "heading3", "heading4", "heading5", "heading6", "bullet_list", "ordered_list", "list_item", "blockquote", "image", "code_inline", "fence", "hr", "html_block", "html_inline"];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Maps a markdown-it token type to a MarkdownNodeType.
|
|
44
|
+
* Normalizes `*_open` / `*_close` suffixes and heading tags.
|
|
45
|
+
* Returns undefined for unsupported or disabled types.
|
|
46
|
+
*/
|
|
47
|
+
const getNodeType = (token, enabledTypes) => {
|
|
48
|
+
const cleanedType = token.type.replace(/_open|_close/g, "");
|
|
49
|
+
const type = cleanedType === "heading" ? `${cleanedType}${token.tag.slice(1)}` : cleanedType;
|
|
50
|
+
return enabledTypes.has(type) ? type : undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Flattens nested inline tokens into the parent token stream.
|
|
55
|
+
* markdown-it wraps inline content in `inline` tokens with children.
|
|
56
|
+
*/
|
|
57
|
+
const flattenInline = tokens => tokens.reduce((acc, token) => {
|
|
58
|
+
if (token.type === "inline" && token.children && token.children.length > 0) {
|
|
59
|
+
return [...acc, ...flattenInline(token.children)];
|
|
60
|
+
}
|
|
61
|
+
return [...acc, token];
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Converts a flat array of tokens into a hierarchical AST,
|
|
66
|
+
* skipping disabled/unsupported token types entirely.
|
|
67
|
+
*/
|
|
68
|
+
const tokensToAST = (tokens, enabledTypes, getKey) => {
|
|
69
|
+
if (!tokens || tokens.length === 0) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const parseFrom = index => {
|
|
73
|
+
if (index >= tokens.length) {
|
|
74
|
+
return [[], index];
|
|
75
|
+
}
|
|
76
|
+
const token = tokens[index];
|
|
77
|
+
const nodeType = getNodeType(token, enabledTypes);
|
|
78
|
+
|
|
79
|
+
// Closing token — stop and return to caller
|
|
80
|
+
if (token.nesting === -1) {
|
|
81
|
+
return [[], index + 1];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Unsupported / disabled type — skip it
|
|
85
|
+
if (nodeType === undefined) {
|
|
86
|
+
if (token.nesting === 1) {
|
|
87
|
+
// Opening token: skip ahead to matching close
|
|
88
|
+
const findMatchingClose = (pos, depth) => pos >= tokens.length || depth === 0 ? pos : findMatchingClose(pos + 1, depth + tokens[pos].nesting);
|
|
89
|
+
return parseFrom(findMatchingClose(index + 1, 1));
|
|
90
|
+
}
|
|
91
|
+
// Self-closing / inline token: skip single token
|
|
92
|
+
return parseFrom(index + 1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Skip empty text nodes
|
|
96
|
+
if (nodeType === "text" && token.content === "") {
|
|
97
|
+
return parseFrom(index + 1);
|
|
98
|
+
}
|
|
99
|
+
const attributes = token.attrs?.reduce((prev, [name, value]) => ({
|
|
100
|
+
...prev,
|
|
101
|
+
[name]: value
|
|
102
|
+
}), {});
|
|
103
|
+
const node = {
|
|
104
|
+
type: nodeType,
|
|
105
|
+
key: getKey(nodeType),
|
|
106
|
+
content: token.content || undefined,
|
|
107
|
+
attributes: attributes || undefined,
|
|
108
|
+
children: [],
|
|
109
|
+
// Preserve ordered flag for lists
|
|
110
|
+
...(nodeType === "ordered_list" ? {
|
|
111
|
+
ordered: true
|
|
112
|
+
} : {}),
|
|
113
|
+
...(nodeType === "bullet_list" ? {
|
|
114
|
+
ordered: false
|
|
115
|
+
} : {}),
|
|
116
|
+
// Preserve image src and alt via attributes
|
|
117
|
+
...(nodeType === "image" ? {
|
|
118
|
+
attributes: {
|
|
119
|
+
...attributes,
|
|
120
|
+
src: token.attrGet?.("src") ?? attributes?.src ?? "",
|
|
121
|
+
alt: token.content ?? ""
|
|
122
|
+
}
|
|
123
|
+
} : {})
|
|
124
|
+
};
|
|
125
|
+
if (token.nesting === 1) {
|
|
126
|
+
// Opening token — parse children
|
|
127
|
+
const [childNodes, nextIndex] = parseFrom(index + 1);
|
|
128
|
+
const nodeWithChildren = {
|
|
129
|
+
...node,
|
|
130
|
+
children: childNodes
|
|
131
|
+
};
|
|
132
|
+
const [restNodes, finalIndex] = parseFrom(nextIndex);
|
|
133
|
+
return [[nodeWithChildren, ...restNodes], finalIndex];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Self-closing / inline token (nesting === 0)
|
|
137
|
+
const [restNodes, finalIndex] = parseFrom(index + 1);
|
|
138
|
+
return [[node, ...restNodes], finalIndex];
|
|
139
|
+
};
|
|
140
|
+
const [nodes] = parseFrom(0);
|
|
141
|
+
return nodes;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Lifts image nodes out of paragraph containers so they become
|
|
146
|
+
* top-level siblings. markdown-it always wraps images inside
|
|
147
|
+
* paragraphs; this post-processing step ensures the existing
|
|
148
|
+
* `imageRule` is actually invoked during rendering.
|
|
149
|
+
*
|
|
150
|
+
* - Paragraph with **only** image children → replaced by the images.
|
|
151
|
+
* - Paragraph with a **mix** of text and images → split into
|
|
152
|
+
* alternating paragraph (text run) and standalone image nodes.
|
|
153
|
+
* - Paragraphs without images → unchanged.
|
|
154
|
+
*/
|
|
155
|
+
const liftImages = (nodes, getKey) => nodes.flatMap(node => {
|
|
156
|
+
if (node.type !== "paragraph") {
|
|
157
|
+
return [node];
|
|
158
|
+
}
|
|
159
|
+
const hasImage = node.children.some(c => c.type === "image");
|
|
160
|
+
if (!hasImage) {
|
|
161
|
+
return [node];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Every child is an image → lift them all out
|
|
165
|
+
const allImages = node.children.every(c => c.type === "image");
|
|
166
|
+
if (allImages) {
|
|
167
|
+
// Return images as top-level nodes (they keep their own keys)
|
|
168
|
+
return [...node.children];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Mixed content: split children into text runs and standalone images.
|
|
172
|
+
// A single reduce accumulates finished nodes and the current text run;
|
|
173
|
+
// a trailing text run is flushed after the fold.
|
|
174
|
+
|
|
175
|
+
const wrapTextRun = run => ({
|
|
176
|
+
...node,
|
|
177
|
+
key: getKey("paragraph"),
|
|
178
|
+
children: run
|
|
179
|
+
});
|
|
180
|
+
const {
|
|
181
|
+
result,
|
|
182
|
+
textRun
|
|
183
|
+
} = node.children.reduce((acc, child) => child.type === "image" ? {
|
|
184
|
+
result: [...acc.result, ...(acc.textRun.length > 0 ? [wrapTextRun(acc.textRun)] : []), child],
|
|
185
|
+
textRun: []
|
|
186
|
+
} : {
|
|
187
|
+
...acc,
|
|
188
|
+
textRun: [...acc.textRun, child]
|
|
189
|
+
}, {
|
|
190
|
+
result: [],
|
|
191
|
+
textRun: []
|
|
192
|
+
});
|
|
193
|
+
return textRun.length > 0 ? [...result, wrapTextRun(textRun)] : [...result];
|
|
194
|
+
});
|
|
195
|
+
const annotateListDepth = (nodes, parentListDepth = 0) => nodes.map(node => {
|
|
196
|
+
const listDepth = parentListDepth;
|
|
197
|
+
const childListDepth = node.type === "bullet_list" || node.type === "ordered_list" ? parentListDepth + 1 : parentListDepth;
|
|
198
|
+
return {
|
|
199
|
+
...node,
|
|
200
|
+
listDepth,
|
|
201
|
+
children: annotateListDepth(node.children, childListDepth)
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Computes the enabled types set from the full set minus disabled types.
|
|
207
|
+
*/
|
|
208
|
+
const getEnabledTypes = disabledTypes => {
|
|
209
|
+
if (!disabledTypes || disabledTypes.length === 0) {
|
|
210
|
+
return ALL_TYPES;
|
|
211
|
+
}
|
|
212
|
+
const disabled = new Set(disabledTypes);
|
|
213
|
+
return new Set([...ALL_TYPES].filter(t => !disabled.has(t)));
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Parses a markdown source string into an AST.
|
|
218
|
+
* @param source The markdown string.
|
|
219
|
+
* @param disabledTypes Node types to exclude from parsing.
|
|
220
|
+
* @returns Array of MarkdownNode.
|
|
221
|
+
*/
|
|
222
|
+
export const parse = (source, disabledTypes) => {
|
|
223
|
+
const enabledTypes = getEnabledTypes(disabledTypes);
|
|
224
|
+
const needsHtml = enabledTypes.has("html_block") || enabledTypes.has("html_inline");
|
|
225
|
+
const md = needsHtml ? mdFull : mdLite;
|
|
226
|
+
const getKey = createKeyFactory();
|
|
227
|
+
return pipe(
|
|
228
|
+
// 1. Tokenize the markdown source using markdown-it
|
|
229
|
+
md.parse(source, {}),
|
|
230
|
+
// 2. Unwrap nested inline tokens into a flat token stream
|
|
231
|
+
flattenInline,
|
|
232
|
+
// 3. Convert the flat token stream into a hierarchical AST
|
|
233
|
+
tokens => tokensToAST(tokens, enabledTypes, getKey),
|
|
234
|
+
// 4. Hoist image nodes out of paragraph wrappers so imageRule is invoked
|
|
235
|
+
nodes => liftImages(nodes, getKey),
|
|
236
|
+
// 5. Drop empty paragraphs left behind by disabled/lifted node types
|
|
237
|
+
nodes => nodes.filter(n => n.type !== "paragraph" || n.children.length > 0),
|
|
238
|
+
// 6. Annotate nodes with their list nesting depth for rendering
|
|
239
|
+
annotateListDepth);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Parses markdown with the lite subset of rules only.
|
|
244
|
+
*/
|
|
245
|
+
export const parseLite = source => parse(source, LITE_DISABLED_TYPES);
|
|
246
|
+
//# sourceMappingURL=parser.js.map
|