react-native-enriched-markdown-scaffold 1.0.2-scaffold.9 → 1.2.0-scaffold.2

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 (346) hide show
  1. package/ReactNativeEnrichedMarkdown.podspec +31 -10
  2. package/android/build.gradle +49 -12
  3. package/android/consumer-rules.pro +3 -0
  4. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +18 -0
  5. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +6 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +3 -0
  7. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +1 -0
  8. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +18 -0
  9. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +6 -0
  10. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
  11. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
  12. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +67 -2
  13. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +929 -178
  14. package/android/src/main/baseline-prof.txt +21 -22
  15. package/android/src/main/cpp/jni-adapter.cpp +17 -5
  16. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +729 -768
  17. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +1 -1
  18. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +72 -3
  19. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +222 -8
  20. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +65 -1
  21. package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +191 -26
  22. package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt +10 -0
  23. package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +54 -6
  24. package/android/src/main/java/com/swmansion/enriched/markdown/events/CodeBlockPressEvent.kt +24 -0
  25. package/android/src/main/java/com/swmansion/enriched/markdown/events/ImagePressEvent.kt +25 -0
  26. package/android/src/main/java/com/swmansion/enriched/markdown/events/LatexErrorEvent.kt +29 -0
  27. package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +21 -0
  28. package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +101 -9
  29. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +48 -0
  30. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +7 -0
  31. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownShortcutMatcher.kt +64 -0
  32. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +44 -6
  33. package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +9 -8
  34. package/android/src/main/java/com/swmansion/enriched/markdown/math/LatexErrorReporter.kt +9 -0
  35. package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +6 -0
  36. package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +5 -1
  37. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlankLineRenderer.kt +38 -0
  38. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +2 -2
  39. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +3 -2
  40. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteTextRenderer.kt +55 -0
  41. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +8 -1
  42. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HighlightRenderer.kt +10 -1
  43. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +31 -3
  44. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +17 -2
  45. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +40 -21
  46. package/android/src/main/java/com/swmansion/enriched/markdown/segments/AdmonitionIcons.kt +62 -0
  47. package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/BlockSegmentView.kt +1 -1
  48. package/android/src/main/java/com/swmansion/enriched/markdown/segments/BlockquoteContainerView.kt +401 -0
  49. package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/CodeBlockContainerView.kt +55 -16
  50. package/android/src/main/java/com/swmansion/enriched/markdown/segments/ContainerNodeView.kt +164 -0
  51. package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/MarkdownSegment.kt +21 -1
  52. package/android/src/main/java/com/swmansion/enriched/markdown/segments/RenderedSegment.kt +137 -0
  53. package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentHeightMeasurer.kt +139 -0
  54. package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentReconciler.kt +1 -1
  55. package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentSignature.kt +3 -1
  56. package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewCreators.kt +262 -0
  57. package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewFactory.kt +29 -0
  58. package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/TableContainerView.kt +100 -36
  59. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +18 -17
  60. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +3 -0
  61. package/android/src/main/java/com/swmansion/enriched/markdown/spans/HighlightSpan.kt +60 -6
  62. package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +15 -5
  63. package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineBackgroundGeometry.kt +42 -0
  64. package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +4 -27
  65. package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +10 -0
  66. package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -1
  67. package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawUtils.kt +11 -0
  68. package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +27 -0
  69. package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +2 -0
  70. package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +10 -0
  71. package/android/src/main/java/com/swmansion/enriched/markdown/styles/VideoStyle.kt +31 -0
  72. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/BorderStyleUtils.kt +86 -0
  73. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EllipsizeUtils.kt +27 -0
  74. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EnrichedMarkdownAncestorUtils.kt +10 -0
  75. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
  76. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +36 -0
  77. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +5 -0
  78. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +227 -0
  79. package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +34 -2
  80. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +50 -28
  81. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +16 -21
  82. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +4 -3
  83. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +3 -2
  84. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/SpanFlags.kt +13 -0
  85. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/CodeBlockPressHost.kt +15 -0
  86. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/ImagePressHost.kt +19 -0
  87. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +11 -0
  88. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +87 -2
  89. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextViewSetup.kt +79 -0
  90. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +2 -0
  91. package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +9 -3
  92. package/android/src/math/java/com/swmansion/enriched/markdown/{views → segments}/MathContainerView.kt +86 -29
  93. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +33 -7
  94. package/android/src/video/java/com/swmansion/enriched/markdown/segments/VideoContainerView.kt +115 -0
  95. package/cpp/md4c/md4c.c +343 -236
  96. package/cpp/md4c/md4c.h +28 -11
  97. package/cpp/parser/MD4CParser.cpp +266 -4
  98. package/cpp/parser/MD4CParser.hpp +6 -2
  99. package/cpp/parser/MarkdownASTNode.hpp +4 -1
  100. package/cpp/wasm/ASTSerializer.cpp +6 -0
  101. package/cpp/wasm/md4c_wasm.cpp +5 -1
  102. package/docs/API_REFERENCE.md +199 -12
  103. package/docs/BREAKING_CHANGES.md +75 -0
  104. package/docs/CODE_HIGHLIGHT.md +4 -0
  105. package/docs/COPY_OPTIONS.md +52 -9
  106. package/docs/ELEMENTS_STRUCTURE.md +48 -1
  107. package/docs/INPUT.md +60 -3
  108. package/docs/LATEX_MATH.md +30 -0
  109. package/docs/MACOS.md +1 -1
  110. package/docs/MENTIONS.md +2 -2
  111. package/docs/STYLES.md +27 -0
  112. package/docs/TEXT.md +8 -0
  113. package/docs/WEB.md +44 -10
  114. package/ios/EnrichedMarkdown.mm +285 -43
  115. package/ios/EnrichedMarkdownText.mm +185 -23
  116. package/ios/attachments/ENRMImageAttachment.h +17 -2
  117. package/ios/attachments/ENRMImageAttachment.m +26 -28
  118. package/ios/attachments/ENRMMathInlineAttachment+macOS.m +10 -2
  119. package/ios/attachments/ENRMMathInlineAttachment.h +3 -1
  120. package/ios/attachments/ENRMMathInlineAttachment.m +17 -1
  121. package/ios/attachments/ENRMMathInlineAttachmentShared.h +3 -0
  122. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
  123. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
  124. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +67 -2
  125. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +929 -178
  126. package/ios/input/ENRMInputFormatter.mm +68 -12
  127. package/ios/input/ENRMInputFormatterStyle.mm +9 -2
  128. package/ios/input/ENRMInputParser.mm +18 -0
  129. package/ios/input/ENRMInputRemend.mm +40 -3
  130. package/ios/input/ENRMMarkdownShortcutMatcher.h +39 -0
  131. package/ios/input/ENRMMarkdownShortcutMatcher.mm +66 -0
  132. package/ios/input/EnrichedMarkdownTextInput.mm +129 -1
  133. package/ios/internals/ENRMViewFreeMeasurement.h +45 -6
  134. package/ios/internals/MeasurementCache.h +20 -4
  135. package/ios/internals/ShadowMeasurementUtils.h +2 -0
  136. package/ios/math/ENRMLatexErrorCoordinator.h +27 -0
  137. package/ios/math/ENRMLatexErrorCoordinator.mm +75 -0
  138. package/ios/math/ENRMLatexErrorReporting.h +13 -0
  139. package/ios/math/ENRMRaTeXBridge.swift +46 -3
  140. package/ios/parser/ENRMMarkdownParser.h +3 -0
  141. package/ios/parser/ENRMMarkdownParser.mm +11 -2
  142. package/ios/parser/MarkdownASTNode.h +8 -1
  143. package/ios/parser/MarkdownASTNode.m +20 -0
  144. package/ios/parser/MarkdownParserBridge.mm +13 -2
  145. package/ios/renderer/AttributedRenderer.h +13 -1
  146. package/ios/renderer/AttributedRenderer.m +24 -13
  147. package/ios/renderer/BaselineShiftTextAttributes.h +4 -0
  148. package/ios/renderer/BaselineShiftTextAttributes.m +4 -0
  149. package/ios/renderer/BlankLineRenderer.h +4 -0
  150. package/ios/renderer/BlankLineRenderer.m +51 -0
  151. package/ios/renderer/BlockquoteRenderer.m +1 -0
  152. package/ios/renderer/CodeBlockRenderer.m +8 -0
  153. package/ios/renderer/CodeRenderer.m +5 -2
  154. package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -0
  155. package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -0
  156. package/ios/renderer/ENRMImageRenderer.m +1 -1
  157. package/ios/renderer/ENRMMathInlineRenderer.m +9 -1
  158. package/ios/renderer/HeadingRenderer.m +1 -0
  159. package/ios/renderer/HighlightRenderer.m +6 -0
  160. package/ios/renderer/LinkRenderer.m +1 -1
  161. package/ios/renderer/ListItemRenderer.m +51 -2
  162. package/ios/renderer/ParagraphRenderer.m +10 -3
  163. package/ios/renderer/RenderContext.h +16 -0
  164. package/ios/renderer/RenderContext.m +16 -0
  165. package/ios/renderer/RendererFactory.m +6 -0
  166. package/ios/renderer/SubscriptRenderer.m +1 -0
  167. package/ios/renderer/SuperscriptRenderer.m +1 -0
  168. package/ios/segments/ENRMAdmonitionIcons.h +31 -0
  169. package/ios/segments/ENRMAdmonitionIcons.m +93 -0
  170. package/ios/segments/ENRMBlockquoteContainerView.h +90 -0
  171. package/ios/segments/ENRMBlockquoteContainerView.mm +551 -0
  172. package/ios/{views → segments}/ENRMCodeBlockContainerView.h +9 -4
  173. package/ios/{views → segments}/ENRMCodeBlockContainerView.m +147 -36
  174. package/ios/segments/ENRMContainerNodeView.h +52 -0
  175. package/ios/segments/ENRMContainerNodeView.mm +201 -0
  176. package/ios/segments/ENRMDynamicBlockProps.h +32 -0
  177. package/ios/segments/ENRMDynamicBlockProps.m +15 -0
  178. package/ios/{views → segments}/ENRMMathContainerView.h +13 -5
  179. package/ios/{views → segments}/ENRMMathContainerView.m +60 -9
  180. package/ios/segments/ENRMSVGPath.h +21 -0
  181. package/ios/segments/ENRMSVGPath.m +409 -0
  182. package/ios/segments/ENRMSegmentHeightMeasurer.h +33 -0
  183. package/ios/segments/ENRMSegmentHeightMeasurer.mm +94 -0
  184. package/ios/segments/ENRMVideoContainerView.h +40 -0
  185. package/ios/segments/ENRMVideoContainerView.m +421 -0
  186. package/ios/{utils → segments}/RenderedMarkdownSegment.h +19 -2
  187. package/ios/{utils → segments}/RenderedMarkdownSegment.m +42 -1
  188. package/ios/segments/SegmentRenderer.h +26 -0
  189. package/ios/{utils → segments}/SegmentRenderer.m +46 -9
  190. package/ios/{views → segments}/TableContainerView.h +5 -4
  191. package/ios/{views → segments}/TableContainerView.m +96 -12
  192. package/ios/styles/StyleConfig.h +17 -0
  193. package/ios/styles/StyleConfig.mm +90 -0
  194. package/ios/utils/ENRMCodeBlockContent.mm +13 -0
  195. package/ios/utils/ENRMFeatureFlags.h +6 -0
  196. package/ios/utils/ENRMTextRenderer.h +8 -0
  197. package/ios/utils/ENRMTextRenderer.m +26 -10
  198. package/ios/utils/ENRMUIKit.h +1 -0
  199. package/ios/utils/FontUtils.h +2 -1
  200. package/ios/utils/FontUtils.m +22 -6
  201. package/ios/utils/LinkTapUtils.h +17 -2
  202. package/ios/utils/LinkTapUtils.m +44 -2
  203. package/ios/utils/ListMarkerDrawer.m +25 -1
  204. package/ios/utils/MarkdownASTSerializer.h +7 -0
  205. package/ios/utils/MarkdownASTSerializer.m +243 -0
  206. package/ios/utils/MarkdownAccessibilityElementBuilder.m +9 -67
  207. package/ios/utils/MarkdownExtractor.m +6 -3
  208. package/ios/utils/ParagraphStyleUtils.h +25 -1
  209. package/ios/utils/ParagraphStyleUtils.m +51 -7
  210. package/ios/utils/StylePropsUtils.h +60 -1
  211. package/ios/utils/TextViewLayoutManager.mm +57 -0
  212. package/lib/module/EnrichedMarkdownNativeComponent.ts +110 -4
  213. package/lib/module/EnrichedMarkdownTextInput.js +60 -2
  214. package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
  215. package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
  216. package/lib/module/EnrichedMarkdownTextNativeComponent.ts +115 -4
  217. package/lib/module/admonitionDefaults.js +34 -0
  218. package/lib/module/admonitionDefaults.js.map +1 -0
  219. package/lib/module/index.js.map +1 -1
  220. package/lib/module/jest/index.js +84 -4
  221. package/lib/module/jest/index.js.map +1 -1
  222. package/lib/module/native/EnrichedMarkdownText.js +58 -5
  223. package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
  224. package/lib/module/normalizeMarkdownShortcuts.js +31 -0
  225. package/lib/module/normalizeMarkdownShortcuts.js.map +1 -0
  226. package/lib/module/normalizeMarkdownStyle.js +15 -1
  227. package/lib/module/normalizeMarkdownStyle.js.map +1 -1
  228. package/lib/module/normalizeMarkdownStyle.web.js +15 -1
  229. package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
  230. package/lib/module/styleUtils.js +15 -3
  231. package/lib/module/styleUtils.js.map +1 -1
  232. package/lib/module/utils/textInputState.js +4 -3
  233. package/lib/module/utils/textInputState.js.map +1 -1
  234. package/lib/module/utils/usePressability.js +28 -0
  235. package/lib/module/utils/usePressability.js.map +1 -0
  236. package/lib/module/web/EnrichedMarkdownText.js +19 -6
  237. package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
  238. package/lib/module/web/globalStyles.js +7 -1
  239. package/lib/module/web/globalStyles.js.map +1 -1
  240. package/lib/module/web/nativeProps.js +70 -0
  241. package/lib/module/web/nativeProps.js.map +1 -0
  242. package/lib/module/web/parseMarkdown.js +5 -3
  243. package/lib/module/web/parseMarkdown.js.map +1 -1
  244. package/lib/module/web/renderers/BlockRenderers.js +164 -8
  245. package/lib/module/web/renderers/BlockRenderers.js.map +1 -1
  246. package/lib/module/web/renderers/admonitionIcons.js +34 -0
  247. package/lib/module/web/renderers/admonitionIcons.js.map +1 -0
  248. package/lib/module/web/styles.js +30 -8
  249. package/lib/module/web/styles.js.map +1 -1
  250. package/lib/module/web/wasm/md4c.js +0 -0
  251. package/lib/module/web/wasm/md4c.js.map +1 -1
  252. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +103 -3
  253. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
  254. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +27 -3
  255. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
  256. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +11 -0
  257. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
  258. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +108 -3
  259. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
  260. package/lib/typescript/src/admonitionDefaults.d.ts +10 -0
  261. package/lib/typescript/src/admonitionDefaults.d.ts.map +1 -0
  262. package/lib/typescript/src/index.d.ts +3 -2
  263. package/lib/typescript/src/index.d.ts.map +1 -1
  264. package/lib/typescript/src/index.web.d.ts +1 -1
  265. package/lib/typescript/src/index.web.d.ts.map +1 -1
  266. package/lib/typescript/src/jest/index.d.ts +2 -2
  267. package/lib/typescript/src/jest/index.d.ts.map +1 -1
  268. package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
  269. package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
  270. package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts +7 -0
  271. package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts.map +1 -0
  272. package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
  273. package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
  274. package/lib/typescript/src/styleUtils.d.ts.map +1 -1
  275. package/lib/typescript/src/types/MarkdownStyle.d.ts +59 -1
  276. package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
  277. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +21 -0
  278. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
  279. package/lib/typescript/src/types/MarkdownTextProps.d.ts +93 -8
  280. package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
  281. package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +25 -1
  282. package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
  283. package/lib/typescript/src/types/events.d.ts +33 -5
  284. package/lib/typescript/src/types/events.d.ts.map +1 -1
  285. package/lib/typescript/src/utils/textInputState.d.ts +5 -3
  286. package/lib/typescript/src/utils/textInputState.d.ts.map +1 -1
  287. package/lib/typescript/src/utils/usePressability.d.ts +24 -0
  288. package/lib/typescript/src/utils/usePressability.d.ts.map +1 -0
  289. package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
  290. package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
  291. package/lib/typescript/src/web/globalStyles.d.ts +1 -0
  292. package/lib/typescript/src/web/globalStyles.d.ts.map +1 -1
  293. package/lib/typescript/src/web/nativeProps.d.ts +34 -0
  294. package/lib/typescript/src/web/nativeProps.d.ts.map +1 -0
  295. package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
  296. package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
  297. package/lib/typescript/src/web/renderers/BlockRenderers.d.ts.map +1 -1
  298. package/lib/typescript/src/web/renderers/admonitionIcons.d.ts +5 -0
  299. package/lib/typescript/src/web/renderers/admonitionIcons.d.ts.map +1 -0
  300. package/lib/typescript/src/web/styles.d.ts +1 -0
  301. package/lib/typescript/src/web/styles.d.ts.map +1 -1
  302. package/lib/typescript/src/web/types.d.ts +8 -2
  303. package/lib/typescript/src/web/types.d.ts.map +1 -1
  304. package/package.json +1 -1
  305. package/postinstall.mjs +7 -0
  306. package/src/EnrichedMarkdownNativeComponent.ts +110 -4
  307. package/src/EnrichedMarkdownTextInput.tsx +101 -4
  308. package/src/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
  309. package/src/EnrichedMarkdownTextNativeComponent.ts +115 -4
  310. package/src/admonitionDefaults.ts +58 -0
  311. package/src/index.tsx +5 -0
  312. package/src/index.web.tsx +3 -0
  313. package/src/jest/index.tsx +138 -5
  314. package/src/native/EnrichedMarkdownText.tsx +55 -3
  315. package/src/normalizeMarkdownShortcuts.ts +38 -0
  316. package/src/normalizeMarkdownStyle.ts +17 -0
  317. package/src/normalizeMarkdownStyle.web.ts +17 -0
  318. package/src/styleUtils.ts +17 -6
  319. package/src/types/MarkdownStyle.ts +62 -1
  320. package/src/types/MarkdownStyleInternal.ts +24 -0
  321. package/src/types/MarkdownTextProps.ts +95 -7
  322. package/src/types/MarkdownTextProps.web.ts +26 -0
  323. package/src/types/events.ts +36 -5
  324. package/src/utils/textInputState.ts +5 -3
  325. package/src/utils/usePressability.ts +34 -0
  326. package/src/web/EnrichedMarkdownText.tsx +36 -3
  327. package/src/web/globalStyles.ts +10 -0
  328. package/src/web/nativeProps.ts +78 -0
  329. package/src/web/parseMarkdown.ts +10 -2
  330. package/src/web/renderers/BlockRenderers.tsx +175 -6
  331. package/src/web/renderers/admonitionIcons.ts +37 -0
  332. package/src/web/styles.ts +28 -3
  333. package/src/web/types.ts +12 -1
  334. package/src/web/wasm/md4c.js +0 -0
  335. package/vendor-ratex.mjs +86 -17
  336. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +0 -16
  337. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +0 -88
  338. package/ios/utils/SegmentRenderer.h +0 -24
  339. /package/ios/{views → segments}/ENRMTableGridView.h +0 -0
  340. /package/ios/{views → segments}/ENRMTableGridView.m +0 -0
  341. /package/ios/{views → segments}/ENRMTableIOSGridView.h +0 -0
  342. /package/ios/{views → segments}/ENRMTableIOSGridView.m +0 -0
  343. /package/ios/{utils → segments}/SegmentReconciler.h +0 -0
  344. /package/ios/{utils → segments}/SegmentReconciler.m +0 -0
  345. /package/ios/{utils → segments}/SegmentViewRegistry.h +0 -0
  346. /package/ios/{utils → segments}/SegmentViewRegistry.m +0 -0
@@ -20,6 +20,36 @@ interface HeadingStyle extends BaseBlockStyle {
20
20
  textAlign?: TextAlign;
21
21
  }
22
22
 
23
+ /**
24
+ * Per-type color overrides for a GitHub admonition/alert.
25
+ */
26
+ export interface AdmonitionColors {
27
+ /**
28
+ * Tints the left accent bar, the title label and the icon for this type.
29
+ * Defaults to the GitHub palette (note=blue, tip=green, important=purple,
30
+ * warning=amber, caution=red).
31
+ */
32
+ color?: string;
33
+ /**
34
+ * Fills the callout background. Omitted or empty means transparent (no fill).
35
+ */
36
+ backgroundColor?: string;
37
+ }
38
+
39
+ /**
40
+ * Color theming for GitHub admonitions/alerts, keyed by type. Nested under
41
+ * `blockquote` because admonitions inherit the blockquote geometry (borderWidth,
42
+ * gapWidth, padding, borderRadius, font, spacing) and only override colors.
43
+ * Requires `flavor="github"` and `md4cFlags.admonitions` enabled (both default on).
44
+ */
45
+ export interface AdmonitionsStyle {
46
+ note?: AdmonitionColors;
47
+ tip?: AdmonitionColors;
48
+ important?: AdmonitionColors;
49
+ warning?: AdmonitionColors;
50
+ caution?: AdmonitionColors;
51
+ }
52
+
23
53
  interface BlockquoteStyle extends BaseBlockStyle {
24
54
  borderColor?: string;
25
55
  borderWidth?: number;
@@ -27,6 +57,7 @@ interface BlockquoteStyle extends BaseBlockStyle {
27
57
  backgroundColor?: string;
28
58
  borderRadius?: number;
29
59
  padding?: number;
60
+ admonitions?: AdmonitionsStyle;
30
61
  }
31
62
 
32
63
  interface ListStyle extends BaseBlockStyle {
@@ -115,6 +146,8 @@ export interface LinkStyle extends LinkChipStyle {
115
146
  }
116
147
 
117
148
  export interface LinkVariantStyle extends LinkChipStyle {
149
+ /** Overrides the base `link` font family for this variant; inherits when omitted. */
150
+ fontFamily?: string;
118
151
  color?: string;
119
152
  underline?: boolean;
120
153
  }
@@ -192,6 +225,14 @@ interface ImageStyle {
192
225
  marginBottom?: number;
193
226
  }
194
227
 
228
+ interface VideoStyle {
229
+ marginTop?: number;
230
+ marginBottom?: number;
231
+ borderRadius?: number;
232
+ aspectRatio?: number;
233
+ backgroundColor?: string;
234
+ }
235
+
195
236
  interface InlineImageStyle {
196
237
  size?: number;
197
238
  }
@@ -397,7 +438,7 @@ export interface MarkdownStyle {
397
438
  * Chip properties (`backgroundColor`, `borderRadius`, `paddingHorizontal`,
398
439
  * `paddingVertical`, `borderColor`, `borderWidth`) do not inherit: when
399
440
  * omitted they default to `0` / `transparent`.
400
- * `fontFamily` always follows the base `link` style and cannot be overridden per-variant.
441
+ * `fontFamily` inherits the base `link` family and can be overridden per variant.
401
442
  *
402
443
  * @example
403
444
  * linkVariants: {
@@ -415,6 +456,7 @@ export interface MarkdownStyle {
415
456
  underline?: UnderlineStyle;
416
457
  code?: CodeStyle;
417
458
  image?: ImageStyle;
459
+ video?: VideoStyle;
418
460
  inlineImage?: InlineImageStyle;
419
461
  thematicBreak?: ThematicBreakStyle;
420
462
  table?: TableStyle;
@@ -475,4 +517,23 @@ export interface Md4cFlags {
475
517
  * @default false
476
518
  */
477
519
  hardSoftBreaks?: boolean;
520
+ /**
521
+ * Preserve runs of consecutive blank lines from the source instead of
522
+ * collapsing them into a single paragraph break. Each blank line renders as
523
+ * one empty line, so the output keeps the exact line count that was typed.
524
+ * Extra block spacing still comes from the paragraph style - set the paragraph
525
+ * margins to 0 in markdownStyle for spacing driven purely by blank lines.
526
+ * @default false
527
+ */
528
+ preserveBlankLines?: boolean;
529
+ /**
530
+ * Enable GitHub-style admonitions/alerts (`> [!NOTE]`, `> [!TIP]`,
531
+ * `> [!IMPORTANT]`, `> [!WARNING]`, `> [!CAUTION]`).
532
+ * When enabled, such blockquotes render as themed callouts with an icon +
533
+ * title header (see `markdownStyle.blockquote.admonitions`).
534
+ * Only takes effect with `flavor="github"`; forced off for `flavor="commonmark"`,
535
+ * where the syntax renders as a plain blockquote.
536
+ * @default true
537
+ */
538
+ admonitions?: boolean;
478
539
  }
@@ -37,6 +37,19 @@ interface HeadingStyleInternal extends BaseBlockStyleInternal {
37
37
  textAlign: BlockTextAlign;
38
38
  }
39
39
 
40
+ export interface AdmonitionColorsInternal {
41
+ color: string;
42
+ backgroundColor: string;
43
+ }
44
+
45
+ export interface AdmonitionsStyleInternal {
46
+ note: AdmonitionColorsInternal;
47
+ tip: AdmonitionColorsInternal;
48
+ important: AdmonitionColorsInternal;
49
+ warning: AdmonitionColorsInternal;
50
+ caution: AdmonitionColorsInternal;
51
+ }
52
+
40
53
  interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
41
54
  borderColor: string;
42
55
  borderWidth: number;
@@ -44,6 +57,7 @@ interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
44
57
  backgroundColor: string;
45
58
  borderRadius: number;
46
59
  padding: number;
60
+ admonitions: AdmonitionsStyleInternal;
47
61
  }
48
62
 
49
63
  interface ListStyleInternal extends BaseBlockStyleInternal {
@@ -105,6 +119,7 @@ export interface LinkVariantEntryInternal {
105
119
  paddingVertical: number;
106
120
  borderColor: string;
107
121
  borderWidth: number;
122
+ fontFamily: string;
108
123
  }
109
124
 
110
125
  interface StrongStyleInternal {
@@ -145,6 +160,14 @@ interface ImageStyleInternal {
145
160
  marginBottom: number;
146
161
  }
147
162
 
163
+ interface VideoStyleInternal {
164
+ marginTop: number;
165
+ marginBottom: number;
166
+ borderRadius: number;
167
+ aspectRatio: number;
168
+ backgroundColor: string;
169
+ }
170
+
148
171
  interface InlineImageStyleInternal {
149
172
  size: number;
150
173
  }
@@ -249,6 +272,7 @@ export interface MarkdownStyleInternal {
249
272
  underline: UnderlineStyleInternal;
250
273
  code: CodeStyleInternal;
251
274
  image: ImageStyleInternal;
275
+ video: VideoStyleInternal;
252
276
  inlineImage: InlineImageStyleInternal;
253
277
  thematicBreak: ThematicBreakStyleInternal;
254
278
  table: TableStyleInternal;
@@ -11,10 +11,13 @@ import type { AccessibilityLabels } from './AccessibilityLabels';
11
11
  import type {
12
12
  LinkPressEvent,
13
13
  LinkLongPressEvent,
14
+ ImagePressEvent,
14
15
  TaskListItemPressEvent,
15
16
  CopyPressEvent,
16
17
  CopyEvent,
17
18
  SelectionChangeEvent,
19
+ LatexErrorEvent,
20
+ CodeBlockPressEvent,
18
21
  } from './events';
19
22
 
20
23
  /** Imperative handle of `EnrichedMarkdownText`, reached through its `ref`. */
@@ -246,6 +249,22 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
246
249
  * @platform ios, android, web
247
250
  */
248
251
  renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
252
+ /**
253
+ * Callback fired when a rendered image is tapped or clicked.
254
+ *
255
+ * Receives the image URL and its alt text (empty string when the image has
256
+ * no alt text). Fires for block and inline images, including images inside
257
+ * headings, lists, and blockquotes.
258
+ *
259
+ * Images that are also links keep link behavior: they fire `onLinkPress`
260
+ * instead, so a single tap never fires both. Setting this prop makes images
261
+ * interactive on the native side; leaving it unset keeps the current tap,
262
+ * text-selection, and long-press menu behavior unchanged.
263
+ *
264
+ * Not fired for images inside GFM tables yet.
265
+ * @platform ios, android, macos, web
266
+ */
267
+ onImagePress?: (event: ImagePressEvent) => void;
249
268
  /**
250
269
  * Callback fired when a task list checkbox is tapped.
251
270
  *
@@ -284,9 +303,9 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
284
303
  onCopyPress?: (event: CopyPressEvent) => void;
285
304
  /**
286
305
  * 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
306
+ * math / code / blockquote (incl. admonition) block menus. When set, native
307
+ * does **not** write the clipboard: it calls this with the copied content and
308
+ * the handler writes whatever it wants (e.g. with `expo-clipboard`). Overrides
290
309
  * `selectionMenuConfig.copy.format`; `copy.enabled: false` still hides the
291
310
  * item. "Copy as Markdown", the code block header button and the VoiceOver
292
311
  * copy action are unaffected, and `onCopyPress` does not fire for an
@@ -298,9 +317,9 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
298
317
  * Reports the text selection so the app can draw its own menu (pair it with
299
318
  * `contextMenuHidden`). Fires at most once per frame while the selection
300
319
  * 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
320
+ * `contextMenuHidden`, a long press on a table / math / code / blockquote
321
+ * block fires it too (`source` is the block kind, `whole: true`), since those
322
+ * blocks have no text selection of their own. Only one part of a component holds a
304
323
  * selection at a time; clearing the selection of *other* components is up to
305
324
  * the app (`ref.current.clearSelection()`).
306
325
  *
@@ -312,6 +331,42 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
312
331
  * @platform ios, android
313
332
  */
314
333
  onSelectionChange?: (event: SelectionChangeEvent) => void;
334
+ /**
335
+ * Callback fired when a math expression cannot be parsed or rendered by the
336
+ * LaTeX engine.
337
+ *
338
+ * Receives the raw LaTeX `source` of the failing expression (no `$`/`$$`
339
+ * delimiters), the engine's error `message` (omitted when the engine gives
340
+ * none), and `displayMode` (`false` for inline `$...$`, `true` for block
341
+ * `$$...$$`). The whole expression is the unit of failure - the engine does
342
+ * not report a single offending command, so there is no `command` field.
343
+ *
344
+ * De-duplicated per component instance (keyed by `displayMode` + `source`):
345
+ * fires at most once per distinct failing expression, and the cache is kept
346
+ * across `markdown` changes so streaming does not re-report the same failure.
347
+ * A remount (new instance) reports again, so de-duplicate on your side if you
348
+ * aggregate app-wide. Requires `md4cFlags.latexMath` (on by default).
349
+ * @platform ios, android
350
+ */
351
+ onLatexError?: (event: LatexErrorEvent) => void;
352
+ /**
353
+ * Callback fired when a fenced code block is tapped/clicked anywhere in its
354
+ * body. Receives the block's `code` and `language`. Setting it arms the block
355
+ * for taps; text selection, the header copy button, and the long-press menu
356
+ * stay unchanged. Works in both flavors and on web.
357
+ * @platform ios, android, web
358
+ */
359
+ onCodeBlockPress?: (event: CodeBlockPressEvent) => void;
360
+ /**
361
+ * Controls the long-press context menu on block views (code blocks, tables,
362
+ * block math, and blockquotes/admonitions). When false, long-pressing a block
363
+ * does not open the copy popup. `contextMenuHidden` takes precedence: when it
364
+ * is true no block menu is shown regardless of this flag. Does not affect the code-block header copy button, the
365
+ * VoiceOver/TalkBack copy action, or the system text-selection menu.
366
+ * @default true
367
+ * @platform ios, android, macos
368
+ */
369
+ enableBlockContextMenu?: boolean;
315
370
  /**
316
371
  * Controls whether the system link preview is shown on long press (iOS only).
317
372
  *
@@ -447,7 +502,8 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
447
502
  * This hides the whole menu, including the custom items from
448
503
  * `contextMenuItems` and the built-in items from `selectionMenuConfig`,
449
504
  * since they all share one menu. It also covers the copy menus on table,
450
- * math and code blocks.
505
+ * math, code and blockquote/admonition blocks, and takes precedence over
506
+ * `enableBlockContextMenu`.
451
507
  *
452
508
  * It does not suppress the system "Save to Camera Roll / Copy" sheet that
453
509
  * UIKit shows when long-pressing an image.
@@ -520,4 +576,36 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
520
576
  * @platform ios
521
577
  */
522
578
  writingDirection?: 'auto' | 'ltr' | 'rtl' | 'first-strong';
579
+ /**
580
+ * Maximum number of lines to display before the text is truncated. `0` (the
581
+ * default) means unlimited. Matches React Native `Text`'s `numberOfLines`.
582
+ *
583
+ * Only supported for CommonMark (the default flavor). When `flavor` is
584
+ * `'github'` the content is laid out as independent block segments and this
585
+ * prop is ignored - see the GFM tracking issue.
586
+ *
587
+ * Android: while clamped (`numberOfLines > 0`) the view is not selectable and
588
+ * its links are not tappable, regardless of `selectable`. Android only draws
589
+ * the truncation ellipsis through `StaticLayout`; enabling selection or a link
590
+ * movement method promotes the text to a `Spannable`, forcing `DynamicLayout`,
591
+ * which has no `maxLines` support and drops the clamp/ellipsis. Both are
592
+ * restored once the clamp is removed. iOS keeps selection and links.
593
+ * @default 0
594
+ */
595
+ numberOfLines?: number;
596
+ /**
597
+ * Where to place the ellipsis when text is truncated by `numberOfLines`.
598
+ * `'clip'` truncates with no ellipsis glyph. Only takes effect when
599
+ * `numberOfLines` is set. Matches React Native `Text`'s `ellipsizeMode`.
600
+ *
601
+ * `'head'` and `'middle'` are single-line truncation modes: they only place
602
+ * the ellipsis as described when `numberOfLines` is `1`. With
603
+ * `numberOfLines > 1` Android falls back to tail-style truncation (only
604
+ * `TruncateAt.END` works past one line) and iOS is likewise unreliable, so
605
+ * use `'tail'` or `'clip'` for multi-line clamps. Same limitation as RN `Text`.
606
+ *
607
+ * Ignored when `flavor` is `'github'` (see `numberOfLines`).
608
+ * @default 'tail'
609
+ */
610
+ ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
523
611
  }
@@ -3,7 +3,9 @@ import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
3
3
  import type {
4
4
  LinkPressEvent,
5
5
  LinkLongPressEvent,
6
+ ImagePressEvent,
6
7
  TaskListItemPressEvent,
8
+ CodeBlockPressEvent,
7
9
  } from './events';
8
10
 
9
11
  /**
@@ -37,6 +39,11 @@ export interface EnrichedMarkdownTextProps extends Omit<
37
39
  HTMLAttributes<HTMLDivElement>,
38
40
  'style' | 'dir'
39
41
  > {
42
+ /**
43
+ * Test identifier applied to the root element as `data-testid`.
44
+ * @platform web
45
+ */
46
+ testID?: string;
40
47
  /**
41
48
  * Markdown content to render.
42
49
  * @platform ios, android, web
@@ -89,6 +96,18 @@ export interface EnrichedMarkdownTextProps extends Omit<
89
96
  * @platform ios, android, web
90
97
  */
91
98
  renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
99
+ /**
100
+ * Callback fired when a rendered image is clicked or activated with the
101
+ * keyboard (Enter/Space). Receives the image URL and its alt text (empty
102
+ * string when the image has no alt text).
103
+ *
104
+ * Images that are also links keep link behavior and fire `onLinkPress`
105
+ * instead, so a single activation never fires both. When set, images become
106
+ * focusable and expose a button role for screen readers; when unset, images
107
+ * stay non-interactive. The browser's right-click menu is preserved.
108
+ * @platform ios, android, macos, web
109
+ */
110
+ onImagePress?: (event: ImagePressEvent) => void;
92
111
  /**
93
112
  * Callback fired when a task list checkbox is tapped.
94
113
  *
@@ -100,6 +119,13 @@ export interface EnrichedMarkdownTextProps extends Omit<
100
119
  * @platform ios, android, web
101
120
  */
102
121
  onTaskListItemPress?: (event: TaskListItemPressEvent) => void;
122
+ /**
123
+ * Callback fired when a fenced code block is clicked. Receives the block's
124
+ * `code` and `language`. The block is focusable and keyboard-activatable
125
+ * (Enter/Space); clicking while text is selected does not fire.
126
+ * @platform ios, android, web
127
+ */
128
+ onCodeBlockPress?: (event: CodeBlockPressEvent) => void;
103
129
  /**
104
130
  * Controls whether tapping a task list checkbox toggles its checked state.
105
131
  *
@@ -6,6 +6,11 @@ export interface LinkLongPressEvent {
6
6
  url: string;
7
7
  }
8
8
 
9
+ export interface ImagePressEvent {
10
+ url: string;
11
+ altText: string;
12
+ }
13
+
9
14
  export interface TaskListItemPressEvent {
10
15
  index: number;
11
16
  checked: boolean;
@@ -17,18 +22,44 @@ export interface CopyPressEvent {
17
22
  language: string;
18
23
  }
19
24
 
25
+ export interface CodeBlockPressEvent {
26
+ code: string;
27
+ language: string;
28
+ }
29
+
30
+ /**
31
+ * Event payload fired when a math expression fails to parse or render.
32
+ *
33
+ * The whole expression is the unit of failure: the LaTeX engine either renders
34
+ * an expression in full or rejects it, so there is no single offending command
35
+ * to report. Consumers can classify `source` themselves (e.g. report it to an
36
+ * error tracker) without maintaining an allowlist that goes stale on engine
37
+ * upgrades.
38
+ */
39
+ export interface LatexErrorEvent {
40
+ /** Raw LaTeX of the failing expression, without `$`/`$$` delimiters. */
41
+ source: string;
42
+ /** Engine error message, when one is available. */
43
+ message?: string;
44
+ /** `false` for inline `$...$`, `true` for block `$$...$$`. */
45
+ displayMode: boolean;
46
+ }
47
+
20
48
  /**
21
49
  * Payload of `onCopy`: what the Copy item would have copied. With `onCopy`
22
50
  * set, native writes nothing to the clipboard — the handler owns the write.
23
51
  */
24
52
  export interface CopyEvent {
25
- /** Which menu the Copy item belongs to. */
26
- source: 'selection' | 'math' | 'table' | 'code';
53
+ /**
54
+ * Which menu the Copy item belongs to. `'blockquote'` covers the block menu
55
+ * of blockquotes and admonitions (`flavor="github"`).
56
+ */
57
+ source: 'selection' | 'math' | 'table' | 'code' | 'blockquote';
27
58
  /**
28
59
  * Markdown of the copied content — what `copy.format: 'markdown'` writes.
29
60
  * Text selections: the original source when `whole`, otherwise rebuilt from
30
61
  * the rendered styles (falls back to `text`). Blocks: `$$…$$`, the table as
31
- * Markdown, or the fenced code block.
62
+ * Markdown, the fenced code block, or the `> `-prefixed blockquote.
32
63
  */
33
64
  markdown: string;
34
65
  /** Rendered text of the selection, or the block's raw content. */
@@ -53,8 +84,8 @@ export interface SelectionRect {
53
84
 
54
85
  /**
55
86
  * 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.
87
+ * math / code / blockquote block long-pressed while `contextMenuHidden` is on.
88
+ * Content fields carry what `onCopy` would receive for the same selection.
58
89
  */
59
90
  export interface SelectionChangeEvent {
60
91
  /** `false` once the selection is gone; every other field is then empty / zero. */
@@ -3,9 +3,10 @@
3
3
  * registry so it participates in RN's keyboard-dismiss behavior (issue #577).
4
4
  *
5
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.
6
+ * focusTextInput and blurTextInput dispatch the built-in TextInput's "focus"
7
+ * and "blur" commands at the given instance, and Fabric command dispatch is
8
+ * name-based — it works as long as the component ships commands with those
9
+ * names, which ours does.
9
10
  *
10
11
  * A deep import is required because the public TextInput.State API lacks the
11
12
  * registerInput/focusInput/blurInput bookkeeping functions.
@@ -17,6 +18,7 @@ interface TextInputStateModule {
17
18
  unregisterInput(input: HostInstance): void;
18
19
  focusInput(input: HostInstance | null): void;
19
20
  blurInput(input: HostInstance | null): void;
21
+ focusTextInput(input: HostInstance | null): void;
20
22
  blurTextInput(input: HostInstance | null): void;
21
23
  currentlyFocusedInput(): HostInstance | null;
22
24
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Deep import of React Native's `usePressability`.
3
+ *
4
+ * The hook only became a root `react-native` export around 0.84. The peer
5
+ * dependency is `react-native: "*"`, so a named root import is `undefined`
6
+ * before that.
7
+ *
8
+ * `Libraries/Pressability/usePressability.js` exists on those versions, so
9
+ * we use that deep import instead.
10
+ *
11
+ * The export shape has changed across versions: newer ones use `export
12
+ * default` (surfacing as `.default` after Metro's CJS transform) while older
13
+ * ones assigned `module.exports` directly. A raw require bypasses Babel's
14
+ * import interop, so both shapes are handled here.
15
+ */
16
+ import type {
17
+ PressabilityConfig,
18
+ PressabilityEventHandlers,
19
+ } from 'react-native';
20
+
21
+ /**
22
+ * Copied from the type for usePressability in
23
+ * packages/react-native-enriched-markdown/node_modules/react-native/types_generated/Libraries/Pressability/usePressability.d.ts
24
+ */
25
+ type UsePressability = (
26
+ config: null | undefined | PressabilityConfig
27
+ ) => null | PressabilityEventHandlers;
28
+
29
+ const usePressabilityModule =
30
+ // eslint-disable-next-line @react-native/no-deep-imports
31
+ require('react-native/Libraries/Pressability/usePressability');
32
+
33
+ export const usePressability = (usePressabilityModule.default ??
34
+ usePressabilityModule) as UsePressability;
@@ -13,6 +13,7 @@ import { indexLinks, indexTaskItems, markInlineImages } from './utils';
13
13
  import { loadKaTeX } from './katex';
14
14
  import type { KaTeXInstance } from './katex';
15
15
  import { ENRM_TEXT_CLASS, ENRM_SELECTION_BG_VAR } from './globalStyles';
16
+ import { filterNativeOnlyProps } from './nativeProps';
16
17
 
17
18
  export const EnrichedMarkdownText = ({
18
19
  markdown,
@@ -20,7 +21,9 @@ export const EnrichedMarkdownText = ({
20
21
  md4cFlags = {},
21
22
  onLinkPress,
22
23
  onLinkLongPress,
24
+ onImagePress,
23
25
  onTaskListItemPress,
26
+ onCodeBlockPress,
24
27
  enableTaskListItemToggle = true,
25
28
  allowTrailingMargin = false,
26
29
  containerStyle,
@@ -28,6 +31,7 @@ export const EnrichedMarkdownText = ({
28
31
  dir,
29
32
  selectionColor,
30
33
  renderLinkDecoration,
34
+ testID,
31
35
  ...rest
32
36
  }: EnrichedMarkdownTextProps) => {
33
37
  const normalizedStyle = useMemo(
@@ -46,6 +50,8 @@ export const EnrichedMarkdownText = ({
46
50
  subscript = false,
47
51
  highlight = false,
48
52
  hardSoftBreaks = false,
53
+ preserveBlankLines = false,
54
+ admonitions = true,
49
55
  } = md4cFlags;
50
56
 
51
57
  useEffect(() => {
@@ -61,6 +67,8 @@ export const EnrichedMarkdownText = ({
61
67
  subscript,
62
68
  highlight,
63
69
  hardSoftBreaks,
70
+ preserveBlankLines,
71
+ admonitions,
64
72
  }),
65
73
  katexPromise,
66
74
  ])
@@ -98,16 +106,27 @@ export const EnrichedMarkdownText = ({
98
106
  subscript,
99
107
  highlight,
100
108
  hardSoftBreaks,
109
+ preserveBlankLines,
110
+ admonitions,
101
111
  ]);
102
112
 
103
113
  const callbacks = useMemo<RendererCallbacks>(
104
114
  () => ({
105
115
  onLinkPress,
106
116
  onLinkLongPress,
117
+ onImagePress,
107
118
  onTaskListItemPress,
119
+ onCodeBlockPress,
108
120
  renderLinkDecoration,
109
121
  }),
110
- [onLinkPress, onLinkLongPress, onTaskListItemPress, renderLinkDecoration]
122
+ [
123
+ onLinkPress,
124
+ onLinkLongPress,
125
+ onImagePress,
126
+ onTaskListItemPress,
127
+ onCodeBlockPress,
128
+ renderLinkDecoration,
129
+ ]
111
130
  );
112
131
 
113
132
  const capabilities = useMemo<RenderCapabilities>(
@@ -143,9 +162,17 @@ export const EnrichedMarkdownText = ({
143
162
  [containerStyle, selectable, selectionColor]
144
163
  );
145
164
 
165
+ const domProps = filterNativeOnlyProps(rest);
166
+
146
167
  if (parseError) {
147
168
  return (
148
- <div className={ENRM_TEXT_CLASS} style={wrapperStyle} dir={dir} {...rest}>
169
+ <div
170
+ className={ENRM_TEXT_CLASS}
171
+ style={wrapperStyle}
172
+ dir={dir}
173
+ data-testid={testID}
174
+ {...domProps}
175
+ >
149
176
  <pre style={parseErrorFallbackStyle}>{markdown}</pre>
150
177
  </div>
151
178
  );
@@ -157,7 +184,13 @@ export const EnrichedMarkdownText = ({
157
184
  const lastIdx = children.length - 1;
158
185
 
159
186
  return (
160
- <div className={ENRM_TEXT_CLASS} style={wrapperStyle} dir={dir} {...rest}>
187
+ <div
188
+ className={ENRM_TEXT_CLASS}
189
+ style={wrapperStyle}
190
+ dir={dir}
191
+ data-testid={testID}
192
+ {...domProps}
193
+ >
161
194
  {children.map((child, index) => (
162
195
  <RenderNode
163
196
  key={`${child.type}-${index}`}
@@ -1,6 +1,7 @@
1
1
  import { injectStyleOnce } from './injectStyle';
2
2
 
3
3
  export const ENRM_TEXT_CLASS = 'enrm-text';
4
+ export const ENRM_ADMONITION_CLASS = 'enrm-admonition';
4
5
  export const ENRM_SELECTION_BG_VAR = '--enrm-selection-bg';
5
6
 
6
7
  const RULES: ReadonlyArray<readonly [id: string, css: string]> = [
@@ -15,6 +16,15 @@ const RULES: ReadonlyArray<readonly [id: string, css: string]> = [
15
16
  // style included. We do not load `katex.css` (MathML output needs no CSS),
16
17
  // but a consumer may, so opt `.katex` back into inheriting.
17
18
  ['enrm-katex-font-weight', '.katex { font-weight: inherit; }'],
19
+ // Trim the trailing margin of a quote's last block so it doesn't add space
20
+ // above the box's bottom padding, mirroring native. !important overrides the
21
+ // per-element inline margin; the quote is a flex-item BFC so the margin can't
22
+ // collapse out on its own.
23
+ [
24
+ 'enrm-blockquote-trailing-margin',
25
+ `.${ENRM_TEXT_CLASS} blockquote > *:last-child, ` +
26
+ `.${ENRM_TEXT_CLASS} .${ENRM_ADMONITION_CLASS} > *:last-child { margin-bottom: 0 !important; }`,
27
+ ],
18
28
  ];
19
29
 
20
30
  for (const [id, css] of RULES) {