react-native-marcus 0.1.0 → 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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { toNumber } from "./blockLayout.js";
3
+ import { SHOWN_MARKERS, toNumber } from "./blockLayout.js";
4
4
  /**
5
5
  * Assigns CSS properties, skipping the ones the style does not define.
6
6
  *
@@ -21,17 +21,96 @@ function applyStyle(node, styles) {
21
21
  });
22
22
  }
23
23
 
24
+ /**
25
+ * Everything a `MarkdownTextStyle` says, in CSS.
26
+ *
27
+ * One place rather than a line per entry in the switch below, because every styled type now carries
28
+ * the same set of text attributes: the difference between a mention and a heading is the box around
29
+ * it and the size it is given, not which properties it understands. `MarkdownFormatter` reads the
30
+ * same struct into attributed-string attributes on iOS and into spans on Android.
31
+ *
32
+ * Undefined properties are dropped by `applyStyle`, so a run inherits whatever the prose around it
33
+ * is drawn in -- which is what an unset text attribute means on all three platforms.
34
+ */
35
+ function textStyle(style) {
36
+ if (!style) {
37
+ return {};
38
+ }
39
+ return {
40
+ color: style.color,
41
+ fontFamily: style.fontFamily,
42
+ fontSize: style.fontSize,
43
+ fontStyle: style.fontStyle,
44
+ fontWeight: style.fontWeight,
45
+ letterSpacing: style.letterSpacing,
46
+ lineHeight: style.lineHeight,
47
+ textDecorationLine: style.textDecorationLine,
48
+ textDecorationColor: style.textDecorationColor,
49
+ textDecorationStyle: style.textDecorationStyle,
50
+ textShadow: textShadow(style)
51
+ };
52
+ }
53
+
54
+ /**
55
+ * React Native's three shadow properties as the one CSS declaration they add up to.
56
+ *
57
+ * The offset and the radius stay raw numbers through `processMarkdownStyle` -- an offset is an
58
+ * object rather than a length, and half a shadow carrying units would not compose -- so the units
59
+ * are put on here.
60
+ */
61
+ function textShadow(style) {
62
+ const color = style.textShadowColor;
63
+ const radius = toNumber(style.textShadowRadius);
64
+ const x = toNumber(style.textShadowOffset?.width);
65
+ const y = toNumber(style.textShadowOffset?.height);
66
+ if (!color && radius <= 0 && x === 0 && y === 0) {
67
+ return undefined;
68
+ }
69
+ return `${x}px ${y}px ${radius}px ${color || "currentColor"}`;
70
+ }
71
+
72
+ /**
73
+ * The room a boxed run holds open on one axis: the axis value where it is set, and the value for
74
+ * both axes where it is not.
75
+ *
76
+ * A fenced block usually wants more above and below than beside it, and the single `padding` a
77
+ * style used to carry could not say that. The native formatters resolve the pair the same way.
78
+ */
79
+ function axis(both, axisValue) {
80
+ return axisValue === undefined || axisValue === null || axisValue === "" ? toNumber(both) : toNumber(axisValue);
81
+ }
82
+
83
+ /**
84
+ * The box a run of code or a mention sits in: its fill, its border, and the room inside and around
85
+ * it, written as the two-value shorthands so the horizontal halves stay direction-agnostic.
86
+ */
87
+ function boxStyle(style) {
88
+ if (!style) {
89
+ return {};
90
+ }
91
+ const borderWidth = toNumber(style.borderWidth);
92
+ return {
93
+ backgroundColor: style.backgroundColor,
94
+ borderRadius: style.borderRadius,
95
+ borderWidth: borderWidth > 0 ? `${borderWidth}px` : undefined,
96
+ borderStyle: borderWidth > 0 ? "solid" : undefined,
97
+ borderColor: borderWidth > 0 ? style.borderColor || "currentColor" : undefined,
98
+ padding: `${axis(style.padding, style.paddingVertical)}px ${axis(style.padding, style.paddingHorizontal)}px`,
99
+ margin: `${axis(style.margin, style.marginVertical)}px ${axis(style.margin, style.marginHorizontal)}px`
100
+ };
101
+ }
102
+
24
103
  /**
25
104
  * Applies the layout the block walk computed for one line.
26
105
  *
27
- * Everything a container contributes lands here rather than on the container's own span: its gutter
106
+ * Everything a container contributes lands here rather than on the container's own element: its gutter
28
107
  * is part of the paragraph's indent, and its ribbon is painted behind the whole paragraph. That is
29
108
  * how the native formatters do it too, and on the web it is the only placement that works -- a
30
- * container's span begins before the markers of the containers outside it, so a border drawn on it
109
+ * container's element begins before the markers of the containers outside it, so a border drawn on it
31
110
  * would sit in front of a bullet that is meant to precede it, and a gutter set on it would open
32
111
  * before that bullet rather than after.
33
112
  *
34
- * `padding-left` holds every line of the paragraph at the indent, and the negative `text-indent`
113
+ * `padding-inline-start` holds every line of the paragraph at the indent, and the negative `text-indent`
35
114
  * pulls the first one back to where its own marker starts -- `firstLineHeadIndent` and `headIndent`,
36
115
  * spelled in CSS. A line that wraps, or a line continuing the block with no marker of its own, then
37
116
  * lines up with the text above it instead of with the marker.
@@ -46,7 +125,10 @@ function addLineLayout(node, layout, markdownStyle) {
46
125
  }
47
126
  if (layout.indent > 0) {
48
127
  applyStyle(node, {
49
- paddingLeft: `${layout.indent}px`,
128
+ // Logical rather than `padding-left`, because a container's gutter opens on the line's
129
+ // leading edge -- which is what `marginStart` and `paddingStart` name, and what both native
130
+ // platforms already indent from.
131
+ paddingInlineStart: `${layout.indent}px`,
50
132
  textIndent: `${layout.firstLineIndent - layout.indent}px`
51
133
  });
52
134
  }
@@ -56,17 +138,80 @@ function addLineLayout(node, layout, markdownStyle) {
56
138
  }
57
139
 
58
140
  // One background layer per ribbon, each a solid bar of its own. They are painted on the paragraph
59
- // rather than on any span so that they run its full height -- a quote that wraps gets one
60
- // unbroken bar, exactly as `MarkdownTextLayoutFragment` draws it over the whole fragment.
141
+ // rather than on anything inside it so that they run its full height -- a quote that wraps gets
142
+ // one unbroken bar, exactly as `MarkdownTextLayoutFragment` draws it over the whole fragment.
143
+ //
144
+ // The offsets are distances from the line's leading edge -- the same numbers `getLeadingMargin`
145
+ // is handed on Android -- so the edge they are measured from has to move with the line's own
146
+ // direction. `RIBBON_EDGE` leaves that edge to be named later, by `setRibbonEdge`.
61
147
  const color = markdownStyle.blockquote?.borderColor || "transparent";
148
+ const radius = toNumber(markdownStyle.blockquote?.borderRadius);
62
149
  applyStyle(node, {
63
- backgroundImage: layout.ribbons.map(() => `linear-gradient(${color}, ${color})`).join(", "),
64
- backgroundPosition: layout.ribbons.map(x => `${x}px 0`).join(", "),
150
+ backgroundImage: layout.ribbons.map(() => bar(color, radius)).join(", "),
151
+ backgroundPositionX: layout.ribbons.map(x => `${RIBBON_EDGE} ${x}px`).join(", "),
152
+ // One value for every layer: a shorter list is repeated to cover them all.
153
+ backgroundPositionY: "0",
65
154
  backgroundSize: layout.ribbons.map(() => `${width}px 100%`).join(", "),
66
155
  backgroundRepeat: "no-repeat"
67
156
  });
68
157
  }
69
158
 
159
+ /**
160
+ * The custom property naming the edge a ribbon's offset is measured from, and the reference to it
161
+ * the offsets are written against.
162
+ *
163
+ * `background-position` is the one part of a line still spelled physically: it has no logical form.
164
+ * So the edge is named indirectly and `setRibbonEdge` fills it in once the line has its text --
165
+ * which is also why it is a custom property rather than a value written straight into the offsets:
166
+ * the offsets are known while building the line, the direction only after.
167
+ *
168
+ * The fallback in the reference is what a line gets before then, and what one gets in a browser
169
+ * that cannot answer the question at all.
170
+ */
171
+ const RIBBON_EDGE_PROPERTY = "--marcus-ribbon-edge";
172
+ const RIBBON_EDGE = `var(${RIBBON_EDGE_PROPERTY}, left)`;
173
+
174
+ /**
175
+ * Turns a line's ribbons round when the line reads right to left.
176
+ *
177
+ * Asked of the browser rather than worked out from the text, because the browser is what lays the
178
+ * line out: whatever it resolved `dir="auto"` to is where it put the gutter, and the bars belong on
179
+ * that side whether or not a bidi rule written here would have agreed. `:dir()` is unsupported in
180
+ * browsers older than Safari 16.4, where `matches` throws and the fallback edge stands.
181
+ *
182
+ * Called once the line holds its text, since that is what a line's own direction is read from, and
183
+ * only for a line that has ribbons: nothing else on a line is measured from an edge.
184
+ */
185
+ function setRibbonEdge(node, layout) {
186
+ if (!layout || layout.ribbons.length === 0) {
187
+ return;
188
+ }
189
+ try {
190
+ if (node.matches(":dir(rtl)")) {
191
+ node.style.setProperty(RIBBON_EDGE_PROPERTY, "right");
192
+ }
193
+ } catch {
194
+ // A browser without `:dir()`. Left is the fallback the offsets already carry.
195
+ }
196
+ }
197
+
198
+ /**
199
+ * One quote bar, as a background layer.
200
+ *
201
+ * A gradient has no corners, so a bar that is asked to round its ends is drawn as an SVG rectangle
202
+ * instead. The SVG carries no `viewBox`, which means its user units are the pixels the layer is
203
+ * sized to and `rx` is the radius that was asked for rather than a radius stretched by the height
204
+ * of the line. `MarkdownTextLayoutFragment` and `MarkdownBlockIndentSpan` round the same bar with a
205
+ * rounded-rect path.
206
+ */
207
+ function bar(color, radius) {
208
+ if (radius <= 0) {
209
+ return `linear-gradient(${color}, ${color})`;
210
+ }
211
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">` + `<rect width="100%" height="100%" rx="${radius}" ry="${radius}" fill="${color}"/>` + `</svg>`;
212
+ return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
213
+ }
214
+
70
215
  /**
71
216
  * Opens the space a marker holds for the container that follows it.
72
217
  *
@@ -75,25 +220,41 @@ function addLineLayout(node, layout, markdownStyle) {
75
220
  */
76
221
  function addBlockPrefixGap(node, gap) {
77
222
  if (gap) {
78
- node.style.marginRight = `${gap}px`;
223
+ // Logical: the room belongs after the marker in reading order, which is its left in a
224
+ // right-to-left line. `MarkdownFormatter` kerns the marker's last character, and kerning
225
+ // follows the run's own direction for the same reason.
226
+ node.style.marginInlineEnd = `${gap}px`;
79
227
  }
80
228
  }
81
- function addStyleToBlock(targetElement, type, markdownStyle, isMultiline = true) {
229
+ function addStyleToBlock(targetElement, type, markdownStyle, isMultiline = true, rendering = SHOWN_MARKERS) {
82
230
  const node = targetElement;
83
231
  switch (type) {
232
+ // A fenced block's language is its own type so that something can read it,
233
+ // but in an input it is part of the fence you are typing and reads as
234
+ // markup, so it is coloured like the rest of it.
84
235
  case "syntax":
85
- applyStyle(node, {
86
- color: markdownStyle.syntax?.color
87
- });
88
- break;
89
- case "bold":
90
- node.style.fontWeight = "bold";
236
+ case "language":
237
+ {
238
+ // A list's marker is the one syntax a display keeps, and it is drawn there
239
+ // rather than shown -- everything else the colour is for has been stripped
240
+ // out by the time a display is built, so this is the only case where the
241
+ // two components part company.
242
+ const list = rendering.display && type === "syntax" ? markerList(node) : null;
243
+ if (list) {
244
+ addMarkerStyle(node, list, markdownStyle, rendering);
245
+ } else {
246
+ applyStyle(node, textStyle(markdownStyle.syntax));
247
+ }
248
+ break;
249
+ }
250
+ case "strong":
251
+ applyStyle(node, textStyle(markdownStyle.strong));
91
252
  break;
92
- case "italic":
93
- node.style.fontStyle = "italic";
253
+ case "emphasis":
254
+ applyStyle(node, textStyle(markdownStyle.emphasis));
94
255
  break;
95
256
  case "strikethrough":
96
- node.style.textDecoration = "line-through";
257
+ applyStyle(node, textStyle(markdownStyle.strikethrough));
97
258
  break;
98
259
  case "emoji":
99
260
  applyStyle(node, {
@@ -104,43 +265,44 @@ function addStyleToBlock(targetElement, type, markdownStyle, isMultiline = true)
104
265
  verticalAlign: "middle"
105
266
  });
106
267
  break;
107
- case "mention-here":
108
- addMentionStyle(node, markdownStyle.mentionHere);
109
- break;
110
- case "mention-user":
111
- addMentionStyle(node, markdownStyle.mentionUser);
112
- break;
113
- case "mention-report":
114
- addMentionStyle(node, markdownStyle.mentionReport);
268
+ // A pill: the same inline box an inline run of code sits in, and drawn the same way. The
269
+ // padding and margin push the words either side of it apart, the padding grows into the
270
+ // line's own spacing above and below rather than pushing the lines apart, and a mention that
271
+ // wraps is rounded only where it begins and ends.
272
+ case "mention":
273
+ applyStyle(node, textStyle(markdownStyle.mention));
274
+ applyStyle(node, boxStyle(markdownStyle.mention));
115
275
  break;
116
276
  case "link":
117
- applyStyle(node, {
118
- color: markdownStyle.link?.color,
119
- textDecoration: "underline"
120
- });
277
+ applyStyle(node, textStyle(markdownStyle.link));
121
278
  break;
122
- // Both carry a font, a colour and a background, and nothing else: native draws no border, no
123
- // corner radius and no padding around either, so neither does this.
279
+ // An inline box, which is what the platforms draw by hand: the padding and margin push the
280
+ // words either side of it apart, the padding grows into the line's own spacing above and
281
+ // below rather than pushing the lines apart, and a run that wraps is rounded only where it
282
+ // begins and ends. All three are what CSS does with an inline element by default.
124
283
  case "code":
125
- applyStyle(node, {
126
- fontFamily: markdownStyle.code?.fontFamily,
127
- fontSize: markdownStyle.code?.fontSize,
128
- color: markdownStyle.code?.color,
129
- backgroundColor: markdownStyle.code?.backgroundColor
130
- });
284
+ applyStyle(node, textStyle(markdownStyle.code));
285
+ applyStyle(node, boxStyle(markdownStyle.code));
131
286
  break;
287
+ // Only the text attributes of a block; the box it sits in is `codeblock`, which is the range
288
+ // that covers the whole thing rather than only the code inside it.
132
289
  case "pre":
133
- applyStyle(node, {
134
- fontFamily: markdownStyle.pre?.fontFamily,
135
- fontSize: markdownStyle.pre?.fontSize,
136
- color: markdownStyle.pre?.color,
137
- backgroundColor: markdownStyle.pre?.backgroundColor
138
- });
290
+ applyStyle(node, textStyle(markdownStyle.pre));
291
+ break;
292
+ case "codeblock":
293
+ addCodeBlockStyle(node, markdownStyle, isMultiline);
139
294
  break;
140
- // Block containers hold no box of their own: their gutters and ribbons belong to the
141
- // paragraph, in `addLineLayout`. All that is left is letting a long unbroken word inside one
295
+ // A quoted block holds no box of its own: its gutter and its ribbons belong to the paragraph,
296
+ // in `addLineLayout`. What is left is the text inside it, and letting a long unbroken word
142
297
  // break rather than push the line past the input's edge.
143
298
  case "blockquote":
299
+ applyStyle(node, textStyle(markdownStyle.blockquote));
300
+ applyStyle(node, {
301
+ overflowWrap: "anywhere"
302
+ });
303
+ break;
304
+ // Neither do the list containers, and their markers are styled from the `syntax` range inside
305
+ // their prefix rather than from here.
144
306
  case "list-ordered":
145
307
  case "list-unordered":
146
308
  applyStyle(node, {
@@ -162,26 +324,136 @@ function addStyleToBlock(targetElement, type, markdownStyle, isMultiline = true)
162
324
  break;
163
325
  }
164
326
  }
165
- function addMentionStyle(node, style) {
327
+
328
+ /**
329
+ * The box behind a fenced or indented block: one fill for the whole thing, from the first line to
330
+ * the last, which is what the native formatters draw.
331
+ *
332
+ * `codeblock` covers the block including its fences, and the builder merges all of its lines into
333
+ * one element, so here the box is a real box rather than the several line rects each platform has
334
+ * to fill by hand. What that costs is the one thing an element cannot do: a block opened after a
335
+ * bullet or a quote's `>` shares that line in the buffer but not on screen, because a block-level
336
+ * box drops below the marker in front of it.
337
+ *
338
+ * A singleline input has no room for a block at all -- every line of it is drawn on one -- so there
339
+ * the background stays an inline one, painted behind the text.
340
+ */
341
+ function addCodeBlockStyle(node, markdownStyle, isMultiline) {
342
+ const style = markdownStyle.pre;
343
+ const box = boxStyle(style);
344
+ applyStyle(node, {
345
+ backgroundColor: box.backgroundColor,
346
+ borderRadius: box.borderRadius,
347
+ borderWidth: box.borderWidth,
348
+ borderStyle: box.borderStyle,
349
+ borderColor: box.borderColor
350
+ });
351
+ if (!isMultiline) {
352
+ return;
353
+ }
354
+ applyStyle(node, {
355
+ display: "block",
356
+ // The padding is inside the box, so the box still spans the line rather than overflowing it.
357
+ boxSizing: "border-box",
358
+ padding: box.padding,
359
+ margin: box.margin
360
+ });
361
+ }
362
+
363
+ /**
364
+ * The list whose marker `node` is, or null if this syntax is something else.
365
+ *
366
+ * A marker is a `syntax` inside the `block-prefix` of a list container, which is a shape only a
367
+ * list has: a quote's `>` is removed with the rest of the markup before a display is built.
368
+ */
369
+ function markerList(node) {
370
+ let current = node.parentNode;
371
+ let inPrefix = false;
372
+ while (current && current.contentEditable !== "true") {
373
+ const type = current.getAttribute?.("data-type");
374
+ if (type === "block-prefix") {
375
+ inPrefix = true;
376
+ } else if (type === "list-ordered" || type === "list-unordered") {
377
+ return inPrefix ? type : null;
378
+ }
379
+ current = current.parentNode;
380
+ }
381
+ return null;
382
+ }
383
+
384
+ /**
385
+ * Draws a list's marker: a bullet for an unordered item, the number at its own scale for an
386
+ * ordered one.
387
+ *
388
+ * Both are sized from the base font rather than from a length of their own, so a list marks itself
389
+ * in proportion to the prose it marks, and both are drawn from the list's own `marker` style over
390
+ * `syntax` -- which, in a display where every other piece of syntax has been removed, is where a
391
+ * marker's colour came from before lists could name one. `MarkdownFormatter` draws the same two
392
+ * shapes from the same numbers on iOS and Android.
393
+ *
394
+ * The bullet keeps the marker character inside it, boxed and invisible: it is what a reader copies
395
+ * and what a screen reader announces, and the box is exactly the width `layoutBlocks` indented the
396
+ * text past.
397
+ */
398
+ function addMarkerStyle(node, type, markdownStyle, rendering) {
399
+ const list = type === "list-ordered" ? markdownStyle.orderedList : markdownStyle.unorderedList;
400
+ // What the list says about its marker, over what `syntax` says about markup in general. Before
401
+ // lists had a `marker` entry this was `syntax.color` and nothing else, which is what an unset
402
+ // `marker` still resolves to.
403
+ const style = {
404
+ ...markdownStyle.syntax,
405
+ ...list?.marker
406
+ };
407
+ const color = style.color || "";
408
+ const {
409
+ fontSize
410
+ } = rendering;
411
+ const scale = toNumber(list?.markerScale);
412
+ if (scale <= 0 || fontSize <= 0) {
413
+ applyStyle(node, textStyle(style));
414
+ return;
415
+ }
416
+ if (type === "list-ordered") {
417
+ applyStyle(node, textStyle(style));
418
+ applyStyle(node, {
419
+ fontSize: fontSize * scale
420
+ });
421
+ return;
422
+ }
423
+ const diameter = fontSize * scale;
424
+
425
+ // A box one line high, aligned to the top of the line, with the circle painted in the middle of
426
+ // it: that is what centres the bullet on the line rather than on the text, which is where both
427
+ // native platforms draw it. The height is the marker character's own line box -- an inline block
428
+ // holding one line of text is exactly one line high -- so it follows the line height without
429
+ // having to be told it.
430
+ applyStyle(node, textStyle(style));
166
431
  applyStyle(node, {
167
- color: style?.color,
168
- backgroundColor: style?.backgroundColor,
169
- borderRadius: style?.borderRadius
432
+ display: "inline-block",
433
+ width: diameter,
434
+ verticalAlign: "top",
435
+ backgroundImage: `radial-gradient(circle closest-side, ${color || "currentColor"} 100%, transparent 100%)`,
436
+ backgroundSize: `${diameter}px ${diameter}px`,
437
+ backgroundPosition: "center",
438
+ backgroundRepeat: "no-repeat",
439
+ // The character is still in the box, and stays out of sight of everything but a selection.
440
+ color: "transparent",
441
+ overflow: "hidden"
170
442
  });
171
443
  }
172
444
 
173
445
  /**
174
446
  * Sizes a heading the way native does: level N is the base size scaled N-1 times.
175
447
  *
176
- * The level does not reach here -- `ungroupRanges` turns it into one nested span per level -- so
448
+ * The level does not reach here -- `ungroupRanges` turns it into one nested element per level -- so
177
449
  * the scaling is expressed in `em` and compounds down the nesting to the same number. This runs
178
- * once the span is in the tree, which is what lets it tell an inner level from the outermost one.
450
+ * once the element is in the tree, which is what lets it tell an inner level from the outermost one.
179
451
  */
180
452
  function addHeadingStyle(node, markdownStyle) {
181
453
  const nested = isChildOfMarkdownElement(node, "heading");
182
454
  const scale = markdownStyle.heading?.scale;
455
+ applyStyle(node, textStyle(markdownStyle.heading));
183
456
  applyStyle(node, {
184
- fontWeight: "bold",
185
457
  fontSize: nested ? `${scale === undefined ? 1 : scale}em` : markdownStyle.heading?.fontSize
186
458
  });
187
459
  }
@@ -206,5 +478,5 @@ function isChildOfMarkdownElement(node, elementType) {
206
478
  function isChildOfMultilineMarkdownElement(node) {
207
479
  return isDescendantOfMarkdownElement(node, type => MULTILINE_MARKDOWN_TYPES.includes(type));
208
480
  }
209
- export { addStyleToBlock, addLineLayout, addBlockPrefixGap, isMultilineMarkdownType, isChildOfMarkdownElement, isChildOfMultilineMarkdownElement, MULTILINE_MARKDOWN_TYPES };
481
+ export { addStyleToBlock, addLineLayout, setRibbonEdge, addBlockPrefixGap, isMultilineMarkdownType, isChildOfMarkdownElement, isChildOfMultilineMarkdownElement, MULTILINE_MARKDOWN_TYPES };
210
482
  //# sourceMappingURL=blockUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["toNumber","applyStyle","node","styles","target","Object","entries","forEach","property","value","undefined","style","addLineLayout","layout","markdownStyle","margin","padding","indent","paddingLeft","textIndent","firstLineIndent","width","blockquote","borderWidth","ribbons","length","color","borderColor","backgroundImage","map","join","backgroundPosition","x","backgroundSize","backgroundRepeat","addBlockPrefixGap","gap","marginRight","addStyleToBlock","targetElement","type","isMultiline","syntax","fontWeight","fontStyle","textDecoration","fontFamily","emoji","fontSize","verticalAlign","addMentionStyle","mentionHere","mentionUser","mentionReport","link","code","backgroundColor","pre","overflowWrap","addHeadingStyle","parentElement","cssText","borderRadius","nested","isChildOfMarkdownElement","scale","heading","MULTILINE_MARKDOWN_TYPES","isMultilineMarkdownType","includes","isDescendantOfMarkdownElement","predicate","currentNode","parentNode","contentEditable","elementType","getAttribute","isChildOfMultilineMarkdownElement"],"sourceRoot":"../../../../src","sources":["web/utils/blockUtils.ts"],"mappings":";;AACA,SAASA,QAAQ,QAAQ,kBAAe;AAIxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAACC,IAAiB,EAAEC,MAAmD,EAAE;EAC1F,MAAMC,MAAM,GAAGF,IAAI;EACnBG,MAAM,CAACC,OAAO,CAACH,MAAM,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,QAAQ,EAAEC,KAAK,CAAC,KAAK;IACpD,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,EAAE,EAAE;MACzD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,CAACC,UAAU;EACtC;EACA,OAAO,KAAK;AACd;AAEA,SAAST,wBAAwBA,CAAC9D,IAAiB,EAAEyE,WAAqB,EAAW;EACnF,OAAOL,6BAA6B,CAACpE,IAAI,EAAGsC,IAAI,IAAKA,IAAI,KAAKmC,WAAW,CAAC;AAC5E;AACA,SAASE,iCAAiCA,CAAC3E,IAAiB,EAAW;EACrE,OAAOoE,6BAA6B,CAACpE,IAAI,EAAGsC,IAAI,IAC9C2B,wBAAwB,CAACE,QAAQ,CAAC7B,IAAgB,CACpD,CAAC;AACH;AAEA,SACEF,eAAe,EACf1B,aAAa,EACbuB,iBAAiB,EACjBiC,uBAAuB,EACvBJ,wBAAwB,EACxBa,iCAAiC,EACjCV,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["SHOWN_MARKERS","toNumber","applyStyle","node","styles","target","Object","entries","forEach","property","value","undefined","style","textStyle","color","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","textDecorationLine","textDecorationColor","textDecorationStyle","textShadow","textShadowColor","radius","textShadowRadius","x","textShadowOffset","width","y","height","axis","both","axisValue","boxStyle","borderWidth","backgroundColor","borderRadius","borderStyle","borderColor","padding","paddingVertical","paddingHorizontal","margin","marginVertical","marginHorizontal","addLineLayout","layout","markdownStyle","indent","paddingInlineStart","textIndent","firstLineIndent","blockquote","ribbons","length","backgroundImage","map","bar","join","backgroundPositionX","RIBBON_EDGE","backgroundPositionY","backgroundSize","backgroundRepeat","RIBBON_EDGE_PROPERTY","setRibbonEdge","matches","setProperty","svg","encodeURIComponent","addBlockPrefixGap","gap","marginInlineEnd","addStyleToBlock","targetElement","type","isMultiline","rendering","list","display","markerList","addMarkerStyle","syntax","strong","emphasis","strikethrough","emoji","verticalAlign","mention","link","code","pre","addCodeBlockStyle","overflowWrap","addHeadingStyle","parentElement","cssText","box","boxSizing","current","parentNode","inPrefix","contentEditable","getAttribute","orderedList","unorderedList","marker","scale","markerScale","diameter","backgroundPosition","overflow","nested","isChildOfMarkdownElement","heading","MULTILINE_MARKDOWN_TYPES","isMultilineMarkdownType","includes","isDescendantOfMarkdownElement","predicate","currentNode","elementType","isChildOfMultilineMarkdownElement"],"sourceRoot":"../../../../src","sources":["web/utils/blockUtils.ts"],"mappings":";;AAKA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,kBAAe;AAIvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAACC,IAAiB,EAAEC,MAAmD,EAAE;EAC1F,MAAMC,MAAM,GAAGF,IAAI;EACnBG,MAAM,CAACC,OAAO,CAACH,MAAM,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,QAAQ,EAAEC,KAAK,CAAC,KAAK;IACpD,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,EAAE,EAAE;MACzD;IACF;IACA;IACA;IAAEL,MAAM,CAACO,KAAK,CAASH,QAAQ,CAAC,GAAG,OAAOC,KAAK,KAAK,QAAQ,GAAG,GAAGA,KAAK,IAAI,GAAGA,KAAK;EACrF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,SAASA,CAACD,KAA6C,EAAE;EAChE,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,CAAC,CAAC;EACX;EAEA,OAAO;IACLE,KAAK,EAAEF,KAAK,CAACE,KAA2B;IACxCC,UAAU,EAAEH,KAAK,CAACG,UAAU;IAC5BC,QAAQ,EAAEJ,KAAK,CAACI,QAAQ;IACxBC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,UAAU,EAAEN,KAAK,CAACM,UAAU;IAC5BC,aAAa,EAAEP,KAAK,CAACO,aAAa;IAClCC,UAAU,EAAER,KAAK,CAACQ,UAAU;IAC5BC,kBAAkB,EAAET,KAAK,CAACS,kBAAkB;IAC5CC,mBAAmB,EAAEV,KAAK,CAACU,mBAAyC;IACpEC,mBAAmB,EAA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,SAAS,GAAG,CAAC,GAAGmG,KAAK,IAAI,GAAG5D,aAAa,CAACmE,OAAO,EAAErG;EACrF,CAAC,CAAC;AACJ;AAEA,MAAMsG,wBAAwB,GAAG,CAAC,WAAW,CAAC;AAE9C,SAASC,uBAAuBA,CAACzC,IAAc,EAAE;EAC/C,OAAOwC,wBAAwB,CAACE,QAAQ,CAAC1C,IAAI,CAAC;AAChD;AAEA,SAAS2C,6BAA6BA,CACpCtH,IAAiB,EACjBuH,SAA2C,EAClC;EACT,IAAIC,WAAW,GAAGxH,IAAI,CAACoG,UAAU;EACjC,OAAOoB,WAAW,IAAKA,WAAW,EAAkBlB,eAAe,KAAK,MAAM,EAAE;IAC9E,MAAMmB,WAAW,GAAID,WAAW,CAAiBjB,YAAY,GAAG,WAAW,CAAC;IAC5E,IAAIgB,SAAS,CAACE,WAAW,CAAC,EAAE;MAC1B,OAAO,IAAI;IACb;IACAD,WAAW,GAAGA,WAAW,CAACpB,UAAU;EACtC;EACA,OAAO,KAAK;AACd;AAEA,SAASa,wBAAwBA,CAACjH,IAAiB,EAAEyH,WAAqB,EAAW;EACnF,OAAOH,6BAA6B,CAACtH,IAAI,EAAG2E,IAAI,IAAKA,IAAI,KAAK8C,WAAW,CAAC;AAC5E;AACA,SAASC,iCAAiCA,CAAC1H,IAAiB,EAAW;EACrE,OAAOsH,6BAA6B,CAACtH,IAAI,EAAG2E,IAAI,IAC9CwC,wBAAwB,CAACE,QAAQ,CAAC1C,IAAgB,CACpD,CAAC;AACH;AAEA,SACEF,eAAe,EACf5B,aAAa,EACboB,aAAa,EACbK,iBAAiB,EACjB8C,uBAAuB,EACvBH,wBAAwB,EACxBS,iCAAiC,EACjCP,wBAAwB","ignoreList":[]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
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
+ const ELEMENT_CLASS = "react-native-marcus";
26
+ const TAGS = {
27
+ "strong": "strong",
28
+ "emphasis": "em",
29
+ // GFM renders `~~x~~` as `<del>`, and so does this. `<s>` is for text that is no longer accurate
30
+ // rather than text that was taken out.
31
+ "strikethrough": "del",
32
+ "code": "code",
33
+ "pre": "code",
34
+ "codeblock": "pre",
35
+ "blockquote": "blockquote",
36
+ "list-ordered": "ol",
37
+ "list-unordered": "ul",
38
+ "list-item": "li",
39
+ "link": "a"
40
+ };
41
+
42
+ /**
43
+ * The types that become a block-level element, and so cannot sit in a `<p>`.
44
+ *
45
+ * `pre` is not among them: it is built as `<code>`, which is phrasing content whatever it is
46
+ * displayed as. Its enclosing `codeblock` is the `<pre>`, and that is.
47
+ */
48
+ const BLOCK_LEVEL_TYPES = new Set(["blockquote", "codeblock", "heading", "list-ordered", "list-unordered"]);
49
+ function isBlockLevelType(type) {
50
+ return BLOCK_LEVEL_TYPES.has(type);
51
+ }
52
+
53
+ /**
54
+ * Builds the element for a range, tagged and typed.
55
+ *
56
+ * `level` applies to headings only, and is the ATX level: `1` through `6` produce that heading,
57
+ * and `0` produces a span. A level arrives as one nested range per level -- `ungroupRanges` is what
58
+ * turns `depth` into the nesting the size scaling compounds down -- so only the outermost of them
59
+ * can be the heading itself, and the copies inside it are spans. `<h2><h2>` is not a thing.
60
+ */
61
+ function createMarkdownElement(type, level = 0) {
62
+ const tag = type === "heading" ? level > 0 ? `h${Math.min(level, 6)}` : "span" : TAGS[type] ?? "span";
63
+ const element = document.createElement(tag);
64
+ element.setAttribute("data-type", type);
65
+
66
+ // Every tag but the span brings the browser's own idea of how it looks, and `MarkdownElements.css`
67
+ // hands that back. The class is what scopes those rules to elements this library built, rather
68
+ // than to every `<blockquote data-type>` on the page.
69
+ if (tag !== "span") {
70
+ element.className = ELEMENT_CLASS;
71
+ }
72
+ return element;
73
+ }
74
+ export { createMarkdownElement, isBlockLevelType, ELEMENT_CLASS };
75
+ //# sourceMappingURL=elementUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ELEMENT_CLASS","TAGS","BLOCK_LEVEL_TYPES","Set","isBlockLevelType","type","has","createMarkdownElement","level","tag","Math","min","element","document","createElement","setAttribute","className"],"sourceRoot":"../../../../src","sources":["web/utils/elementUtils.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,aAAa,GAAG,qBAAqB;AAE3C,MAAMC,IAAuC,GAAG;EAC9C,QAAQ,EAAE,QAAQ;EAClB,UAAU,EAAE,IAAI;EAChB;EACA;EACA,eAAe,EAAE,KAAK;EACtB,MAAM,EAAE,MAAM;EACd,KAAK,EAAE,MAAM;EACb,WAAW,EAAE,KAAK;EAClB,YAAY,EAAE,YAAY;EAC1B,cAAc,EAAE,IAAI;EACpB,gBAAgB,EAAE,IAAI;EACtB,WAAW,EAAE,IAAI;EACjB,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,i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