react-native-enriched-markdown-scaffold 0.7.4-scaffold.9 → 1.0.2-scaffold.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (505) hide show
  1. package/README.md +54 -8
  2. package/ReactNativeEnrichedMarkdown.podspec +82 -73
  3. package/android/build.gradle +188 -1
  4. package/android/consumer-rules.pro +1 -1
  5. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +27 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +7 -0
  7. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +24 -0
  8. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +8 -0
  9. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +27 -0
  10. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +7 -0
  11. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +223 -0
  12. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +183 -0
  13. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +65 -0
  14. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +1086 -61
  15. package/android/src/main/baseline-prof.txt +1 -1
  16. package/android/src/main/cpp/jni-adapter.cpp +74 -0
  17. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +351 -13
  18. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +62 -0
  19. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +85 -0
  20. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +160 -1
  21. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextLayoutManager.kt +10 -1
  22. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +76 -0
  23. package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +126 -10
  24. package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyPressEvent.kt +24 -0
  25. package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyRequestEvent.kt +28 -0
  26. package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLayoutEvent.kt +36 -0
  27. package/android/src/main/java/com/swmansion/enriched/markdown/events/SelectionChangeEvent.kt +43 -0
  28. package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +54 -4
  29. package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +923 -462
  30. package/android/src/main/java/com/swmansion/enriched/markdown/input/MarkdownClipboard.kt +42 -0
  31. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/BlockEditCoordinator.kt +196 -0
  32. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/ClipboardCoordinator.kt +73 -0
  33. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditContext.kt +19 -0
  34. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +248 -0
  35. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditSession.kt +52 -0
  36. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +108 -7
  37. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/LinkCoordinator.kt +69 -0
  38. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownTextWatcher.kt +3 -3
  39. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MentionCoordinator.kt +118 -0
  40. package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeStateEvent.kt +26 -0
  41. package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnContextMenuItemPressEvent.kt +26 -0
  42. package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnInputKeyPressEvent.kt +24 -0
  43. package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnPasteEvent.kt +24 -0
  44. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/BlockStore.kt +254 -0
  45. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/FormattingStore.kt +80 -87
  46. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputFormatter.kt +109 -1
  47. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputParser.kt +116 -22
  48. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/MarkdownSerializer.kt +167 -38
  49. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/RangeEditAdjustment.kt +149 -0
  50. package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +66 -5
  51. package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputMeasurementStore.kt +4 -2
  52. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/BlockRange.kt +27 -0
  53. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/BlockType.kt +48 -0
  54. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/FormattingRange.kt +9 -4
  55. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/InputFormatterStyle.kt +39 -2
  56. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathAtom.kt +20 -0
  57. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +1 -1
  58. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MutableRangeBounds.kt +11 -0
  59. package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputBulletSpan.kt +82 -0
  60. package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputHeadingSpan.kt +58 -0
  61. package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputListItemSpacingSpan.kt +37 -0
  62. package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputOrderedListMarkerSpan.kt +63 -0
  63. package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/BlockHandler.kt +54 -0
  64. package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/HeadingBlockHandler.kt +27 -0
  65. package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/OrderedListBlockHandler.kt +38 -0
  66. package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/UnorderedListBlockHandler.kt +37 -0
  67. package/android/src/main/java/com/swmansion/enriched/markdown/input/toolbar/InputContextMenu.kt +8 -26
  68. package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +1 -0
  69. package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +1 -0
  70. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +9 -2
  71. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +100 -12
  72. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +16 -1
  73. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt +4 -0
  74. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt +37 -7
  75. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListContextManager.kt +2 -1
  76. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListItemRenderer.kt +74 -18
  77. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListRenderer.kt +43 -4
  78. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +9 -1
  79. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SoftBreakRenderer.kt +16 -0
  80. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +35 -28
  81. package/android/src/main/java/com/swmansion/enriched/markdown/spans/BaseListSpan.kt +24 -0
  82. package/android/src/main/java/com/swmansion/enriched/markdown/spans/BlockquoteSpan.kt +174 -24
  83. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +20 -82
  84. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +13 -16
  85. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeSpan.kt +1 -1
  86. package/android/src/main/java/com/swmansion/enriched/markdown/spans/EmphasisSpan.kt +1 -1
  87. package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +182 -46
  88. package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +140 -0
  89. package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkChipSpans.kt +177 -0
  90. package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -6
  91. package/android/src/main/java/com/swmansion/enriched/markdown/spans/ListItemSpacingSpan.kt +33 -0
  92. package/android/src/main/java/com/swmansion/enriched/markdown/spans/ListMarkerAnchorSpan.kt +38 -0
  93. package/android/src/main/java/com/swmansion/enriched/markdown/spans/OrderedListSpan.kt +2 -0
  94. package/android/src/main/java/com/swmansion/enriched/markdown/spans/StrongSpan.kt +1 -1
  95. package/android/src/main/java/com/swmansion/enriched/markdown/spans/TaskListSpan.kt +3 -2
  96. package/android/src/main/java/com/swmansion/enriched/markdown/spans/UnorderedListSpan.kt +3 -2
  97. package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +6 -0
  98. package/android/src/main/java/com/swmansion/enriched/markdown/styles/CodeBlockStyle.kt +26 -0
  99. package/android/src/main/java/com/swmansion/enriched/markdown/styles/ImageStyle.kt +7 -1
  100. package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +16 -1
  101. package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkStyle.kt +36 -1
  102. package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +7 -3
  103. package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +4 -1
  104. package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +3 -0
  105. package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +13 -4
  106. package/android/src/main/java/com/swmansion/enriched/markdown/styles/TableStyle.kt +6 -0
  107. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/CodeBlockHighlighter.kt +90 -0
  108. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/CodeBlockNode.kt +57 -0
  109. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
  110. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownSegment.kt +9 -0
  111. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +84 -7
  112. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +3 -0
  113. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +10 -0
  114. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/SegmentSignature.kt +1 -0
  115. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/StreamingMarkdownFilter.kt +83 -5
  116. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +4 -0
  117. package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +74 -44
  118. package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +52 -0
  119. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageCache.kt +26 -3
  120. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageDownloader.kt +22 -9
  121. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/LocalImageLoader.kt +161 -0
  122. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +2 -1
  123. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +6 -0
  124. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/TextPaintExtensions.kt +23 -0
  125. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/CheckboxTouchHelper.kt +7 -0
  126. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/TaskListTapUtils.kt +41 -21
  127. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +15 -8
  128. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/HeadlessActionMode.kt +88 -0
  129. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLayoutCollector.kt +100 -0
  130. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +58 -27
  131. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +72 -16
  132. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionChangeReporter.kt +232 -0
  133. package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +64 -0
  134. package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +414 -0
  135. package/android/src/main/java/com/swmansion/enriched/markdown/views/ContextMenuPopup.kt +9 -6
  136. package/android/src/main/java/com/swmansion/enriched/markdown/views/CopyGlyph.kt +101 -0
  137. package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +61 -11
  138. package/android/src/main/jni/CMakeLists.txt +53 -0
  139. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.cpp +10 -0
  140. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.h +11 -2
  141. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.cpp +10 -0
  142. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.h +12 -2
  143. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.cpp +9 -0
  144. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.h +24 -0
  145. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +16 -0
  146. package/android/src/math/java/com/swmansion/enriched/markdown/input/math/MathChipControllerImpl.kt +21 -4
  147. package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +8 -2
  148. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
  149. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +13 -6
  150. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathMeasureHelper.kt +2 -1
  151. package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +26 -8
  152. package/cpp/highlight/CodeBlockHighlighter.cpp +284 -0
  153. package/cpp/highlight/CodeBlockHighlighter.hpp +66 -0
  154. package/cpp/highlight/CodeBlockLanguages.cpp +138 -0
  155. package/cpp/highlight/CodeBlockLanguages.hpp +25 -0
  156. package/cpp/highlight/HighlightGrammars.hpp +28 -0
  157. package/cpp/highlight/code_highlight_podspec.rb +211 -0
  158. package/cpp/highlight/gen-registry.mjs +155 -0
  159. package/cpp/highlight/grammar-versions.json +159 -0
  160. package/cpp/highlight/vendor/generated/generated_queries.h +1665 -0
  161. package/cpp/highlight/vendor/generated/generated_registry.cpp +59 -0
  162. package/cpp/parser/MD4CParser.cpp +173 -61
  163. package/cpp/parser/MD4CParser.hpp +1 -0
  164. package/cpp/parser/MarkdownASTNode.hpp +2 -1
  165. package/cpp/wasm/ASTSerializer.cpp +2 -0
  166. package/cpp/wasm/build.sh +1 -0
  167. package/cpp/wasm/md4c_wasm.cpp +3 -1
  168. package/docs/ACCESSIBILITY.md +14 -2
  169. package/docs/API_REFERENCE.md +405 -12
  170. package/docs/BREAKING_CHANGES.md +129 -0
  171. package/docs/CODE_HIGHLIGHT.md +133 -0
  172. package/docs/COPY_OPTIONS.md +61 -3
  173. package/docs/ELEMENTS_STRUCTURE.md +52 -4
  174. package/docs/IMAGE_CACHING.md +30 -0
  175. package/docs/INPUT.md +110 -11
  176. package/docs/LATEX_MATH.md +87 -45
  177. package/docs/MACOS.md +1 -1
  178. package/docs/MARKDOWN_STREAMING.md +27 -1
  179. package/docs/MENTIONS.md +8 -1
  180. package/docs/NATIVE_ASSETS.md +127 -0
  181. package/docs/RTL.md +1 -1
  182. package/docs/STYLES.md +73 -6
  183. package/docs/TESTING.md +112 -0
  184. package/docs/TEXT.md +18 -6
  185. package/docs/WEB.md +4 -1
  186. package/ios/EnrichedMarkdown.h +7 -0
  187. package/ios/EnrichedMarkdown.mm +583 -76
  188. package/ios/EnrichedMarkdownText.h +7 -0
  189. package/ios/EnrichedMarkdownText.mm +299 -73
  190. package/ios/attachments/ENRMImageAttachment.h +9 -0
  191. package/ios/attachments/ENRMImageAttachment.m +143 -40
  192. package/ios/attachments/ENRMMathInlineAttachment+macOS.m +2 -1
  193. package/ios/attachments/ENRMMathInlineAttachment.h +5 -0
  194. package/ios/attachments/ENRMMathInlineAttachment.m +50 -82
  195. package/ios/attachments/ENRMMathInlineAttachmentShared.h +2 -0
  196. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +223 -0
  197. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +183 -0
  198. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +65 -0
  199. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +1086 -61
  200. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +181 -2
  201. package/ios/input/ENRMAutoLinkDetector.h +2 -1
  202. package/ios/input/ENRMAutoLinkDetector.mm +79 -41
  203. package/ios/input/ENRMBlockEditCoordinator.h +71 -0
  204. package/ios/input/ENRMBlockEditCoordinator.mm +195 -0
  205. package/ios/input/ENRMBlockRange.h +28 -0
  206. package/ios/input/ENRMBlockRange.mm +30 -0
  207. package/ios/input/ENRMBlockStore.h +56 -0
  208. package/ios/input/ENRMBlockStore.mm +275 -0
  209. package/ios/input/ENRMClipboardCoordinator.h +45 -0
  210. package/ios/input/ENRMClipboardCoordinator.mm +120 -0
  211. package/ios/input/ENRMDetectorPipeline.h +2 -1
  212. package/ios/input/ENRMEditPipeline.h +76 -0
  213. package/ios/input/ENRMEditPipeline.mm +228 -0
  214. package/ios/input/ENRMEditSession.h +36 -0
  215. package/ios/input/ENRMEditSession.mm +63 -0
  216. package/ios/input/ENRMFormattingStore.h +17 -0
  217. package/ios/input/ENRMFormattingStore.mm +95 -105
  218. package/ios/input/ENRMInputBlockType.h +91 -0
  219. package/ios/input/ENRMInputBlockType.mm +5 -0
  220. package/ios/input/ENRMInputDecorationDrawer.h +18 -0
  221. package/ios/input/ENRMInputEventEmitter.h +56 -0
  222. package/ios/input/ENRMInputEventEmitter.mm +308 -0
  223. package/ios/input/ENRMInputFormatter.h +29 -69
  224. package/ios/input/ENRMInputFormatter.mm +216 -124
  225. package/ios/input/ENRMInputFormatterStyle.h +99 -0
  226. package/ios/input/ENRMInputFormatterStyle.mm +188 -0
  227. package/ios/input/ENRMInputLayoutManager.h +9 -0
  228. package/ios/input/ENRMInputLayoutManager.mm +30 -0
  229. package/ios/input/ENRMInputListMarkerDrawer.h +32 -0
  230. package/ios/input/ENRMInputListMarkerDrawer.mm +426 -0
  231. package/ios/input/ENRMInputParser.h +5 -6
  232. package/ios/input/ENRMInputParser.mm +461 -178
  233. package/ios/input/ENRMInputRemend.mm +2 -2
  234. package/ios/input/ENRMInputStyleStateBuilder.h +40 -0
  235. package/ios/input/ENRMInputStyleStateBuilder.mm +60 -0
  236. package/ios/input/ENRMInputTextView.mm +103 -8
  237. package/ios/input/ENRMInputTypingAttributesController.h +42 -0
  238. package/ios/input/ENRMInputTypingAttributesController.mm +203 -0
  239. package/ios/input/ENRMLinkCoordinator.h +41 -0
  240. package/ios/input/ENRMLinkCoordinator.mm +89 -0
  241. package/ios/input/ENRMMarkdownSerializer.h +29 -5
  242. package/ios/input/ENRMMarkdownSerializer.mm +170 -48
  243. package/ios/input/ENRMMathAtom.h +26 -0
  244. package/ios/input/ENRMMathAtom.mm +12 -0
  245. package/ios/input/ENRMMentionCoordinator.h +45 -0
  246. package/ios/input/ENRMMentionCoordinator.mm +167 -0
  247. package/ios/input/ENRMRangeEditAdjustment.h +38 -0
  248. package/ios/input/ENRMRangeEditAdjustment.mm +91 -0
  249. package/ios/input/ENRMRangeStoreUtils.h +39 -0
  250. package/ios/input/EnrichedMarkdownTextInput+ContextMenu.mm +6 -6
  251. package/ios/input/EnrichedMarkdownTextInput+Internal.h +11 -3
  252. package/ios/input/EnrichedMarkdownTextInput.h +7 -1
  253. package/ios/input/EnrichedMarkdownTextInput.mm +1089 -1023
  254. package/ios/input/InputStylePropsUtils.h +109 -68
  255. package/ios/input/internals/EnrichedMarkdownTextInputShadowNode.mm +2 -1
  256. package/ios/input/styles/ENRMBlockHandler.h +46 -0
  257. package/ios/input/styles/ENRMHeadingBlockHandler.h +15 -0
  258. package/ios/input/styles/ENRMHeadingBlockHandler.mm +38 -0
  259. package/ios/input/styles/ENRMOrderedListBlockHandler.h +14 -0
  260. package/ios/input/styles/ENRMOrderedListBlockHandler.mm +48 -0
  261. package/ios/input/styles/ENRMUnorderedListBlockHandler.h +15 -0
  262. package/ios/input/styles/ENRMUnorderedListBlockHandler.mm +51 -0
  263. package/ios/internals/ENRMViewFreeMeasurement.h +331 -0
  264. package/ios/internals/EnrichedMarkdownShadowNode.h +1 -3
  265. package/ios/internals/EnrichedMarkdownShadowNode.mm +16 -20
  266. package/ios/internals/EnrichedMarkdownTextShadowNode.h +1 -3
  267. package/ios/internals/EnrichedMarkdownTextShadowNode.mm +15 -20
  268. package/ios/internals/MeasurementCache.h +41 -9
  269. package/ios/internals/ShadowMeasurementUtils.h +63 -58
  270. package/ios/math/ENRMMathChipController.h +74 -0
  271. package/ios/math/ENRMMathChipController.mm +476 -0
  272. package/ios/math/ENRMRaTeXBridge.swift +27 -6
  273. package/ios/parser/ENRMMarkdownParser.h +1 -8
  274. package/ios/parser/ENRMMarkdownParser.mm +2 -11
  275. package/ios/parser/MarkdownASTNode.h +2 -1
  276. package/ios/parser/MarkdownParserBridge.mm +4 -0
  277. package/ios/renderer/AttributedRenderer.m +20 -2
  278. package/ios/renderer/BaseRenderer.h +17 -2
  279. package/ios/renderer/BaseRenderer.m +30 -0
  280. package/ios/renderer/BlockquoteRenderer.h +1 -1
  281. package/ios/renderer/BlockquoteRenderer.m +144 -35
  282. package/ios/renderer/CodeBlockRenderer.h +1 -1
  283. package/ios/renderer/CodeBlockRenderer.m +27 -23
  284. package/ios/renderer/CodeRenderer.h +1 -1
  285. package/ios/renderer/CodeRenderer.m +3 -1
  286. package/ios/renderer/ENRMImageRenderer.h +1 -1
  287. package/ios/renderer/ENRMImageRenderer.m +5 -1
  288. package/ios/renderer/ENRMMathInlineRenderer.h +1 -1
  289. package/ios/renderer/ENRMMathInlineRenderer.m +6 -1
  290. package/ios/renderer/ENRMSpoilerRenderer.h +1 -1
  291. package/ios/renderer/ENRMSpoilerRenderer.m +3 -1
  292. package/ios/renderer/EmphasisRenderer.h +1 -1
  293. package/ios/renderer/EmphasisRenderer.m +3 -1
  294. package/ios/renderer/HeadingRenderer.h +1 -1
  295. package/ios/renderer/HeadingRenderer.m +13 -6
  296. package/ios/renderer/HighlightRenderer.h +1 -1
  297. package/ios/renderer/HighlightRenderer.m +3 -1
  298. package/ios/renderer/LinkRenderer.h +1 -1
  299. package/ios/renderer/LinkRenderer.m +50 -16
  300. package/ios/renderer/ListItemRenderer.h +13 -1
  301. package/ios/renderer/ListItemRenderer.m +102 -44
  302. package/ios/renderer/ListRenderer.h +2 -2
  303. package/ios/renderer/ListRenderer.m +63 -25
  304. package/ios/renderer/ParagraphRenderer.h +1 -1
  305. package/ios/renderer/ParagraphRenderer.m +16 -8
  306. package/ios/renderer/RenderContext.h +10 -0
  307. package/ios/renderer/RenderContext.m +44 -0
  308. package/ios/renderer/RendererFactory.m +14 -0
  309. package/ios/renderer/StrikethroughRenderer.h +1 -1
  310. package/ios/renderer/StrikethroughRenderer.m +3 -1
  311. package/ios/renderer/StrongRenderer.h +1 -1
  312. package/ios/renderer/StrongRenderer.m +3 -1
  313. package/ios/renderer/SubscriptRenderer.h +1 -1
  314. package/ios/renderer/SubscriptRenderer.m +3 -1
  315. package/ios/renderer/SuperscriptRenderer.h +1 -1
  316. package/ios/renderer/SuperscriptRenderer.m +3 -1
  317. package/ios/renderer/TextRenderer.h +2 -2
  318. package/ios/renderer/TextRenderer.m +3 -1
  319. package/ios/renderer/ThematicBreakRenderer.h +1 -1
  320. package/ios/renderer/ThematicBreakRenderer.m +3 -1
  321. package/ios/renderer/UnderlineRenderer.h +1 -1
  322. package/ios/renderer/UnderlineRenderer.m +3 -1
  323. package/ios/styles/StyleConfig.h +42 -0
  324. package/ios/styles/StyleConfig.mm +216 -0
  325. package/ios/utils/BlockquoteBorder.h +6 -0
  326. package/ios/utils/BlockquoteBorder.m +249 -52
  327. package/ios/utils/CodeBackground.m +3 -65
  328. package/ios/utils/CodeBlockBackground.m +16 -2
  329. package/ios/utils/ENRMAtomicSize.h +65 -0
  330. package/ios/utils/ENRMBlockMenu.h +66 -0
  331. package/ios/utils/ENRMChipDrawing.h +24 -0
  332. package/ios/utils/ENRMChipDrawing.m +83 -0
  333. package/ios/utils/ENRMCodeBlockContent.h +37 -0
  334. package/ios/utils/ENRMCodeBlockContent.mm +79 -0
  335. package/ios/utils/ENRMCodeBlockHighlighter.h +37 -0
  336. package/ios/utils/ENRMCodeBlockHighlighter.mm +51 -0
  337. package/ios/utils/ENRMFeatureFlags.h +7 -0
  338. package/ios/utils/ENRMImageDownloader.h +11 -1
  339. package/ios/utils/ENRMImageDownloader.m +60 -16
  340. package/ios/utils/ENRMLinkChip.h +70 -0
  341. package/ios/utils/ENRMLinkChip.m +213 -0
  342. package/ios/utils/ENRMLinkLayout.h +50 -0
  343. package/ios/utils/ENRMLinkLayout.m +45 -0
  344. package/ios/utils/ENRMLocalImageLoader.h +31 -0
  345. package/ios/utils/ENRMLocalImageLoader.m +68 -0
  346. package/ios/utils/ENRMMathFallback.h +26 -0
  347. package/ios/utils/ENRMMathFallback.m +18 -0
  348. package/ios/utils/ENRMSelectionChange.h +120 -0
  349. package/ios/utils/ENRMSelectionChange.m +282 -0
  350. package/ios/utils/ENRMTextViewSetup.h +35 -17
  351. package/ios/utils/EditMenuUtils+macOS.m +4 -1
  352. package/ios/utils/EditMenuUtils.h +35 -6
  353. package/ios/utils/EditMenuUtils.m +188 -11
  354. package/ios/utils/HTMLGenerator.m +2 -1
  355. package/ios/utils/ImageRequestHeaderUtils.h +35 -0
  356. package/ios/utils/LastElementUtils.h +1 -0
  357. package/ios/utils/ListMarkerDrawer.m +29 -42
  358. package/ios/utils/MarkdownASTSerializer.m +4 -0
  359. package/ios/utils/MarkdownAccessibilityElementBuilder.m +3 -1
  360. package/ios/utils/MarkdownExtractor.m +2 -1
  361. package/ios/utils/ParagraphStyleUtils.h +5 -0
  362. package/ios/utils/ParagraphStyleUtils.m +77 -17
  363. package/ios/utils/RTFExportUtils.m +2 -0
  364. package/ios/utils/RenderedMarkdownSegment.h +13 -1
  365. package/ios/utils/RenderedMarkdownSegment.m +20 -0
  366. package/ios/utils/SegmentRenderer.m +17 -4
  367. package/ios/utils/StreamingMarkdownFilter.h +11 -1
  368. package/ios/utils/StreamingMarkdownFilter.m +98 -2
  369. package/ios/utils/StylePropsUtils.h +110 -1
  370. package/ios/utils/TaskListTapUtils.m +24 -0
  371. package/ios/utils/TextViewLayoutManager.mm +3 -0
  372. package/ios/views/ENRMCodeBlockContainerView.h +60 -0
  373. package/ios/views/ENRMCodeBlockContainerView.m +569 -0
  374. package/ios/views/ENRMMathContainerView.h +23 -0
  375. package/ios/views/ENRMMathContainerView.m +87 -20
  376. package/ios/views/TableContainerView.h +32 -0
  377. package/ios/views/TableContainerView.m +291 -175
  378. package/jest.d.ts +1 -0
  379. package/jest.js +5 -0
  380. package/lib/module/EnrichedMarkdownNativeComponent.ts +203 -1
  381. package/lib/module/EnrichedMarkdownTextInput.js +84 -5
  382. package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
  383. package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
  384. package/lib/module/EnrichedMarkdownTextNativeComponent.ts +204 -1
  385. package/lib/module/headingDefaults.js +34 -0
  386. package/lib/module/headingDefaults.js.map +1 -0
  387. package/lib/module/index.js.map +1 -1
  388. package/lib/module/jest/index.js +205 -0
  389. package/lib/module/jest/index.js.map +1 -0
  390. package/lib/module/native/EnrichedMarkdownText.js +199 -15
  391. package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
  392. package/lib/module/normalizeMarkdownStyle.js +98 -23
  393. package/lib/module/normalizeMarkdownStyle.js.map +1 -1
  394. package/lib/module/normalizeMarkdownStyle.web.js +73 -22
  395. package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
  396. package/lib/module/normalizeMarkdownTextInputStyle.js +62 -15
  397. package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
  398. package/lib/module/normalizeMenuItem.js +1 -1
  399. package/lib/module/utils/textInputState.js +26 -0
  400. package/lib/module/utils/textInputState.js.map +1 -0
  401. package/lib/module/web/EnrichedMarkdownText.js +15 -8
  402. package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
  403. package/lib/module/web/parseMarkdown.js +4 -3
  404. package/lib/module/web/parseMarkdown.js.map +1 -1
  405. package/lib/module/web/renderers/InlineRenderers.js +102 -3
  406. package/lib/module/web/renderers/InlineRenderers.js.map +1 -1
  407. package/lib/module/web/renderers/ListRenderers.js +7 -2
  408. package/lib/module/web/renderers/ListRenderers.js.map +1 -1
  409. package/lib/module/web/renderers/index.js +7 -4
  410. package/lib/module/web/renderers/index.js.map +1 -1
  411. package/lib/module/web/styles.js +101 -6
  412. package/lib/module/web/styles.js.map +1 -1
  413. package/lib/module/web/utils.js +14 -0
  414. package/lib/module/web/utils.js.map +1 -1
  415. package/lib/module/web/wasm/md4c.js +0 -0
  416. package/lib/module/web/wasm/md4c.js.map +1 -1
  417. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +185 -2
  418. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
  419. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +94 -9
  420. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
  421. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +69 -5
  422. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
  423. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +185 -2
  424. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
  425. package/lib/typescript/src/headingDefaults.d.ts +9 -0
  426. package/lib/typescript/src/headingDefaults.d.ts.map +1 -0
  427. package/lib/typescript/src/index.d.ts +3 -3
  428. package/lib/typescript/src/index.d.ts.map +1 -1
  429. package/lib/typescript/src/index.web.d.ts +2 -2
  430. package/lib/typescript/src/index.web.d.ts.map +1 -1
  431. package/lib/typescript/src/jest/index.d.ts +6 -0
  432. package/lib/typescript/src/jest/index.d.ts.map +1 -0
  433. package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +5 -5
  434. package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
  435. package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
  436. package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
  437. package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +19 -5
  438. package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
  439. package/lib/typescript/src/types/MarkdownStyle.d.ts +122 -5
  440. package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
  441. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +39 -0
  442. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
  443. package/lib/typescript/src/types/MarkdownTextProps.d.ts +207 -10
  444. package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
  445. package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +60 -1
  446. package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
  447. package/lib/typescript/src/types/events.d.ts +85 -0
  448. package/lib/typescript/src/types/events.d.ts.map +1 -1
  449. package/lib/typescript/src/utils/textInputState.d.ts +24 -0
  450. package/lib/typescript/src/utils/textInputState.d.ts.map +1 -0
  451. package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
  452. package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
  453. package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
  454. package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
  455. package/lib/typescript/src/web/renderers/InlineRenderers.d.ts.map +1 -1
  456. package/lib/typescript/src/web/renderers/ListRenderers.d.ts.map +1 -1
  457. package/lib/typescript/src/web/renderers/index.d.ts +2 -1
  458. package/lib/typescript/src/web/renderers/index.d.ts.map +1 -1
  459. package/lib/typescript/src/web/styles.d.ts +2 -1
  460. package/lib/typescript/src/web/styles.d.ts.map +1 -1
  461. package/lib/typescript/src/web/types.d.ts +10 -2
  462. package/lib/typescript/src/web/types.d.ts.map +1 -1
  463. package/lib/typescript/src/web/utils.d.ts +4 -0
  464. package/lib/typescript/src/web/utils.d.ts.map +1 -1
  465. package/package.json +36 -9
  466. package/postinstall.mjs +131 -0
  467. package/ratex-version.json +21 -0
  468. package/src/EnrichedMarkdownNativeComponent.ts +203 -1
  469. package/src/EnrichedMarkdownTextInput.tsx +159 -8
  470. package/src/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
  471. package/src/EnrichedMarkdownTextNativeComponent.ts +204 -1
  472. package/src/headingDefaults.ts +21 -0
  473. package/src/index.tsx +15 -0
  474. package/src/index.web.tsx +6 -1
  475. package/src/jest/index.tsx +236 -0
  476. package/src/native/EnrichedMarkdownText.tsx +260 -11
  477. package/src/normalizeMarkdownStyle.ts +117 -16
  478. package/src/normalizeMarkdownStyle.web.ts +76 -15
  479. package/src/normalizeMarkdownTextInputStyle.ts +110 -35
  480. package/src/normalizeMenuItem.ts +1 -1
  481. package/src/types/MarkdownStyle.ts +125 -5
  482. package/src/types/MarkdownStyleInternal.ts +51 -0
  483. package/src/types/MarkdownTextProps.ts +215 -10
  484. package/src/types/MarkdownTextProps.web.ts +62 -1
  485. package/src/types/events.ts +90 -0
  486. package/src/utils/textInputState.ts +35 -0
  487. package/src/web/EnrichedMarkdownText.tsx +26 -5
  488. package/src/web/parseMarkdown.ts +6 -2
  489. package/src/web/renderers/InlineRenderers.tsx +116 -3
  490. package/src/web/renderers/ListRenderers.tsx +14 -2
  491. package/src/web/renderers/index.tsx +6 -2
  492. package/src/web/styles.ts +114 -5
  493. package/src/web/types.ts +10 -1
  494. package/src/web/utils.ts +9 -0
  495. package/src/web/wasm/md4c.js +0 -0
  496. package/vendor-grammars.mjs +511 -0
  497. package/vendor-ratex.mjs +173 -0
  498. package/app.plugin.js +0 -2
  499. package/plugin/build/withAndroidMath.js +0 -19
  500. package/plugin/build/withIosMath.js +0 -28
  501. package/plugin/build/withReactNativeEnrichedMarkdown.js +0 -11
  502. package/plugin/src/withAndroidMath.ts +0 -24
  503. package/plugin/src/withIosMath.ts +0 -35
  504. package/plugin/src/withReactNativeEnrichedMarkdown.ts +0 -17
  505. package/plugin/tsconfig.build.json +0 -16
@@ -6,6 +6,19 @@ export type BlockTextAlign = 'auto' | 'left' | 'right' | 'center' | 'justify';
6
6
  // Mirrors the public fontStyle values; empty string means "inherit / no override".
7
7
  export type EmphasisFontStyle = 'normal' | 'italic' | 'oblique' | '';
8
8
 
9
+ // empty string means "no table alignment set" (legacy start-aligned placement).
10
+ export type TableAlign = 'left' | 'center' | 'right' | '';
11
+
12
+ // empty string means "legacy sizing" (fill width, no resize-mode handling).
13
+ // resolves to 'cover' when maxHeight/aspectRatio is present.
14
+ export type ImageResizeMode =
15
+ | 'contain'
16
+ | 'cover'
17
+ | 'stretch'
18
+ | 'center'
19
+ | 'none'
20
+ | '';
21
+
9
22
  interface BaseBlockStyleInternal {
10
23
  fontSize: number;
11
24
  fontFamily: string;
@@ -29,6 +42,8 @@ interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
29
42
  borderWidth: number;
30
43
  gapWidth: number;
31
44
  backgroundColor: string;
45
+ borderRadius: number;
46
+ padding: number;
32
47
  }
33
48
 
34
49
  interface ListStyleInternal extends BaseBlockStyleInternal {
@@ -39,6 +54,24 @@ interface ListStyleInternal extends BaseBlockStyleInternal {
39
54
  markerFontWeight: string;
40
55
  gapWidth: number;
41
56
  marginLeft: number;
57
+ itemSpacing: number;
58
+ }
59
+
60
+ export interface CodeBlockSyntaxColorsInternal {
61
+ keyword: string;
62
+ operatorColor: string;
63
+ punctuation: string;
64
+ string: string;
65
+ number: string;
66
+ constant: string;
67
+ comment: string;
68
+ function: string;
69
+ type: string;
70
+ variable: string;
71
+ property: string;
72
+ tag: string;
73
+ attribute: string;
74
+ embedded: string;
42
75
  }
43
76
 
44
77
  interface CodeBlockStyleInternal extends BaseBlockStyleInternal {
@@ -47,6 +80,7 @@ interface CodeBlockStyleInternal extends BaseBlockStyleInternal {
47
80
  borderRadius: number;
48
81
  borderWidth: number;
49
82
  padding: number;
83
+ syntaxColors: CodeBlockSyntaxColorsInternal;
50
84
  }
51
85
 
52
86
  interface LinkStyleInternal {
@@ -54,6 +88,11 @@ interface LinkStyleInternal {
54
88
  color: string;
55
89
  underline: boolean;
56
90
  backgroundColor: string;
91
+ borderRadius: number;
92
+ paddingHorizontal: number;
93
+ paddingVertical: number;
94
+ borderColor: string;
95
+ borderWidth: number;
57
96
  }
58
97
 
59
98
  export interface LinkVariantEntryInternal {
@@ -61,6 +100,11 @@ export interface LinkVariantEntryInternal {
61
100
  color: string;
62
101
  underline: boolean;
63
102
  backgroundColor: string;
103
+ borderRadius: number;
104
+ paddingHorizontal: number;
105
+ paddingVertical: number;
106
+ borderColor: string;
107
+ borderWidth: number;
64
108
  }
65
109
 
66
110
  interface StrongStyleInternal {
@@ -93,6 +137,9 @@ interface CodeStyleInternal {
93
137
 
94
138
  interface ImageStyleInternal {
95
139
  height: number;
140
+ maxHeight: number;
141
+ aspectRatio: number;
142
+ resizeMode: ImageResizeMode;
96
143
  borderRadius: number;
97
144
  marginTop: number;
98
145
  marginBottom: number;
@@ -120,6 +167,8 @@ interface TableStyleInternal extends BaseBlockStyleInternal {
120
167
  borderRadius: number;
121
168
  cellPaddingHorizontal: number;
122
169
  cellPaddingVertical: number;
170
+ horizontalOverflow: number;
171
+ align: TableAlign;
123
172
  }
124
173
 
125
174
  interface TaskListStyleInternal {
@@ -141,12 +190,14 @@ interface MathStyleInternal {
141
190
  marginBottom: number;
142
191
  textAlign: BlockTextAlign;
143
192
  fontWeight: string;
193
+ glyphOverflow: number;
144
194
  }
145
195
 
146
196
  interface InlineMathStyleInternal {
147
197
  color: string;
148
198
  paddingVertical: number;
149
199
  fontWeight: string;
200
+ glyphOverflow: number;
150
201
  }
151
202
 
152
203
  interface SpoilerParticlesStyleInternal {
@@ -1,12 +1,62 @@
1
- import type { ColorValue, ViewProps, ViewStyle, TextStyle } from 'react-native';
1
+ import type { ReactNode, RefObject } from 'react';
2
+ import type {
3
+ ColorValue,
4
+ HostInstance,
5
+ ViewProps,
6
+ ViewStyle,
7
+ TextStyle,
8
+ } from 'react-native';
2
9
  import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
3
10
  import type { AccessibilityLabels } from './AccessibilityLabels';
4
11
  import type {
5
12
  LinkPressEvent,
6
13
  LinkLongPressEvent,
7
14
  TaskListItemPressEvent,
15
+ CopyPressEvent,
16
+ CopyEvent,
17
+ SelectionChangeEvent,
8
18
  } from './events';
9
19
 
20
+ /** Imperative handle of `EnrichedMarkdownText`, reached through its `ref`. */
21
+ export interface EnrichedMarkdownTextInstance {
22
+ /**
23
+ * Clears the text selection (and any long-pressed block) and fires
24
+ * `onSelectionChange` with `active: false`.
25
+ * @platform ios, android
26
+ */
27
+ clearSelection: () => void;
28
+ measure: HostInstance['measure'];
29
+ measureInWindow: HostInstance['measureInWindow'];
30
+ measureLayout: HostInstance['measureLayout'];
31
+ }
32
+
33
+ /**
34
+ * A rect in dp, relative to the component's content box (inside any
35
+ * `containerStyle` padding).
36
+ */
37
+ export interface LinkRect {
38
+ x: number;
39
+ y: number;
40
+ width: number;
41
+ height: number;
42
+ }
43
+
44
+ /** Layout of one rendered link, passed to `renderLinkDecoration`. */
45
+ export interface LinkDecorationInfo {
46
+ /** Position of the link in the document (0-based) — stable key for a link. */
47
+ index: number;
48
+ url: string;
49
+ /** The link's visible text. */
50
+ text: string;
51
+ /**
52
+ * Anchor rect. Native: the drawn chip (glyphs + padding) of the link's last
53
+ * line fragment. Web: the link's inline box.
54
+ */
55
+ rect: LinkRect;
56
+ /** Every line fragment of the link (several when it wraps). Web: `[rect]`. */
57
+ rects: LinkRect[];
58
+ }
59
+
10
60
  /**
11
61
  * Public context menu item. Each item includes a JS-side `onPress` callback
12
62
  * that is called when the user taps the item in the selection context menu.
@@ -56,22 +106,31 @@ export interface SelectionMenuPluralLabels {
56
106
  * Controls the built-in items added to the native text selection menu and
57
107
  * lets you localize their labels.
58
108
  *
59
- * Each item accepts an object: `{ enabled }` toggles visibility (the system
60
- * `copy` item can't be hidden — only relabeled) and `label` overrides the
61
- * English default. Wire `label` to your i18n library to match the rest of your
62
- * app's UI. Labels apply to the main text selection menu as well as the table
63
- * and math block copy menus.
109
+ * Each item accepts an object: `{ enabled }` toggles visibility and `label`
110
+ * overrides the English default. Wire `label` to your i18n library to match
111
+ * the rest of your app's UI. Items and labels apply to the main text selection
112
+ * menu as well as the table, math and code block copy menus.
113
+ *
114
+ * `copy.enabled`, `copy.format` and `systemItems` are ignored on macOS.
64
115
  *
65
116
  * @platform ios, android, macos
66
117
  */
67
118
  export interface SelectionMenuConfig {
68
119
  /**
69
- * The system "Copy" item. It can't be hidden — only its label is configurable.
70
- * @default { label: "Copy" }
120
+ * The "Copy" item.
121
+ * - `enabled`: `false` removes it from the text selection menu, the table /
122
+ * math / code block menus and the code block VoiceOver copy action.
123
+ * - `format`: `'rich'` copies rich text (plain + HTML, plus RTF on iOS) from
124
+ * text selections and the raw content from blocks; `'markdown'` copies
125
+ * Markdown as plain text everywhere the item appears (inline math becomes
126
+ * `$…$`, math blocks `$$…$$`, code blocks are fenced). The code block header
127
+ * button and VoiceOver action always copy the raw code.
128
+ * @default { enabled: true, label: "Copy", format: "rich" }
71
129
  */
72
- copy?: { label?: string };
130
+ copy?: { enabled?: boolean; label?: string; format?: 'rich' | 'markdown' };
73
131
  /**
74
- * The built-in "Copy as Markdown" action for text selections.
132
+ * The built-in "Copy as Markdown" action, in the text selection menu and in
133
+ * the table / math / code block menus.
75
134
  * @default { enabled: true, label: "Copy as Markdown" }
76
135
  */
77
136
  copyAsMarkdown?: { enabled?: boolean; label?: string };
@@ -86,6 +145,23 @@ export interface SelectionMenuConfig {
86
145
  label?: string;
87
146
  pluralLabels?: SelectionMenuPluralLabels;
88
147
  };
148
+ /**
149
+ * Which system items the text selection menu keeps.
150
+ * - `'default'`: keep everything the OS adds (Select All, Look Up, Share,
151
+ * Translate, app text actions…), with Copy replaced by the built-in one.
152
+ * - `'none'`: drop every system item; the menu only holds the built-in items
153
+ * above and `contextMenuItems`.
154
+ * @default 'default'
155
+ * @platform ios, android
156
+ */
157
+ systemItems?: 'default' | 'none';
158
+ /**
159
+ * The copy button in the code block header. `false` hides the button; the
160
+ * header and language label stay.
161
+ * @default { enabled: true }
162
+ * @platform ios, android, macos
163
+ */
164
+ codeBlockCopyButton?: { enabled?: boolean };
89
165
  }
90
166
 
91
167
  export interface StreamingConfig {
@@ -98,9 +174,26 @@ export interface StreamingConfig {
98
174
  * @platform ios, android
99
175
  */
100
176
  tableMode?: 'hidden' | 'progressive';
177
+ /**
178
+ * Controls how a fenced code block whose closing fence has not arrived yet
179
+ * is handled during streaming.
180
+ * - `'hidden'`: hide the entire code block until its closing fence arrives.
181
+ * - `'progressive'` (default): show the code as it streams in with its header
182
+ * visible but non-interactive (copying is disabled); syntax highlighting is
183
+ * deferred until the closing fence arrives, so it appears once atomically.
184
+ * Only effective when `streamingAnimation` is `true`.
185
+ * @default 'progressive'
186
+ * @platform ios, android
187
+ */
188
+ codeBlockMode?: 'hidden' | 'progressive';
101
189
  }
102
190
 
103
191
  export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
192
+ /**
193
+ * Imperative handle: `clearSelection()` plus the host `measure*` methods.
194
+ * @platform ios, android
195
+ */
196
+ ref?: RefObject<EnrichedMarkdownTextInstance | null>;
104
197
  /**
105
198
  * Markdown content to render.
106
199
  * @platform ios, android, web
@@ -138,6 +231,21 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
138
231
  * @platform ios, android, web
139
232
  */
140
233
  onLinkLongPress?: (event: LinkLongPressEvent) => void;
234
+ /**
235
+ * Renders a decoration (e.g. a badge or icon) over each link. The returned
236
+ * node is placed in an absolutely positioned box matching `info.rect` (the
237
+ * link's last line fragment, including chip padding) with
238
+ * `pointerEvents="box-none"`; position content relative to it (negative
239
+ * offsets overflow the box). Return `null` to leave a link undecorated.
240
+ *
241
+ * Native caveats: rects arrive from native after layout, so decorations
242
+ * appear one frame after the text; links inside tables (`flavor="github"`)
243
+ * are not reported; content overflowing the component bounds does not
244
+ * receive touches on Android. Toggling this prop between set and unset
245
+ * remounts the native view.
246
+ * @platform ios, android, web
247
+ */
248
+ renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
141
249
  /**
142
250
  * Callback fired when a task list checkbox is tapped.
143
251
  *
@@ -149,6 +257,61 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
149
257
  * @platform ios, android, web
150
258
  */
151
259
  onTaskListItemPress?: (event: TaskListItemPressEvent) => void;
260
+ /**
261
+ * Controls whether tapping a task list checkbox toggles its checked state.
262
+ *
263
+ * When `true` (default), tapping the checkbox toggles it and fires
264
+ * `onTaskListItemPress`. When `false`, the checkbox renders its markdown
265
+ * state read-only: the tap is fully inert — no visual toggle and no
266
+ * `onTaskListItemPress` emission. Text selection and links in the same row
267
+ * are unaffected.
268
+ *
269
+ * @default true
270
+ * @platform ios, android, web
271
+ */
272
+ enableTaskListItemToggle?: boolean;
273
+ /**
274
+ * Callback fired when code is copied from a fenced code block, via the header
275
+ * copy button, the long-press context-menu "Copy" action, or the VoiceOver
276
+ * copy action. Receives the copied code and its language. Does not fire for
277
+ * "Copy as Markdown", nor for the context-menu "Copy" when
278
+ * `selectionMenuConfig.copy.format` is `'markdown'`.
279
+ *
280
+ * Only fires when `flavor="github"` (the copy button is part of the GitHub
281
+ * flavor's container-based code block renderer).
282
+ * @platform ios, android, macos
283
+ */
284
+ onCopyPress?: (event: CopyPressEvent) => void;
285
+ /**
286
+ * Takes over the "Copy" item of the text selection menu and of the table /
287
+ * math / code block menus. When set, native does **not** write the
288
+ * clipboard: it calls this with the copied content and the handler writes
289
+ * whatever it wants (e.g. with `expo-clipboard`). Overrides
290
+ * `selectionMenuConfig.copy.format`; `copy.enabled: false` still hides the
291
+ * item. "Copy as Markdown", the code block header button and the VoiceOver
292
+ * copy action are unaffected, and `onCopyPress` does not fire for an
293
+ * intercepted Copy.
294
+ * @platform ios, android
295
+ */
296
+ onCopy?: (event: CopyEvent) => void;
297
+ /**
298
+ * Reports the text selection so the app can draw its own menu (pair it with
299
+ * `contextMenuHidden`). Fires at most once per frame while the selection
300
+ * changes, and with `active: false` once it is gone. With
301
+ * `contextMenuHidden`, a long press on a table / math / code block fires it
302
+ * too (`source` is the block kind, `whole: true`), since those blocks have no
303
+ * text selection of their own. Only one part of a component holds a
304
+ * selection at a time; clearing the selection of *other* components is up to
305
+ * the app (`ref.current.clearSelection()`).
306
+ *
307
+ * Rects are relative to the view that `ref.current.measureInWindow`
308
+ * measures — add that origin to position UI on screen. On iOS, `adjusting`
309
+ * is `true` while a selection handle is dragged: hide the menu until it is
310
+ * `false` again. Android reports every step of the drag instead (with
311
+ * `adjusting: false`), so debounce before showing a menu there.
312
+ * @platform ios, android
313
+ */
314
+ onSelectionChange?: (event: SelectionChangeEvent) => void;
152
315
  /**
153
316
  * Controls whether the system link preview is shown on long press (iOS only).
154
317
  *
@@ -162,6 +325,16 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
162
325
  * @platform ios
163
326
  */
164
327
  enableLinkPreview?: boolean;
328
+ /**
329
+ * When `true`, long-pressing a link selects its label and shows the
330
+ * selection edit menu, like a manual text selection, instead of the system
331
+ * link preview. Takes precedence over `enableLinkPreview` and
332
+ * `onLinkLongPress`.
333
+ *
334
+ * @default false
335
+ * @platform ios
336
+ */
337
+ linkLongPressSelects?: boolean;
165
338
  /**
166
339
  * Controls text selection.
167
340
  * - iOS: Controls text selection and link previews on long press.
@@ -254,6 +427,38 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
254
427
  * @platform ios, android
255
428
  */
256
429
  contextMenuItems?: ContextMenuItem[];
430
+ /**
431
+ * HTTP headers to attach to remote image requests, e.g. a `Referer`
432
+ * required by CDN hotlink protection or an `Authorization` token.
433
+ *
434
+ * Headers participate in image cache identity, so the same URL requested
435
+ * with different headers is fetched and cached separately.
436
+ *
437
+ * Not supported on web — browsers don't allow custom headers on `<img>`
438
+ * requests.
439
+ * @platform ios, android
440
+ */
441
+ imageRequestHeaders?: Record<string, string>;
442
+ /**
443
+ * Hides the text selection context menu. Text stays selectable (and stays
444
+ * reachable by TalkBack / VoiceOver) — only the menu is suppressed. Use
445
+ * `selectable={false}` instead if you want to disable selection itself.
446
+ *
447
+ * This hides the whole menu, including the custom items from
448
+ * `contextMenuItems` and the built-in items from `selectionMenuConfig`,
449
+ * since they all share one menu. It also covers the copy menus on table,
450
+ * math and code blocks.
451
+ *
452
+ * It does not suppress the system "Save to Camera Roll / Copy" sheet that
453
+ * UIKit shows when long-pressing an image.
454
+ *
455
+ * On Android no selection toolbar is created at all, so ROMs that draw
456
+ * their own (MIUI) stay hidden too. A selection made while this is on
457
+ * keeps no menu if it is turned off mid-selection; the next one gets it.
458
+ * @default false
459
+ * @platform ios, android, macos
460
+ */
461
+ contextMenuHidden?: boolean;
257
462
  /**
258
463
  * Controls the built-in items added to the native text selection menu and
259
464
  * lets you localize their labels. Custom app-provided actions are controlled
@@ -1,4 +1,4 @@
1
- import type { CSSProperties, HTMLAttributes } from 'react';
1
+ import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
2
2
  import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
3
3
  import type {
4
4
  LinkPressEvent,
@@ -6,6 +6,33 @@ import type {
6
6
  TaskListItemPressEvent,
7
7
  } from './events';
8
8
 
9
+ /**
10
+ * A rect in dp, relative to the component's content box (inside any
11
+ * `containerStyle` padding).
12
+ */
13
+ export interface LinkRect {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ }
19
+
20
+ /** Layout of one rendered link, passed to `renderLinkDecoration`. */
21
+ export interface LinkDecorationInfo {
22
+ /** Position of the link in the document (0-based) — stable key for a link. */
23
+ index: number;
24
+ url: string;
25
+ /** The link's visible text. */
26
+ text: string;
27
+ /**
28
+ * Anchor rect. Native: the drawn chip (glyphs + padding) of the link's last
29
+ * line fragment. Web: the link's inline box.
30
+ */
31
+ rect: LinkRect;
32
+ /** Every line fragment of the link (several when it wraps). Web: `[rect]`. */
33
+ rects: LinkRect[];
34
+ }
35
+
9
36
  export interface EnrichedMarkdownTextProps extends Omit<
10
37
  HTMLAttributes<HTMLDivElement>,
11
38
  'style' | 'dir'
@@ -47,6 +74,21 @@ export interface EnrichedMarkdownTextProps extends Omit<
47
74
  * @platform ios, android, web
48
75
  */
49
76
  onLinkLongPress?: (event: LinkLongPressEvent) => void;
77
+ /**
78
+ * Renders a decoration (e.g. a badge or icon) over each link. The returned
79
+ * node is placed in an absolutely positioned box matching `info.rect` (the
80
+ * link's last line fragment, including chip padding) with
81
+ * `pointerEvents="box-none"`; position content relative to it (negative
82
+ * offsets overflow the box). Return `null` to leave a link undecorated.
83
+ *
84
+ * Native caveats: rects arrive from native after layout, so decorations
85
+ * appear one frame after the text; links inside tables (`flavor="github"`)
86
+ * are not reported; content overflowing the component bounds does not
87
+ * receive touches on Android. Toggling this prop between set and unset
88
+ * remounts the native view.
89
+ * @platform ios, android, web
90
+ */
91
+ renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
50
92
  /**
51
93
  * Callback fired when a task list checkbox is tapped.
52
94
  *
@@ -58,6 +100,25 @@ export interface EnrichedMarkdownTextProps extends Omit<
58
100
  * @platform ios, android, web
59
101
  */
60
102
  onTaskListItemPress?: (event: TaskListItemPressEvent) => void;
103
+ /**
104
+ * Controls whether tapping a task list checkbox toggles its checked state.
105
+ *
106
+ * When `true` (default), tapping the checkbox toggles it and fires
107
+ * `onTaskListItemPress`. When `false`, the checkbox renders its markdown
108
+ * state read-only: the tap is fully inert — no visual toggle and no
109
+ * `onTaskListItemPress` emission. Text selection and links in the same row
110
+ * are unaffected.
111
+ *
112
+ * On web the checkbox keeps its normal appearance and is marked
113
+ * `readOnly` / `aria-disabled` rather than `disabled`, so it stays visually
114
+ * consistent with iOS and Android. It is also made pointer-inert
115
+ * (`pointer-events: none`) so the browser cannot paint hover or active
116
+ * states on a checkbox that cannot be toggled.
117
+ *
118
+ * @default true
119
+ * @platform ios, android, web
120
+ */
121
+ enableTaskListItemToggle?: boolean;
61
122
  /**
62
123
  * Controls text selection.
63
124
  * - iOS: Controls text selection and link previews on long press.
@@ -12,6 +12,80 @@ export interface TaskListItemPressEvent {
12
12
  text: string;
13
13
  }
14
14
 
15
+ export interface CopyPressEvent {
16
+ code: string;
17
+ language: string;
18
+ }
19
+
20
+ /**
21
+ * Payload of `onCopy`: what the Copy item would have copied. With `onCopy`
22
+ * set, native writes nothing to the clipboard — the handler owns the write.
23
+ */
24
+ export interface CopyEvent {
25
+ /** Which menu the Copy item belongs to. */
26
+ source: 'selection' | 'math' | 'table' | 'code';
27
+ /**
28
+ * Markdown of the copied content — what `copy.format: 'markdown'` writes.
29
+ * Text selections: the original source when `whole`, otherwise rebuilt from
30
+ * the rendered styles (falls back to `text`). Blocks: `$$…$$`, the table as
31
+ * Markdown, or the fenced code block.
32
+ */
33
+ markdown: string;
34
+ /** Rendered text of the selection, or the block's raw content. */
35
+ text: string;
36
+ /**
37
+ * `true` when the selection covers the whole component, so `markdown` is the
38
+ * original source. Always `true` for blocks.
39
+ */
40
+ whole: boolean;
41
+ }
42
+
43
+ /**
44
+ * A rect in dp, relative to the component's native view: add the origin from
45
+ * the component ref's `measureInWindow` to get window coordinates.
46
+ */
47
+ export interface SelectionRect {
48
+ x: number;
49
+ y: number;
50
+ width: number;
51
+ height: number;
52
+ }
53
+
54
+ /**
55
+ * Payload of `onSelectionChange`: the current text selection, or a table /
56
+ * math / code block long-pressed while `contextMenuHidden` is on. Content
57
+ * fields carry what `onCopy` would receive for the same selection.
58
+ */
59
+ export interface SelectionChangeEvent {
60
+ /** `false` once the selection is gone; every other field is then empty / zero. */
61
+ active: boolean;
62
+ /** `'selection'` for text; the block kind for a long-pressed block. */
63
+ source: CopyEvent['source'];
64
+ /** Rendered text of the selection, or the block's raw content. */
65
+ text: string;
66
+ /** Same as `CopyEvent.markdown` for this selection. */
67
+ markdown: string;
68
+ /** Same as `CopyEvent.whole`. Always `true` for blocks. */
69
+ whole: boolean;
70
+ /**
71
+ * Bounding box of the selection (full content width when it spans several
72
+ * lines); the block's frame for blocks.
73
+ */
74
+ rect: SelectionRect;
75
+ /** Selected part of the first line (block: same as `rect`). */
76
+ startRect: SelectionRect;
77
+ /** Selected part of the last line (block: same as `rect`). */
78
+ endRect: SelectionRect;
79
+ /**
80
+ * `true` while a selection handle is dragged (or the loupe is held), with the
81
+ * selection as it was when the drag began; `false` again, with the new
82
+ * selection, once the finger lifts. Hide your menu while it is `true`.
83
+ * Always `false` on Android, which reports the selection continuously
84
+ * during the drag.
85
+ */
86
+ adjusting: boolean;
87
+ }
88
+
15
89
  /**
16
90
  * Native-level context menu item config sent to the native component.
17
91
  * Does not include the `onPress` callback — callbacks are managed on the JS side.
@@ -30,3 +104,19 @@ export interface OnContextMenuItemPressEvent {
30
104
  selectionStart: number;
31
105
  selectionEnd: number;
32
106
  }
107
+
108
+ /**
109
+ * Event payload fired by the native component when the user pastes while
110
+ * `interceptPaste` is on. Native does not touch the buffer — it only reports
111
+ * what the clipboard held. The handler must call `resolvePaste` exactly once,
112
+ * or the paste is dropped.
113
+ */
114
+ export interface OnPasteEvent {
115
+ /** Plain text from the clipboard, verbatim, before the text view sees it. */
116
+ text: string;
117
+ /**
118
+ * Markdown flavor, set only when the copy source was an input of this
119
+ * component. iOS-only; Android always reports `''`.
120
+ */
121
+ markdown: string;
122
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Bridges EnrichedMarkdownTextInput into React Native's TextInputState focus
3
+ * registry so it participates in RN's keyboard-dismiss behavior (issue #577).
4
+ *
5
+ * Registering a non-TextInput host component is safe: TextInputState's
6
+ * blurTextInput dispatches the built-in TextInput's "blur" command at the
7
+ * registered instance, and Fabric command dispatch is name-based — it works
8
+ * as long as the component ships a command with that name, which ours does.
9
+ *
10
+ * A deep import is required because the public TextInput.State API lacks the
11
+ * registerInput/focusInput/blurInput bookkeeping functions.
12
+ */
13
+ import type { HostInstance } from 'react-native';
14
+
15
+ interface TextInputStateModule {
16
+ registerInput(input: HostInstance): void;
17
+ unregisterInput(input: HostInstance): void;
18
+ focusInput(input: HostInstance | null): void;
19
+ blurInput(input: HostInstance | null): void;
20
+ blurTextInput(input: HostInstance | null): void;
21
+ currentlyFocusedInput(): HostInstance | null;
22
+ }
23
+
24
+ /**
25
+ * The internal module's export shape has changed across RN versions: newer
26
+ * versions use `export default` (surfacing as `.default` after Metro's CJS
27
+ * transform) while older ones assigned `module.exports` directly. A raw
28
+ * require bypasses Babel's import interop, so both shapes are handled here.
29
+ */
30
+ const TextInputStateModuleImpl =
31
+ // eslint-disable-next-line @react-native/no-deep-imports
32
+ require('react-native/Libraries/Components/TextInput/TextInputState');
33
+
34
+ export const TextInputState = (TextInputStateModuleImpl.default ??
35
+ TextInputStateModuleImpl) as TextInputStateModule;