| ... | @@ -4,16 +4,13 @@ import type { MarkdownNode } from "react-native-nitro-markdown/headless"; | ... | @@ -4,16 +4,13 @@ import type { MarkdownNode } from "react-native-nitro-markdown/headless"; |
| 4 | | 4 | |
| 5 | import { CopyTextButton } from "./CopyTextButton"; | 5 | import { CopyTextButton } from "./CopyTextButton"; |
| 6 | import { MarkdownTextPrimitive } from "./MarkdownTextPrimitive"; | 6 | import { MarkdownTextPrimitive } from "./MarkdownTextPrimitive"; |
| 7 | import { | 7 | import { nativeMarkdownDocumentRuns, nativeMarkdownListItemBlocks } from "./nativeMarkdownText"; |
| 8 | nativeMarkdownDocumentRuns, | | |
| 9 | nativeMarkdownListItemBlocks, | | |
| 10 | nativeMarkdownTextRuns, | | |
| 11 | } from "./nativeMarkdownText"; | | |
| 12 | import { NativeMarkdownSelectableText } from "./NativeMarkdownSelectableText.ios"; | 8 | import { NativeMarkdownSelectableText } from "./NativeMarkdownSelectableText.ios"; |
| 13 | import type { | 9 | import type { |
| 14 | MarkdownCodeHighlighter, | 10 | MarkdownCodeHighlighter, |
| 15 | MarkdownHighlightedToken, | 11 | MarkdownHighlightedToken, |
| 16 | NativeMarkdownTextStyle, | 12 | NativeMarkdownTextStyle, |
| | 13 | SelectableMarkdownSkill, |
| 17 | } from "./SelectableMarkdownText.types"; | 14 | } from "./SelectableMarkdownText.types"; |
| 18 | | 15 | |
| 19 | type HighlightedCode = ReadonlyArray<ReadonlyArray<MarkdownHighlightedToken>>; | 16 | type HighlightedCode = ReadonlyArray<ReadonlyArray<MarkdownHighlightedToken>>; |
| ... | @@ -48,12 +45,13 @@ function documentFor(node: MarkdownNode): MarkdownNode { | ... | @@ -48,12 +45,13 @@ function documentFor(node: MarkdownNode): MarkdownNode { |
| 48 | | 45 | |
| 49 | function SelectableNode(props: { | 46 | function SelectableNode(props: { |
| 50 | readonly node: MarkdownNode; | 47 | readonly node: MarkdownNode; |
| | 48 | readonly skills: ReadonlyArray<SelectableMarkdownSkill>; |
| 51 | readonly textStyle: NativeMarkdownTextStyle; | 49 | readonly textStyle: NativeMarkdownTextStyle; |
| 52 | readonly onLinkPress?: (href: string) => void; | 50 | readonly onLinkPress?: (href: string) => void; |
| 53 | }) { | 51 | }) { |
| 54 | return ( | 52 | return ( |
| 55 | <NativeMarkdownSelectableText | 53 | <NativeMarkdownSelectableText |
| 56 | runs={nativeMarkdownDocumentRuns(documentFor(props.node))} | 54 | runs={nativeMarkdownDocumentRuns(documentFor(props.node), props.skills)} |
| 57 | textStyle={props.textStyle} | 55 | textStyle={props.textStyle} |
| 58 | onLinkPress={props.onLinkPress} | 56 | onLinkPress={props.onLinkPress} |
| 59 | /> | 57 | /> |
| ... | @@ -322,6 +320,7 @@ function collectTableRows(node: MarkdownNode): MarkdownNode[] { | ... | @@ -322,6 +320,7 @@ function collectTableRows(node: MarkdownNode): MarkdownNode[] { |
| 322 | | 320 | |
| 323 | function NativeTable(props: { | 321 | function NativeTable(props: { |
| 324 | readonly node: MarkdownNode; | 322 | readonly node: MarkdownNode; |
| | 323 | readonly skills: ReadonlyArray<SelectableMarkdownSkill>; |
| 325 | readonly textStyle: NativeMarkdownTextStyle; | 324 | readonly textStyle: NativeMarkdownTextStyle; |
| 326 | readonly onLinkPress?: (href: string) => void; | 325 | readonly onLinkPress?: (href: string) => void; |
| 327 | }) { | 326 | }) { |
| ... | @@ -359,7 +358,7 @@ function NativeTable(props: { | ... | @@ -359,7 +358,7 @@ function NativeTable(props: { |
| 359 | }} | 358 | }} |
| 360 | > | 359 | > |
| 361 | <NativeMarkdownSelectableText | 360 | <NativeMarkdownSelectableText |
| 362 | runs={nativeMarkdownTextRuns(cell).map((run) => | 361 | runs={nativeMarkdownDocumentRuns(documentFor(cell), props.skills).map((run) => |
| 363 | rowIndex === 0 || cell.isHeader ? { ...run, bold: true } : run, | 362 | rowIndex === 0 || cell.isHeader ? { ...run, bold: true } : run, |
| 364 | )} | 363 | )} |
| 365 | textStyle={props.textStyle} | 364 | textStyle={props.textStyle} |
| ... | @@ -376,6 +375,7 @@ function NativeTable(props: { | ... | @@ -376,6 +375,7 @@ function NativeTable(props: { |
| 376 | | 375 | |
| 377 | function NativeMarkdownImage(props: { | 376 | function NativeMarkdownImage(props: { |
| 378 | readonly node: MarkdownNode; | 377 | readonly node: MarkdownNode; |
| | 378 | readonly skills: ReadonlyArray<SelectableMarkdownSkill>; |
| 379 | readonly textStyle: NativeMarkdownTextStyle; | 379 | readonly textStyle: NativeMarkdownTextStyle; |
| 380 | readonly onLinkPress?: (href: string) => void; | 380 | readonly onLinkPress?: (href: string) => void; |
| 381 | }) { | 381 | }) { |
| ... | @@ -384,6 +384,7 @@ function NativeMarkdownImage(props: { | ... | @@ -384,6 +384,7 @@ function NativeMarkdownImage(props: { |
| 384 | return ( | 384 | return ( |
| 385 | <SelectableNode | 385 | <SelectableNode |
| 386 | node={props.node} | 386 | node={props.node} |
| | 387 | skills={props.skills} |
| 387 | textStyle={props.textStyle} | 388 | textStyle={props.textStyle} |
| 388 | onLinkPress={props.onLinkPress} | 389 | onLinkPress={props.onLinkPress} |
| 389 | /> | 390 | /> |
| ... | @@ -445,6 +446,7 @@ function inlineGroups(nodes: ReadonlyArray<MarkdownNode>): MarkdownNode[] { | ... | @@ -445,6 +446,7 @@ function inlineGroups(nodes: ReadonlyArray<MarkdownNode>): MarkdownNode[] { |
| 445 | | 446 | |
| 446 | function NativeMixedParagraph(props: { | 447 | function NativeMixedParagraph(props: { |
| 447 | readonly node: MarkdownNode; | 448 | readonly node: MarkdownNode; |
| | 449 | readonly skills: ReadonlyArray<SelectableMarkdownSkill>; |
| 448 | readonly textStyle: NativeMarkdownTextStyle; | 450 | readonly textStyle: NativeMarkdownTextStyle; |
| 449 | readonly onLinkPress?: (href: string) => void; | 451 | readonly onLinkPress?: (href: string) => void; |
| 450 | }) { | 452 | }) { |
| ... | @@ -455,6 +457,7 @@ function NativeMixedParagraph(props: { | ... | @@ -455,6 +457,7 @@ function NativeMixedParagraph(props: { |
| 455 | <NativeMarkdownImage | 457 | <NativeMarkdownImage |
| 456 | key={nodeKey(child, index)} | 458 | key={nodeKey(child, index)} |
| 457 | node={child} | 459 | node={child} |
| | 460 | skills={props.skills} |
| 458 | textStyle={props.textStyle} | 461 | textStyle={props.textStyle} |
| 459 | onLinkPress={props.onLinkPress} | 462 | onLinkPress={props.onLinkPress} |
| 460 | /> | 463 | /> |
| ... | @@ -462,6 +465,7 @@ function NativeMixedParagraph(props: { | ... | @@ -462,6 +465,7 @@ function NativeMixedParagraph(props: { |
| 462 | <SelectableNode | 465 | <SelectableNode |
| 463 | key={nodeKey(child, index)} | 466 | key={nodeKey(child, index)} |
| 464 | node={child} | 467 | node={child} |
| | 468 | skills={props.skills} |
| 465 | textStyle={props.textStyle} | 469 | textStyle={props.textStyle} |
| 466 | onLinkPress={props.onLinkPress} | 470 | onLinkPress={props.onLinkPress} |
| 467 | /> | 471 | /> |
| ... | @@ -473,6 +477,7 @@ function NativeMixedParagraph(props: { | ... | @@ -473,6 +477,7 @@ function NativeMixedParagraph(props: { |
| 473 | | 477 | |
| 474 | function NativeList(props: { | 478 | function NativeList(props: { |
| 475 | readonly node: MarkdownNode; | 479 | readonly node: MarkdownNode; |
| | 480 | readonly skills: ReadonlyArray<SelectableMarkdownSkill>; |
| 476 | readonly textStyle: NativeMarkdownTextStyle; | 481 | readonly textStyle: NativeMarkdownTextStyle; |
| 477 | readonly highlightCode: MarkdownCodeHighlighter; | 482 | readonly highlightCode: MarkdownCodeHighlighter; |
| 478 | readonly onLinkPress?: (href: string) => void; | 483 | readonly onLinkPress?: (href: string) => void; |
| ... | @@ -534,6 +539,7 @@ function NativeList(props: { | ... | @@ -534,6 +539,7 @@ function NativeList(props: { |
| 534 | <NativeMarkdownBlock | 539 | <NativeMarkdownBlock |
| 535 | key={nodeKey(child, childIndex)} | 540 | key={nodeKey(child, childIndex)} |
| 536 | node={child} | 541 | node={child} |
| | 542 | skills={props.skills} |
| 537 | textStyle={props.textStyle} | 543 | textStyle={props.textStyle} |
| 538 | highlightCode={props.highlightCode} | 544 | highlightCode={props.highlightCode} |
| 539 | onLinkPress={props.onLinkPress} | 545 | onLinkPress={props.onLinkPress} |
| ... | @@ -551,6 +557,7 @@ function NativeList(props: { | ... | @@ -551,6 +557,7 @@ function NativeList(props: { |
| 551 | | 557 | |
| 552 | export function NativeMarkdownBlock(props: { | 558 | export function NativeMarkdownBlock(props: { |
| 553 | readonly node: MarkdownNode; | 559 | readonly node: MarkdownNode; |
| | 560 | readonly skills: ReadonlyArray<SelectableMarkdownSkill>; |
| 554 | readonly textStyle: NativeMarkdownTextStyle; | 561 | readonly textStyle: NativeMarkdownTextStyle; |
| 555 | readonly highlightCode: MarkdownCodeHighlighter; | 562 | readonly highlightCode: MarkdownCodeHighlighter; |
| 556 | readonly onLinkPress?: (href: string) => void; | 563 | readonly onLinkPress?: (href: string) => void; |
| ... | @@ -566,6 +573,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -566,6 +573,7 @@ export function NativeMarkdownBlock(props: { |
| 566 | <NativeMarkdownBlock | 573 | <NativeMarkdownBlock |
| 567 | key={nodeKey(child, index)} | 574 | key={nodeKey(child, index)} |
| 568 | node={child} | 575 | node={child} |
| | 576 | skills={props.skills} |
| 569 | textStyle={props.textStyle} | 577 | textStyle={props.textStyle} |
| 570 | highlightCode={props.highlightCode} | 578 | highlightCode={props.highlightCode} |
| 571 | onLinkPress={props.onLinkPress} | 579 | onLinkPress={props.onLinkPress} |
| ... | @@ -587,6 +595,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -587,6 +595,7 @@ export function NativeMarkdownBlock(props: { |
| 587 | return ( | 595 | return ( |
| 588 | <NativeTable | 596 | <NativeTable |
| 589 | node={props.node} | 597 | node={props.node} |
| | 598 | skills={props.skills} |
| 590 | textStyle={props.textStyle} | 599 | textStyle={props.textStyle} |
| 591 | onLinkPress={props.onLinkPress} | 600 | onLinkPress={props.onLinkPress} |
| 592 | /> | 601 | /> |
| ... | @@ -595,6 +604,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -595,6 +604,7 @@ export function NativeMarkdownBlock(props: { |
| 595 | return ( | 604 | return ( |
| 596 | <NativeMarkdownImage | 605 | <NativeMarkdownImage |
| 597 | node={props.node} | 606 | node={props.node} |
| | 607 | skills={props.skills} |
| 598 | textStyle={props.textStyle} | 608 | textStyle={props.textStyle} |
| 599 | onLinkPress={props.onLinkPress} | 609 | onLinkPress={props.onLinkPress} |
| 600 | /> | 610 | /> |
| ... | @@ -624,6 +634,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -624,6 +634,7 @@ export function NativeMarkdownBlock(props: { |
| 624 | <NativeMarkdownBlock | 634 | <NativeMarkdownBlock |
| 625 | key={nodeKey(child, index)} | 635 | key={nodeKey(child, index)} |
| 626 | node={child} | 636 | node={child} |
| | 637 | skills={props.skills} |
| 627 | textStyle={props.textStyle} | 638 | textStyle={props.textStyle} |
| 628 | highlightCode={props.highlightCode} | 639 | highlightCode={props.highlightCode} |
| 629 | onLinkPress={props.onLinkPress} | 640 | onLinkPress={props.onLinkPress} |
| ... | @@ -637,6 +648,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -637,6 +648,7 @@ export function NativeMarkdownBlock(props: { |
| 637 | return ( | 648 | return ( |
| 638 | <NativeList | 649 | <NativeList |
| 639 | node={props.node} | 650 | node={props.node} |
| | 651 | skills={props.skills} |
| 640 | textStyle={props.textStyle} | 652 | textStyle={props.textStyle} |
| 641 | highlightCode={props.highlightCode} | 653 | highlightCode={props.highlightCode} |
| 642 | onLinkPress={props.onLinkPress} | 654 | onLinkPress={props.onLinkPress} |
| ... | @@ -647,12 +659,14 @@ export function NativeMarkdownBlock(props: { | ... | @@ -647,12 +659,14 @@ export function NativeMarkdownBlock(props: { |
| 647 | return (props.node.children ?? []).some((child) => child.type === "image") ? ( | 659 | return (props.node.children ?? []).some((child) => child.type === "image") ? ( |
| 648 | <NativeMixedParagraph | 660 | <NativeMixedParagraph |
| 649 | node={props.node} | 661 | node={props.node} |
| | 662 | skills={props.skills} |
| 650 | textStyle={props.textStyle} | 663 | textStyle={props.textStyle} |
| 651 | onLinkPress={props.onLinkPress} | 664 | onLinkPress={props.onLinkPress} |
| 652 | /> | 665 | /> |
| 653 | ) : ( | 666 | ) : ( |
| 654 | <SelectableNode | 667 | <SelectableNode |
| 655 | node={props.node} | 668 | node={props.node} |
| | 669 | skills={props.skills} |
| 656 | textStyle={props.textStyle} | 670 | textStyle={props.textStyle} |
| 657 | onLinkPress={props.onLinkPress} | 671 | onLinkPress={props.onLinkPress} |
| 658 | /> | 672 | /> |
| ... | @@ -673,6 +687,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -673,6 +687,7 @@ export function NativeMarkdownBlock(props: { |
| 673 | > | 687 | > |
| 674 | <SelectableNode | 688 | <SelectableNode |
| 675 | node={props.node} | 689 | node={props.node} |
| | 690 | skills={props.skills} |
| 676 | textStyle={props.textStyle} | 691 | textStyle={props.textStyle} |
| 677 | onLinkPress={props.onLinkPress} | 692 | onLinkPress={props.onLinkPress} |
| 678 | /> | 693 | /> |
| ... | @@ -690,6 +705,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -690,6 +705,7 @@ export function NativeMarkdownBlock(props: { |
| 690 | <NativeMarkdownBlock | 705 | <NativeMarkdownBlock |
| 691 | key={nodeKey(child, index)} | 706 | key={nodeKey(child, index)} |
| 692 | node={child} | 707 | node={child} |
| | 708 | skills={props.skills} |
| 693 | textStyle={props.textStyle} | 709 | textStyle={props.textStyle} |
| 694 | highlightCode={props.highlightCode} | 710 | highlightCode={props.highlightCode} |
| 695 | onLinkPress={props.onLinkPress} | 711 | onLinkPress={props.onLinkPress} |
| ... | @@ -703,6 +719,7 @@ export function NativeMarkdownBlock(props: { | ... | @@ -703,6 +719,7 @@ export function NativeMarkdownBlock(props: { |
| 703 | return ( | 719 | return ( |
| 704 | <SelectableNode | 720 | <SelectableNode |
| 705 | node={props.node} | 721 | node={props.node} |
| | 722 | skills={props.skills} |
| 706 | textStyle={props.textStyle} | 723 | textStyle={props.textStyle} |
| 707 | onLinkPress={props.onLinkPress} | 724 | onLinkPress={props.onLinkPress} |
| 708 | /> | 725 | /> |