react-native-marcus 0.1.1 → 0.2.0

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 (294) hide show
  1. package/README.md +220 -63
  2. package/RNMarcus.podspec +6 -0
  3. package/android/src/main/java/app/getbullet/marcus/MarcusPackage.kt +2 -1
  4. package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorView.kt +168 -0
  5. package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorViewManager.kt +38 -0
  6. package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorViewManagerSpec.kt +19 -0
  7. package/android/src/main/java/app/getbullet/marcus/MarcusTextInputDecoratorView.kt +23 -1
  8. package/android/src/main/java/app/getbullet/marcus/MarkdownBackgroundPainter.kt +147 -0
  9. package/android/src/main/java/app/getbullet/marcus/MarkdownBackgroundPass.kt +19 -0
  10. package/android/src/main/java/app/getbullet/marcus/MarkdownCopy.kt +87 -0
  11. package/android/src/main/java/app/getbullet/marcus/MarkdownFormatter.kt +652 -113
  12. package/android/src/main/java/app/getbullet/marcus/MarkdownRanges.kt +47 -0
  13. package/android/src/main/java/app/getbullet/marcus/MarkdownStyle.kt +140 -61
  14. package/android/src/main/java/app/getbullet/marcus/MarkdownUtils.kt +37 -7
  15. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownAbsoluteLineHeightSpan.kt +48 -0
  16. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundSpan.kt +102 -48
  17. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBlockIndentSpan.kt +22 -4
  18. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBulletSpan.kt +78 -0
  19. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownCodeBlockSpan.kt +177 -0
  20. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontStyleSpan.kt +32 -0
  21. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontWeightSpan.kt +34 -0
  22. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownGapSpan.kt +24 -11
  23. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownLetterSpacingSpan.kt +32 -0
  24. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownTextShadowSpan.kt +32 -0
  25. package/android/src/main/new_arch/CMakeLists.txt +17 -0
  26. package/android/src/main/new_arch/RNMarcusSpec.h +1 -0
  27. package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorShadowNode.cpp +235 -0
  28. package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorShadowNode.h +62 -0
  29. package/android/src/reactNativeVersionPatch/CustomMountingManager/81/app/getbullet/marcus/CustomFabricUIManager.java +22 -3
  30. package/android/src/reactNativeVersionPatch/CustomMountingManager/latest/app/getbullet/marcus/CustomFabricUIManager.java +22 -3
  31. package/android/src/test/java/app/getbullet/marcus/MarkdownCopyTest.kt +69 -0
  32. package/android/src/test/java/app/getbullet/marcus/MarkdownFormatterTest.kt +170 -25
  33. package/android/src/test/java/app/getbullet/marcus/RenderModel.kt +22 -5
  34. package/android/src/test/java/app/getbullet/marcus/spans/MarkdownCodeBlockSpanTest.kt +91 -0
  35. package/android/src/test/resources/render-model.txt +221 -16
  36. package/apple/MarcusSwizzle.h +25 -0
  37. package/apple/MarcusTextDecoratorComponentView.h +22 -0
  38. package/apple/MarcusTextDecoratorComponentView.mm +72 -0
  39. package/apple/MarcusTextDecoratorShadowNode.h +62 -0
  40. package/apple/MarcusTextDecoratorShadowNode.mm +192 -0
  41. package/apple/MarcusTextDecoratorViewManager.h +4 -0
  42. package/apple/MarcusTextDecoratorViewManager.mm +11 -0
  43. package/apple/MarcusTextInputDecoratorComponentView.mm +1 -1
  44. package/apple/MarcusTextInputDecoratorShadowNode.mm +1 -1
  45. package/apple/MarcusTextLayoutManager.h +40 -0
  46. package/apple/MarcusTextLayoutManager.mm +173 -0
  47. package/apple/MarkdownAttributes.h +23 -2
  48. package/apple/MarkdownAttributes.m +6 -0
  49. package/apple/MarkdownCopy.swift +63 -0
  50. package/apple/MarkdownDecorator.swift +2 -2
  51. package/apple/MarkdownFormatter+React.swift +23 -0
  52. package/apple/MarkdownFormatter.swift +869 -148
  53. package/apple/MarkdownParagraphLayoutManager.swift +455 -0
  54. package/apple/MarkdownSwiftInterop.h +0 -1
  55. package/apple/MarkdownTextBackground.swift +59 -1
  56. package/apple/MarkdownTextFieldObserver.swift +2 -2
  57. package/apple/MarkdownTextLayoutFragment.swift +159 -33
  58. package/apple/MarkdownTextLayoutManagerDelegate.swift +67 -3
  59. package/apple/MarkdownTextStorageDelegate.swift +2 -2
  60. package/apple/MarkdownTextViewObserver.swift +2 -2
  61. package/apple/MarkdownUtils.swift +38 -0
  62. package/apple/MarkdownWritingDirection.swift +132 -0
  63. package/apple/RCTMarcusStyle+Codegen.h +115 -9
  64. package/apple/RCTMarcusStyle.h +128 -31
  65. package/apple/RCTMarcusStyle.m +48 -0
  66. package/apple/RCTParagraphComponentView+Marcus.h +17 -0
  67. package/apple/RCTParagraphComponentView+Marcus.mm +38 -0
  68. package/apple/RCTTextInputComponentView+Marcus.mm +1 -25
  69. package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorState.h +37 -0
  70. package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorViewComponentDescriptor.h +17 -0
  71. package/lib/commonjs/MarcusTextDecoratorViewNativeComponent.ts +199 -0
  72. package/lib/commonjs/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
  73. package/lib/commonjs/MarkdownText.js +330 -0
  74. package/lib/commonjs/MarkdownText.js.map +1 -0
  75. package/lib/commonjs/MarkdownText.web.js +529 -0
  76. package/lib/commonjs/MarkdownText.web.js.map +1 -0
  77. package/lib/commonjs/MarkdownTextInput.js +22 -27
  78. package/lib/commonjs/MarkdownTextInput.js.map +1 -1
  79. package/lib/commonjs/MarkdownTextInput.web.js +12 -7
  80. package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
  81. package/lib/commonjs/atomUtils.js +112 -0
  82. package/lib/commonjs/atomUtils.js.map +1 -0
  83. package/lib/commonjs/childrenUtils.js +36 -0
  84. package/lib/commonjs/childrenUtils.js.map +1 -0
  85. package/lib/commonjs/index.js +8 -7
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/math/environment.js +69 -0
  88. package/lib/commonjs/math/environment.js.map +1 -0
  89. package/lib/commonjs/math/index.js +61 -0
  90. package/lib/commonjs/math/index.js.map +1 -0
  91. package/lib/commonjs/math/mathjax.js +548 -0
  92. package/lib/commonjs/math/mathjax.js.map +1 -0
  93. package/lib/commonjs/metro.js +172 -0
  94. package/lib/commonjs/metro.js.map +1 -0
  95. package/lib/commonjs/parser/index.d.ts +3 -0
  96. package/lib/commonjs/parser/index.js +450 -42
  97. package/lib/commonjs/parser/index.js.map +4 -4
  98. package/lib/commonjs/stripUtils.js +743 -0
  99. package/lib/commonjs/stripUtils.js.map +1 -0
  100. package/lib/commonjs/styleUtils.js +194 -23
  101. package/lib/commonjs/styleUtils.js.map +1 -1
  102. package/lib/commonjs/web/MarkdownElements.css +67 -0
  103. package/lib/commonjs/web/MarkdownTextInput.css +9 -7
  104. package/lib/commonjs/web/utils/blockLayout.js +95 -7
  105. package/lib/commonjs/web/utils/blockLayout.js.map +1 -1
  106. package/lib/commonjs/web/utils/blockUtils.js +327 -54
  107. package/lib/commonjs/web/utils/blockUtils.js.map +1 -1
  108. package/lib/commonjs/web/utils/elementUtils.js +80 -0
  109. package/lib/commonjs/web/utils/elementUtils.js.map +1 -0
  110. package/lib/commonjs/web/utils/parserUtils.js +84 -28
  111. package/lib/commonjs/web/utils/parserUtils.js.map +1 -1
  112. package/lib/commonjs/web/utils/treeUtils.js +6 -0
  113. package/lib/commonjs/web/utils/treeUtils.js.map +1 -1
  114. package/lib/commonjs/web/utils/webStyleUtils.js +25 -5
  115. package/lib/commonjs/web/utils/webStyleUtils.js.map +1 -1
  116. package/lib/module/MarcusTextDecoratorViewNativeComponent.ts +199 -0
  117. package/lib/module/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
  118. package/lib/module/MarkdownText.js +325 -0
  119. package/lib/module/MarkdownText.js.map +1 -0
  120. package/lib/module/MarkdownText.web.js +524 -0
  121. package/lib/module/MarkdownText.web.js.map +1 -0
  122. package/lib/module/MarkdownTextInput.js +24 -29
  123. package/lib/module/MarkdownTextInput.js.map +1 -1
  124. package/lib/module/MarkdownTextInput.web.js +12 -7
  125. package/lib/module/MarkdownTextInput.web.js.map +1 -1
  126. package/lib/module/atomUtils.js +106 -0
  127. package/lib/module/atomUtils.js.map +1 -0
  128. package/lib/module/childrenUtils.js +33 -0
  129. package/lib/module/childrenUtils.js.map +1 -0
  130. package/lib/module/index.js +1 -1
  131. package/lib/module/index.js.map +1 -1
  132. package/lib/module/math/environment.js +67 -0
  133. package/lib/module/math/environment.js.map +1 -0
  134. package/lib/module/math/index.js +56 -0
  135. package/lib/module/math/index.js.map +1 -0
  136. package/lib/module/math/mathjax.js +541 -0
  137. package/lib/module/math/mathjax.js.map +1 -0
  138. package/lib/module/metro.js +169 -0
  139. package/lib/module/metro.js.map +1 -0
  140. package/lib/module/parser/index.d.ts +3 -0
  141. package/lib/module/parser/index.js +450 -42
  142. package/lib/module/parser/index.js.map +4 -4
  143. package/lib/module/stripUtils.js +739 -0
  144. package/lib/module/stripUtils.js.map +1 -0
  145. package/lib/module/styleUtils.js +196 -25
  146. package/lib/module/styleUtils.js.map +1 -1
  147. package/lib/module/web/MarkdownElements.css +67 -0
  148. package/lib/module/web/MarkdownTextInput.css +9 -7
  149. package/lib/module/web/utils/blockLayout.js +94 -8
  150. package/lib/module/web/utils/blockLayout.js.map +1 -1
  151. package/lib/module/web/utils/blockUtils.js +328 -56
  152. package/lib/module/web/utils/blockUtils.js.map +1 -1
  153. package/lib/module/web/utils/elementUtils.js +75 -0
  154. package/lib/module/web/utils/elementUtils.js.map +1 -0
  155. package/lib/module/web/utils/parserUtils.js +86 -30
  156. package/lib/module/web/utils/parserUtils.js.map +1 -1
  157. package/lib/module/web/utils/treeUtils.js +6 -0
  158. package/lib/module/web/utils/treeUtils.js.map +1 -1
  159. package/lib/module/web/utils/webStyleUtils.js +25 -5
  160. package/lib/module/web/utils/webStyleUtils.js.map +1 -1
  161. package/lib/typescript/commonjs/e2e/links.test.d.ts +2 -0
  162. package/lib/typescript/commonjs/e2e/links.test.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/src/MarcusTextDecoratorViewNativeComponent.d.ts +93 -0
  164. package/lib/typescript/commonjs/src/MarcusTextDecoratorViewNativeComponent.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +64 -51
  166. package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/src/MarkdownText.d.ts +127 -0
  168. package/lib/typescript/commonjs/src/MarkdownText.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/src/MarkdownText.web.d.ts +126 -0
  170. package/lib/typescript/commonjs/src/MarkdownText.web.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts +23 -1
  172. package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts +26 -4
  174. package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/src/atomUtils.d.ts +58 -0
  176. package/lib/typescript/commonjs/src/atomUtils.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/src/childrenUtils.d.ts +12 -0
  178. package/lib/typescript/commonjs/src/childrenUtils.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/src/commonTypes.d.ts +39 -3
  180. package/lib/typescript/commonjs/src/commonTypes.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/src/index.d.ts +2 -1
  182. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  183. package/lib/typescript/commonjs/src/math/environment.d.ts +7 -0
  184. package/lib/typescript/commonjs/src/math/environment.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/src/math/index.d.ts +64 -0
  186. package/lib/typescript/commonjs/src/math/index.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/src/math/mathjax.d.ts +63 -0
  188. package/lib/typescript/commonjs/src/math/mathjax.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/src/metro.d.ts +59 -0
  190. package/lib/typescript/commonjs/src/metro.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/src/parser/index.d.ts +3 -3
  192. package/lib/typescript/commonjs/src/parser/index.d.ts.map +1 -1
  193. package/lib/typescript/commonjs/src/parser/micromark-extension-mentions.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/src/rangeUtils.d.ts +1 -1
  195. package/lib/typescript/commonjs/src/stripUtils.d.ts +108 -0
  196. package/lib/typescript/commonjs/src/stripUtils.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/src/styleUtils.d.ts +62 -4
  198. package/lib/typescript/commonjs/src/styleUtils.d.ts.map +1 -1
  199. package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts +32 -4
  200. package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts.map +1 -1
  201. package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts +20 -8
  202. package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts.map +1 -1
  203. package/lib/typescript/commonjs/src/web/utils/elementUtils.d.ts +37 -0
  204. package/lib/typescript/commonjs/src/web/utils/elementUtils.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts +5 -5
  206. package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts.map +1 -1
  207. package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts +6 -1
  208. package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts.map +1 -1
  209. package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts +2 -2
  210. package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts.map +1 -1
  211. package/lib/typescript/module/e2e/links.test.d.ts +2 -0
  212. package/lib/typescript/module/e2e/links.test.d.ts.map +1 -0
  213. package/lib/typescript/module/src/MarcusTextDecoratorViewNativeComponent.d.ts +93 -0
  214. package/lib/typescript/module/src/MarcusTextDecoratorViewNativeComponent.d.ts.map +1 -0
  215. package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +64 -51
  216. package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
  217. package/lib/typescript/module/src/MarkdownText.d.ts +127 -0
  218. package/lib/typescript/module/src/MarkdownText.d.ts.map +1 -0
  219. package/lib/typescript/module/src/MarkdownText.web.d.ts +126 -0
  220. package/lib/typescript/module/src/MarkdownText.web.d.ts.map +1 -0
  221. package/lib/typescript/module/src/MarkdownTextInput.d.ts +23 -1
  222. package/lib/typescript/module/src/MarkdownTextInput.d.ts.map +1 -1
  223. package/lib/typescript/module/src/MarkdownTextInput.web.d.ts +26 -4
  224. package/lib/typescript/module/src/MarkdownTextInput.web.d.ts.map +1 -1
  225. package/lib/typescript/module/src/atomUtils.d.ts +58 -0
  226. package/lib/typescript/module/src/atomUtils.d.ts.map +1 -0
  227. package/lib/typescript/module/src/childrenUtils.d.ts +12 -0
  228. package/lib/typescript/module/src/childrenUtils.d.ts.map +1 -0
  229. package/lib/typescript/module/src/commonTypes.d.ts +39 -3
  230. package/lib/typescript/module/src/commonTypes.d.ts.map +1 -1
  231. package/lib/typescript/module/src/index.d.ts +2 -1
  232. package/lib/typescript/module/src/index.d.ts.map +1 -1
  233. package/lib/typescript/module/src/math/environment.d.ts +7 -0
  234. package/lib/typescript/module/src/math/environment.d.ts.map +1 -0
  235. package/lib/typescript/module/src/math/index.d.ts +64 -0
  236. package/lib/typescript/module/src/math/index.d.ts.map +1 -0
  237. package/lib/typescript/module/src/math/mathjax.d.ts +63 -0
  238. package/lib/typescript/module/src/math/mathjax.d.ts.map +1 -0
  239. package/lib/typescript/module/src/metro.d.ts +59 -0
  240. package/lib/typescript/module/src/metro.d.ts.map +1 -0
  241. package/lib/typescript/module/src/parser/index.d.ts +3 -3
  242. package/lib/typescript/module/src/parser/index.d.ts.map +1 -1
  243. package/lib/typescript/module/src/parser/micromark-extension-mentions.d.ts.map +1 -1
  244. package/lib/typescript/module/src/rangeUtils.d.ts +1 -1
  245. package/lib/typescript/module/src/stripUtils.d.ts +108 -0
  246. package/lib/typescript/module/src/stripUtils.d.ts.map +1 -0
  247. package/lib/typescript/module/src/styleUtils.d.ts +62 -4
  248. package/lib/typescript/module/src/styleUtils.d.ts.map +1 -1
  249. package/lib/typescript/module/src/web/utils/blockLayout.d.ts +32 -4
  250. package/lib/typescript/module/src/web/utils/blockLayout.d.ts.map +1 -1
  251. package/lib/typescript/module/src/web/utils/blockUtils.d.ts +20 -8
  252. package/lib/typescript/module/src/web/utils/blockUtils.d.ts.map +1 -1
  253. package/lib/typescript/module/src/web/utils/elementUtils.d.ts +37 -0
  254. package/lib/typescript/module/src/web/utils/elementUtils.d.ts.map +1 -0
  255. package/lib/typescript/module/src/web/utils/parserUtils.d.ts +5 -5
  256. package/lib/typescript/module/src/web/utils/parserUtils.d.ts.map +1 -1
  257. package/lib/typescript/module/src/web/utils/treeUtils.d.ts +6 -1
  258. package/lib/typescript/module/src/web/utils/treeUtils.d.ts.map +1 -1
  259. package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts +2 -2
  260. package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts.map +1 -1
  261. package/package.json +29 -2
  262. package/react-native.config.js +8 -1
  263. package/src/MarcusTextDecoratorViewNativeComponent.ts +199 -0
  264. package/src/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
  265. package/src/MarkdownText.tsx +472 -0
  266. package/src/MarkdownText.web.tsx +668 -0
  267. package/src/MarkdownTextInput.tsx +42 -38
  268. package/src/MarkdownTextInput.web.tsx +36 -13
  269. package/src/atomUtils.ts +112 -0
  270. package/src/childrenUtils.ts +39 -0
  271. package/src/commonTypes.ts +69 -9
  272. package/src/index.tsx +2 -1
  273. package/src/math/environment.ts +68 -0
  274. package/src/math/index.ts +78 -0
  275. package/src/math/mathjax.ts +604 -0
  276. package/src/metro.ts +238 -0
  277. package/src/parser/index.ts +175 -10
  278. package/src/parser/micromark-extension-mentions.ts +104 -11
  279. package/src/stripUtils.ts +919 -0
  280. package/src/styleUtils.ts +290 -26
  281. package/src/web/MarkdownElements.css +67 -0
  282. package/src/web/MarkdownTextInput.css +9 -7
  283. package/src/web/utils/blockLayout.ts +124 -14
  284. package/src/web/utils/blockUtils.ts +365 -59
  285. package/src/web/utils/elementUtils.ts +87 -0
  286. package/src/web/utils/parserUtils.ts +119 -31
  287. package/src/web/utils/treeUtils.ts +6 -1
  288. package/src/web/utils/webStyleUtils.ts +32 -8
  289. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundColorSpan.kt +0 -6
  290. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBoldSpan.kt +0 -6
  291. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownItalicSpan.kt +0 -6
  292. package/apple/RCTMarcusStyle+Codegen.mm +0 -64
  293. package/apple/RCTMarcusUtils.h +0 -26
  294. package/apple/RCTMarcusUtils.mm +0 -26
@@ -46,10 +46,12 @@ emphasis-adjacent-syntax
46
46
  0..1 color(#808080)
47
47
  2..3 color(#808080)
48
48
  3..4 color(#808080)
49
- 4..8 background(#D3D3D3)
49
+ 4..8 background-shape
50
50
  4..8 color(#000000)
51
51
  4..8 font-family
52
52
  4..8 font-size(16)
53
+ 4..5 gap
54
+ 7..8 gap
53
55
  8..9 color(#808080)
54
56
  emphasis-unterminated
55
57
  (no spans)
@@ -198,54 +200,74 @@ nesting-repeat-adjacent
198
200
  3..4 color(#808080)
199
201
  code-inline
200
202
  5..6 color(#808080)
201
- 6..10 background(#D3D3D3)
203
+ 6..10 background-shape
202
204
  6..10 color(#000000)
203
205
  6..10 font-family
204
206
  6..10 font-size(16)
207
+ 6..7 gap
208
+ 9..10 gap
205
209
  10..11 color(#808080)
206
210
  code-inline-double
207
211
  2..4 color(#808080)
208
- 4..9 background(#D3D3D3)
212
+ 4..9 background-shape
209
213
  4..9 color(#000000)
210
214
  4..9 font-family
211
215
  4..9 font-size(16)
216
+ 4..5 gap
217
+ 8..9 gap
212
218
  9..11 color(#808080)
213
219
  code-fenced
220
+ 0..14 code-block
221
+ 0..14 indent(12,12)
214
222
  0..3 color(#808080)
215
- 4..11 background(#D3D3D3)
216
223
  4..11 color(#000000)
217
224
  4..11 font-family
218
225
  4..11 font-size(16)
219
226
  11..14 color(#808080)
220
227
  code-fenced-lang
228
+ 0..21 code-block
229
+ 0..21 indent(12,12)
221
230
  0..3 color(#808080)
222
- 6..18 background(#D3D3D3)
231
+ 3..5 color(#808080)
223
232
  6..18 color(#000000)
224
233
  6..18 font-family
225
234
  6..18 font-size(16)
226
235
  18..21 color(#808080)
227
236
  code-fenced-unterminated
237
+ 0..10 code-block
238
+ 0..10 indent(12,12)
239
+ 0..3 color(#808080)
240
+ 4..10 color(#000000)
241
+ 4..10 font-family
242
+ 4..10 font-size(16)
243
+ code-fenced-blank-line
244
+ 0..19 code-block
245
+ 0..19 indent(12,12)
228
246
  0..3 color(#808080)
229
- 4..10 background(#D3D3D3)
230
247
  4..10 color(#000000)
231
248
  4..10 font-family
232
249
  4..10 font-size(16)
250
+ 11..16 color(#000000)
251
+ 11..16 font-family
252
+ 11..16 font-size(16)
253
+ 16..19 color(#808080)
233
254
  code-indented
234
- 4..13 background(#D3D3D3)
255
+ 0..12 code-block
256
+ 0..12 indent(12,12)
235
257
  4..13 color(#000000)
236
258
  4..13 font-family
237
259
  4..13 font-size(16)
238
260
  code-in-blockquote
239
- 0..5 indent(18,20)
261
+ 0..5 indent(30,32)
240
262
  0..1 color(#808080)
263
+ 2..20 code-block
241
264
  2..5 color(#808080)
242
- 6..14 indent(18,20)
265
+ 6..14 indent(30,32)
243
266
  6..7 color(#808080)
244
- 8..15 background(#D3D3D3)
245
267
  8..15 color(#000000)
246
268
  8..15 font-family
247
269
  8..15 font-size(16)
248
- 15..20 indent(18,20)
270
+ 15..20 indent(30,32)
249
271
  15..16 color(#808080)
250
272
  17..20 color(#808080)
251
273
  link-inline
@@ -264,6 +286,16 @@ link-title
264
286
  27..28 color(#808080)
265
287
  33..34 color(#808080)
266
288
  34..35 color(#808080)
289
+ link-markup
290
+ 0..1 color(#808080)
291
+ 1..9 bold
292
+ 1..3 color(#808080)
293
+ 7..9 color(#808080)
294
+ 14..15 color(#808080)
295
+ 15..16 color(#808080)
296
+ 16..35 color(#0000FF)
297
+ 16..35 underline
298
+ 35..36 color(#808080)
267
299
  link-reference
268
300
  0..1 color(#808080)
269
301
  5..6 color(#808080)
@@ -296,19 +328,178 @@ image-inline
296
328
  7..32 color(#0000FF)
297
329
  7..32 underline
298
330
  32..33 color(#808080)
331
+ image-title
332
+ 0..1 color(#808080)
333
+ 1..2 color(#808080)
334
+ 5..6 color(#808080)
335
+ 6..7 color(#808080)
336
+ 7..32 color(#0000FF)
337
+ 7..32 underline
338
+ 33..34 color(#808080)
339
+ 39..40 color(#808080)
340
+ 40..41 color(#808080)
341
+ image-in-text
342
+ 3..4 color(#808080)
343
+ 4..5 color(#808080)
344
+ 9..10 color(#808080)
345
+ 10..11 color(#808080)
346
+ 11..36 color(#0000FF)
347
+ 11..36 underline
348
+ 36..37 color(#808080)
349
+ image-alt-markup
350
+ 0..1 color(#808080)
351
+ 1..2 color(#808080)
352
+ 2..4 color(#808080)
353
+ 8..10 color(#808080)
354
+ 14..15 color(#808080)
355
+ 15..16 color(#808080)
356
+ 16..41 color(#0000FF)
357
+ 16..41 underline
358
+ 41..42 color(#808080)
359
+ image-alt-emoji
360
+ 0..1 color(#808080)
361
+ 1..2 color(#808080)
362
+ 8..10 font-family
363
+ 8..10 font-size(16)
364
+ 15..16 color(#808080)
365
+ 16..17 color(#808080)
366
+ 17..42 color(#0000FF)
367
+ 17..42 underline
368
+ 42..43 color(#808080)
369
+ image-in-blockquote
370
+ 0..35 indent(18,20)
371
+ 0..1 color(#808080)
372
+ 2..3 color(#808080)
373
+ 3..4 color(#808080)
374
+ 7..8 color(#808080)
375
+ 8..9 color(#808080)
376
+ 9..34 color(#0000FF)
377
+ 9..34 underline
378
+ 34..35 color(#808080)
379
+ link-label-url
380
+ 0..1 color(#808080)
381
+ 18..19 color(#808080)
382
+ 19..20 color(#808080)
383
+ 20..38 color(#0000FF)
384
+ 20..38 underline
385
+ 38..39 color(#808080)
386
+ link-label-autolink
387
+ 0..1 color(#808080)
388
+ 1..2 color(#808080)
389
+ 15..16 color(#808080)
390
+ 16..17 color(#808080)
391
+ 17..18 color(#808080)
392
+ 18..37 color(#0000FF)
393
+ 18..37 underline
394
+ 37..38 color(#808080)
395
+ link-label-image
396
+ 0..1 color(#808080)
397
+ 3..4 color(#808080)
398
+ 4..5 color(#808080)
399
+ 8..9 color(#808080)
400
+ 9..10 color(#808080)
401
+ 10..35 color(#0000FF)
402
+ 10..35 underline
403
+ 35..36 color(#808080)
404
+ 38..39 color(#808080)
405
+ 39..40 color(#808080)
406
+ 40..59 color(#0000FF)
407
+ 40..59 underline
408
+ 59..60 color(#808080)
409
+ link-image
410
+ 0..1 color(#808080)
411
+ 1..2 color(#808080)
412
+ 2..3 color(#808080)
413
+ 6..7 color(#808080)
414
+ 7..8 color(#808080)
415
+ 8..33 color(#0000FF)
416
+ 8..33 underline
417
+ 33..34 color(#808080)
418
+ 34..35 color(#808080)
419
+ 35..36 color(#808080)
420
+ 36..55 color(#0000FF)
421
+ 36..55 underline
422
+ 55..56 color(#808080)
299
423
  mention
300
424
  4..12 background-shape
301
425
  4..12 color(#0000FF)
426
+ 4..5 gap
427
+ 11..12 gap
302
428
  mention-hyphen
303
- (no spans)
429
+ 0..9 background-shape
430
+ 0..9 color(#0000FF)
431
+ 0..1 gap
432
+ 8..9 gap
433
+ mention-underscore
434
+ 0..9 background-shape
435
+ 0..9 color(#0000FF)
436
+ 0..1 gap
437
+ 8..9 gap
304
438
  mention-trailing-hyphen
439
+ 0..8 background-shape
440
+ 0..8 color(#0000FF)
441
+ 0..1 gap
442
+ 7..8 gap
443
+ mention-dot
444
+ 0..8 background-shape
445
+ 0..8 color(#0000FF)
446
+ 0..1 gap
447
+ 7..8 gap
448
+ 13..23 background-shape
449
+ 13..23 color(#0000FF)
450
+ 13..14 gap
451
+ 22..23 gap
452
+ mention-double-dot
453
+ 0..8 background-shape
454
+ 0..8 color(#0000FF)
455
+ 0..1 gap
456
+ 7..8 gap
457
+ mention-at
458
+ 4..21 background-shape
459
+ 4..21 color(#0000FF)
460
+ 4..5 gap
461
+ 20..21 gap
462
+ mention-trailing-at
463
+ 0..5 background-shape
464
+ 0..5 color(#0000FF)
465
+ 0..1 gap
466
+ 4..5 gap
467
+ mention-leading-at
468
+ (no spans)
469
+ mention-mid-word
305
470
  (no spans)
471
+ mention-punctuation
472
+ 3..8 background-shape
473
+ 3..8 color(#0000FF)
474
+ 3..4 gap
475
+ 7..8 gap
306
476
  mention-in-bold
307
477
  0..12 bold
308
478
  0..2 color(#808080)
309
479
  2..10 background-shape
310
480
  2..10 color(#0000FF)
481
+ 2..3 gap
482
+ 9..10 gap
311
483
  10..12 color(#808080)
484
+ mention-in-italic-underscore
485
+ 0..10 italic
486
+ 0..1 color(#808080)
487
+ 1..9 background-shape
488
+ 1..9 color(#0000FF)
489
+ 1..2 gap
490
+ 8..9 gap
491
+ 9..10 color(#808080)
492
+ mention-in-link
493
+ 0..1 color(#808080)
494
+ 1..6 background-shape
495
+ 1..6 color(#0000FF)
496
+ 1..2 gap
497
+ 5..6 gap
498
+ 6..7 color(#808080)
499
+ 7..8 color(#808080)
500
+ 8..27 color(#0000FF)
501
+ 8..27 underline
502
+ 27..28 color(#808080)
312
503
  emoji
313
504
  6..8 font-family
314
505
  6..8 font-size(16)
@@ -423,10 +614,12 @@ cjk-blockquote
423
614
  0..1 color(#808080)
424
615
  cjk-code
425
616
  0..1 color(#808080)
426
- 1..5 background(#D3D3D3)
617
+ 1..5 background-shape
427
618
  1..5 color(#000000)
428
619
  1..5 font-family
429
620
  1..5 font-size(16)
621
+ 1..2 gap
622
+ 4..5 gap
430
623
  5..6 color(#808080)
431
624
  cjk-link
432
625
  0..1 color(#808080)
@@ -438,6 +631,8 @@ cjk-link
438
631
  cjk-mention
439
632
  4..8 background-shape
440
633
  4..8 color(#0000FF)
634
+ 4..5 gap
635
+ 7..8 gap
441
636
  cjk-combining-dakuten
442
637
  (no spans)
443
638
  unicode-rtl
@@ -481,10 +676,12 @@ rtl-link
481
676
  29..30 color(#808080)
482
677
  rtl-code
483
678
  0..1 color(#808080)
484
- 1..5 background(#D3D3D3)
679
+ 1..5 background-shape
485
680
  1..5 color(#000000)
486
681
  1..5 font-family
487
682
  1..5 font-size(16)
683
+ 1..2 gap
684
+ 4..5 gap
488
685
  5..6 color(#808080)
489
686
  rtl-arabic-indic-digits
490
687
  (no spans)
@@ -507,6 +704,8 @@ rtl-punctuation
507
704
  rtl-mention
508
705
  0..7 background-shape
509
706
  0..7 color(#0000FF)
707
+ 0..1 gap
708
+ 6..7 gap
510
709
  empty
511
710
  (no spans)
512
711
  whitespace-only
@@ -551,10 +750,12 @@ kitchen-sink
551
750
  39..41 color(#808080)
552
751
  47..49 color(#808080)
553
752
  60..61 color(#808080)
554
- 61..65 background(#D3D3D3)
753
+ 61..65 background-shape
555
754
  61..65 color(#000000)
556
755
  61..65 font-family
557
756
  61..65 font-size(16)
757
+ 61..62 gap
758
+ 64..65 gap
558
759
  65..66 color(#808080)
559
760
  69..113 indent(18,20)
560
761
  69..70 color(#808080)
@@ -571,13 +772,17 @@ kitchen-sink
571
772
  137..148 indent(50,55)
572
773
  139..140 color(#808080)
573
774
  140..141 color(#808080)
775
+ 150..171 code-block
776
+ 150..171 indent(12,12)
574
777
  150..153 color(#808080)
575
- 156..168 background(#D3D3D3)
778
+ 153..155 color(#808080)
576
779
  156..168 color(#000000)
577
780
  156..168 font-family
578
781
  156..168 font-size(16)
579
782
  168..171 color(#808080)
580
783
  177..185 background-shape
581
784
  177..185 color(#0000FF)
785
+ 177..178 gap
786
+ 184..185 gap
582
787
  186..188 font-family
583
788
  186..188 font-size(16)
@@ -0,0 +1,25 @@
1
+ #import <objc/runtime.h>
2
+
3
+ // Installs `swizzledSelector` in place of `originalSelector` on `cls`.
4
+ //
5
+ // method_exchangeImplementations alone is only safe when `cls` implements
6
+ // `originalSelector` itself. For an inherited method -- didAddSubview:, for
7
+ // instance -- class_getInstanceMethod returns the *superclass's* method, and
8
+ // exchanging it rewrites UIView for every view in the app. So the
9
+ // implementation is added to this class first; when that succeeds, the
10
+ // "call the original" selector is pointed at the inherited implementation.
11
+ static inline void
12
+ RCTMarcusSwizzle(Class cls, SEL originalSelector, SEL swizzledSelector) {
13
+ Method originalMethod = class_getInstanceMethod(cls, originalSelector);
14
+ Method swizzledMethod = class_getInstanceMethod(cls, swizzledSelector);
15
+ if (originalMethod == NULL || swizzledMethod == NULL) {
16
+ return;
17
+ }
18
+
19
+ BOOL didAddMethod = class_addMethod(cls, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
20
+ if (didAddMethod) {
21
+ class_replaceMethod(cls, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
22
+ } else {
23
+ method_exchangeImplementations(originalMethod, swizzledMethod);
24
+ }
25
+ }
@@ -0,0 +1,22 @@
1
+ #import <React/RCTViewComponentView.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ // The decorator has a host view only because unsetting `ForceFlattenView` in
6
+ // the shadow node forces one; nothing is drawn into it and nothing is observed
7
+ // on it. All of the formatting happens in the text layout manager the shadow
8
+ // node hands to the child paragraph.
9
+ @interface MarcusTextDecoratorComponentView : RCTViewComponentView
10
+
11
+ // `attributedText`'s string with every placeholder character written back out
12
+ // as the markdown it stands for, or nil when this paragraph has none.
13
+ //
14
+ // The offsets come from JavaScript, measured against the stripped text -- the
15
+ // same string the ranges are measured against, and the same one React Native
16
+ // laid out, since a view nested in a `Text` costs exactly the one character the
17
+ // strip left behind. So nothing has to be remapped here.
18
+ - (nullable NSString *)substitutedTextOf:(NSAttributedString *)attributedText;
19
+
20
+ @end
21
+
22
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,72 @@
1
+ #import <React/RCTConversions.h>
2
+ #import <React/RCTFabricComponentsPlugins.h>
3
+ #import <react/renderer/components/RNMarcusSpec/Props.h>
4
+
5
+ #import <RNMarcus/MarcusTextDecoratorComponentView.h>
6
+ #import <RNMarcus/MarcusTextDecoratorViewComponentDescriptor.h>
7
+ #import <RNMarcus/MarkdownSwiftInterop.h>
8
+
9
+ using namespace facebook::react;
10
+
11
+ @implementation MarcusTextDecoratorComponentView
12
+
13
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
14
+ return concreteComponentDescriptorProvider<
15
+ MarcusTextDecoratorViewComponentDescriptor>();
16
+ }
17
+
18
+ // Needed because of this: https://github.com/facebook/react-native/pull/37274
19
+ + (void)load {
20
+ [super load];
21
+ }
22
+
23
+ - (instancetype)initWithFrame:(CGRect)frame {
24
+ if (self = [super initWithFrame:frame]) {
25
+ static const auto defaultProps =
26
+ std::make_shared<const MarcusTextDecoratorViewProps>();
27
+ _props = defaultProps;
28
+ }
29
+
30
+ return self;
31
+ }
32
+
33
+ - (void)prepareForRecycle {
34
+ [super prepareForRecycle];
35
+
36
+ static const auto defaultProps =
37
+ std::make_shared<const MarcusTextDecoratorViewProps>();
38
+ _props = defaultProps;
39
+ }
40
+
41
+ - (NSString *)substitutedTextOf:(NSAttributedString *)attributedText {
42
+ const auto &props =
43
+ static_cast<const MarcusTextDecoratorViewProps &>(*_props);
44
+
45
+ if (props.substitutions.empty() || attributedText.length == 0) {
46
+ return nil;
47
+ }
48
+
49
+ // Carried across as two plain arrays and handed to Swift, which is where the
50
+ // rule about what a copy looks like lives. This end only translates: props
51
+ // are C++ and cannot be seen from Swift at all.
52
+ NSMutableArray<NSNumber *> *indices =
53
+ [NSMutableArray arrayWithCapacity:props.substitutions.size()];
54
+ NSMutableArray<NSString *> *sources =
55
+ [NSMutableArray arrayWithCapacity:props.substitutions.size()];
56
+
57
+ for (const auto &substitution : props.substitutions) {
58
+ [indices addObject:@(substitution.index)];
59
+ [sources addObject:RCTNSStringFromString(substitution.text)];
60
+ }
61
+
62
+ return [MarkdownCopy substituteInto:attributedText.string
63
+ indices:indices
64
+ sources:sources];
65
+ }
66
+
67
+ Class<RCTComponentViewProtocol>
68
+ MarcusTextDecoratorViewCls(void) {
69
+ return MarcusTextDecoratorComponentView.class;
70
+ }
71
+
72
+ @end
@@ -0,0 +1,62 @@
1
+ #pragma once
2
+
3
+ #include <react/renderer/components/RNMarcusSpec/EventEmitters.h>
4
+ #include <react/renderer/components/RNMarcusSpec/MarcusTextDecoratorState.h>
5
+ #include <react/renderer/components/RNMarcusSpec/Props.h>
6
+
7
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
8
+ #include <react/renderer/core/LayoutContext.h>
9
+ #include <react/renderer/textlayoutmanager/TextLayoutManager.h>
10
+
11
+ #include <memory>
12
+
13
+ namespace facebook {
14
+ namespace react {
15
+
16
+ JSI_EXPORT extern const char MarcusTextDecoratorViewComponentName[];
17
+
18
+ /*
19
+ * Wraps a `Text` and swaps the text layout manager underneath it.
20
+ *
21
+ * Deliberately much less invasive than its `TextInput` counterpart. A paragraph
22
+ * measures itself through its own layout manager, so replacing that manager is
23
+ * enough to reach measurement, drawing and hit testing alike -- there is no
24
+ * Yoga measure callback to hijack, no cast past `private`, and no state to
25
+ * write into. All that is left of the original technique is unsetting
26
+ * `ForceFlattenView` so the decorator gets a host view, and copying the child's
27
+ * layout metrics back up so wrapping it changes nothing about layout.
28
+ */
29
+ class JSI_EXPORT MarcusTextDecoratorShadowNode final
30
+ : public ConcreteViewShadowNode<MarcusTextDecoratorViewComponentName, MarcusTextDecoratorViewProps, MarcusTextDecoratorViewEventEmitter, MarcusTextDecoratorState> {
31
+ public:
32
+ MarcusTextDecoratorShadowNode(ShadowNodeFragment const &fragment, ShadowNodeFamily::Shared const &family, ShadowNodeTraits traits);
33
+
34
+ MarcusTextDecoratorShadowNode(ShadowNode const &sourceShadowNode, ShadowNodeFragment const &fragment);
35
+
36
+ void
37
+ appendChild(const std::shared_ptr<const ShadowNode> &child) override;
38
+
39
+ void
40
+ replaceChild(const ShadowNode &oldChild, const std::shared_ptr<const ShadowNode> &newChild, size_t suggestedIndex = SIZE_MAX) override;
41
+
42
+ void
43
+ layout(LayoutContext layoutContext) override;
44
+
45
+ private:
46
+ void
47
+ initialize();
48
+
49
+ void
50
+ makeChildNodeMutable();
51
+
52
+ void
53
+ createTextLayoutManager();
54
+
55
+ void
56
+ overwriteTextLayoutManager();
57
+
58
+ std::shared_ptr<const TextLayoutManager> textLayoutManager_;
59
+ };
60
+
61
+ } // namespace react
62
+ } // namespace facebook