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,7 +1,7 @@
1
1
  import type { HTMLMarkdownElement, MarkdownTextInputElement } from "../../MarkdownTextInput.web";
2
2
  import type { TreeNode } from "./treeUtils";
3
- import type { PartialMarkdownStyle } from "../../styleUtils";
4
- import type { LineLayout } from "./blockLayout";
3
+ import type { ResolvedMarkdownStyle } from "../../styleUtils";
4
+ import type { LineLayout, MarkerRendering } from "./blockLayout";
5
5
  import type { TextMeasurer } from "./measureUtils";
6
6
  import type { MarkdownRange } from "../../commonTypes";
7
7
  type Paragraph = {
@@ -18,7 +18,7 @@ type Paragraph = {
18
18
  */
19
19
  declare function normalizeLines(lines: Paragraph[], ranges: MarkdownRange[]): Paragraph[];
20
20
  /** Builds HTML DOM structure based on passed text and markdown ranges */
21
- declare function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], isMultiline?: boolean, markdownStyle?: PartialMarkdownStyle, disableInlineStyles?: boolean, measure?: TextMeasurer): {
21
+ declare function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], isMultiline?: boolean, markdownStyle?: ResolvedMarkdownStyle, disableInlineStyles?: boolean, measure?: TextMeasurer, rendering?: MarkerRendering): {
22
22
  dom: HTMLMarkdownElement;
23
23
  tree: TreeNode;
24
24
  };
@@ -31,11 +31,11 @@ type CachedLine = {
31
31
  node: TreeNode;
32
32
  };
33
33
  type LineCache = {
34
- markdownStyle: PartialMarkdownStyle;
34
+ markdownStyle: ResolvedMarkdownStyle;
35
35
  isMultiline: boolean;
36
36
  lines: CachedLine[];
37
37
  };
38
- declare function updateInputStructure(parserFunction: (input: string) => MarkdownRange[], target: MarkdownTextInputElement, text: string, cursorPositionIndex: number | null, isMultiline?: boolean, markdownStyle?: PartialMarkdownStyle, alwaysMoveCursorToTheEnd?: boolean, shouldForceDOMUpdate?: boolean, shouldScrollIntoView?: boolean): {
38
+ declare function updateInputStructure(parserFunction: (input: string) => MarkdownRange[], target: MarkdownTextInputElement, text: string, cursorPositionIndex: number | null, isMultiline?: boolean, markdownStyle?: ResolvedMarkdownStyle, alwaysMoveCursorToTheEnd?: boolean, shouldForceDOMUpdate?: boolean, shouldScrollIntoView?: boolean): {
39
39
  text: string;
40
40
  cursorPosition: number;
41
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parserUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/parserUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAEhG,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA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AE,QAAQ,CAAA;CACf,CAAA;AAED,KAAK,SAAS,GAAG;IACf,aAAa,EAAE,qBAAqB,CAAA;IACpC,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB,CAAA;AA4QD,iBAAS,oBAAoB,CAC3B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,EAAE,EAClD,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,WAAW,UAAO,EAClB,aAAa,GAAE,qBAA0B,EACzC,wBAAwB,UAAQ,EAChC,oBAAoB,UAAQ,EAC5B,oBAAoB,UAAQ;;;EAiD7B;AAED,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAA;AACvE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA"}
@@ -1,6 +1,11 @@
1
1
  import type { HTMLMarkdownElement } from "../../MarkdownTextInput.web";
2
2
  import type { MarkdownRange, MarkdownType } from "../../commonTypes";
3
- type NodeType = MarkdownType | "line" | "text" | "br" | "root";
3
+ /**
4
+ * `list-item` is the one node with no range behind it: `<ul>` and `<ol>` may hold nothing but
5
+ * `<li>`, so the builder puts one inside each list container and everything the container holds
6
+ * goes in there. It covers exactly what its container does.
7
+ */
8
+ type NodeType = MarkdownType | "line" | "text" | "br" | "root" | "list-item";
4
9
  type TreeNode = Omit<MarkdownRange, "type"> & {
5
10
  element: HTMLMarkdownElement;
6
11
  parentNode: TreeNode | null;
@@ -1 +1 @@
1
- {"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/treeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEpE,KAAK,QAAQ,GAAG,YAAY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,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,WAAW,CAAA;AAE5E,KAAK,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;IAC5C,OAAO,EAAE,mBAAmB,CAAA;IAC5B,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAA;IAC3B,UAAU,EAAE,QAAQ,EAAE,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,mBAAmB,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,iBAAS,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,SAAI,EAAE,KAAK,SAAI,GAAG,QAAQ,CAWxF;AAED;;;;;;GAMG;AACH,iBAAS,aAAa,CACpB,OAAO,EAAE,mBAAmB,EAC5B,cAAc,EAAE,QAAQ,EACxB,IAAI,EAAE,QAAQ,EACd,MAAM,GAAE,MAAM,GAAG,IAAW,EAC5B,KAAK,GAAE,MAAM,GAAG,IAAW,YAyC5B;AAED,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,GAAG,IAAI,CAuBxF;AAED,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAqC9E;AAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;AAEvF,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import type { TextStyle } from "react-native";
2
- import type { MarkdownStyle } from "../../MarcusTextInputDecoratorViewNativeComponent";
3
- declare function processMarkdownStyle(input: MarkdownStyle | undefined): MarkdownStyle;
2
+ import type { PartialMarkdownStyle, ResolvedMarkdownStyle } from "../../styleUtils";
3
+ declare function processMarkdownStyle(input: PartialMarkdownStyle | undefined): ResolvedMarkdownStyle;
4
4
  declare function parseToReactDOMStyle(style: TextStyle): any;
5
5
  declare const idGenerator: Generator<string, void, unknown>;
6
6
  export { parseToReactDOMStyle, processMarkdownStyle, idGenerator };
@@ -1 +1 @@
1
- {"version":3,"file":"webStyleUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/webStyleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAA;AAiDtF,iBAAS,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,aAAa,CAE7E;AAED,iBAAS,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAEnD;AASD,QAAA,MAAM,WAAW,kCAAqB,CAAA;AAEtC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAA"}
1
+ {"version":3,"file":"webStyleUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/webStyleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAwEnF,iBAAS,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,qBAAqB,CAE5F;AAED,iBAAS,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAEnD;AASD,QAAA,MAAM,WAAW,kCAAqB,CAAA;AAEtC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=links.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.test.d.ts","sourceRoot":"","sources":["../../../../e2e/links.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,93 @@
1
+ import type { ColorValue, ViewProps } from "react-native";
2
+ import type { Float, Int32 } from "react-native/Libraries/Types/CodegenTypes";
3
+ import type { MarkdownStyle as TextInputMarkdownStyle } from "./MarcusTextInputDecoratorViewNativeComponent";
4
+ interface MarkdownTextStyle {
5
+ color?: ColorValue;
6
+ fontFamily?: string;
7
+ fontSize?: Float;
8
+ fontStyle?: string;
9
+ fontWeight?: string;
10
+ letterSpacing?: Float;
11
+ lineHeight?: Float;
12
+ textDecorationLine?: string;
13
+ textDecorationColor?: ColorValue;
14
+ textDecorationStyle?: string;
15
+ textShadowColor?: ColorValue;
16
+ textShadowOffset?: {
17
+ width: Float;
18
+ height: Float;
19
+ };
20
+ textShadowRadius?: Float;
21
+ }
22
+ interface MarkdownBoxStyle extends MarkdownTextStyle {
23
+ backgroundColor?: ColorValue;
24
+ borderColor?: ColorValue;
25
+ borderWidth?: Float;
26
+ borderRadius?: Float;
27
+ padding?: Float;
28
+ paddingHorizontal?: Float;
29
+ paddingVertical?: Float;
30
+ margin?: Float;
31
+ marginHorizontal?: Float;
32
+ marginVertical?: Float;
33
+ }
34
+ interface MarkdownHeadingStyle extends MarkdownTextStyle {
35
+ scale?: Float;
36
+ }
37
+ interface MarkdownBlockquoteStyle extends MarkdownTextStyle {
38
+ borderColor?: ColorValue;
39
+ borderWidth?: Float;
40
+ borderRadius?: Float;
41
+ marginStart?: Float;
42
+ paddingStart?: Float;
43
+ }
44
+ interface MarkdownListStyle {
45
+ marginStart?: Float;
46
+ paddingStart?: Float;
47
+ markerScale?: Float;
48
+ markerPadding?: Float;
49
+ marker?: MarkdownTextStyle;
50
+ }
51
+ interface MarkdownEmojiStyle {
52
+ fontSize?: Float;
53
+ fontFamily?: string;
54
+ }
55
+ interface MarkdownStyle {
56
+ syntax: MarkdownTextStyle;
57
+ emoji: MarkdownEmojiStyle;
58
+ link: MarkdownTextStyle;
59
+ strong: MarkdownTextStyle;
60
+ emphasis: MarkdownTextStyle;
61
+ strikethrough: MarkdownTextStyle;
62
+ heading: MarkdownHeadingStyle;
63
+ blockquote: MarkdownBlockquoteStyle;
64
+ orderedList: MarkdownListStyle;
65
+ unorderedList: MarkdownListStyle;
66
+ code: MarkdownBoxStyle;
67
+ pre: MarkdownBoxStyle;
68
+ mention: MarkdownBoxStyle;
69
+ }
70
+ interface MarkdownRangeStruct {
71
+ type: string;
72
+ start: Int32;
73
+ length: Int32;
74
+ depth: Int32;
75
+ }
76
+ interface MarkdownSubstitutionStruct {
77
+ index: Int32;
78
+ text: string;
79
+ }
80
+ interface NativeProps extends ViewProps {
81
+ markdownStyle: MarkdownStyle;
82
+ ranges: ReadonlyArray<MarkdownRangeStruct>;
83
+ substitutions: ReadonlyArray<MarkdownSubstitutionStruct>;
84
+ }
85
+ type Assignable<A extends B, B> = A;
86
+ type StyleMatchesTextInput = [
87
+ Assignable<MarkdownStyle, TextInputMarkdownStyle>,
88
+ Assignable<TextInputMarkdownStyle, MarkdownStyle>
89
+ ];
90
+ declare const _default: import("react-native").HostComponent<NativeProps>;
91
+ export default _default;
92
+ export type { MarkdownRangeStruct, MarkdownSubstitutionStruct, StyleMatchesTextInput };
93
+ //# sourceMappingURL=MarcusTextDecoratorViewNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarcusTextDecoratorViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/MarcusTextDecoratorViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AAE7E,OAAO,KAAK,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AAyB5G,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,E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,sBAAsB,CAAC;IACjD,UAAU,CAAC,sBAAsB,EAAE,aAAa,CAAC;CAClD,CAAA;;AAED,wBAEE;AAEF,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,CAAA"}
@@ -1,57 +1,70 @@
1
1
  import type { ColorValue, ViewProps } from "react-native";
2
2
  import type { Float, Int32 } from "react-native/Libraries/Types/CodegenTypes";
3
- interface CodeBlockStyle {
4
- fontFamily: string;
5
- fontSize: Float;
6
- color: ColorValue;
7
- backgroundColor: ColorValue;
3
+ interface MarkdownTextStyle {
4
+ color?: ColorValue;
5
+ fontFamily?: string;
6
+ fontSize?: Float;
7
+ fontStyle?: string;
8
+ fontWeight?: string;
9
+ letterSpacing?: Float;
10
+ lineHeight?: Float;
11
+ textDecorationLine?: string;
12
+ textDecorationColor?: ColorValue;
13
+ textDecorationStyle?: string;
14
+ textShadowColor?: ColorValue;
15
+ textShadowOffset?: {
16
+ width: Float;
17
+ height: Float;
18
+ };
19
+ textShadowRadius?: Float;
20
+ }
21
+ interface MarkdownBoxStyle extends MarkdownTextStyle {
22
+ backgroundColor?: ColorValue;
23
+ borderColor?: ColorValue;
24
+ borderWidth?: Float;
25
+ borderRadius?: Float;
26
+ padding?: Float;
27
+ paddingHorizontal?: Float;
28
+ paddingVertical?: Float;
29
+ margin?: Float;
30
+ marginHorizontal?: Float;
31
+ marginVertical?: Float;
32
+ }
33
+ interface MarkdownHeadingStyle extends MarkdownTextStyle {
34
+ scale?: Float;
35
+ }
36
+ interface MarkdownBlockquoteStyle extends MarkdownTextStyle {
37
+ borderColor?: ColorValue;
38
+ borderWidth?: Float;
39
+ borderRadius?: Float;
40
+ marginStart?: Float;
41
+ paddingStart?: Float;
42
+ }
43
+ interface MarkdownListStyle {
44
+ marginStart?: Float;
45
+ paddingStart?: Float;
46
+ markerScale?: Float;
47
+ markerPadding?: Float;
48
+ marker?: MarkdownTextStyle;
49
+ }
50
+ interface MarkdownEmojiStyle {
51
+ fontSize?: Float;
52
+ fontFamily?: string;
8
53
  }
9
54
  interface MarkdownStyle {
10
- syntax: {
11
- color: ColorValue;
12
- };
13
- emoji: {
14
- fontSize: Float;
15
- fontFamily: string;
16
- };
17
- link: {
18
- color: ColorValue;
19
- };
20
- heading: {
21
- fontSize: Float;
22
- scale: Float;
23
- };
24
- blockquote: {
25
- borderColor: ColorValue;
26
- borderWidth: Float;
27
- marginLeft: Float;
28
- paddingLeft: Float;
29
- };
30
- orderedList: {
31
- marginLeft: Float;
32
- paddingLeft: Float;
33
- };
34
- unorderedList: {
35
- marginLeft: Float;
36
- paddingLeft: Float;
37
- };
38
- code: CodeBlockStyle;
39
- pre: CodeBlockStyle;
40
- mentionHere: {
41
- color: ColorValue;
42
- backgroundColor: ColorValue;
43
- borderRadius?: Float;
44
- };
45
- mentionUser: {
46
- color: ColorValue;
47
- backgroundColor: ColorValue;
48
- borderRadius?: Float;
49
- };
50
- mentionReport: {
51
- color: ColorValue;
52
- backgroundColor: ColorValue;
53
- borderRadius?: Float;
54
- };
55
+ syntax: MarkdownTextStyle;
56
+ emoji: MarkdownEmojiStyle;
57
+ link: MarkdownTextStyle;
58
+ strong: MarkdownTextStyle;
59
+ emphasis: MarkdownTextStyle;
60
+ strikethrough: MarkdownTextStyle;
61
+ heading: MarkdownHeadingStyle;
62
+ blockquote: MarkdownBlockquoteStyle;
63
+ orderedList: MarkdownListStyle;
64
+ unorderedList: MarkdownListStyle;
65
+ code: MarkdownBoxStyle;
66
+ pre: MarkdownBoxStyle;
67
+ mention: MarkdownBoxStyle;
55
68
  }
56
69
  interface NativeProps extends ViewProps {
57
70
  markdownStyle: MarkdownStyle;
@@ -59,5 +72,5 @@ interface NativeProps extends ViewProps {
59
72
  }
60
73
  declare const _default: import("react-native").HostComponent<NativeProps>;
61
74
  export default _default;
62
- export type { MarkdownStyle };
75
+ export type { MarkdownStyle, MarkdownTextStyle, MarkdownEmojiStyle, MarkdownBoxStyle, MarkdownHeadingStyle, MarkdownBlockquoteStyle, MarkdownListStyle, };
63
76
  //# sourceMappingURL=MarcusTextInputDecoratorViewNativeComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarcusTextInputDecoratorViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/MarcusTextInputDecoratorViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AAK7E,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,eAAe,EAAE,UAAU,CAAA;CAC5B;AAED,UAAU,aAAa;IACrB,MAAM,EAAE;QACN,KAAK,EAAE,UAAU,CAAA;KAClB,CAAA;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,UAAU,CAAA;KAClB,CAAA;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,KAAK,CAAA;QAGf,KAAK,EAAE,KAAK,CAAA;KACb,CAAA;IACD,UAAU,EAAE;QACV,WAAW,EAAE,UAAU,CAAA;QACvB,WAAW,EAAE,KAAK,CAAA;QAClB,UAAU,EAAE,KAAK,CAAA;QACjB,WAAW,EAAE,KAAK,CAAA;KACnB,CAAA;IAGD,WAAW,EAAE;QACX,UAAU,EAAE,KAAK,CAAA;QACjB,WAAW,EAAE,KAAK,CAAA;KACnB,CAAA;IACD,aAAa,EAAE;QACb,UAAU,EAAE,KAAK,CAAA;QACjB,WAAW,EAAE,KAAK,CAAA;KACnB,CAAA;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE;QACX,KAAK,EAAE,UAAU,CAAA;QACjB,eAAe,EAAE,UAAU,CAAA;QAC3B,YAAY,CAAC,EAAE,KAAK,CAAA;KACrB,CAAA;IACD,WAAW,EAAE;QACX,KAAK,EAAE,UAAU,CAAA;QACjB,eAAe,EAAE,UAAU,CAAA;QAC3B,YAAY,CAAC,EAAE,KAAK,CAAA;KACrB,CAAA;IACD,aAAa,EAAE;QACb,KAAK,EAAE,UAAU,CAAA;QACjB,eAAe,EAAE,UAAU,CAAA;QAC3B,YAAY,CAAC,EAAE,KAAK,CAAA;KACrB,CAAA;CACF;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,KAAK,CAAA;CAChB;;AAED,wBAEE;AAEF,YAAY,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"MarcusTextInputDecoratorViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/MarcusTextInputDecoratorViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAA;AAmB7E,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,KAAK,CAAA;IAGrB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAG3B,mBAAmB,CAAC,EAAE,UAAU,CAAA;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,eAAe,CAAC,EAAE,UAAU,CAAA;IAC5B,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,EA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iB,CAAA;IACzB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,aAAa,EAAE,iBAAiB,CAAA;IAChC,OAAO,EAAE,oBAAoB,CAAA;IAC7B,UAAU,EAAE,uBAAuB,CAAA;IACnC,WAAW,EAAE,iBAAiB,CAAA;IAC9B,aAAa,EAAE,iBAAiB,CAAA;IAChC,IAAI,EAAE,gBAAgB,CAAA;IACtB,GAAG,EAAE,gBAAgB,CAAA;IAGrB,OAAO,EAAE,gBAAgB,CAAA;CAC1B;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,KAAK,CAAA;CAChB;;AAED,wBAEE;AAEF,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,GAClB,CAAA"}
@@ -0,0 +1,127 @@
1
+ import { Text } from "react-native";
2
+ import React from "react";
3
+ import type { TextProps } from "react-native";
4
+ import type { PartialMarkdownStyle } from "./styleUtils.js";
5
+ /**
6
+ * What to show in place of an image.
7
+ *
8
+ * Must return a single view with a definite width and height, or nothing: the
9
+ * text layout has to know how much room to leave before it can lay the line
10
+ * out, and markdown carries no dimensions. Anything that reports no size --
11
+ * a bare `Image` with a remote source, most obviously -- measures zero and
12
+ * disappears.
13
+ *
14
+ * The alt text is passed through rather than used: what it is good for, an
15
+ * accessibility label most of all, is a question only the caller can answer.
16
+ *
17
+ * `inline` says whether the image shares its line with anything else, which is
18
+ * usually what decides how big it should be: alone on a line it is a figure,
19
+ * and in the middle of a sentence it is a badge. A block marker does not count
20
+ * as company, and another image does.
21
+ *
22
+ * Every string is always a string: an image written without a title is handed
23
+ * an empty one rather than nothing, so a caller never has to tell the two
24
+ * apart.
25
+ */
26
+ type RenderEmbed = (uri: string, alt: string, title: string, inline: boolean) => React.ReactElement | null | undefined;
27
+ /**
28
+ * What to draw an SVG with.
29
+ *
30
+ * Handed a complete SVG document and the box it belongs in, and expected to
31
+ * return a view of exactly that size. There is deliberately nothing else in the
32
+ * signature: everything a picture needs -- the colour, the glyph outlines, the
33
+ * baseline it sits on -- is either inside the XML already or has been taken
34
+ * care of by the time this is called, so `<SvgXml xml={xml} width={width}
35
+ * height={height} />` is the whole of a correct implementation.
36
+ *
37
+ * It exists because a renderer for SVG is a dependency, and which one is not
38
+ * this library's business: `react-native-svg` on native, whatever you like on
39
+ * the web.
40
+ *
41
+ * Returning nothing leaves the drawing out, and the span it stood for still
42
+ * costs its one character either way.
43
+ */
44
+ type RenderSVG = (xml: string, width: number, height: number) => React.ReactElement | null | undefined;
45
+ /**
46
+ * What to do when a link is pressed.
47
+ *
48
+ * The label is the text the link was rendered as, which is all a reader saw of
49
+ * it: the destination is not in the document any more. Reference links are not
50
+ * covered -- their destination is written somewhere else and is not resolved
51
+ * yet -- so they render as links and do nothing.
52
+ *
53
+ * Opening the URL is deliberately not done for you: what a link means is the
54
+ * application's to decide, and a message from a stranger is the last place to
55
+ * hand an arbitrary URL to `Linking.openURL` without looking at it first.
56
+ *
57
+ * Every string is always a string: a link written without a title is handed an
58
+ * empty one rather than nothing.
59
+ */
60
+ type OnLinkPress = (uri: string, label: string, title: string) => void;
61
+ interface MarkdownTextProps extends TextProps {
62
+ markdownStyle?: PartialMarkdownStyle;
63
+ /**
64
+ * GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
65
+ *
66
+ * @default false
67
+ */
68
+ gfm?: boolean;
69
+ /**
70
+ * `@name` mentions, which no flavour of markdown has a notion of.
71
+ *
72
+ * @default false
73
+ */
74
+ mention?: boolean;
75
+ /**
76
+ * LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
77
+ * of its own for a block.
78
+ *
79
+ * @default false
80
+ */
81
+ math?: boolean;
82
+ renderEmbed?: RenderEmbed;
83
+ /**
84
+ * What to draw a maths span with. Nothing is drawn without it, and `$$x^2$$`
85
+ * is left on the screen as it was written.
86
+ */
87
+ renderSVG?: RenderSVG;
88
+ /**
89
+ * The language a drawn equation is read out in, as the speech engine names
90
+ * it: `af`, `ca`, `da`, `de`, `en`, `es`, `fr`, `hi`, `it`, `ko`, `nb`, `nn`
91
+ * or `sv`.
92
+ *
93
+ * What a document is written in and what its reader speaks are two different
94
+ * questions, and only the application knows the answer to the second, so this
95
+ * is usually whatever the rest of the interface is translated into. It
96
+ * changes only how the maths is *said*: the prose around it is read in the
97
+ * language it was written in, and the drawing itself is the same picture in
98
+ * every language.
99
+ *
100
+ * The rules for one language are around 300KB, so only the ones named in
101
+ * `withMath(config, { locales })` are in the bundle. A language that is not
102
+ * is read in English, with a warning in the console saying which line of
103
+ * Metro config would fix it.
104
+ *
105
+ * @default "en"
106
+ */
107
+ mathAccessibilityLocale?: string;
108
+ onLinkPress?: OnLinkPress;
109
+ }
110
+ type MarkdownText = Text & React.Component<MarkdownTextProps>;
111
+ /**
112
+ * `Text`, with the markdown in its content rendered rather than shown.
113
+ *
114
+ * The syntax is removed in JavaScript before the text ever reaches the shadow
115
+ * tree, so what gets measured, drawn, selected, copied and read out is the
116
+ * finished prose. What is left over -- which run is bold, where a quote starts
117
+ * -- is handed to the native decorator as ranges over that stripped string, and
118
+ * styled by the same formatter the input uses, so a message and the composer it
119
+ * was typed in agree by construction.
120
+ *
121
+ * List markers are the exception that stays: `1.` numbers an item and `-`
122
+ * stands in for a bullet, so they are laid out rather than removed.
123
+ */
124
+ declare const MarkdownText: React.ForwardRefExoticComponent<MarkdownTextProps & React.RefAttributes<MarkdownText>>;
125
+ export type { MarkdownTextProps, OnLinkPress, RenderEmbed, RenderSVG };
126
+ export default MarkdownText;
127
+ //# sourceMappingURL=MarkdownText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownText.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAQ,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,MAAM,OAAO,CAAA;AACz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B,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;AAEtE,eAAe,YAAY,CAAA"}
@@ -0,0 +1,126 @@
1
+ import { Text } from "react-native";
2
+ import React from "react";
3
+ import type { TextProps } from "react-native";
4
+ import "./web/MarkdownElements.css";
5
+ import type { PartialMarkdownStyle } from "./styleUtils.js";
6
+ /**
7
+ * What to show in place of an image.
8
+ *
9
+ * The native contract asks for a view with a definite size, because the text
10
+ * layout has to know how much room to leave before it lays the line out. The
11
+ * web has no such requirement -- the browser reflows around whatever turns up
12
+ * -- but the same callback runs on both, so write it for the stricter one.
13
+ *
14
+ * `inline` says whether the image shares its line with anything else, which is
15
+ * usually what decides how big it should be: alone on a line it is a figure,
16
+ * and in the middle of a sentence it is a badge. A block marker does not count
17
+ * as company, and another image does.
18
+ *
19
+ * Every string is always a string: an image written without a title is handed
20
+ * an empty one rather than nothing, so a caller never has to tell the two
21
+ * apart.
22
+ */
23
+ type RenderEmbed = (uri: string, alt: string, title: string, inline: boolean) => React.ReactElement | null | undefined;
24
+ /**
25
+ * What to draw an SVG with.
26
+ *
27
+ * Handed a complete SVG document and the box it belongs in, and expected to
28
+ * return a view of exactly that size. There is deliberately nothing else in the
29
+ * signature: everything a picture needs -- the colour, the glyph outlines, the
30
+ * baseline it sits on -- is either inside the XML already or has been taken
31
+ * care of by the time this is called, so `<SvgXml xml={xml} width={width}
32
+ * height={height} />` is the whole of a correct implementation.
33
+ *
34
+ * It exists because a renderer for SVG is a dependency, and which one is not
35
+ * this library's business: `react-native-svg` on native, whatever you like on
36
+ * the web.
37
+ *
38
+ * Returning nothing leaves the drawing out, and the span it stood for still
39
+ * costs its one character either way.
40
+ */
41
+ type RenderSVG = (xml: string, width: number, height: number) => React.ReactElement | null | undefined;
42
+ /**
43
+ * What to do when a link is pressed.
44
+ *
45
+ * The label is the text the link was rendered as, which is all a reader saw of
46
+ * it: the destination is not in the document any more. Reference links are not
47
+ * covered -- their destination is written somewhere else and is not resolved
48
+ * yet -- so they render as links and do nothing.
49
+ *
50
+ * Opening the URL is deliberately not done for you: what a link means is the
51
+ * application's to decide, and a message from a stranger is the last place to
52
+ * hand an arbitrary URL to `Linking.openURL` without looking at it first.
53
+ *
54
+ * Every string is always a string: a link written without a title is handed an
55
+ * empty one rather than nothing.
56
+ */
57
+ type OnLinkPress = (uri: string, label: string, title: string) => void;
58
+ interface MarkdownTextProps extends TextProps {
59
+ markdownStyle?: PartialMarkdownStyle;
60
+ /**
61
+ * GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
62
+ *
63
+ * @default false
64
+ */
65
+ gfm?: boolean;
66
+ /**
67
+ * `@name` mentions, which no flavour of markdown has a notion of.
68
+ *
69
+ * @default false
70
+ */
71
+ mention?: boolean;
72
+ /**
73
+ * LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
74
+ * of its own for a block.
75
+ *
76
+ * @default false
77
+ */
78
+ math?: boolean;
79
+ renderEmbed?: RenderEmbed;
80
+ /**
81
+ * What to draw a maths span with. Nothing is drawn without it, and `$$x^2$$`
82
+ * is left on the screen as it was written.
83
+ */
84
+ renderSVG?: RenderSVG;
85
+ /**
86
+ * The language a drawn equation is read out in, as the speech engine names
87
+ * it: `af`, `ca`, `da`, `de`, `en`, `es`, `fr`, `hi`, `it`, `ko`, `nb`, `nn`
88
+ * or `sv`.
89
+ *
90
+ * What a document is written in and what its reader speaks are two different
91
+ * questions, and only the application knows the answer to the second, so this
92
+ * is usually whatever the rest of the interface is translated into. It
93
+ * changes only how the maths is *said*: the prose around it is read in the
94
+ * language it was written in, and the drawing itself is the same picture in
95
+ * every language.
96
+ *
97
+ * The rules for one language are around 300KB, so only the ones named in
98
+ * `withMath(config, { locales })` are in the bundle. A language that is not
99
+ * is read in English, with a warning in the console saying which line of
100
+ * Metro config would fix it.
101
+ *
102
+ * @default "en"
103
+ */
104
+ mathAccessibilityLocale?: string;
105
+ onLinkPress?: OnLinkPress;
106
+ }
107
+ type MarkdownText = Text & React.Component<MarkdownTextProps>;
108
+ /**
109
+ * `Text`, with the markdown in its content rendered rather than shown.
110
+ *
111
+ * Built by the same DOM builder the input uses, from the same ranges, so a message and the composer
112
+ * it was typed in agree by construction -- which on the web means agreeing about indents, about
113
+ * ribbons drawn as background layers, and about the marker widths those are measured from. The only
114
+ * difference is the input, where the syntax is still there to be edited.
115
+ *
116
+ * Rendered as a real `Text` whose children are then replaced. React only ever writes the stripped
117
+ * string into the host element -- a lone string child is set with `textContent`, never as a node it
118
+ * holds on to -- so the effect below is free to put the built markup there instead, and a render
119
+ * that changes the text simply wipes it and lets the effect rebuild before the frame is painted.
120
+ * Rendering the plain string rather than nothing also means a prerendered page carries the prose:
121
+ * `expo export` runs every route through Node, where there is no DOM to build markup with.
122
+ */
123
+ declare const MarkdownText: React.ForwardRefExoticComponent<MarkdownTextProps & React.RefAttributes<MarkdownText>>;
124
+ export type { MarkdownTextProps, OnLinkPress, RenderEmbed, RenderSVG };
125
+ export default MarkdownText;
126
+ //# sourceMappingURL=MarkdownText.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownText.web.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownText.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,4BAA4B,CAAA;AAUnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAc,CAAA;AAIxD;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,WAAW,GAAG,CACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,KACZ,KAAK,CAAC,YAAY,GAAG,IAAI,GAAG,SAAS,CAAA;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,SAAS,GAAG,CACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,KACX,KAAK,CAAC,YAAY,GAAG,IAAI,GAAG,SAAS,CAAA;AAE1C;;;;;;;;;;;;;;GAcG;AACH,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;AAEtE,UAAU,iBAAkB,SAAQ,SAAS;IAC3C,aAAa,CAAC,EAAE,oBAAoB,CAAA;IACpC;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;;;;;;;;;;;;;;;;;OAkBG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED,KAAK,YAAY,GAAG,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAA;AA6J7D;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,YAAY,wFAsWhB,CAAA;AAEF,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;AAEtE,eAAe,YAAY,CAAA"}
@@ -12,7 +12,29 @@ declare global {
12
12
  declare function getWorkletRuntime(): WorkletRuntime;
13
13
  interface MarkdownTextInputProps extends TextInputProps {
14
14
  markdownStyle?: PartialMarkdownStyle;
15
- parser: (value: string) => MarkdownRange[];
15
+ /**
16
+ * GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
17
+ *
18
+ * @default false
19
+ */
20
+ gfm?: boolean;
21
+ /**
22
+ * `@name` mentions, which no flavour of markdown has a notion of.
23
+ *
24
+ * @default false
25
+ */
26
+ mention?: boolean;
27
+ /**
28
+ * LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
29
+ * of its own for a block.
30
+ *
31
+ * An input shows what was typed, so the maths stays as written -- what this
32
+ * turns on is recognising it, which greys the dollars as the markup they are
33
+ * and leaves the TeX between them alone.
34
+ *
35
+ * @default false
36
+ */
37
+ math?: boolean;
16
38
  }
17
39
  type MarkdownTextInput = TextInput & React.Component<MarkdownTextInputProps>;
18
40
  declare const MarkdownTextInput: React.ForwardRefExoticComponent<MarkdownTextInputProps & React.RefAttributes<MarkdownTextInput>>;
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownTextInput.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownTextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAgB,MAAM,cAAc,CAAA;AAClE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAK7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAc,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAe,CAAA;AAElD,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,oBAAoB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAA;IAE3D,IAAI,yBAAyB,EAAE,CAC7B,gBAAgB,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,KAC1E,MAAM,CAAA;IAEX,IAAI,2BAA2B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5D;AAKD,iBAAS,iBAAiB,IAAI,cAAc,CAO3C;AA8BD,UAAU,sBAAuB,SAAQ,cAAc;IACrD,aAAa,CAAC,EAAE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