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