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,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/MarcusTextInputDecoratorVi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@@
1
+ import { Text } from "react-native";
2
+ import React from "react";
3
+ import type { TextProps } from "react-native";
4
+ import type { PartialMarkdownStyle } from "./styleUtils";
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;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAQ7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAUxD;;;;;;;;;;;;;;;;;;;;GAoBG;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;AAsJ7D;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,YAAY,wFAgKhB,CAAA;AAQF,YAAY,EAAE,iBAAiB,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";
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,cAAc,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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A;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,eAAe,CAAA;AAElE,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,oBAAoB,CAAA;IACpC;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,KAAK,iBAAiB,GAAG,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;AAE5E,QAAA,MAAM,iBAAiB,kGAsCtB,CAAA;AAQD,YAAY,EAAE,oBAAoB,IAAI,aAAa,EAAE,sBAAsB,EAAE,CAAA;AAE7E,eAAe,iBAAiB,CAAA;AAEhC,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -3,12 +3,34 @@ import React from "react";
3
3
  import type { MouseEvent } from "react";
4
4
  import type { LineCache } from "./web/utils/parserUtils";
5
5
  import type { TreeNode } from "./web/utils/treeUtils";
6
+ import "./web/MarkdownElements.css";
6
7
  import "./web/MarkdownTextInput.css";
7
- import type { MarkdownStyle } from "./MarcusTextInputDecoratorViewNativeComponent";
8
- import type { MarkdownRange } from "./commonTypes";
8
+ import type { PartialMarkdownStyle } from "./styleUtils";
9
9
  interface MarkdownTextInputProps extends TextInputProps {
10
- markdownStyle?: MarkdownStyle;
11
- parser: (text: string) => MarkdownRange[];
10
+ markdownStyle?: PartialMarkdownStyle;
11
+ /**
12
+ * GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
13
+ *
14
+ * @default false
15
+ */
16
+ gfm?: boolean;
17
+ /**
18
+ * `@name` mentions, which no flavour of markdown has a notion of.
19
+ *
20
+ * @default false
21
+ */
22
+ mention?: boolean;
23
+ /**
24
+ * LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
25
+ * of its own for a block.
26
+ *
27
+ * An input shows what was typed, so the maths stays as written -- what this
28
+ * turns on is recognising it, which greys the dollars as the markup they are
29
+ * and leaves the TeX between them alone.
30
+ *
31
+ * @default false
32
+ */
33
+ math?: boolean;
12
34
  onClick?: (e: MouseEvent<HTMLDivElement>) => void;
13
35
  dir?: string;
14
36
  disabled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownTextInput.web.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownTextInput.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EAKT,cAAc,EAKf,MAAM,cAAc,CAAA;AACrB,OAAO,KAAmE,MAAM,OAAO,CAAA;AACvF,OAAO,KAAK,EAKV,UAAU,EAKX,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAMrD,OAAO,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAalF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIlD,UAAU,sBAAuB,SAAQ,cAAc;IACrD,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E,SAAS,CAAA;CACtB,CAAA;AAEH,KAAK,mBAAmB,GAAG,WAAW,GAAG;IACvC,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,QAAA,MAAM,iBAAiB,kGAkzBtB,CAAA;AAwBD,eAAe,iBAAiB,CAAA;AAEhC,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,GACpB,CAAA;AAED,iBAAS,iBAAiB,SAIzB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -0,0 +1,58 @@
1
+ import type { MarkdownEmbed, MarkdownMath, StrippedMarkdown } from "./stripUtils";
2
+ type Atom = ({
3
+ kind: "embed";
4
+ } & MarkdownEmbed) | ({
5
+ kind: "math";
6
+ } & MarkdownMath);
7
+ /**
8
+ * How a maths span is said out loud, or nothing for one that cannot be said.
9
+ *
10
+ * Passed in rather than imported so that this module knows nothing about
11
+ * typesetting: it is `./math`'s `speakMath` at both call sites, and a display
12
+ * with no maths backend passes one that always declines.
13
+ */
14
+ type SpeakMath = (tex: string, display: boolean, locale?: string) => string | null;
15
+ declare const NO_ATOMS: Atom[];
16
+ /**
17
+ * Every placeholder in the stripped text, in the order it stands there.
18
+ *
19
+ * Sorting is enough to interleave the two kinds correctly: each index is a
20
+ * distinct character in the same string, so no two atoms can share one.
21
+ */
22
+ declare function atomsOf(markdown: StrippedMarkdown): Atom[];
23
+ /**
24
+ * The text as it should be read out, with every placeholder written back out
25
+ * as what it stands for.
26
+ *
27
+ * A drawing costs exactly one character in the string the platform lays out --
28
+ * U+FFFC, the object replacement character -- and there is nothing in that
29
+ * character for a screen reader to say. An image's `alt` is its accessible name
30
+ * by every spec there is, and left empty it declares the image decorative, so
31
+ * it is used as written. A maths span is read as what was drawn, which is what
32
+ * `speak` answers; the TeX behind it is the fallback, because an expression
33
+ * read out as its source is still better than a sentence with a hole in it.
34
+ *
35
+ * `locale` is the language the maths is said in, and is passed straight
36
+ * through: the prose around it is in whatever language it was written in, and
37
+ * nothing here can or should change that.
38
+ */
39
+ declare function describeAtoms(markdown: StrippedMarkdown, speak: SpeakMath, locale?: string): string;
40
+ /**
41
+ * What a placeholder puts on the clipboard, which is the markdown it was
42
+ * written as.
43
+ *
44
+ * A copy of rendered text is plain text: `**bold**` comes off the screen as
45
+ * "bold", because that is what a copy of styled text has always been. A drawing
46
+ * has no plain text at all -- it is one U+FFFC, which pastes as a box -- and
47
+ * the source is the only honest thing to put there. Written back out with its
48
+ * dollar signs, a copied paragraph is markdown again and goes back into an
49
+ * editor as the document it came from.
50
+ *
51
+ * An image copies as nothing, the way an `<img>` does on the web: its alt text
52
+ * describes the picture for someone who cannot see it, and pasting a
53
+ * description where a picture was is not what anyone asked for.
54
+ */
55
+ declare function sourceOf(atom: Atom): string;
56
+ export type { Atom, SpeakMath };
57
+ export { NO_ATOMS, atomsOf, describeAtoms, sourceOf };
58
+ //# sourceMappingURL=atomUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomUtils.d.ts","sourceRoot":"","sources":["../../../../src/atomUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AASjF,KAAK,IAAI,GAAG,CAAC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAAC,GAAG,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAAC,CAAA;AAEnF;;;;;;GAMG;AACH,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;AAElF,QAAA,MAAM,QAAQ,EAAE,IAAI,EAAO,CAAA;AAE3B;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EAAE,CAkBnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,aAAa,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB5F;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQpC;AAED,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type React from "react";
2
+ /**
3
+ * Flattens children into the string they render as, or null if they are not
4
+ * text.
5
+ *
6
+ * Only strings and numbers are markdown. An element child is content there are
7
+ * no parser offsets for and no way to strip syntax out of, so a subtree
8
+ * containing one renders unformatted rather than half formatted.
9
+ */
10
+ declare function flattenText(children: React.ReactNode): string | null;
11
+ export { flattenText };
12
+ //# sourceMappingURL=childrenUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"childrenUtils.d.ts","sourceRoot":"","sources":["../../../../src/childrenUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;;GAOG;AACH,iBAAS,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,CAI7D;AAwBD,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -1,10 +1,46 @@
1
- type MarkdownType = "bold" | "italic" | "strikethrough" | "emoji" | "mention-here" | "mention-user" | "mention-short" | "mention-report" | "link" | "code" | "pre" | "blockquote" | "list-ordered" | "list-unordered" | "block-prefix" | "heading" | "syntax" | "inline-image" | "codeblock";
1
+ type MarkdownType = "strong" | "emphasis" | "strikethrough" | "emoji" | "mention" | "link" | "label" | "alt" | "title" | "code" | "pre" | "blockquote" | "list-ordered" | "list-unordered" | "block-prefix" | "heading" | "syntax" | "image" | "codeblock" | "math" | "math-block" | "language";
2
2
  interface MarkdownRange {
3
3
  type: MarkdownType;
4
4
  start: number;
5
5
  length: number;
6
6
  depth?: number;
7
- syntaxType?: "opening" | "closing";
8
7
  }
9
- export type { MarkdownType, MarkdownRange };
8
+ /**
9
+ * What the parser recognises beyond CommonMark.
10
+ *
11
+ * Every one of them is off unless it is asked for. Each changes what an
12
+ * ordinary character means -- a tilde, an `@`, a dollar sign -- and a document
13
+ * written somewhere else, by someone who never heard of this library, is the
14
+ * one place where guessing at that is least recoverable. They are the whole of
15
+ * the parser's configuration: a caller chooses a flavour, not a parser, and the
16
+ * components take these as props of their own.
17
+ */
18
+ interface ParserOptions {
19
+ /**
20
+ * GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
21
+ *
22
+ * @default false
23
+ */
24
+ gfm?: boolean;
25
+ /**
26
+ * `@name` mentions, which no flavour of markdown has a notion of.
27
+ *
28
+ * @default false
29
+ */
30
+ mention?: boolean;
31
+ /**
32
+ * LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
33
+ * of its own for a block.
34
+ *
35
+ * Two dollars, never one: `$5 and $6` is a price list in every document that
36
+ * has ever been written, and single-dollar maths would quietly turn it into a
37
+ * picture of the word "and".
38
+ *
39
+ * @default false
40
+ */
41
+ math?: boolean;
42
+ }
43
+ /** A parser, as the components hold one: text in, ranges out. */
44
+ type MarkdownParser = (markdown: string) => MarkdownRange[];
45
+ export type { MarkdownType, MarkdownRange, ParserOptions, MarkdownParser };
10
46
  //# sourceMappingURL=commonTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commonTypes.d.ts","sourceRoot":"","sources":["../../../../src/commonTypes.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GACb,MAAM,GACN,QAAQ,GACR,eAAe,GACf,OAAO,GACP,cAAc,GACd,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,KAAK,GACL,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,SAAS,GACT,QAAQ,GACR,cAAc,GACd,WAAW,CAAA;AAEf,UAAU,aAAa;IACrB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CACnC;AAED,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"commonTypes.d.ts","sourceRoot":"","sources":["../../../../src/commonTypes.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GACb,QAAQ,GACR,UAAU,GACV,eAAe,GACf,OAAO,GAIP,SAAS,GACT,MAAM,GAIN,OAAO,GAKP,KAAK,GAIL,OAAO,GACP,MAAM,GACN,KAAK,GACL,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,SAAS,GACT,QAAQ,GACR,OAAO,GACP,WAAW,GAIX,MAAM,GAEN,YAAY,GAGZ,UAAU,CAAA;AAEd,UAAU,aAAa;IACrB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;GASG;AACH,UAAU,aAAa;IACrB;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,iEAAiE;AACjE,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,aAAa,EAAE,CAAA;AAE3D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export { default as MarkdownTextInput, getWorkletRuntime } from "./MarkdownTextInput";
2
2
  export type { MarkdownTextInputProps, MarkdownStyle } from "./MarkdownTextInput";
3
+ export { default as MarkdownText } from "./MarkdownText";
4
+ export type { MarkdownTextProps, OnLinkPress, RenderEmbed, RenderSVG } from "./MarkdownText";
3
5
  export type { MarkdownType, MarkdownRange } from "./commonTypes";
4
- export { parse as parser } from "./parser";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrF,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAChF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrF,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC5F,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA"}