@@ -4,16 +4,13 @@ import type { MarkdownNode } from "react-native-nitro-markdown/headless";
44
55import { CopyTextButton } from "./CopyTextButton" ;
66import { MarkdownTextPrimitive } from "./MarkdownTextPrimitive" ;
7- import {
8- nativeMarkdownDocumentRuns ,
9- nativeMarkdownListItemBlocks ,
10- nativeMarkdownTextRuns ,
11- } from "./nativeMarkdownText" ;
7+ import { nativeMarkdownDocumentRuns , nativeMarkdownListItemBlocks } from "./nativeMarkdownText" ;
128import { NativeMarkdownSelectableText } from "./NativeMarkdownSelectableText.ios" ;
139import type {
1410 MarkdownCodeHighlighter ,
1511 MarkdownHighlightedToken ,
1612 NativeMarkdownTextStyle ,
13+ SelectableMarkdownSkill ,
1714} from "./SelectableMarkdownText.types" ;
1815
1916type HighlightedCode = ReadonlyArray < ReadonlyArray < MarkdownHighlightedToken > > ;
@@ -48,12 +45,13 @@ function documentFor(node: MarkdownNode): MarkdownNode {
4845
4946function SelectableNode ( props : {
5047 readonly node : MarkdownNode ;
48+ readonly skills : ReadonlyArray < SelectableMarkdownSkill > ;
5149 readonly textStyle : NativeMarkdownTextStyle ;
5250 readonly onLinkPress ?: ( href : string ) => void ;
5351} ) {
5452 return (
5553 < NativeMarkdownSelectableText
56- runs = { nativeMarkdownDocumentRuns ( documentFor ( props . node ) ) }
54+ runs = { nativeMarkdownDocumentRuns ( documentFor ( props . node ) , props . skills ) }
5755 textStyle = { props . textStyle }
5856 onLinkPress = { props . onLinkPress }
5957 />
@@ -322,6 +320,7 @@ function collectTableRows(node: MarkdownNode): MarkdownNode[] {
322320
323321function NativeTable ( props : {
324322 readonly node : MarkdownNode ;
323+ readonly skills : ReadonlyArray < SelectableMarkdownSkill > ;
325324 readonly textStyle : NativeMarkdownTextStyle ;
326325 readonly onLinkPress ?: ( href : string ) => void ;
327326} ) {
@@ -359,7 +358,7 @@ function NativeTable(props: {
359358 } }
360359 >
361360 < NativeMarkdownSelectableText
362- runs = { nativeMarkdownTextRuns ( cell ) . map ( ( run ) =>
361+ runs = { nativeMarkdownDocumentRuns ( documentFor ( cell ) , props . skills ) . map ( ( run ) =>
363362 rowIndex === 0 || cell . isHeader ? { ...run , bold : true } : run ,
364363 ) }
365364 textStyle = { props . textStyle }
@@ -376,6 +375,7 @@ function NativeTable(props: {
376375
377376function NativeMarkdownImage ( props : {
378377 readonly node : MarkdownNode ;
378+ readonly skills : ReadonlyArray < SelectableMarkdownSkill > ;
379379 readonly textStyle : NativeMarkdownTextStyle ;
380380 readonly onLinkPress ?: ( href : string ) => void ;
381381} ) {
@@ -384,6 +384,7 @@ function NativeMarkdownImage(props: {
384384 return (
385385 < SelectableNode
386386 node = { props . node }
387+ skills = { props . skills }
387388 textStyle = { props . textStyle }
388389 onLinkPress = { props . onLinkPress }
389390 />
@@ -445,6 +446,7 @@ function inlineGroups(nodes: ReadonlyArray<MarkdownNode>): MarkdownNode[] {
445446
446447function NativeMixedParagraph ( props : {
447448 readonly node : MarkdownNode ;
449+ readonly skills : ReadonlyArray < SelectableMarkdownSkill > ;
448450 readonly textStyle : NativeMarkdownTextStyle ;
449451 readonly onLinkPress ?: ( href : string ) => void ;
450452} ) {
@@ -455,13 +457,15 @@ function NativeMixedParagraph(props: {
455457 < NativeMarkdownImage
456458 key = { nodeKey ( child , index ) }
457459 node = { child }
460+ skills = { props . skills }
458461 textStyle = { props . textStyle }
459462 onLinkPress = { props . onLinkPress }
460463 />
461464 ) : (
462465 < SelectableNode
463466 key = { nodeKey ( child , index ) }
464467 node = { child }
468+ skills = { props . skills }
465469 textStyle = { props . textStyle }
466470 onLinkPress = { props . onLinkPress }
467471 />
@@ -473,6 +477,7 @@ function NativeMixedParagraph(props: {
473477
474478function NativeList ( props : {
475479 readonly node : MarkdownNode ;
480+ readonly skills : ReadonlyArray < SelectableMarkdownSkill > ;
476481 readonly textStyle : NativeMarkdownTextStyle ;
477482 readonly highlightCode : MarkdownCodeHighlighter ;
478483 readonly onLinkPress ?: ( href : string ) => void ;
@@ -534,6 +539,7 @@ function NativeList(props: {
534539 < NativeMarkdownBlock
535540 key = { nodeKey ( child , childIndex ) }
536541 node = { child }
542+ skills = { props . skills }
537543 textStyle = { props . textStyle }
538544 highlightCode = { props . highlightCode }
539545 onLinkPress = { props . onLinkPress }
@@ -551,6 +557,7 @@ function NativeList(props: {
551557
552558export function NativeMarkdownBlock ( props : {
553559 readonly node : MarkdownNode ;
560+ readonly skills : ReadonlyArray < SelectableMarkdownSkill > ;
554561 readonly textStyle : NativeMarkdownTextStyle ;
555562 readonly highlightCode : MarkdownCodeHighlighter ;
556563 readonly onLinkPress ?: ( href : string ) => void ;
@@ -566,6 +573,7 @@ export function NativeMarkdownBlock(props: {
566573 < NativeMarkdownBlock
567574 key = { nodeKey ( child , index ) }
568575 node = { child }
576+ skills = { props . skills }
569577 textStyle = { props . textStyle }
570578 highlightCode = { props . highlightCode }
571579 onLinkPress = { props . onLinkPress }
@@ -587,6 +595,7 @@ export function NativeMarkdownBlock(props: {
587595 return (
588596 < NativeTable
589597 node = { props . node }
598+ skills = { props . skills }
590599 textStyle = { props . textStyle }
591600 onLinkPress = { props . onLinkPress }
592601 />
@@ -595,6 +604,7 @@ export function NativeMarkdownBlock(props: {
595604 return (
596605 < NativeMarkdownImage
597606 node = { props . node }
607+ skills = { props . skills }
598608 textStyle = { props . textStyle }
599609 onLinkPress = { props . onLinkPress }
600610 />
@@ -624,6 +634,7 @@ export function NativeMarkdownBlock(props: {
624634 < NativeMarkdownBlock
625635 key = { nodeKey ( child , index ) }
626636 node = { child }
637+ skills = { props . skills }
627638 textStyle = { props . textStyle }
628639 highlightCode = { props . highlightCode }
629640 onLinkPress = { props . onLinkPress }
@@ -637,6 +648,7 @@ export function NativeMarkdownBlock(props: {
637648 return (
638649 < NativeList
639650 node = { props . node }
651+ skills = { props . skills }
640652 textStyle = { props . textStyle }
641653 highlightCode = { props . highlightCode }
642654 onLinkPress = { props . onLinkPress }
@@ -647,12 +659,14 @@ export function NativeMarkdownBlock(props: {
647659 return ( props . node . children ?? [ ] ) . some ( ( child ) => child . type === "image" ) ? (
648660 < NativeMixedParagraph
649661 node = { props . node }
662+ skills = { props . skills }
650663 textStyle = { props . textStyle }
651664 onLinkPress = { props . onLinkPress }
652665 />
653666 ) : (
654667 < SelectableNode
655668 node = { props . node }
669+ skills = { props . skills }
656670 textStyle = { props . textStyle }
657671 onLinkPress = { props . onLinkPress }
658672 />
@@ -673,6 +687,7 @@ export function NativeMarkdownBlock(props: {
673687 >
674688 < SelectableNode
675689 node = { props . node }
690+ skills = { props . skills }
676691 textStyle = { props . textStyle }
677692 onLinkPress = { props . onLinkPress }
678693 />
@@ -690,6 +705,7 @@ export function NativeMarkdownBlock(props: {
690705 < NativeMarkdownBlock
691706 key = { nodeKey ( child , index ) }
692707 node = { child }
708+ skills = { props . skills }
693709 textStyle = { props . textStyle }
694710 highlightCode = { props . highlightCode }
695711 onLinkPress = { props . onLinkPress }
@@ -703,6 +719,7 @@ export function NativeMarkdownBlock(props: {
703719 return (
704720 < SelectableNode
705721 node = { props . node }
722+ skills = { props . skills }
706723 textStyle = { props . textStyle }
707724 onLinkPress = { props . onLinkPress }
708725 />
0 commit comments