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