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
@@ -0,0 +1,58 @@
1
+ import { normalizeColor } from './styleUtils';
2
+ import type { AdmonitionsStyle } from './types/MarkdownStyle';
3
+
4
+ // The five GitHub-flavored admonition/alert types, in the order md4c reports
5
+ // them (see MD_ADMONITION_TAGS). The `admonitionType` attribute emitted by the
6
+ // parser is always one of these lowercase strings.
7
+ export const ADMONITION_TYPES = [
8
+ 'note',
9
+ 'tip',
10
+ 'important',
11
+ 'warning',
12
+ 'caution',
13
+ ] as const;
14
+
15
+ export type AdmonitionType = (typeof ADMONITION_TYPES)[number];
16
+
17
+ // GitHub alert palette. Each `color` tints the left accent bar, the title label
18
+ // and the icon for that type. Backgrounds default to transparent (no fill) per
19
+ // the issue; users opt into a tint via markdownStyle.blockquote.admonitions.
20
+ const ADMONITION_COLOR_DEFAULTS: Record<AdmonitionType, string> = {
21
+ note: '#0969DA',
22
+ tip: '#1A7F37',
23
+ important: '#8250DF',
24
+ warning: '#9A6700',
25
+ caution: '#CF222E',
26
+ };
27
+
28
+ export interface ResolvedAdmonitionColors {
29
+ color: string;
30
+ backgroundColor: string;
31
+ }
32
+
33
+ export type ResolvedAdmonitions = Record<
34
+ AdmonitionType,
35
+ ResolvedAdmonitionColors
36
+ >;
37
+
38
+ // Merge user overrides over the GitHub defaults and normalize every color, so
39
+ // native/web receive a complete, concrete per-type palette. Mirrors the
40
+ // linkVariants resolution: `color` falls back to the type default, and an empty
41
+ // or omitted `backgroundColor` resolves to transparent (drawn as no fill).
42
+ export function resolveAdmonitionColors(
43
+ user: AdmonitionsStyle | undefined
44
+ ): ResolvedAdmonitions {
45
+ const transparent = normalizeColor('transparent')! as string;
46
+ const result = {} as ResolvedAdmonitions;
47
+ for (const type of ADMONITION_TYPES) {
48
+ const override = user?.[type];
49
+ result[type] = {
50
+ color: ((override?.color ? normalizeColor(override.color) : undefined) ??
51
+ normalizeColor(ADMONITION_COLOR_DEFAULTS[type])!) as string,
52
+ backgroundColor: (override?.backgroundColor
53
+ ? (normalizeColor(override.backgroundColor) ?? transparent)
54
+ : transparent) as string,
55
+ };
56
+ }
57
+ return result;
58
+ }
package/src/index.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ export type { LinkVariantStyle } from './types/MarkdownStyle';
1
2
  export { default as EnrichedMarkdownText } from './native/EnrichedMarkdownText';
2
3
  export type {
3
4
  EnrichedMarkdownTextProps,
@@ -14,12 +15,15 @@ export type {
14
15
  export type {
15
16
  LinkPressEvent,
16
17
  LinkLongPressEvent,
18
+ ImagePressEvent,
17
19
  TaskListItemPressEvent,
18
20
  CopyPressEvent,
19
21
  CopyEvent,
20
22
  OnPasteEvent,
21
23
  SelectionChangeEvent,
22
24
  SelectionRect,
25
+ LatexErrorEvent,
26
+ CodeBlockPressEvent,
23
27
  } from './types/events';
24
28
  export type {
25
29
  AccessibilityLabels,
@@ -39,6 +43,7 @@ export type {
39
43
  ContextMenuItem,
40
44
  InputSelectionMenuConfig,
41
45
  FormatMenuConfig,
46
+ MarkdownShortcutsConfig,
42
47
  OnKeyPressEvent,
43
48
  OnLinkDetected,
44
49
  OnStartMentionEvent,
package/src/index.web.tsx CHANGED
@@ -8,6 +8,9 @@ export type { MarkdownStyle, Md4cFlags } from './types/MarkdownStyle';
8
8
  export type {
9
9
  LinkPressEvent,
10
10
  LinkLongPressEvent,
11
+ ImagePressEvent,
11
12
  TaskListItemPressEvent,
12
13
  CopyPressEvent,
14
+ LatexErrorEvent,
15
+ CodeBlockPressEvent,
13
16
  } from './types/events';
@@ -18,7 +18,7 @@
18
18
  * silently drift from the real component.
19
19
  */
20
20
  import { useImperativeHandle, useRef, useState } from 'react';
21
- import type { ComponentRef } from 'react';
21
+ import type { ComponentRef, ReactNode } from 'react';
22
22
  import { Text, TextInput } from 'react-native';
23
23
  import type {
24
24
  CaretRect,
@@ -30,6 +30,11 @@ import type {
30
30
  EnrichedMarkdownTextInstance,
31
31
  EnrichedMarkdownTextProps,
32
32
  } from '../native/EnrichedMarkdownText';
33
+ import type {
34
+ LinkPressEvent,
35
+ LinkLongPressEvent,
36
+ TaskListItemPressEvent,
37
+ } from '../types/events';
33
38
 
34
39
  export {
35
40
  DEFAULT_ACCESSIBILITY_LABELS,
@@ -81,6 +86,7 @@ export const EnrichedMarkdownTextInput = ({
81
86
  selectionMenuConfig: _selectionMenuConfig,
82
87
  formatMenuConfig: _formatMenuConfig,
83
88
  linkRegex: _linkRegex,
89
+ markdownShortcuts: _markdownShortcuts,
84
90
  writingDirection: _writingDirection,
85
91
  }: EnrichedMarkdownTextInputProps) => {
86
92
  const [text, setText] = useState(defaultValue ?? '');
@@ -167,6 +173,129 @@ export const EnrichedMarkdownTextInput = ({
167
173
  );
168
174
  };
169
175
 
176
+ // Composable transforms: split raw-string segments into React children.
177
+ // To add a feature, write a transform and append it to `buildChildren`.
178
+ type Segment = string | ReactNode;
179
+ type TransformFn = (text: string) => Segment[];
180
+
181
+ type BuildChildrenOptions = Pick<
182
+ EnrichedMarkdownTextProps,
183
+ 'onLinkPress' | 'onLinkLongPress' | 'onTaskListItemPress'
184
+ >;
185
+
186
+ const INLINE_FMT_RE = /\*{1,2}|_{1,2}/g;
187
+ const LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
188
+ const TASK_ITEM_RE = /^- \[([ xX])\] (.+)$/gm;
189
+
190
+ function stripInlineFormatting(text: string): string {
191
+ return text.replace(INLINE_FMT_RE, '');
192
+ }
193
+
194
+ function splitByPattern(
195
+ segment: string,
196
+ regex: RegExp,
197
+ renderMatch: (match: RegExpExecArray) => Segment
198
+ ): Segment[] {
199
+ const parts: Segment[] = [];
200
+ let lastIndex = 0;
201
+ regex.lastIndex = 0;
202
+ let match: RegExpExecArray | null;
203
+ while ((match = regex.exec(segment)) !== null) {
204
+ if (match.index > lastIndex) {
205
+ parts.push(segment.slice(lastIndex, match.index));
206
+ }
207
+ parts.push(renderMatch(match));
208
+ lastIndex = match.index + match[0].length;
209
+ }
210
+ if (lastIndex < segment.length) {
211
+ parts.push(segment.slice(lastIndex));
212
+ }
213
+ return parts.length > 0 ? parts : [segment];
214
+ }
215
+
216
+ function applyTransform(
217
+ children: Segment[],
218
+ transformFn: TransformFn
219
+ ): Segment[] {
220
+ return children.flatMap((child) =>
221
+ typeof child === 'string' ? transformFn(child) : child
222
+ );
223
+ }
224
+
225
+ function createLinkTransform(
226
+ onLinkPress?: (event: LinkPressEvent) => void,
227
+ onLinkLongPress?: (event: LinkLongPressEvent) => void
228
+ ): TransformFn {
229
+ let keyCounter = 0;
230
+ return (segment) =>
231
+ splitByPattern(segment, LINK_RE, (match) => {
232
+ const linkText = stripInlineFormatting(match[1]!);
233
+ const url = match[2]!;
234
+ return (
235
+ <Text
236
+ key={`link-${keyCounter++}`}
237
+ accessibilityRole="link"
238
+ onPress={() => onLinkPress?.({ url })}
239
+ onLongPress={
240
+ onLinkLongPress ? () => onLinkLongPress({ url }) : undefined
241
+ }
242
+ >
243
+ {linkText}
244
+ </Text>
245
+ );
246
+ });
247
+ }
248
+
249
+ function createTaskListTransform(
250
+ onTaskListItemPress?: (event: TaskListItemPressEvent) => void
251
+ ): TransformFn {
252
+ let itemIndex = 0;
253
+ return (segment) =>
254
+ splitByPattern(segment, TASK_ITEM_RE, (match) => {
255
+ const checked = match[1] !== ' ';
256
+ const text = match[2]!;
257
+ const currentIndex = itemIndex++;
258
+ return (
259
+ <Text
260
+ key={`task-${currentIndex}`}
261
+ accessibilityRole="checkbox"
262
+ accessibilityState={{ checked }}
263
+ onPress={() =>
264
+ onTaskListItemPress?.({
265
+ index: currentIndex,
266
+ checked: !checked,
267
+ text,
268
+ })
269
+ }
270
+ >
271
+ {`${checked ? '☑' : '☐'} ${text}`}
272
+ </Text>
273
+ );
274
+ });
275
+ }
276
+
277
+ function buildChildren(
278
+ markdown: string | undefined,
279
+ opts: BuildChildrenOptions
280
+ ): Segment[] {
281
+ let children: Segment[] = [String(markdown ?? '')];
282
+
283
+ const transforms: TransformFn[] = [
284
+ opts.onTaskListItemPress
285
+ ? createTaskListTransform(opts.onTaskListItemPress)
286
+ : undefined,
287
+ opts.onLinkPress || opts.onLinkLongPress
288
+ ? createLinkTransform(opts.onLinkPress, opts.onLinkLongPress)
289
+ : undefined,
290
+ ].filter((t): t is TransformFn => t != null);
291
+
292
+ for (const transform of transforms) {
293
+ children = applyTransform(children, transform);
294
+ }
295
+
296
+ return children;
297
+ }
298
+
170
299
  export const EnrichedMarkdownText = ({
171
300
  ref,
172
301
  markdown,
@@ -179,9 +308,9 @@ export const EnrichedMarkdownText = ({
179
308
  accessibilityState,
180
309
  nativeID,
181
310
  markdownStyle: _markdownStyle,
182
- onLinkPress: _onLinkPress,
183
- onLinkLongPress: _onLinkLongPress,
184
- onTaskListItemPress: _onTaskListItemPress,
311
+ onLinkPress,
312
+ onLinkLongPress,
313
+ onTaskListItemPress,
185
314
  onSelectionChange: _onSelectionChange,
186
315
  enableLinkPreview: _enableLinkPreview,
187
316
  linkLongPressSelects: _linkLongPressSelects,
@@ -230,7 +359,11 @@ export const EnrichedMarkdownText = ({
230
359
  accessibilityState={accessibilityState}
231
360
  nativeID={nativeID}
232
361
  >
233
- {markdown}
362
+ {buildChildren(markdown, {
363
+ onLinkPress,
364
+ onLinkLongPress,
365
+ onTaskListItemPress,
366
+ })}
234
367
  </Text>
235
368
  );
236
369
  };
@@ -43,9 +43,12 @@ import type {
43
43
  import type {
44
44
  LinkPressEvent,
45
45
  LinkLongPressEvent,
46
+ ImagePressEvent,
46
47
  TaskListItemPressEvent,
47
48
  CopyPressEvent,
48
49
  CopyEvent,
50
+ LatexErrorEvent,
51
+ CodeBlockPressEvent,
49
52
  OnContextMenuItemPressEvent,
50
53
  SelectionChangeEvent,
51
54
  SelectionRect,
@@ -65,11 +68,14 @@ export type {
65
68
  export type {
66
69
  LinkPressEvent,
67
70
  LinkLongPressEvent,
71
+ ImagePressEvent,
68
72
  TaskListItemPressEvent,
69
73
  CopyPressEvent,
70
74
  CopyEvent,
71
75
  SelectionChangeEvent,
72
76
  SelectionRect,
77
+ LatexErrorEvent,
78
+ CodeBlockPressEvent,
73
79
  };
74
80
 
75
81
  // Default English labels for the built-in selection menu actions. Defaults are
@@ -168,6 +174,8 @@ const defaultMd4cFlags: Md4cFlags = {
168
174
  latexMath: true,
169
175
  highlight: false,
170
176
  hardSoftBreaks: false,
177
+ preserveBlankLines: false,
178
+ admonitions: true,
171
179
  };
172
180
 
173
181
  export const EnrichedMarkdownText = ({
@@ -177,11 +185,15 @@ export const EnrichedMarkdownText = ({
177
185
  containerStyle,
178
186
  onLinkPress,
179
187
  onLinkLongPress,
188
+ onImagePress,
180
189
  onTaskListItemPress,
181
190
  enableTaskListItemToggle = true,
182
191
  onCopyPress,
183
192
  onCopy,
184
193
  onSelectionChange,
194
+ onLatexError,
195
+ onCodeBlockPress,
196
+ enableBlockContextMenu = true,
185
197
  enableLinkPreview,
186
198
  linkLongPressSelects = false,
187
199
  selectable = true,
@@ -205,6 +217,8 @@ export const EnrichedMarkdownText = ({
205
217
  writingDirection = 'first-strong',
206
218
  renderLinkDecoration,
207
219
  onLayout,
220
+ numberOfLines,
221
+ ellipsizeMode,
208
222
  ...rest
209
223
  }: EnrichedMarkdownTextProps) => {
210
224
  const normalizedStyleRef = useRef<MarkdownStyleInternal | null>(null);
@@ -224,8 +238,13 @@ export const EnrichedMarkdownText = ({
224
238
  latexMath: md4cFlags.latexMath ?? true,
225
239
  highlight: md4cFlags.highlight ?? false,
226
240
  hardSoftBreaks: md4cFlags.hardSoftBreaks ?? false,
241
+ preserveBlankLines: md4cFlags.preserveBlankLines ?? false,
242
+ // Admonitions are a GitHub-flavor feature; force them off in commonmark so
243
+ // `> [!NOTE]` renders as a plain blockquote.
244
+ admonitions:
245
+ flavor === 'github' ? (md4cFlags.admonitions ?? true) : false,
227
246
  }),
228
- [md4cFlags]
247
+ [md4cFlags, flavor]
229
248
  );
230
249
 
231
250
  const contextMenuCallbacksRef = useRef<
@@ -289,6 +308,14 @@ export const EnrichedMarkdownText = ({
289
308
  [onLinkLongPress]
290
309
  );
291
310
 
311
+ const handleImagePress = useCallback(
312
+ (e: NativeSyntheticEvent<ImagePressEvent>) => {
313
+ const { url, altText } = e.nativeEvent;
314
+ onImagePress?.({ url, altText });
315
+ },
316
+ [onImagePress]
317
+ );
318
+
292
319
  const handleTaskListItemPress = useCallback(
293
320
  (e: NativeSyntheticEvent<TaskListItemPressEvent>) => {
294
321
  const { index, checked, text } = e.nativeEvent;
@@ -305,8 +332,24 @@ export const EnrichedMarkdownText = ({
305
332
  [onCopyPress]
306
333
  );
307
334
 
335
+ const handleLatexError = useCallback(
336
+ (e: NativeSyntheticEvent<LatexErrorEvent>) => {
337
+ const { source, message, displayMode } = e.nativeEvent;
338
+ onLatexError?.({ source, message: message || undefined, displayMode });
339
+ },
340
+ [onLatexError]
341
+ );
342
+
343
+ const handleCodeBlockPress = useCallback(
344
+ (e: NativeSyntheticEvent<CodeBlockPressEvent>) => {
345
+ const { code, language } = e.nativeEvent;
346
+ onCodeBlockPress?.({ code, language });
347
+ },
348
+ [onCodeBlockPress]
349
+ );
350
+
308
351
  const handleCopyRequest = useCallback(
309
- // Codegen types `source` as a plain string; native only sends the four
352
+ // Codegen types `source` as a plain string; native only sends the
310
353
  // values of CopyEvent['source'].
311
354
  (
312
355
  e: NativeSyntheticEvent<Omit<CopyEvent, 'source'> & { source: string }>
@@ -343,7 +386,7 @@ export const EnrichedMarkdownText = ({
343
386
  // Rects stay relative to the native view — the view the ref's
344
387
  // `measureInWindow` measures — even when decorations wrap it.
345
388
  const handleSelectionChange = useCallback(
346
- // Codegen types `source` as a plain string; native only sends the four
389
+ // Codegen types `source` as a plain string; native only sends the
347
390
  // values of SelectionChangeEvent['source'].
348
391
  (e: NativeSyntheticEvent<NativeSelectionChangeEvent>) => {
349
392
  const { source, ...payload } = e.nativeEvent;
@@ -465,16 +508,23 @@ export const EnrichedMarkdownText = ({
465
508
  markdownStyle: normalizedStyle,
466
509
  onLinkPress: handleLinkPress,
467
510
  onLinkLongPress: handleLinkLongPress,
511
+ onImagePress: handleImagePress,
512
+ enableImagePress: onImagePress != null,
468
513
  onTaskListItemPress: handleTaskListItemPress,
469
514
  enableTaskListItemToggle,
470
515
  onCopyPress: handleCopyPress,
471
516
  onCopyRequest: handleCopyRequest,
472
517
  emitSelectionChange: onSelectionChange != null,
473
518
  onSelectionChange: handleSelectionChange,
519
+ onLatexError: handleLatexError,
520
+ onCodeBlockPress: handleCodeBlockPress,
521
+ enableCodeBlockPress: onCodeBlockPress != null,
522
+ enableBlockContextMenu,
474
523
  enableLinkPreview: onLinkLongPress == null && (enableLinkPreview ?? true),
475
524
  linkLongPressSelects,
476
525
  selectable,
477
526
  md4cFlags: normalizedMd4cFlags,
527
+ isGFM: flavor === 'github',
478
528
  allowFontScaling,
479
529
  maxFontSizeMultiplier,
480
530
  allowTrailingMargin,
@@ -493,6 +543,8 @@ export const EnrichedMarkdownText = ({
493
543
  textBreakStrategy,
494
544
  lineBreakStrategyIOS,
495
545
  writingDirection,
546
+ numberOfLines,
547
+ ellipsizeMode,
496
548
  ...rest,
497
549
  };
498
550
 
@@ -0,0 +1,38 @@
1
+ export type NormalizedMarkdownShortcuts = {
2
+ heading: boolean;
3
+ unorderedList: boolean;
4
+ orderedList: boolean;
5
+ };
6
+
7
+ const OFF: NormalizedMarkdownShortcuts = {
8
+ heading: false,
9
+ unorderedList: false,
10
+ orderedList: false,
11
+ };
12
+
13
+ // Validated per leaf rather than trusted from the prop type: `getBoolean` on the
14
+ // Android side throws on a missing or non-boolean field, and a null root would
15
+ // crash JS on property access.
16
+ const flag = (raw: unknown): boolean =>
17
+ typeof raw === 'boolean' ? raw : false;
18
+
19
+ export const normalizeMarkdownShortcuts = (
20
+ raw: unknown
21
+ ): NormalizedMarkdownShortcuts => {
22
+ if (typeof raw === 'boolean') {
23
+ return { heading: raw, unorderedList: raw, orderedList: raw };
24
+ }
25
+ if (typeof raw !== 'object' || raw === null) {
26
+ return OFF;
27
+ }
28
+ const obj = raw as {
29
+ heading?: unknown;
30
+ unorderedList?: unknown;
31
+ orderedList?: unknown;
32
+ };
33
+ return {
34
+ heading: flag(obj.heading),
35
+ unorderedList: flag(obj.unorderedList),
36
+ orderedList: flag(obj.orderedList),
37
+ };
38
+ };
@@ -8,6 +8,7 @@ import type {
8
8
  } from './types/MarkdownStyleInternal';
9
9
  import { isStyleEqual, normalizeColor, mergeSubStyle } from './styleUtils';
10
10
  import { normalizeLinkVariantEntries } from './linkVariantUtils';
11
+ import { resolveAdmonitionColors } from './admonitionDefaults';
11
12
  import {
12
13
  DEFAULT_HEADING_FONT_WEIGHT,
13
14
  HEADING_DEFAULTS,
@@ -145,6 +146,7 @@ const DEFAULT_NORMALIZED_STYLE = Object.freeze({
145
146
  backgroundColor: normalizeColor('#F9FAFB')!,
146
147
  borderRadius: 0,
147
148
  padding: 0,
149
+ admonitions: resolveAdmonitionColors(undefined),
148
150
  },
149
151
  list: {
150
152
  fontSize: 16,
@@ -216,6 +218,13 @@ const DEFAULT_NORMALIZED_STYLE = Object.freeze({
216
218
  marginTop: 0,
217
219
  marginBottom: 16,
218
220
  },
221
+ video: {
222
+ marginTop: 0,
223
+ marginBottom: 16,
224
+ borderRadius: 8,
225
+ aspectRatio: 16 / 9,
226
+ backgroundColor: normalizeColor('#000000')!,
227
+ },
219
228
  inlineImage: { size: 20 },
220
229
  thematicBreak: {
221
230
  color: normalizeColor('#E5E7EB')!,
@@ -342,6 +351,7 @@ export const normalizeMarkdownStyle = (
342
351
  ([pattern, override]): LinkVariantEntryInternal => {
343
352
  return {
344
353
  pattern,
354
+ fontFamily: override.fontFamily ?? linkBase.fontFamily,
345
355
  color: ((override.color ? normalizeColor(override.color) : null) ??
346
356
  linkBase.color) as string,
347
357
  underline: override.underline ?? linkBase.underline,
@@ -381,6 +391,13 @@ export const normalizeMarkdownStyle = (
381
391
  paragraphColor;
382
392
  }
383
393
 
394
+ // Admonition colors are nested two levels deep (blockquote.admonitions.<type>),
395
+ // deeper than mergeSubStyle merges, so resolve the full per-type palette here.
396
+ (result.blockquote as MarkdownStyleInternal['blockquote']).admonitions =
397
+ resolveAdmonitionColors(
398
+ style.blockquote?.admonitions
399
+ ) as MarkdownStyleInternal['blockquote']['admonitions'];
400
+
384
401
  const codeBlock = result.codeBlock as MarkdownStyleInternal['codeBlock'];
385
402
  const userSyntaxColors = style.codeBlock?.syntaxColors as
386
403
  | Record<string, unknown>
@@ -7,6 +7,7 @@ import type {
7
7
  } from './types/MarkdownStyleInternal';
8
8
  import { isStyleEqual, mergeSubStyle } from './styleUtils';
9
9
  import { normalizeLinkVariantEntries } from './linkVariantUtils';
10
+ import { resolveAdmonitionColors } from './admonitionDefaults';
10
11
  import {
11
12
  DEFAULT_HEADING_FONT_WEIGHT,
12
13
  HEADING_DEFAULTS,
@@ -94,6 +95,7 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
94
95
  backgroundColor: '#F9FAFB',
95
96
  borderRadius: 0,
96
97
  padding: 0,
98
+ admonitions: resolveAdmonitionColors(undefined),
97
99
  },
98
100
  list: {
99
101
  fontSize: 16,
@@ -178,6 +180,13 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
178
180
  marginTop: 0,
179
181
  marginBottom: 16,
180
182
  },
183
+ video: {
184
+ marginTop: 0,
185
+ marginBottom: 16,
186
+ borderRadius: 8,
187
+ aspectRatio: 16 / 9,
188
+ backgroundColor: '#000000',
189
+ },
181
190
  inlineImage: { size: 20 },
182
191
  thematicBreak: {
183
192
  color: '#E5E7EB',
@@ -294,6 +303,7 @@ export const normalizeMarkdownStyle = (
294
303
  ([pattern, override]): LinkVariantEntryInternal => {
295
304
  return {
296
305
  pattern,
306
+ fontFamily: override.fontFamily ?? linkBase.fontFamily,
297
307
  color: override.color ?? linkBase.color,
298
308
  underline: override.underline ?? linkBase.underline,
299
309
  // Chip ("box") properties never inherit from the base link style.
@@ -328,6 +338,13 @@ export const normalizeMarkdownStyle = (
328
338
  paragraphColor;
329
339
  }
330
340
 
341
+ // Admonition colors are nested two levels deep (blockquote.admonitions.<type>),
342
+ // deeper than mergeSubStyle merges, so resolve the full per-type palette here.
343
+ (result.blockquote as MarkdownStyleInternal['blockquote']).admonitions =
344
+ resolveAdmonitionColors(
345
+ style.blockquote?.admonitions
346
+ ) as MarkdownStyleInternal['blockquote']['admonitions'];
347
+
331
348
  // The public API exposes `operator`, but the internal token is `operatorColor`
332
349
  // (`operator` is reserved in the generated C++ struct). Remap it after merge.
333
350
  const syntaxColors = (
package/src/styleUtils.ts CHANGED
@@ -6,7 +6,16 @@ export const normalizeColor = (
6
6
  ): ColorValue | undefined => {
7
7
  if (!color) return undefined;
8
8
  if (Platform.OS === 'web') return color;
9
- return processColor(color) ?? undefined;
9
+ const processed = processColor(color);
10
+ if (processed === null || processed === undefined) {
11
+ if (__DEV__) {
12
+ console.warn(
13
+ `[MarkdownStyle] Ignoring invalid color value "${color}"; falling back to the default.`
14
+ );
15
+ }
16
+ return undefined;
17
+ }
18
+ return processed;
10
19
  };
11
20
 
12
21
  export function mergeSubStyle<T extends Record<string, unknown>>(
@@ -31,11 +40,13 @@ export function mergeSubStyle<T extends Record<string, unknown>>(
31
40
  ...(userValue as Record<string, unknown>),
32
41
  };
33
42
  }
34
- if (
35
- key.toLowerCase().includes('color') &&
36
- typeof result[key] === 'string'
37
- ) {
38
- result[key] = normalizeColor(result[key] as string);
43
+ if (key.toLowerCase().includes('color')) {
44
+ const value = result[key];
45
+ if (typeof value === 'string') {
46
+ result[key] = normalizeColor(value) ?? defaultValue;
47
+ } else if (value === undefined || value === null) {
48
+ result[key] = defaultValue;
49
+ }
39
50
  }
40
51
  }
41
52
  return result as T;