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
@@ -26,7 +26,8 @@ static NSArray *ENRMSplitASTIntoSegments(MarkdownASTNode *root)
26
26
  [currentTextNodes removeAllObjects];
27
27
  }
28
28
  NSString *latex = child.children.count > 0 ? child.children.firstObject.content : child.content;
29
- [segments addObject:[ENRMMathSegment segmentWithLatex:latex ?: @""]];
29
+ BOOL highlighted = [child.attributes[@"highlight"] isEqualToString:@"true"];
30
+ [segments addObject:[ENRMMathSegment segmentWithLatex:latex ?: @"" highlighted:highlighted]];
30
31
  #else
31
32
  // TODO: Fix block math rendering on macOS. Adding ENRMMathContainerView as a
32
33
  // segment causes all preceding text segments to become invisible.
@@ -39,7 +40,23 @@ static NSArray *ENRMSplitASTIntoSegments(MarkdownASTNode *root)
39
40
  [currentTextNodes removeAllObjects];
40
41
  }
41
42
  [segments addObject:[ENRMCodeBlockSegment segmentWithCodeBlockNode:child]];
42
- } else {
43
+ } else if (child.type == MarkdownNodeTypeBlockquote || child.type == MarkdownNodeTypeAdmonition) {
44
+ if (currentTextNodes.count > 0) {
45
+ [segments addObject:[ENRMTextSegment segmentWithNodes:[currentTextNodes copy]]];
46
+ [currentTextNodes removeAllObjects];
47
+ }
48
+ [segments addObject:[ENRMBlockquoteSegment segmentWithBlockquoteNode:child]];
49
+ }
50
+ #if ENRICHED_MARKDOWN_VIDEO
51
+ else if (child.type == MarkdownNodeTypeVideo) {
52
+ if (currentTextNodes.count > 0) {
53
+ [segments addObject:[ENRMTextSegment segmentWithNodes:[currentTextNodes copy]]];
54
+ [currentTextNodes removeAllObjects];
55
+ }
56
+ [segments addObject:[ENRMVideoSegment segmentWithVideoNode:child]];
57
+ }
58
+ #endif
59
+ else {
43
60
  [currentTextNodes addObject:child];
44
61
  }
45
62
  }
@@ -54,21 +71,26 @@ static NSArray *ENRMSplitASTIntoSegments(MarkdownASTNode *root)
54
71
  NSArray<ENRMRenderedSegment *> *ENRMRenderSegmentsFromAST(MarkdownASTNode *ast, StyleConfig *config,
55
72
  BOOL allowTrailingMargin, BOOL allowFontScaling,
56
73
  CGFloat maxFontSizeMultiplier,
57
- NSLineBreakStrategy lineBreakStrategy)
74
+ NSLineBreakStrategy lineBreakStrategy, BOOL blockquoteContent)
58
75
  {
59
76
  NSArray *segments = ENRMSplitASTIntoSegments(ast);
60
77
  NSMutableArray<ENRMRenderedSegment *> *renderedSegments = [NSMutableArray array];
61
78
 
62
- static const uint64_t kTextKindSalt = 0x7465787400000000ULL; // "text"
63
- static const uint64_t kTableKindSalt = 0x7461626C00000000ULL; // "tabl"
64
- static const uint64_t kMathKindSalt = 0x6D61746800000000ULL; // "math"
65
- static const uint64_t kCodeBlockKindSalt = 0x63626C6B00000000ULL; // "cblk"
79
+ static const uint64_t kTextKindSalt = 0x7465787400000000ULL; // "text"
80
+ static const uint64_t kTableKindSalt = 0x7461626C00000000ULL; // "tabl"
81
+ static const uint64_t kMathKindSalt = 0x6D61746800000000ULL; // "math"
82
+ static const uint64_t kCodeBlockKindSalt = 0x63626C6B00000000ULL; // "cblk"
83
+ static const uint64_t kBlockquoteKindSalt = 0x6271746500000000ULL; // "bqte"
84
+ static const uint64_t kVideoKindSalt = 0x7669646F00000000ULL; // "vido"
66
85
 
67
86
  for (id segment in segments) {
68
87
  if ([segment isKindOfClass:[ENRMTextSegment class]]) {
69
88
  ENRMTextSegment *textSegment = (ENRMTextSegment *)segment;
70
- ENRMRenderResult *rendered = ENRMRenderASTNodes(textSegment.nodes, config, allowTrailingMargin, allowFontScaling,
71
- maxFontSizeMultiplier, lineBreakStrategy);
89
+ ENRMRenderResult *rendered = blockquoteContent
90
+ ? ENRMRenderBlockquoteContentNodes(textSegment.nodes, config, allowFontScaling,
91
+ maxFontSizeMultiplier, lineBreakStrategy)
92
+ : ENRMRenderASTNodes(textSegment.nodes, config, allowTrailingMargin,
93
+ allowFontScaling, maxFontSizeMultiplier, lineBreakStrategy);
72
94
  uint64_t signature = ENRMSignatureForNodes(textSegment.nodes) ^ kTextKindSalt;
73
95
  [renderedSegments addObject:[ENRMRenderedSegment textSegmentWithResult:rendered signature:signature]];
74
96
  } else if ([segment isKindOfClass:[ENRMTableSegment class]]) {
@@ -86,6 +108,9 @@ NSArray<ENRMRenderedSegment *> *ENRMRenderSegmentsFromAST(MarkdownASTNode *ast,
86
108
  signature ^= (uint8_t)*utf8++;
87
109
  signature *= 1099511628211ULL;
88
110
  }
111
+ // A highlight toggle keeps the latex, so it must change the signature or the view is skipped.
112
+ signature ^= mathSegment.highlighted ? 1ULL : 0ULL;
113
+ signature *= 1099511628211ULL;
89
114
  [renderedSegments addObject:[ENRMRenderedSegment mathSegmentWithSegment:mathSegment signature:signature]];
90
115
  }
91
116
  #endif
@@ -94,7 +119,19 @@ NSArray<ENRMRenderedSegment *> *ENRMRenderSegmentsFromAST(MarkdownASTNode *ast,
94
119
  uint64_t signature = ENRMSignatureForNode(codeBlockSegment.codeBlockNode) ^ kCodeBlockKindSalt;
95
120
  [renderedSegments addObject:[ENRMRenderedSegment codeBlockSegmentWithSegment:codeBlockSegment
96
121
  signature:signature]];
122
+ } else if ([segment isKindOfClass:[ENRMBlockquoteSegment class]]) {
123
+ ENRMBlockquoteSegment *blockquoteSegment = (ENRMBlockquoteSegment *)segment;
124
+ uint64_t signature = ENRMSignatureForNode(blockquoteSegment.blockquoteNode) ^ kBlockquoteKindSalt;
125
+ [renderedSegments addObject:[ENRMRenderedSegment blockquoteSegmentWithSegment:blockquoteSegment
126
+ signature:signature]];
127
+ }
128
+ #if ENRICHED_MARKDOWN_VIDEO
129
+ else if ([segment isKindOfClass:[ENRMVideoSegment class]]) {
130
+ ENRMVideoSegment *videoSegment = (ENRMVideoSegment *)segment;
131
+ uint64_t signature = ENRMSignatureForNode(videoSegment.videoNode) ^ kVideoKindSalt;
132
+ [renderedSegments addObject:[ENRMRenderedSegment videoSegmentWithSegment:videoSegment signature:signature]];
97
133
  }
134
+ #endif
98
135
  }
99
136
 
100
137
  return renderedSegments;
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
  #import "ENRMBlockMenu.h"
3
+ #import "ENRMDynamicBlockProps.h"
3
4
  #import "ENRMUIKit.h"
4
5
  #import "ParagraphStyleUtils.h"
5
6
  #import "StyleConfig.h"
@@ -48,10 +49,10 @@ typedef void (^TableLinkPressBlock)(NSString *url);
48
49
 
49
50
  @property (nonatomic, strong, nullable) ENRMAccessibilityLabels *accessibilityLabels;
50
51
 
51
- // Renamed getters avoid the Cocoa `copy` method family (which signals +1
52
- // retained returns). Property names are unchanged so call sites stay the same.
53
- @property (nonatomic, copy, nullable, getter=menuCopyLabel) NSString *copyLabel;
54
- @property (nonatomic, copy, nullable, getter=menuCopyAsMarkdownLabel) NSString *copyAsMarkdownLabel;
52
+ // Shared, runtime-mutable block props (context-menu gate + copy labels) read live
53
+ // at menu-open. Set to the root's shared instance at creation. See
54
+ // ENRMDynamicBlockProps.
55
+ @property (nonatomic, strong) ENRMDynamicBlockProps *dynamicProps;
55
56
 
56
57
  /// Suppresses the long-press copy menu on this block. Mirrors the
57
58
  /// `contextMenuHidden` prop; selection and link handling are unaffected.
@@ -2,6 +2,7 @@
2
2
  #import "AttributedRenderer.h"
3
3
  #import "ENRMAccessibilityLabels.h"
4
4
  #import "ENRMLinkChip.h"
5
+ #import "ENRMImageAttachment.h"
5
6
  #import "HTMLGenerator.h"
6
7
  #import "LinkTapUtils.h"
7
8
  #import "MarkdownASTNode.h"
@@ -78,22 +79,18 @@ static NSMutableAttributedString *ENRMTableRenderCellNode(MarkdownASTNode *cellN
78
79
  ENRMWritingDirectionMode writingDirectionMode,
79
80
  NSWritingDirection resolvedLayoutDirection)
80
81
  {
81
- MarkdownASTNode *temporaryRoot = [[MarkdownASTNode alloc] initWithType:MarkdownNodeTypeDocument];
82
- for (MarkdownASTNode *child in cellNode.children) {
83
- [temporaryRoot addChild:child];
84
- }
85
-
86
82
  AttributedRenderer *renderer = [[AttributedRenderer alloc] initWithConfig:cellConfig];
87
83
  RenderContext *context = [RenderContext new];
88
84
  context.allowFontScaling = allowFontScaling;
89
85
  context.maxFontSizeMultiplier = maxFontSizeMultiplier;
90
86
 
91
- NSMutableAttributedString *attributedText = [renderer renderRoot:temporaryRoot context:context];
87
+ NSMutableAttributedString *attributedText = [renderer renderNodes:cellNode.children context:context block:nil];
92
88
 
93
89
  [context applyLinkAttributesToString:attributedText];
94
90
  // Cells draw with -drawWithRect:, which bypasses the layout manager that paints link chips.
95
91
  ENRMApplyLinkChipBackgroundsAsTextBackground(attributedText);
96
92
 
93
+ ENRMPinLineMetricsToStyledFonts(attributedText, NSMakeRange(0, attributedText.length));
97
94
  ENRMApplyWritingDirectionMode(attributedText, writingDirectionMode, resolvedLayoutDirection);
98
95
 
99
96
  if (alignment != NSTextAlignmentLeft && attributedText.length > 0) {
@@ -113,6 +110,29 @@ static NSMutableAttributedString *ENRMTableRenderCellNode(MarkdownASTNode *cellN
113
110
  return attributedText;
114
111
  }
115
112
 
113
+ // The grid rasterizes each cell's attributed string via -drawWithRect: in a single
114
+ // drawRect: pass, so an image attachment loading asynchronously has no live text view
115
+ // to invalidate (its -refreshDisplay no-ops). Point every cell image at the grid's own
116
+ // redraw so the cell repaints once the image finishes loading.
117
+ static void ENRMTableWireImageRedraw(NSArray<NSArray<TableCellData *> *> *rows, void (^redraw)(void))
118
+ {
119
+ for (NSArray<TableCellData *> *row in rows) {
120
+ for (TableCellData *cell in row) {
121
+ NSAttributedString *text = cell.attributedText;
122
+ if (text.length == 0)
123
+ continue;
124
+ [text enumerateAttribute:NSAttachmentAttributeName
125
+ inRange:NSMakeRange(0, text.length)
126
+ options:0
127
+ usingBlock:^(id value, NSRange range, BOOL *stop) {
128
+ if ([value isKindOfClass:[ENRMImageAttachment class]]) {
129
+ ((ENRMImageAttachment *)value).onImageLoaded = redraw;
130
+ }
131
+ }];
132
+ }
133
+ }
134
+ }
135
+
116
136
  static NSArray<NSArray<TableCellData *> *> *ENRMTableBuildRows(MarkdownASTNode *tableNode, StyleConfig *config,
117
137
  BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
118
138
  ENRMWritingDirectionMode writingDirectionMode,
@@ -231,6 +251,8 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
231
251
  NSString *_cachedMarkdown;
232
252
 
233
253
  NSArray *_cachedAccessibilityElements;
254
+
255
+ BOOL _imageRemeasurePending;
234
256
  }
235
257
 
236
258
  - (instancetype)initWithConfig:(StyleConfig *)config
@@ -241,6 +263,7 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
241
263
  _allowFontScaling = YES;
242
264
  _maxFontSizeMultiplier = 0;
243
265
  _enableLinkPreview = YES;
266
+ _dynamicProps = [[ENRMDynamicBlockProps alloc] init];
244
267
  _writingDirectionMode = ENRMWritingDirectionModeFirstStrong;
245
268
  _resolvedLayoutDirection = NSWritingDirectionLeftToRight;
246
269
  [self setupScrollView];
@@ -267,15 +290,17 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
267
290
  // a single drawRect: pass (no subview / layer compositing issues).
268
291
  ENRMTableGridView *gridView = [[ENRMTableGridView alloc] initWithFrame:CGRectZero];
269
292
  __weak TableContainerView *weakSelf = self;
270
- gridView.menuProvider = ^NSMenu * {
293
+ gridView.menuProvider = ^NSMenu *
294
+ {
271
295
  TableContainerView *strongSelf = weakSelf;
272
- if (!strongSelf)
296
+ if (!strongSelf || !strongSelf.dynamicProps.enableBlockContextMenu)
273
297
  return nil;
274
298
  if (strongSelf.contextMenuHidden)
275
299
  return nil;
276
300
  NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
277
- [menu addItem:ENRMCreateMenuItem(strongSelf.copyLabel, ^{ [strongSelf copyTableToPasteboard]; })];
278
- [menu addItem:ENRMCreateMenuItem(strongSelf.copyAsMarkdownLabel, ^{ [strongSelf copyMarkdownToPasteboard]; })];
301
+ [menu addItem:ENRMCreateMenuItem(strongSelf.dynamicProps.menuCopyLabel, ^{ [strongSelf copyTableToPasteboard]; })];
302
+ [menu addItem:ENRMCreateMenuItem(strongSelf.dynamicProps.menuCopyAsMarkdownLabel,
303
+ ^{ [strongSelf copyMarkdownToPasteboard]; })];
279
304
  return menu;
280
305
  };
281
306
  _gridContainer = gridView;
@@ -442,6 +467,9 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
442
467
  horizontalCellPadding:self.config.tableCellPaddingHorizontal
443
468
  verticalCellPadding:self.config.tableCellPaddingVertical
444
469
  cornerRadius:self.config.tableBorderRadius];
470
+
471
+ __weak TableContainerView *weakSelf = self;
472
+ ENRMTableWireImageRedraw(_rows, ^{ [weakSelf handleCellImageResolved]; });
445
473
  }
446
474
 
447
475
  #else
@@ -477,24 +505,80 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
477
505
  horizontalCellPadding:self.config.tableCellPaddingHorizontal
478
506
  verticalCellPadding:self.config.tableCellPaddingVertical
479
507
  cornerRadius:self.config.tableBorderRadius];
508
+
509
+ __weak TableContainerView *weakSelf = self;
510
+ ENRMTableWireImageRedraw(_rows, ^{ [weakSelf handleCellImageResolved]; });
511
+ }
512
+ #endif
513
+
514
+ // A dynamic cell image (maxHeight / aspectRatio) resolves its box height only after
515
+ // loading. Recompute this table's layout locally; if a row height actually changed
516
+ // (the maxHeight fitted case), re-render and ask the host to re-measure its Fabric
517
+ // height, otherwise just repaint the freshly loaded pixels. The height guard makes this
518
+ // a no-op once heights are stable, so a deterministic image never churns, and the host's
519
+ // own needs-update guard stops the propagation from looping.
520
+ - (void)handleCellImageResolved
521
+ {
522
+ if (_imageRemeasurePending) {
523
+ return;
524
+ }
525
+ _imageRemeasurePending = YES;
526
+ __weak TableContainerView *weakSelf = self;
527
+ dispatch_async(dispatch_get_main_queue(), ^{
528
+ TableContainerView *strongSelf = weakSelf;
529
+ if (!strongSelf) {
530
+ return;
531
+ }
532
+ strongSelf->_imageRemeasurePending = NO;
533
+ [strongSelf remeasureForCellImage];
534
+ });
480
535
  }
536
+
537
+ - (void)remeasureForCellImage
538
+ {
539
+ if (_rows.count == 0) {
540
+ return;
541
+ }
542
+ NSArray<NSNumber *> *oldRowHeights = _rowHeights;
543
+ CGFloat oldTotalHeight = _totalTableHeight;
544
+ [self computeLayout];
545
+
546
+ BOOL changed = ![_rowHeights isEqualToArray:oldRowHeights] || fabs(_totalTableHeight - oldTotalHeight) > 0.5;
547
+ if (!changed) {
548
+ #if TARGET_OS_OSX
549
+ _gridContainer.needsDisplay = YES;
550
+ #else
551
+ [_gridContainer setNeedsDisplay];
481
552
  #endif
553
+ return;
554
+ }
555
+
556
+ [self renderGrid];
557
+ [self setNeedsLayout];
558
+
559
+ [[self.superview enrm_imageLayoutObserver] imageAttachmentDidResolveLayout];
560
+ }
482
561
 
483
562
  #if !TARGET_OS_OSX
484
563
  - (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
485
564
  configurationForMenuAtLocation:(CGPoint)location
486
565
  {
487
566
  // Returning nil is the UIKit-sanctioned way to suppress a context menu.
567
+ // `contextMenuHidden` (fork) wins over `enableBlockContextMenu` (upstream #708) and still
568
+ // reports the block through onMenuSuppressed (merge decision D1).
488
569
  if (self.contextMenuHidden) {
489
570
  if (self.onMenuSuppressed) {
490
571
  self.onMenuSuppressed(_cachedMarkdown ?: @"", [self buildPlainTextFromRows] ?: @"");
491
572
  }
492
573
  return nil;
493
574
  }
575
+ if (!self.dynamicProps.enableBlockContextMenu) {
576
+ return nil;
577
+ }
494
578
  __weak __typeof(self) weakSelf = self;
495
579
  return ENRMBlockContextMenuConfiguration(
496
- self.menuOptions, self.copyLabel, self.copyAsMarkdownLabel, ^{ [weakSelf copyTableToPasteboard]; },
497
- ^{ [weakSelf copyMarkdownToPasteboard]; }, ^{ [weakSelf requestCopy]; });
580
+ self.menuOptions, self.dynamicProps.menuCopyLabel, self.dynamicProps.menuCopyAsMarkdownLabel,
581
+ ^{ [weakSelf copyTableToPasteboard]; }, ^{ [weakSelf copyMarkdownToPasteboard]; }, ^{ [weakSelf requestCopy]; });
498
582
  }
499
583
 
500
584
  - (void)requestCopy
@@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
9
9
  * Populated from the JS `linkVariants` map by StylePropsUtils and consumed by LinkRenderer.
10
10
  */
11
11
  @interface LinkVariantConfig : NSObject
12
+ @property (nonatomic, copy) NSString *fontFamily;
12
13
  @property (nonatomic, copy) NSString *pattern;
13
14
  @property (nonatomic, strong) RCTUIColor *color;
14
15
  @property (nonatomic, assign) BOOL underline;
@@ -238,6 +239,17 @@ NS_ASSUME_NONNULL_BEGIN
238
239
  - (void)setImageMarginBottom:(CGFloat)newValue;
239
240
  - (nullable NSDictionary<NSString *, NSString *> *)imageRequestHeaders;
240
241
  - (void)setImageRequestHeaders:(nullable NSDictionary<NSString *, NSString *> *)newValue;
242
+ // Video properties
243
+ - (CGFloat)videoMarginTop;
244
+ - (void)setVideoMarginTop:(CGFloat)newValue;
245
+ - (CGFloat)videoMarginBottom;
246
+ - (void)setVideoMarginBottom:(CGFloat)newValue;
247
+ - (CGFloat)videoBorderRadius;
248
+ - (void)setVideoBorderRadius:(CGFloat)newValue;
249
+ - (CGFloat)videoAspectRatio;
250
+ - (void)setVideoAspectRatio:(CGFloat)newValue;
251
+ - (RCTUIColor *)videoBackgroundColor;
252
+ - (void)setVideoBackgroundColor:(RCTUIColor *)newValue;
241
253
  // Inline image properties
242
254
  - (CGFloat)inlineImageSize;
243
255
  - (void)setInlineImageSize:(CGFloat)newValue;
@@ -269,6 +281,11 @@ NS_ASSUME_NONNULL_BEGIN
269
281
  - (void)setBlockquoteBorderRadius:(CGFloat)newValue;
270
282
  - (CGFloat)blockquotePadding;
271
283
  - (void)setBlockquotePadding:(CGFloat)newValue;
284
+ // Per-admonition-type colors (keyed by "note"/"tip"/"important"/"warning"/"caution").
285
+ - (void)setAdmonitionColors:(NSDictionary<NSString *, RCTUIColor *> *)colors
286
+ backgroundColors:(NSDictionary<NSString *, RCTUIColor *> *)backgroundColors;
287
+ - (RCTUIColor *)admonitionColorForType:(NSString *)type;
288
+ - (RCTUIColor *)admonitionBackgroundColorForType:(NSString *)type;
272
289
  // List style properties (combined for both ordered and unordered lists)
273
290
  - (CGFloat)listStyleFontSize;
274
291
  - (void)setListStyleFontSize:(CGFloat)newValue;
@@ -150,6 +150,12 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
150
150
  CGFloat _imageMarginTop;
151
151
  CGFloat _imageMarginBottom;
152
152
  NSDictionary<NSString *, NSString *> *_imageRequestHeaders;
153
+ // Video properties
154
+ CGFloat _videoMarginTop;
155
+ CGFloat _videoMarginBottom;
156
+ CGFloat _videoBorderRadius;
157
+ CGFloat _videoAspectRatio;
158
+ RCTUIColor *_videoBackgroundColor;
153
159
  // Inline image properties
154
160
  CGFloat _inlineImageSize;
155
161
  // Blockquote properties
@@ -166,6 +172,9 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
166
172
  RCTUIColor *_blockquoteBackgroundColor;
167
173
  CGFloat _blockquoteBorderRadius;
168
174
  CGFloat _blockquotePadding;
175
+ // Per-admonition-type colors keyed by type ("note"/"tip"/…). Empty until set.
176
+ NSDictionary<NSString *, RCTUIColor *> *_admonitionColors;
177
+ NSDictionary<NSString *, RCTUIColor *> *_admonitionBackgroundColors;
169
178
  ENRMFontSlot *_blockquoteFont;
170
179
  // List style properties (combined for both ordered and unordered lists)
171
180
  CGFloat _listStyleFontSize;
@@ -296,6 +305,8 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
296
305
  _primaryFont, _paragraphFont, _h1Font, _h2Font, _h3Font, _h4Font, _h5Font, _h6Font, _listMarkerFont, _listStyleFont,
297
306
  _codeBlockFont, _blockquoteFont, _tableFont, _tableHeaderFont
298
307
  ];
308
+ _admonitionColors = @{};
309
+ _admonitionBackgroundColors = @{};
299
310
  return self;
300
311
  }
301
312
 
@@ -442,6 +453,11 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
442
453
  copy->_imageMarginTop = _imageMarginTop;
443
454
  copy->_imageMarginBottom = _imageMarginBottom;
444
455
  copy->_imageRequestHeaders = [_imageRequestHeaders copy];
456
+ copy->_videoMarginTop = _videoMarginTop;
457
+ copy->_videoMarginBottom = _videoMarginBottom;
458
+ copy->_videoBorderRadius = _videoBorderRadius;
459
+ copy->_videoAspectRatio = _videoAspectRatio;
460
+ copy->_videoBackgroundColor = [_videoBackgroundColor copy];
445
461
  copy->_inlineImageSize = _inlineImageSize;
446
462
  copy->_blockquoteFontSize = _blockquoteFontSize;
447
463
  copy->_blockquoteFontFamily = [_blockquoteFontFamily copy];
@@ -456,6 +472,8 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
456
472
  copy->_blockquoteBackgroundColor = [_blockquoteBackgroundColor copy];
457
473
  copy->_blockquoteBorderRadius = _blockquoteBorderRadius;
458
474
  copy->_blockquotePadding = _blockquotePadding;
475
+ copy->_admonitionColors = [_admonitionColors copy];
476
+ copy->_admonitionBackgroundColors = [_admonitionBackgroundColors copy];
459
477
  copy->_listStyleFontSize = _listStyleFontSize;
460
478
  copy->_listStyleFontFamily = [_listStyleFontFamily copy];
461
479
  copy->_listStyleFontWeight = [_listStyleFontWeight copy];
@@ -1669,6 +1687,56 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
1669
1687
  _imageRequestHeaders = [newValue copy];
1670
1688
  }
1671
1689
 
1690
+ - (CGFloat)videoMarginTop
1691
+ {
1692
+ return _videoMarginTop;
1693
+ }
1694
+
1695
+ - (void)setVideoMarginTop:(CGFloat)newValue
1696
+ {
1697
+ _videoMarginTop = newValue;
1698
+ }
1699
+
1700
+ - (CGFloat)videoMarginBottom
1701
+ {
1702
+ return _videoMarginBottom;
1703
+ }
1704
+
1705
+ - (void)setVideoMarginBottom:(CGFloat)newValue
1706
+ {
1707
+ _videoMarginBottom = newValue;
1708
+ }
1709
+
1710
+ - (CGFloat)videoBorderRadius
1711
+ {
1712
+ return _videoBorderRadius;
1713
+ }
1714
+
1715
+ - (void)setVideoBorderRadius:(CGFloat)newValue
1716
+ {
1717
+ _videoBorderRadius = newValue;
1718
+ }
1719
+
1720
+ - (CGFloat)videoAspectRatio
1721
+ {
1722
+ return _videoAspectRatio;
1723
+ }
1724
+
1725
+ - (void)setVideoAspectRatio:(CGFloat)newValue
1726
+ {
1727
+ _videoAspectRatio = newValue;
1728
+ }
1729
+
1730
+ - (RCTUIColor *)videoBackgroundColor
1731
+ {
1732
+ return _videoBackgroundColor;
1733
+ }
1734
+
1735
+ - (void)setVideoBackgroundColor:(RCTUIColor *)newValue
1736
+ {
1737
+ _videoBackgroundColor = newValue;
1738
+ }
1739
+
1672
1740
  - (CGFloat)inlineImageSize
1673
1741
  {
1674
1742
  return _inlineImageSize;
@@ -1831,6 +1899,28 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
1831
1899
  _blockquotePadding = newValue;
1832
1900
  }
1833
1901
 
1902
+ - (void)setAdmonitionColors:(NSDictionary<NSString *, RCTUIColor *> *)colors
1903
+ backgroundColors:(NSDictionary<NSString *, RCTUIColor *> *)backgroundColors
1904
+ {
1905
+ _admonitionColors = [colors copy];
1906
+ _admonitionBackgroundColors = [backgroundColors copy];
1907
+ }
1908
+
1909
+ // The tint (border + title + icon) for an admonition type; falls back to the
1910
+ // base blockquote border color if the type was never configured.
1911
+ - (RCTUIColor *)admonitionColorForType:(NSString *)type
1912
+ {
1913
+ RCTUIColor *color = _admonitionColors[type];
1914
+ return color ?: _blockquoteBorderColor;
1915
+ }
1916
+
1917
+ // The callout fill for an admonition type; clear (no fill) when unset.
1918
+ - (RCTUIColor *)admonitionBackgroundColorForType:(NSString *)type
1919
+ {
1920
+ RCTUIColor *color = _admonitionBackgroundColors[type];
1921
+ return color ?: [RCTUIColor clearColor];
1922
+ }
1923
+
1834
1924
  // List style properties (combined for both ordered and unordered lists)
1835
1925
  - (CGFloat)listStyleFontSize
1836
1926
  {
@@ -75,5 +75,18 @@ void ENRMApplyCodeBlockTextAttributes(NSMutableAttributedString *string, NSRange
75
75
  NSMutableParagraphStyle *paragraphStyle = [getOrCreateParagraphStyle(string, range.location) mutableCopy];
76
76
  paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
77
77
  paragraphStyle.alignment = NSTextAlignmentLeft;
78
+ // Re-clamp unconditionally (applyLineHeight carves math/block-image lines out of its clamp,
79
+ // fork D7 option b). Code blocks reserve their height analytically as
80
+ // lineCount * lineHeight (ENRMCodeBlockCodeHeight), so a line must not grow past the
81
+ // configured lineHeight or a tall run (emoji, wide glyph) would overflow and clip the block.
82
+ if (lineHeight > 0) {
83
+ paragraphStyle.maximumLineHeight = lineHeight;
84
+ }
78
85
  [string addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
86
+
87
+ if (lineHeight > 0) {
88
+ applyBaselineOffset(string, range);
89
+ }
90
+
91
+ ENRMPinLineMetricsToStyledFonts(string, range);
79
92
  }
@@ -17,3 +17,9 @@
17
17
  #if !defined(ENRICHED_MARKDOWN_CODE_HIGHLIGHT)
18
18
  #define ENRICHED_MARKDOWN_CODE_HIGHLIGHT 0
19
19
  #endif
20
+
21
+ // Video playback support. Uses AVKit (built into both iOS and macOS — no
22
+ // external framework), so the flag gates only the container view code itself.
23
+ #if !defined(ENRICHED_MARKDOWN_VIDEO)
24
+ #define ENRICHED_MARKDOWN_VIDEO 0
25
+ #endif
@@ -23,6 +23,14 @@ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleCon
23
23
  BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
24
24
  NSLineBreakStrategy lineBreakStrategy);
25
25
 
26
+ // Renders a blockquote's own text content: like ENRMRenderASTNodes but with a blockquote baseline
27
+ // (tight paragraphs, quote font/color) and the quote's line height applied over the result. Draws
28
+ // no box - the ENRMBlockquoteContainerView draws the border/background/padding. Mirrors Android's
29
+ // BlockquoteTextRenderer.
30
+ ENRMRenderResult *ENRMRenderBlockquoteContentNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config,
31
+ BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
32
+ NSLineBreakStrategy lineBreakStrategy);
33
+
26
34
  #ifdef __cplusplus
27
35
  }
28
36
  #endif
@@ -1,7 +1,7 @@
1
1
  #import "ENRMTextRenderer.h"
2
2
  #import "AccessibilityInfo.h"
3
3
  #import "AttributedRenderer.h"
4
- #import "MarkdownASTNode.h"
4
+ #import "ENRMBlockquoteTextRenderer.h"
5
5
  #import "ParagraphStyleUtils.h"
6
6
  #import "RenderContext.h"
7
7
  #import "StyleConfig.h"
@@ -9,15 +9,11 @@
9
9
  @implementation ENRMRenderResult
10
10
  @end
11
11
 
12
- ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config, BOOL allowTrailingMargin,
13
- BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
14
- NSLineBreakStrategy lineBreakStrategy)
12
+ static ENRMRenderResult *ENRMRenderASTNodesCore(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config,
13
+ BOOL allowTrailingMargin, BOOL allowFontScaling,
14
+ CGFloat maxFontSizeMultiplier, NSLineBreakStrategy lineBreakStrategy,
15
+ ENRMBlockquoteTextRenderer *block)
15
16
  {
16
- MarkdownASTNode *root = [[MarkdownASTNode alloc] initWithType:MarkdownNodeTypeDocument];
17
- for (MarkdownASTNode *node in nodes) {
18
- [root addChild:node];
19
- }
20
-
21
17
  AttributedRenderer *renderer = [[AttributedRenderer alloc] initWithConfig:config];
22
18
  [renderer setAllowTrailingMargin:allowTrailingMargin];
23
19
 
@@ -25,9 +21,12 @@ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleCon
25
21
  context.allowFontScaling = allowFontScaling;
26
22
  context.maxFontSizeMultiplier = maxFontSizeMultiplier;
27
23
 
28
- NSMutableAttributedString *attributedText = [renderer renderRoot:root context:context];
24
+ NSMutableAttributedString *attributedText = [renderer renderNodes:nodes context:context block:block];
25
+
29
26
  [context applyLinkAttributesToString:attributedText];
27
+ [context applyImageAttributesToString:attributedText];
30
28
  ENRMApplyLineBreakStrategyToParagraphStyles(attributedText, lineBreakStrategy);
29
+ ENRMPinLineMetricsToStyledFonts(attributedText, NSMakeRange(0, attributedText.length));
31
30
 
32
31
  ENRMRenderResult *result = [[ENRMRenderResult alloc] init];
33
32
  result.attributedText = attributedText;
@@ -36,3 +35,20 @@ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleCon
36
35
  result.lastElementMarginBottom = [renderer getLastElementMarginBottom];
37
36
  return result;
38
37
  }
38
+
39
+ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config, BOOL allowTrailingMargin,
40
+ BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
41
+ NSLineBreakStrategy lineBreakStrategy)
42
+ {
43
+ return ENRMRenderASTNodesCore(nodes, config, allowTrailingMargin, allowFontScaling, maxFontSizeMultiplier,
44
+ lineBreakStrategy, /*block*/ nil);
45
+ }
46
+
47
+ ENRMRenderResult *ENRMRenderBlockquoteContentNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config,
48
+ BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
49
+ NSLineBreakStrategy lineBreakStrategy)
50
+ {
51
+ ENRMBlockquoteTextRenderer *block = [[ENRMBlockquoteTextRenderer alloc] initWithConfig:config];
52
+ return ENRMRenderASTNodesCore(nodes, config, /*allowTrailingMargin*/ NO, allowFontScaling, maxFontSizeMultiplier,
53
+ lineBreakStrategy, block);
54
+ }
@@ -273,6 +273,7 @@ static inline void ENRMConfigureMarkdownTextView(ENRMPlatformTextView *textView)
273
273
  textView.drawsBackground = NO;
274
274
  #endif
275
275
  textView.textContainer.lineFragmentPadding = 0;
276
+ textView.layoutManager.usesFontLeading = NO;
276
277
  textView.linkTextAttributes = @{};
277
278
  textView.selectable = YES;
278
279
  #if !TARGET_OS_OSX
@@ -19,7 +19,8 @@ extern UIFont *cachedFontFromBlockStyle(BlockStyle *blockStyle, RenderContext *c
19
19
  extern CGFloat RCTFontSizeMultiplierWithMax(CGFloat maxFontSizeMultiplier);
20
20
 
21
21
  /** Converts a CSS-style font weight string to a UIFontWeight constant.
22
- * Supports: "bold"/"700", "semibold"/"600", "medium"/"500", "light"/"300".
22
+ * Mirrors React Native's RCTFont table: "100"/"ultralight" through
23
+ * "900"/"black", plus the "normal"/"regular"/"bold"/etc. aliases.
23
24
  * Returns UIFontWeightRegular for unrecognised or nil input. */
24
25
  extern UIFontWeight ENRMFontWeightFromString(NSString *_Nullable weightString);
25
26
 
@@ -31,17 +31,33 @@ UIFontWeight ENRMFontWeightFromString(NSString *weightString)
31
31
  if (weightString.length == 0) {
32
32
  return UIFontWeightRegular;
33
33
  }
34
- if ([weightString isEqualToString:@"bold"] || [weightString isEqualToString:@"700"]) {
35
- return UIFontWeightBold;
34
+ if ([weightString isEqualToString:@"ultralight"] || [weightString isEqualToString:@"100"]) {
35
+ return UIFontWeightUltraLight;
36
36
  }
37
- if ([weightString isEqualToString:@"semibold"] || [weightString isEqualToString:@"600"]) {
38
- return UIFontWeightSemibold;
37
+ if ([weightString isEqualToString:@"thin"] || [weightString isEqualToString:@"200"]) {
38
+ return UIFontWeightThin;
39
+ }
40
+ if ([weightString isEqualToString:@"light"] || [weightString isEqualToString:@"300"]) {
41
+ return UIFontWeightLight;
42
+ }
43
+ if ([weightString isEqualToString:@"normal"] || [weightString isEqualToString:@"regular"] ||
44
+ [weightString isEqualToString:@"400"]) {
45
+ return UIFontWeightRegular;
39
46
  }
40
47
  if ([weightString isEqualToString:@"medium"] || [weightString isEqualToString:@"500"]) {
41
48
  return UIFontWeightMedium;
42
49
  }
43
- if ([weightString isEqualToString:@"light"] || [weightString isEqualToString:@"300"]) {
44
- return UIFontWeightLight;
50
+ if ([weightString isEqualToString:@"semibold"] || [weightString isEqualToString:@"600"]) {
51
+ return UIFontWeightSemibold;
52
+ }
53
+ if ([weightString isEqualToString:@"bold"] || [weightString isEqualToString:@"700"]) {
54
+ return UIFontWeightBold;
55
+ }
56
+ if ([weightString isEqualToString:@"heavy"] || [weightString isEqualToString:@"800"]) {
57
+ return UIFontWeightHeavy;
58
+ }
59
+ if ([weightString isEqualToString:@"black"] || [weightString isEqualToString:@"900"]) {
60
+ return UIFontWeightBlack;
45
61
  }
46
62
  return UIFontWeightRegular;
47
63
  }