Files
paseo/packages/react-native-enriched-markdown/lib/module/linkContextMenuUtils.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

47 lines
1.9 KiB
JavaScript

"use strict";
import { normalizeLinkPatternEntries } from "./linkVariantUtils.js";
/**
* Flattens `linkContextMenuItems` for native: patterns in matching order, hidden
* items and patterns left without items dropped, callbacks kept on the JS side.
*/
export function normalizeLinkContextMenuItems(menus) {
return normalizeLinkPatternEntries(menus, '[EnrichedMarkdownText] linkContextMenuItems').flatMap(([pattern, items]) => {
const visible = items.filter(item => item.visible !== false).map(item => ({
text: item.text,
icon: item.icon ?? '',
disabled: item.disabled ?? false,
destructive: item.destructive ?? false
}));
return visible.length > 0 ? [{
pattern,
items: visible
}] : [];
});
}
/** Whether two flattened `linkContextMenuItems` arrays describe the same menus. */
export function isLinkContextMenuItemsEqual(a, b) {
if (a === b) return true;
if (a.length !== b.length) return false;
return a.every((entry, index) => {
const other = b[index];
return entry.pattern === other.pattern && entry.items.length === other.items.length && entry.items.every((item, itemIndex) => {
const otherItem = other.items[itemIndex];
return item.text === otherItem.text && item.icon === otherItem.icon && item.disabled === otherItem.disabled && item.destructive === otherItem.destructive;
});
});
}
/**
* Runs the callback of the item native reported. A menu can stay open while the
* prop changes, so the item is looked up in the current config and ignored when
* that no longer offers it.
*/
export function dispatchLinkContextMenuItem(menus, pattern, itemText, url) {
if (!menus || !Object.prototype.hasOwnProperty.call(menus, pattern)) return;
const item = menus[pattern]?.find(candidate => candidate.text === itemText);
if (item && item.visible !== false && !item.disabled) item.onPress({
url
});
}
//# sourceMappingURL=linkContextMenuUtils.js.map