Files
paseo/packages/react-native-enriched-markdown/lib/module/web/nativeProps.js
T
Mohamed Boudra eda906f6ee chore(app): vendor react-native-enriched-markdown with the Paseo patch applied
Copy react-native-enriched-markdown@1.2.0-nightly-20261014-766fc0e67 (upstream
software-mansion/enriched-markdown 766fc0e67) into
packages/react-native-enriched-markdown, with
patches/react-native-enriched-markdown+1.2.0-nightly-20261014-766fc0e67.patch
applied. Nothing else changes in this commit; the package is not a workspace yet.

Reproduce:

  npm pack react-native-enriched-markdown@1.2.0-nightly-20261014-766fc0e67
  tar xzf react-native-enriched-markdown-*.tgz
  mkdir -p t/node_modules && mv package t/node_modules/react-native-enriched-markdown
  (cd t && git init -q && git apply ../patches/react-native-enriched-markdown+*.patch)
  diff -r t/node_modules/react-native-enriched-markdown packages/react-native-enriched-markdown

The diff is empty.
2026-11-22 08:14:39 +01:00

65 lines
2.2 KiB
JavaScript

"use strict";
/**
* Props that form the native (iOS/Android) EnrichedMarkdownText API but have no
* effect on web.
*
* In a typical React Native + react-native-web project the component is
* type-checked against the native `MarkdownTextProps.ts` interface (bundlers
* swap in `.web.tsx` at runtime, but `tsc` resolves the base `.ts` unless the
* project sets `moduleSuffixes`). So JSX like `flavor="github"` or
* `streamingAnimation` compiles fine and would otherwise be spread onto the
* root DOM element, triggering React "unknown prop" warnings. They are dropped
* here before reaching the DOM.
*
* The set below is not hand-maintained: `NativeOnlyPropName` is derived as the
* native prop names minus the ones web implements, so adding a native-only prop
* to `MarkdownTextProps.ts` fails the build here until it is listed and thus
* filtered. Generic React Native ViewProps (nativeID, accessibility*, hitSlop,
* etc.) are excluded from that union and stay out of scope; they are documented
* as not stripped in docs/WEB.md.
*
* The `react-native` and native-props imports are type-only, so nothing from
* either reaches the web bundle.
*/
export const NATIVE_ONLY_PROP_NAMES = {
onCopyPress: true,
onLatexError: true,
enableBlockContextMenu: true,
enableLinkPreview: true,
selectionHandleColor: true,
allowFontScaling: true,
maxFontSizeMultiplier: true,
flavor: true,
streamingAnimation: true,
streamingConfig: true,
spoilerOverlay: true,
contextMenuItems: true,
imageRequestHeaders: true,
linkPillContent: true,
linkContextMenuItems: true,
selectionMenuConfig: true,
accessibilityLabels: true,
textBreakStrategy: true,
lineBreakStrategyIOS: true,
writingDirection: true,
numberOfLines: true,
ellipsizeMode: true
};
const NATIVE_ONLY_PROPS = new Set(Object.keys(NATIVE_ONLY_PROP_NAMES));
/**
* Removes native-only props so they are never forwarded to a DOM element.
* Returns a shallow copy; the input is left untouched.
*/
export function filterNativeOnlyProps(props) {
const result = {};
for (const [key, value] of Object.entries(props)) {
if (!NATIVE_ONLY_PROPS.has(key)) {
result[key] = value;
}
}
return result;
}
//# sourceMappingURL=nativeProps.js.map