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
@@ -0,0 +1,7 @@
1
+ /**
2
+ * What MathJax and SRE assume about their host that React Native does not
3
+ * provide. Imported before either of them, and first, because `import`
4
+ * statements are hoisted and run in the order they are written.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../src/math/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+DH,OAAO,EAAE,CAAA"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The maths backend, in its "there isn't one" form.
3
+ *
4
+ * Typesetting TeX takes a library an order of magnitude larger than this one,
5
+ * and most applications will never draw an equation. So the real backend --
6
+ * `./mathjax.ts`, right beside this -- is never imported by anything: a
7
+ * bundler would follow the import and pull MathJax into every app that has
8
+ * ever installed this package, whether or not it renders maths.
9
+ *
10
+ * Instead the two are swapped at build time. `react-native-marcus/metro`'s
11
+ * `withMath()` resolves this module to that one, so an application opts in by
12
+ * editing its `metro.config.js` and the default bundle carries nothing.
13
+ *
14
+ * What the swap has to preserve is this shape and nothing else.
15
+ */
16
+ /** One expression, drawn, with the box it needs. */
17
+ interface RenderedMath {
18
+ /**
19
+ * A standalone SVG document: glyph outlines inline, no `<use>`, no `<defs>`,
20
+ * and the colour already substituted in.
21
+ */
22
+ svg: string;
23
+ /** Points, at the font size that was asked for. */
24
+ width: number;
25
+ height: number;
26
+ /**
27
+ * How far below the baseline the drawing hangs -- zero for `x^2`, real for
28
+ * `\frac{a}{b}`. Part of the picture rather than of the size: `height`
29
+ * already covers it.
30
+ */
31
+ depth: number;
32
+ }
33
+ /**
34
+ * Whether maths can be drawn at all.
35
+ *
36
+ * Read by the display components, which leave a maths span exactly as it was
37
+ * written when this is false. Showing `$$x^2$$` is a good deal better than
38
+ * showing an empty box where an equation should be, and it is the one hint an
39
+ * application will get that its Metro config is missing a line.
40
+ */
41
+ declare const available = false;
42
+ declare function renderMath(_tex: string, _display: boolean, _fontSize: number, _color: string | undefined): RenderedMath | null;
43
+ /**
44
+ * The expression as it should be read out, or nothing.
45
+ *
46
+ * A drawn equation is a picture, and the TeX behind it is source code: an
47
+ * author reading `\frac{a}{b}` knows what it means, and a reader who asked
48
+ * for a document rather than for its markup hears three words of punctuation.
49
+ * So a display says what it drew -- "StartFraction a Over b EndFraction" --
50
+ * while an input, where the TeX is what is on the screen and what the caret
51
+ * moves through, keeps the TeX.
52
+ *
53
+ * `locale` is the language it should be said in, as a name the backend knows;
54
+ * nothing means the backend's own default. What a document is written in and
55
+ * what its reader speaks are two different questions, and only the application
56
+ * knows the answer to the second.
57
+ *
58
+ * Returning nothing means the caller falls back to the TeX, which is what the
59
+ * stub does and what a backend does for an expression it cannot say.
60
+ */
61
+ declare function speakMath(_tex: string, _display: boolean, _locale?: string): string | null;
62
+ export type { RenderedMath };
63
+ export { available, renderMath, speakMath };
64
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/math/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oDAAoD;AACpD,UAAU,YAAY;IACpB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS,QAAQ,CAAA;AAEvB,iBAAS,UAAU,CACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,YAAY,GAAG,IAAI,CAErB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEnF;AAED,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * TeX -> SVG with MathJax 4, wired up the way React Native needs.
3
+ *
4
+ * Nothing imports this module. `react-native-marcus/metro`'s `withMath()`
5
+ * resolves `./index.ts` -- the stub beside it -- to this file, which is how an
6
+ * application opts into a dependency this size. See `./index.ts`.
7
+ *
8
+ * Three things here are not the defaults:
9
+ *
10
+ * - **`liteAdaptor`**, so nothing wants a DOM. It runs the same in Hermes, in a
11
+ * browser and in Node, which is what makes one renderer serve all three
12
+ * platforms and draw the same glyphs on each.
13
+ * - **`fontCache: "none"`**, so each expression is a standalone SVG with its
14
+ * glyph outlines inline. `"local"`, the default, emits `<use>` against a
15
+ * `<defs>` block, which is smaller on a page full of maths and useless when
16
+ * every expression is a separate attachment in someone else's view tree.
17
+ * - **`linebreaks: { inline: false }`**. v4 breaks long inline maths into
18
+ * several `<svg>` fragments separated by `<mjx-break>`; one attachment is one
19
+ * SVG, and left on, the metrics read off the first fragment are silently
20
+ * wrong.
21
+ *
22
+ * Every specifier below names `mjs/` outright rather than going through
23
+ * MathJax's `js/*` export, and that is not cosmetic. That export maps to `mjs`
24
+ * for `import` and to `cjs` for `require`, so a module reached both ways --
25
+ * which is exactly what this file does, importing the machinery and requiring
26
+ * the font ranges -- is loaded twice, and the two copies each hold half of what
27
+ * is needed. The symptom is every `\mathbb`, `\mathcal`, `\mathfrak`,
28
+ * `\mathsf` and `\mathtt` coming out blank while everything else draws
29
+ * perfectly. `mjs/` goes through the package's `"./*": "./*"` fallback, which
30
+ * has no conditions to disagree about.
31
+ */
32
+ import "./environment";
33
+ import "@mathjax/src/mjs/input/tex/base/BaseConfiguration.js";
34
+ import "@mathjax/src/mjs/input/tex/ams/AmsConfiguration.js";
35
+ import "@mathjax/src/mjs/input/tex/newcommand/NewcommandConfiguration.js";
36
+ import "@mathjax/src/mjs/input/tex/boldsymbol/BoldsymbolConfiguration.js";
37
+ import type { RenderedMath } from "./index";
38
+ declare const available = true;
39
+ /**
40
+ * TeX in, one standalone SVG and its box out.
41
+ *
42
+ * The box is read off the root element rather than measured: MathJax reports
43
+ * width, height and the depth below the baseline in `ex`, and an `ex` is half
44
+ * the font size by its own `exFactor`. So nothing has to be laid out to find
45
+ * out how much room to ask for -- which is exactly what a text layout needs to
46
+ * know before it can lay the line out.
47
+ *
48
+ * Returns nothing for an expression it cannot draw, rather than throwing. TeX
49
+ * that reaches for something the bundled fonts do not carry ends in a
50
+ * `RangeError`, and one bad equation should cost the equation rather than the
51
+ * message it is in.
52
+ */
53
+ declare function renderMath(tex: string, display: boolean, fontSize: number, color: string | undefined): RenderedMath | null;
54
+ /**
55
+ * TeX in, the expression as a sentence out.
56
+ *
57
+ * Returns nothing for anything it cannot say, which includes TeX that does not
58
+ * parse and a document where the rules never loaded.
59
+ */
60
+ declare function speakMath(tex: string, display: boolean, locale?: string): string | null;
61
+ export type { RenderedMath };
62
+ export { available, renderMath, speakMath };
63
+ //# sourceMappingURL=mathjax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mathjax.d.ts","sourceRoot":"","sources":["../../../../../src/math/mathjax.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,eAAe,CAAA;AAqBtB,OAAO,sDAAsD,CAAA;AAC7D,OAAO,oDAAoD,CAAA;AAC3D,OAAO,kEAAkE,CAAA;AACzE,OAAO,kEAAkE,CAAA;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAyJ3C,QAAA,MAAM,SAAS,OAAO,CAAA;AAqBtB;;;;;;;;;;;;;GAaG;AACH,iBAAS,UAAU,CACjB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,YAAY,GAAG,IAAI,CAqBrB;AAyRD;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyChF;AAED,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
@@ -0,0 +1,59 @@
1
+ /** As much of a Metro config as this touches. */
2
+ interface MetroConfig {
3
+ resolver?: {
4
+ resolveRequest?: ResolveRequest;
5
+ [key: string]: unknown;
6
+ };
7
+ [key: string]: unknown;
8
+ }
9
+ type Resolution = {
10
+ type?: string;
11
+ filePath?: string;
12
+ } | null | undefined;
13
+ type ResolveRequest = (context: unknown, moduleName: string, platform: string | null) => Resolution;
14
+ interface WithMathOptions {
15
+ /**
16
+ * The package whose `imports` field is read, in case a fork or a pinned copy
17
+ * is installed under another name.
18
+ *
19
+ * @default "@mathjax/src"
20
+ */
21
+ packageName?: string;
22
+ /**
23
+ * This library, in case it is installed under another name. Its own directory
24
+ * is what bounds the backend swap below.
25
+ *
26
+ * @default "react-native-marcus"
27
+ */
28
+ libraryName?: string;
29
+ /**
30
+ * The languages maths can be read out in, as the speech engine names them:
31
+ * `af`, `ca`, `da`, `de`, `en`, `es`, `fr`, `hi`, `it`, `ko`, `nb`, `nn` and
32
+ * `sv`. Everything else is left out of the bundle.
33
+ *
34
+ * This is what `MarkdownText`'s `mathAccessibilityLocale` can choose between.
35
+ * It is a build-time list rather than a runtime one for the same reason
36
+ * MathJax itself is: the rules for one language are around 300KB, and an
37
+ * application that reads its maths in English has no business carrying the
38
+ * four megabytes of rules for the twelve languages it does not. Naming the
39
+ * ones you support is the same thing you already do for your own
40
+ * translations.
41
+ *
42
+ * A locale asked for and not bundled is read in English instead, with a
43
+ * warning in the console saying so.
44
+ *
45
+ * @default ["en"]
46
+ */
47
+ locales?: string[];
48
+ }
49
+ /**
50
+ * Teaches Metro to resolve MathJax, and points the library's maths backend at
51
+ * it.
52
+ *
53
+ * Any `resolveRequest` already on the config is kept and called for everything
54
+ * else, so this composes with whatever else the application is doing.
55
+ */
56
+ declare function withMath(config: MetroConfig, options?: WithMathOptions): MetroConfig;
57
+ export type { MetroConfig, WithMathOptions };
58
+ export { withMath };
59
+ //# sourceMappingURL=metro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metro.d.ts","sourceRoot":"","sources":["../../../../src/metro.ts"],"names":[],"mappings":"AAiCA,iDAAiD;AACjD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE;QACT,cAAc,CAAC,EAAE,cAAc,CAAA;QAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;IACD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,KAAK,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzE,KAAK,cAAc,GAAG,CACpB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,KACpB,UAAU,CAAA;AAMf,UAAU,eAAe;IACvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAoFD;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,WAAW,CAkDjF;AAMD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -1,8 +1,8 @@
1
- import type { MarkdownRange } from "../commonTypes";
1
+ import type { MarkdownParser, MarkdownRange, ParserOptions } from "../commonTypes";
2
2
  declare module "./index" {
3
- function parse(markdown: string): MarkdownRange[];
3
+ function createParser(options?: ParserOptions): MarkdownParser;
4
4
  }
5
5
  declare global {
6
- function __parse__micromark(markdown: string): MarkdownRange[];
6
+ function __parse__micromark(markdown: string, options?: ParserOptions): MarkdownRange[];
7
7
  }
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/parser/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AA8JjE,OAAO,QAAQ,SAAS,CAAC;IACvB,SAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,CAAA;CACzD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,SAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,CAAA;CAC/D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/parser/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAgB,aAAa,EAAE,MAAM,gBAAgB,CAAA;AA2MhG,OAAO,QAAQ,SAAS,CAAC;IACvB,SAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,cAAc,CAAA;CACtE;AAED,OAAO,CAAC,MAAM,CAAC;IACb,SAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,CAAA;CACxF"}
@@ -1 +1 @@
1
- {"version":3,"file":"micromark-extension-mentions.d.ts","sourceRoot":"","sources":["../../../../../src/parser/micromark-extension-mentions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAS,MAAM,sBAAsB,CAAA;AAM3E,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,YAAY;QACpB,OAAO,EAAE,SAAS,CAAA;KACnB;CACF;AAOD,wBAAgB,QAAQ,IAAI,SAAS,CAMpC"}
1
+ {"version":3,"file":"micromark-extension-mentions.d.ts","sourceRoot":"","sources":["../../../../../src/parser/micromark-extension-mentions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EAGV,MAAM,sBAAsB,CAAA;AAU7B,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,YAAY;QACpB,OAAO,EAAE,SAAS,CAAA;KACnB;CACF;AAmBD,wBAAgB,QAAQ,IAAI,SAAS,CAMpC"}
@@ -1,5 +1,5 @@
1
1
  import type { MarkdownRange } from "./commonTypes";
2
- declare function getTagPriority(tag: string): 0 | 1 | -1 | 3 | 2;
2
+ declare function getTagPriority(tag: string): 0 | 2 | 1 | -1 | 3;
3
3
  declare function sortRanges(ranges: MarkdownRange[]): MarkdownRange[];
4
4
  declare function ungroupRanges(ranges: MarkdownRange[]): MarkdownRange[];
5
5
  export { getTagPriority, sortRanges, ungroupRanges };
@@ -0,0 +1,108 @@
1
+ import type { MarkdownRange } from "./commonTypes";
2
+ /** What an image stood for, for a caller that has something to show instead. */
3
+ interface MarkdownEmbed {
4
+ /** Where the placeholder character stands in the stripped text. */
5
+ index: number;
6
+ uri: string;
7
+ alt: string;
8
+ /** Empty when the image was written without one, never absent. */
9
+ title: string;
10
+ /**
11
+ * Whether the image shares its line with anything else.
12
+ *
13
+ * An image is written inline and is laid out inline either way, but what it
14
+ * is for depends on what is around it: alone on a line it is a figure, and
15
+ * in the middle of a sentence it is a badge or an emoji. Only the caller can
16
+ * pick a size, and this is what that decision is usually made on.
17
+ *
18
+ * A block marker does not count as company -- an image alone in a list item
19
+ * or a quote is still alone -- and another image does.
20
+ */
21
+ inline: boolean;
22
+ }
23
+ /** A maths span, for a caller that has something to draw it with. */
24
+ interface MarkdownMath {
25
+ /** Where the placeholder character stands in the stripped text. */
26
+ index: number;
27
+ /**
28
+ * The TeX between the dollars, with the dollars and the padding of `$ x $`
29
+ * taken off and the surrounding whitespace of a `$$` block trimmed. Never
30
+ * empty: a span with nothing in it is dropped rather than reported.
31
+ */
32
+ tex: string;
33
+ /**
34
+ * Whether it was written as a `$$` block on lines of its own, which is what
35
+ * decides whether TeX sets it in display style: bigger operators, limits
36
+ * above and below a sum rather than beside it. Where it sits on the page is
37
+ * the block layout's business, not the typesetter's.
38
+ */
39
+ display: boolean;
40
+ }
41
+ /** A link the display can hand to whatever is going to act on a press. */
42
+ interface MarkdownLink {
43
+ /** Where the link's text stands in the stripped text. */
44
+ start: number;
45
+ length: number;
46
+ uri: string;
47
+ /** The text between the brackets, which is all that is left of the link. */
48
+ label: string;
49
+ /** Empty when the link was written without one, never absent. */
50
+ title: string;
51
+ }
52
+ interface StrippedMarkdown {
53
+ text: string;
54
+ ranges: MarkdownRange[];
55
+ embeds: MarkdownEmbed[];
56
+ maths: MarkdownMath[];
57
+ links: MarkdownLink[];
58
+ }
59
+ interface StripOptions {
60
+ /**
61
+ * Replace each image with a single placeholder character and report what it
62
+ * stood for, instead of leaving its alt text behind as prose.
63
+ *
64
+ * One character because that is exactly what a view mounted inside text costs
65
+ * the platform: both iOS and Android splice a single U+FFFC into the string
66
+ * the formatters index, in place of the attachment. So the ranges this
67
+ * returns are already right for a `Text` whose children have the embed
68
+ * spliced in where the placeholder is.
69
+ */
70
+ embeds?: boolean;
71
+ /**
72
+ * Replace each maths span with a single placeholder character and report the
73
+ * TeX it stood for, instead of leaving `$x^2$` behind as prose.
74
+ *
75
+ * The same one character an embed costs, for the same reason: what draws the
76
+ * maths is a view mounted in the text, and a view in a text is one character
77
+ * to both platforms.
78
+ */
79
+ math?: boolean;
80
+ /**
81
+ * Report where each link ended up and where it points.
82
+ *
83
+ * The destination is removed along with the rest of the markup, so a display
84
+ * that means to do something when a link is pressed has to be told here or
85
+ * not at all.
86
+ */
87
+ links?: boolean;
88
+ }
89
+ /**
90
+ * The character standing in for an embed, matching what the platforms use for
91
+ * an attachment so that the stripped text and the string that reaches the
92
+ * formatters are the same length.
93
+ */
94
+ declare const OBJECT_REPLACEMENT = "\uFFFC";
95
+ /**
96
+ * Removes the markdown syntax from `text` and rewrites `ranges` to index what
97
+ * is left.
98
+ *
99
+ * Ranges are only ever dropped or shortened, never reordered, so the emission
100
+ * order the native formatters depend on survives -- a `block-prefix` still
101
+ * arrives immediately before its container, and a container that lost its
102
+ * marker entirely arrives with none, which is exactly the gutter-without-marker
103
+ * case the block layout already handles.
104
+ */
105
+ declare function stripSyntax(text: string, ranges: MarkdownRange[], options?: StripOptions): StrippedMarkdown;
106
+ export type { MarkdownEmbed, MarkdownMath, MarkdownLink, StrippedMarkdown, StripOptions };
107
+ export { OBJECT_REPLACEMENT, stripSyntax };
108
+ //# sourceMappingURL=stripUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripUtils.d.ts","sourceRoot":"","sources":["../../../../src/stripUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAalD,gFAAgF;AAChF,UAAU,aAAa;IACrB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;;;OAUG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,qEAAqE;AACrE,UAAU,YAAY;IACpB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,0EAA0E;AAC1E,UAAU,YAAY;IACpB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB;AAED,UAAU,YAAY;IACpB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,WAAW,CAAA;AAglBnC;;;;;;;;;GASG;AACH,iBAAS,WAAW,CAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,GAAE,YAAiB,GACzB,gBAAgB,CAsMlB;AAED,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA;AAEzF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAA"}
@@ -1,8 +1,66 @@
1
- import type { MarkdownStyle } from "./MarcusTextInputDecoratorViewNativeComponent";
2
- type PartialMarkdownStyle = Partial<{
1
+ import type { TextStyle, ViewStyle } from "react-native";
2
+ import type { MarkdownEmojiStyle, MarkdownStyle } from "./MarcusTextInputDecoratorViewNativeComponent";
3
+ type MarkdownTextStyleProps = Pick<TextStyle, "color" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textDecorationLine" | "textDecorationColor" | "textDecorationStyle" | "textShadowColor" | "textShadowOffset" | "textShadowRadius">;
4
+ type MarkdownBoxStyleProps = MarkdownTextStyleProps & Pick<ViewStyle, "backgroundColor" | "borderColor" | "borderWidth" | "borderRadius" | "padding" | "paddingHorizontal" | "paddingVertical" | "margin" | "marginHorizontal" | "marginVertical"> & {
5
+ padding?: number;
6
+ paddingHorizontal?: number;
7
+ paddingVertical?: number;
8
+ margin?: number;
9
+ marginHorizontal?: number;
10
+ marginVertical?: number;
11
+ borderWidth?: number;
12
+ borderRadius?: number;
13
+ };
14
+ type MarkdownHeadingStyleProps = MarkdownTextStyleProps & {
15
+ scale?: number;
16
+ };
17
+ type MarkdownBlockquoteStyleProps = MarkdownTextStyleProps & Pick<ViewStyle, "borderColor"> & {
18
+ borderWidth?: number;
19
+ borderRadius?: number;
20
+ marginStart?: number;
21
+ paddingStart?: number;
22
+ };
23
+ type MarkdownListStyleProps = {
24
+ marginStart?: number;
25
+ paddingStart?: number;
26
+ markerScale?: number;
27
+ markerPadding?: number;
28
+ marker?: MarkdownTextStyleProps;
29
+ };
30
+ /**
31
+ * A markdown style as it is written: every entry optional, every property
32
+ * optional, and anything left out taken from the defaults below.
33
+ */
34
+ type PartialMarkdownStyle = {
35
+ syntax?: MarkdownTextStyleProps;
36
+ emoji?: MarkdownEmojiStyle;
37
+ link?: MarkdownTextStyleProps;
38
+ strong?: MarkdownTextStyleProps;
39
+ emphasis?: MarkdownTextStyleProps;
40
+ strikethrough?: MarkdownTextStyleProps;
41
+ heading?: MarkdownHeadingStyleProps;
42
+ blockquote?: MarkdownBlockquoteStyleProps;
43
+ orderedList?: MarkdownListStyleProps;
44
+ unorderedList?: MarkdownListStyleProps;
45
+ code?: MarkdownBoxStyleProps;
46
+ pre?: MarkdownBoxStyleProps;
47
+ mention?: MarkdownBoxStyleProps;
48
+ };
49
+ /**
50
+ * The style once the defaults have been merged in: every entry present, every
51
+ * property still optional.
52
+ *
53
+ * Distinct from `PartialMarkdownStyle`, which is what a caller writes. This is
54
+ * what a renderer reads, and on the web its lengths have been through React
55
+ * Native Web's compiler by the time they get there -- a `fontSize` of `16` is
56
+ * the string `"16px"` -- which is why everything downstream of it either casts
57
+ * or runs the value back through `toNumber`.
58
+ */
59
+ type ResolvedMarkdownStyle = Partial<{
3
60
  [K in keyof MarkdownStyle]: Partial<MarkdownStyle[K]>;
4
61
  }>;
5
62
  declare function mergeMarkdownStyleWithDefault(input: PartialMarkdownStyle | undefined): MarkdownStyle;
6
- export type { PartialMarkdownStyle };
7
- export { mergeMarkdownStyleWithDefault };
63
+ declare function processMarkdownStyle(input: PartialMarkdownStyle | undefined): MarkdownStyle;
64
+ export type { PartialMarkdownStyle, ResolvedMarkdownStyle, MarkdownTextStyleProps, MarkdownBoxStyleProps, MarkdownHeadingStyleProps, MarkdownBlockquoteStyleProps, MarkdownListStyleProps, };
65
+ export { mergeMarkdownStyleWithDefault, processMarkdownStyle };
8
66
  //# sourceMappingURL=styleUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styleUtils.d.ts","sourceRoot":"","sources":["../../../../src/styleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAElF,KAAK,oBAAoB,GAAG,OAAO,CAAC;KACjC,CAAC,IAAI,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CACtD,CAAC,CAAA;AAyEF,iBAAS,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,aAAa,CAiB7F;AAED,YAAY,EAAE,oBAAoB,EAAE,CAAA;AAEpC,OAAO,EAAE,6BAA6B,EAAE,CAAA"}
1
+ {"version":3,"file":"styleUtils.d.ts","sourceRoot":"","sources":["../../../../src/styleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,+CAA+C,CAAA;AAatD,KAAK,sBAAsB,GAAG,IAAI,CAChC,SAAS,EACP,OAAO,GACP,YAAY,GACZ,UAAU,GACV,WAAW,GACX,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,CACrB,CAAA;AAID,KAAK,qBAAqB,GAAG,sBAAsB,GACjD,IAAI,CACF,SAAS,EACP,iBAAiB,GACjB,aAAa,GACb,aAAa,GACb,cAAc,GACd,SAAS,GACT,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,GACR,kBAAkB,GAClB,gBAAgB,CACnB,GAAG;IAGF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAEH,KAAK,yBAAyB,GAAG,sBAAsB,GAAG;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,KAAK,4BAA4B,GAAG,sBAAsB,GACxD,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAEH,KAAK,sBAAsB,GAAG;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAChC,CAAA;AAED;;;GAGG;AACH,KAAK,oBAAoB,GAAG;IAC1B,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,IAAI,CAAC,EAAE,sBAAsB,CAAA;IAC7B,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,QAAQ,CAAC,EAAE,sBAAsB,CAAA;IACjC,aAAa,CAAC,EAAE,sBAAsB,CAAA;IACtC,OAAO,CAAC,EAAE,yBAAyB,CAAA;IACnC,UAAU,CAAC,EAAE,4BAA4B,CAAA;IACzC,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC,aAAa,CAAC,EAAE,sBAAsB,CAAA;IACtC,IAAI,CAAC,EAAE,qBAAqB,CAAA;IAC5B,GAAG,CAAC,EAAE,qBAAqB,CAAA;IAC3B,OAAO,CAAC,EAAE,qBAAqB,CAAA;CAChC,CAAA;AAED;;;;;;;;;GASG;AACH,KAAK,qBAAqB,GAAG,OAAO,CAAC;KAClC,CAAC,IAAI,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CACtD,CAAC,CAAA;AAiLF,iBAAS,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,aAAa,CAmB7F;AAsCD,iBAAS,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,aAAa,CAEpF;AAED,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,GACvB,CAAA;AAED,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { MarkdownRange } from "../../commonTypes";
2
- import type { PartialMarkdownStyle } from "../../styleUtils";
2
+ import type { ResolvedMarkdownStyle } from "../../styleUtils";
3
3
  import type { TextMeasurer } from "./measureUtils";
4
4
  /**
5
5
  * Where one line's text sits, and what has to be drawn in the space to its left.
@@ -16,7 +16,35 @@ type LineLayout = {
16
16
  /** Space to open after a marker, so the next container's gutter lands between the two. */
17
17
  gaps: Map<number, number>;
18
18
  };
19
+ /**
20
+ * How a list's markers are drawn, which is the one thing a display does differently from an input.
21
+ *
22
+ * A display renders the marker rather than showing it: an unordered item's `-` becomes a bullet, an
23
+ * ordered item's `1.` stays the number it means but at its own scale, and both hold a little room
24
+ * either side. An input shows the marker you typed, in the base font, because there it is text
25
+ * being edited rather than a rendering of it. `MarkdownFormatter` draws the same distinction on
26
+ * both native platforms from the same style values.
27
+ *
28
+ * `fontSize` is what the wrapped element renders at, in pixels, which is what a marker is sized in
29
+ * proportion to.
30
+ */
31
+ type MarkerRendering = {
32
+ display: boolean;
33
+ fontSize: number;
34
+ };
35
+ /** An input's markers, and the default everywhere the question does not arise. */
36
+ declare const SHOWN_MARKERS: MarkerRendering;
19
37
  declare function toNumber(value: string | number | undefined | null): number;
38
+ /**
39
+ * The marker at the end of a prefix: the `-` of a bullet or the `1.` of a numbered item, without
40
+ * the indent in front of it or the space after it.
41
+ *
42
+ * Read off the text rather than taken from the `syntax` range covering it, because a prefix runs
43
+ * from wherever the previous container's marker ended and so can carry another container's marker
44
+ * with it -- the ordered list in `- > 1. ` is handed `> 1. `. The last run of non-blanks is this
45
+ * container's own. `MarkdownFormatter` reads it the same way on both native platforms.
46
+ */
47
+ declare function markerRun(prefix: string): string;
20
48
  /**
21
49
  * Places the containers of every line, left to right -- the web half of `BlockLayout` in
22
50
  * `apple/MarkdownFormatter.swift` and `android/.../MarkdownFormatter.kt`, and deliberately the same
@@ -35,7 +63,7 @@ declare function toNumber(value: string | number | undefined | null): number;
35
63
  * to -- so it has to run before `sortRanges` rearranges them into the containment order the DOM
36
64
  * builder needs.
37
65
  */
38
- declare function layoutBlocks(text: string, ranges: MarkdownRange[], markdownStyle: PartialMarkdownStyle, measure: TextMeasurer): Map<number, LineLayout>;
39
- export { layoutBlocks, toNumber };
40
- export type { LineLayout };
66
+ declare function layoutBlocks(text: string, ranges: MarkdownRange[], markdownStyle: ResolvedMarkdownStyle, measure: TextMeasurer, rendering?: MarkerRendering): Map<number, LineLayout>;
67
+ export { layoutBlocks, markerRun, SHOWN_MARKERS, toNumber };
68
+ export type { LineLayout, MarkerRendering };
41
69
  //# sourceMappingURL=blockLayout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blockLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAIlD;;;;;;;GAOG;AACH,KAAK,UAAU,GAAG;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,0FAA0F;IAC1F,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1B,CAAA;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CASnE;AA0BD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,YAAY,CACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EAAE,EACvB,aAAa,EAAE,oBAAoB,EACnC,OAAO,EAAE,YAAY,GACpB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CA+EzB;AAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA;AACjC,YAAY,EAAE,UAAU,EAAE,CAAA"}
1
+ {"version":3,"file":"blockLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAIlD;;;;;;;GAOG;AACH,KAAK,UAAU,GAAG;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,0FAA0F;IAC1F,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,kFAAkF;AAClF,QAAA,MAAM,aAAa,EAAE,eAAiD,CAAA;AAEtE,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CASnE;AAmDD;;;;;;;;GAQG;AACH,iBAAS,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKzC;AAoCD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,YAAY,CACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EAAE,EACvB,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,YAAY,EACrB,SAAS,GAAE,eAA+B,GACzC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CA6FzB;AAED,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAC3D,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,CAAA"}
@@ -1,22 +1,34 @@
1
- import type { PartialMarkdownStyle } from "../../styleUtils";
2
- import type { LineLayout } from "./blockLayout";
1
+ import type { ResolvedMarkdownStyle } from "../../styleUtils";
2
+ import type { LineLayout, MarkerRendering } from "./blockLayout";
3
3
  import type { NodeType } from "./treeUtils";
4
4
  /**
5
5
  * Applies the layout the block walk computed for one line.
6
6
  *
7
- * Everything a container contributes lands here rather than on the container's own span: its gutter
7
+ * Everything a container contributes lands here rather than on the container's own element: its gutter
8
8
  * is part of the paragraph's indent, and its ribbon is painted behind the whole paragraph. That is
9
9
  * how the native formatters do it too, and on the web it is the only placement that works -- a
10
- * container's span begins before the markers of the containers outside it, so a border drawn on it
10
+ * container's element begins before the markers of the containers outside it, so a border drawn on it
11
11
  * would sit in front of a bullet that is meant to precede it, and a gutter set on it would open
12
12
  * before that bullet rather than after.
13
13
  *
14
- * `padding-left` holds every line of the paragraph at the indent, and the negative `text-indent`
14
+ * `padding-inline-start` holds every line of the paragraph at the indent, and the negative `text-indent`
15
15
  * pulls the first one back to where its own marker starts -- `firstLineHeadIndent` and `headIndent`,
16
16
  * spelled in CSS. A line that wraps, or a line continuing the block with no marker of its own, then
17
17
  * lines up with the text above it instead of with the marker.
18
18
  */
19
- declare function addLineLayout(node: HTMLElement, layout: LineLayout | undefined, markdownStyle: PartialMarkdownStyle): void;
19
+ declare function addLineLayout(node: HTMLElement, layout: LineLayout | undefined, markdownStyle: ResolvedMarkdownStyle): void;
20
+ /**
21
+ * Turns a line's ribbons round when the line reads right to left.
22
+ *
23
+ * Asked of the browser rather than worked out from the text, because the browser is what lays the
24
+ * line out: whatever it resolved `dir="auto"` to is where it put the gutter, and the bars belong on
25
+ * that side whether or not a bidi rule written here would have agreed. `:dir()` is unsupported in
26
+ * browsers older than Safari 16.4, where `matches` throws and the fallback edge stands.
27
+ *
28
+ * Called once the line holds its text, since that is what a line's own direction is read from, and
29
+ * only for a line that has ribbons: nothing else on a line is measured from an edge.
30
+ */
31
+ declare function setRibbonEdge(node: HTMLElement, layout: LineLayout | undefined): void;
20
32
  /**
21
33
  * Opens the space a marker holds for the container that follows it.
22
34
  *
@@ -24,10 +36,10 @@ declare function addLineLayout(node: HTMLElement, layout: LineLayout | undefined
24
36
  * puts a nested list's indent between the quote's `>` and the bullet rather than in front of both.
25
37
  */
26
38
  declare function addBlockPrefixGap(node: HTMLElement, gap: number | undefined): void;
27
- declare function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownStyle: PartialMarkdownStyle, isMultiline?: boolean): void;
39
+ declare function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownStyle: ResolvedMarkdownStyle, isMultiline?: boolean, rendering?: MarkerRendering): void;
28
40
  declare const MULTILINE_MARKDOWN_TYPES: string[];
29
41
  declare function isMultilineMarkdownType(type: NodeType): boolean;
30
42
  declare function isChildOfMarkdownElement(node: HTMLElement, elementType: NodeType): boolean;
31
43
  declare function isChildOfMultilineMarkdownElement(node: HTMLElement): boolean;
32
- export { addStyleToBlock, addLineLayout, addBlockPrefixGap, isMultilineMarkdownType, isChildOfMarkdownElement, isChildOfMultilineMarkdownElement, MULTILINE_MARKDOWN_TYPES, };
44
+ export { addStyleToBlock, addLineLayout, setRibbonEdge, addBlockPrefixGap, isMultilineMarkdownType, isChildOfMarkdownElement, isChildOfMultilineMarkdownElement, MULTILINE_MARKDOWN_TYPES, };
33
45
  //# sourceMappingURL=blockUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blockUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAqB3C;;;;;;;;;;;;;;GAcG;AACH,iBAAS,aAAa,CACpB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,aAAa,EAAE,oBAAoB,QAiCpC;AAED;;;;;GAKG;AACH,iBAAS,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,QAIpE;AAED,iBAAS,eAAe,CACtB,aAAa,EAAE,WAAW,EAC1B,IAAI,EAAE,QAAQ,EACd,aAAa,EAAE,oBAAoB,EACnC,WAAW,UAAO,QAiFnB;AAgCD,QAAA,MAAM,wBAAwB,UAAgB,CAAA;AAE9C,iBAAS,uBAAuB,CAAC,IAAI,EAAE,QAAQ,WAE9C;AAiBD,iBAAS,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAEnF;AACD,iBAAS,iCAAiC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAIrE;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,wBAAwB,GACzB,CAAA"}
1
+ {"version":3,"file":"blockUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockUtils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAiH3C;;;;;;;;;;;;;;GAcG;AACH,iBAAS,aAAa,CACpB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,aAAa,EAAE,qBAAqB,QA4CrC;AAiBD;;;;;;;;;;GAUG;AACH,iBAAS,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,QAYvE;AAwBD;;;;;GAKG;AACH,iBAAS,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,QAOpE;AAED,iBAAS,eAAe,CACtB,aAAa,EAAE,WAAW,EAC1B,IAAI,EAAE,QAAQ,EACd,aAAa,EAAE,qBAAqB,EACpC,WAAW,UAAO,EAClB,SAAS,GAAE,eAA+B,QA+F3C;AAsJD,QAAA,MAAM,wBAAwB,UAAgB,CAAA;AAE9C,iBAAS,uBAAuB,CAAC,IAAI,EAAE,QAAQ,WAE9C;AAiBD,iBAAS,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAEnF;AACD,iBAAS,iCAAiC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAIrE;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,wBAAwB,GACzB,CAAA"}
@@ -0,0 +1,37 @@
1
+ import type { HTMLMarkdownElement } from "../../MarkdownTextInput.web";
2
+ import type { NodeType } from "./treeUtils";
3
+ /**
4
+ * The tag each markdown type is built as.
5
+ *
6
+ * A range says what a run of text *is*; the element it becomes should say the same thing to
7
+ * everything that reads the document rather than looking at it. A screen reader announces a
8
+ * `<strong>` and a `<blockquote>` and says nothing about a span; text copied out of the input
9
+ * arrives in another editor still emphasised; and the page `expo export` prerenders carries the
10
+ * structure rather than a wall of undifferentiated spans.
11
+ *
12
+ * `data-type` stays on every one of them regardless -- it is what the styling, the CSS and the
13
+ * render-model baselines are keyed on, and it distinguishes the several types that share a tag.
14
+ *
15
+ * Two pairings are worth spelling out. A fenced or indented block is `<pre>` from `codeblock`, the
16
+ * range covering the whole thing including its fences, with `<code>` inside it from `pre`, the
17
+ * range covering only the code -- which is the nesting HTML asks for, in the opposite naming to
18
+ * ours. And `link` is an anchor even in the input, where it has no `href` yet: an anchor without
19
+ * one is exactly what HTML has for a link whose destination is not resolved.
20
+ *
21
+ * Everything absent from here is a span, because HTML has nothing that means it: markdown's own
22
+ * punctuation, the parts of a link's markup, a mention, an emoji run.
23
+ */
24
+ /** Marks an element as one of ours, for the rules that undo the tag's browser defaults. */
25
+ declare const ELEMENT_CLASS = "react-native-marcus";
26
+ declare function isBlockLevelType(type: NodeType): boolean;
27
+ /**
28
+ * Builds the element for a range, tagged and typed.
29
+ *
30
+ * `level` applies to headings only, and is the ATX level: `1` through `6` produce that heading,
31
+ * and `0` produces a span. A level arrives as one nested range per level -- `ungroupRanges` is what
32
+ * turns `depth` into the nesting the size scaling compounds down -- so only the outermost of them
33
+ * can be the heading itself, and the copies inside it are spans. `<h2><h2>` is not a thing.
34
+ */
35
+ declare function createMarkdownElement(type: NodeType, level?: number): HTMLMarkdownElement;
36
+ export { createMarkdownElement, isBlockLevelType, ELEMENT_CLASS };
37
+ //# sourceMappingURL=elementUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elementUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/elementUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,2FAA2F;AAC3F,QAAA,MAAM,aAAa,wBAAwB,CAAA;AAgC3C,iBAAS,gBAAgB,CAAC,IAAI,EAAE,QAAQ,WAEvC;AAED;;;;;;;GAOG;AACH,iBAAS,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,SAAI,GAAG,mBAAmB,CAe7E;AAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAA"}