Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Cross): [IOAPPX-422] Replace the legacy markdown renderer with IOMarkdown #6445

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bdbd550
replace Markdown with IOMarkdown
adelloste Nov 12, 2024
5d8dbdd
IOMarkdown for message's preconditions
Vangaorth Nov 12, 2024
4c56ee2
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 22, 2024
a0aba8b
Remove legacy `Markdown` playground from Developer mode section
dmnplb Nov 22, 2024
fa53d07
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 22, 2024
352605c
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 25, 2024
3da8939
Remove `LegacyMarkdown` from `ManualConfigBottomSheet`
dmnplb Nov 25, 2024
310b798
Remove `LegacyMarkdown` from `ShareDataFeatureInfos`
dmnplb Nov 25, 2024
293a91c
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 25, 2024
be90854
Remove `LegacyMarkdown` from IDPay related screens
dmnplb Nov 25, 2024
0b8dc9b
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 25, 2024
9d404de
RootedDeviceModal
Vangaorth Nov 26, 2024
4f76da5
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Nov 26, 2024
c3ba3f8
CiePinScreen
Vangaorth Nov 26, 2024
aaac7e8
Removed unused CieAuthorizeDataUsageScreen
Vangaorth Nov 26, 2024
84d0723
ItwCiePinScreen
Vangaorth Nov 26, 2024
34e9e9e
OnboardingDescriptionMarkdown
Vangaorth Nov 26, 2024
f549582
useFciAbortSignatureFlow
Vangaorth Nov 26, 2024
0a8d9fe
EycaInformationComponent
Vangaorth Nov 26, 2024
36362aa
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Nov 26, 2024
1202df5
Removed LegacyMarkdown
Vangaorth Nov 26, 2024
358ec41
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 26, 2024
20acd6a
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Nov 26, 2024
78c72cf
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Nov 26, 2024
5bdfc2a
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Nov 26, 2024
acff871
Removed MessageMarkdown
Vangaorth Nov 26, 2024
23c402b
Remove MarkdownHandleCustomLink
Vangaorth Nov 26, 2024
862a62b
Tests
Vangaorth Nov 26, 2024
3ff7828
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 27, 2024
aa83948
Merge branch 'master' into IOAPPX-422-IOMarkdown
dmnplb Nov 29, 2024
bea148f
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 5, 2024
97f699a
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 5, 2024
b0d9a41
BonusInformationComponent
Vangaorth Dec 5, 2024
4f50b9f
Revert podfile
Vangaorth Dec 5, 2024
c61b510
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 5, 2024
7a5385b
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 9, 2024
9433d05
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 17, 2024
2d27b8d
yarn.lock
Vangaorth Dec 17, 2024
9d03374
Fixes
Vangaorth Dec 17, 2024
29230e3
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 18, 2024
f1535ca
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 19, 2024
3112c97
Merge branch 'master' into IOAPPX-422-IOMarkdown
Vangaorth Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
locales/locales.ts
ts/utils/__tests__/xss.test.ts
definitions/*
**/*.typegen.ts
2 changes: 1 addition & 1 deletion jest-e2e.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
preset: "react-native",
transformIgnorePatterns: [
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@shopify/react-native-skia|lottie-react-native|@codler|remark|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|@pagopa/io-react-native-zendesk|rn-qr-generator|mixpanel-react-native|@pagopa/io-app-design-system|@sentry/react-native)"
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@shopify/react-native-skia|lottie-react-native|@codler|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|@pagopa/io-react-native-zendesk|rn-qr-generator|mixpanel-react-native|@pagopa/io-app-design-system|@sentry/react-native)"
],
moduleNameMapper: {
"\\.svg": "<rootDir>/ts/__mocks__/svgMock.js"
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
preset: "react-native",
transformIgnorePatterns: [
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@shopify/react-native-skia|lottie-react-native|@codler|remark|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|@pagopa/io-react-native-zendesk|rn-qr-generator|mixpanel-react-native|@pagopa/io-app-design-system|uuid|@sentry/react-native|decode-named-character-reference|mdast-util-phrasing|unist-util-is)"
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@shopify/react-native-skia|lottie-react-native|@codler|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|@pagopa/io-react-native-zendesk|rn-qr-generator|mixpanel-react-native|@pagopa/io-app-design-system|uuid|@sentry/react-native|decode-named-character-reference|mdast-util-phrasing|unist-util-is)"
],
moduleNameMapper: {
"\\.svg": "<rootDir>/ts/__mocks__/svgMock.js"
Expand Down
2 changes: 1 addition & 1 deletion jest.config.no.timezone.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
preset: "react-native",
transformIgnorePatterns: [
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@shopify/react-native-skia|lottie-react-native|@codler|remark|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|@pagopa/io-react-native-zendesk|rn-qr-generator|mixpanel-react-native|@pagopa/io-app-design-system|uuid|@sentry/react-native)"
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@shopify/react-native-skia|lottie-react-native|@codler|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|@pagopa/io-react-native-zendesk|rn-qr-generator|mixpanel-react-native|@pagopa/io-app-design-system|uuid|@sentry/react-native)"
],
moduleNameMapper: {
"\\.svg": "<rootDir>/ts/__mocks__/svgMock.js"
Expand Down
7 changes: 0 additions & 7 deletions jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ global.fetch = nodeFetch;
// eslint-disable-next-line functional/immutable-data
global.AbortController = AbortController;

jest.mock("remark-directive", () => jest.fn());
jest.mock("remark-rehype", () => jest.fn());
jest.mock("rehype-stringify", () => jest.fn());
jest.mock("rehype-format", () => jest.fn());
jest.mock("unist-util-visit", () => jest.fn());
jest.mock("hastscript", () => jest.fn());

jest.mock("react-native-device-info", () => mockRNDeviceInfo);

// eslint-disable-next-line no-underscore-dangle, functional/immutable-data
Expand Down
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"eslint-plugin-react-native": "^4.0.0",
"fp-ts": "^2.12.1",
"front-matter": "^4.0.2",
"hastscript": "^7.0.2",
"hoist-non-react-statics": "^3.0.1",
"io-ts": "^2.2.16",
"jail-monkey": "^2.8.0",
Expand Down Expand Up @@ -156,11 +155,6 @@
"redux-logger": "3.0.6",
"redux-persist": "5.10.0",
"redux-saga": "1.1.3",
"rehype-format": "^4.0.0",
"rehype-stringify": "^9.0.2",
"remark": "^14.0.1",
"remark-directive": "^2.0.0",
"remark-rehype": "^9.1.0",
"reselect": "4.0.0",
"rn-placeholder": "^1.3.3",
"rn-qr-generator": "^1.4.0",
Expand All @@ -169,12 +163,10 @@
"tslib": "^1.9.3",
"typed-redux-saga": "^1.4.0",
"typesafe-actions": "4.4.2",
"unist-util-visit": "^4.1.0",
"url-parse": "^1.5.9",
"uuid": "^8.3.2",
"validator": "^13.7.0",
"xml2js": "^0.5.0",
"xss": "1.0.10",
"xstate": "^5"
},
"devDependencies": {
Expand Down
16 changes: 0 additions & 16 deletions ts/@types/xss.d.ts

This file was deleted.

54 changes: 54 additions & 0 deletions ts/components/IOMarkdown/customRules.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { TxtHeaderNode, TxtLinkNode } from "@textlint/ast-node-types";
import { Body, IOToast, MdH1, MdH2, MdH3 } from "@pagopa/io-app-design-system";
import React from "react";
import { isIoInternalLink } from "../ui/Markdown/handlers/link";
import { handleInternalLink } from "../../utils/internalLink";
import { openWebUrl } from "../../utils/url";
import I18n from "../../i18n";
import { getTxtNodeKey } from "./renderRules";
import { IOMarkdownRenderRules, Renderer } from "./types";

const HEADINGS_MAP = {
1: MdH1,
2: MdH2,
3: MdH3,
4: Body,
5: Body,
6: Body
};

export const generateMessagesAndServicesRules = (
linkTo: (path: string) => void
): Partial<IOMarkdownRenderRules> => ({
Header(header: TxtHeaderNode, render: Renderer) {
const Heading = HEADINGS_MAP[header.depth];

return (
<Heading key={getTxtNodeKey(header)}>
{header.children.map(render)}
</Heading>
);
},
Link(link: TxtLinkNode, render: Renderer) {
const handlePress = () => {
if (isIoInternalLink(link.url)) {
handleInternalLink(linkTo, link.url);
} else {
openWebUrl(link.url, () => {
IOToast.error(I18n.t("global.jserror.title"));
});
}
};

return (
<Body
weight="Semibold"
asLink
key={getTxtNodeKey(link)}
onPress={handlePress}
>
{link.children.map(render)}
</Body>
);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { View } from "react-native";
import Placeholder from "rn-placeholder";
import { IOColors, VSpacer } from "@pagopa/io-app-design-system";
import I18n from "../../../i18n";
import I18n from "../../i18n";

type LoadingSkeletonProps = {
lines?: number;
Expand Down
Loading
Loading