react-native-marcus 0.1.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 (304) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +227 -0
  3. package/RNMarcus.podspec +78 -0
  4. package/android/build.gradle +220 -0
  5. package/android/proguard-rules.pro +1 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/cpp/CMakeLists.txt +41 -0
  9. package/android/src/main/cpp/MarkdownParser.cpp +49 -0
  10. package/android/src/main/cpp/MarkdownParser.h +56 -0
  11. package/android/src/main/cpp/OnLoad.cpp +17 -0
  12. package/android/src/main/java/app/getbullet/marcus/MarcusModule.kt +28 -0
  13. package/android/src/main/java/app/getbullet/marcus/MarcusPackage.kt +31 -0
  14. package/android/src/main/java/app/getbullet/marcus/MarcusTextInputDecoratorView.kt +63 -0
  15. package/android/src/main/java/app/getbullet/marcus/MarcusTextInputDecoratorViewManager.kt +32 -0
  16. package/android/src/main/java/app/getbullet/marcus/MarcusTextInputDecoratorViewManagerSpec.kt +21 -0
  17. package/android/src/main/java/app/getbullet/marcus/MarkdownFormatter.kt +333 -0
  18. package/android/src/main/java/app/getbullet/marcus/MarkdownParseResult.kt +12 -0
  19. package/android/src/main/java/app/getbullet/marcus/MarkdownParser.kt +89 -0
  20. package/android/src/main/java/app/getbullet/marcus/MarkdownRange.kt +11 -0
  21. package/android/src/main/java/app/getbullet/marcus/MarkdownStyle.kt +81 -0
  22. package/android/src/main/java/app/getbullet/marcus/MarkdownTextWatcher.kt +17 -0
  23. package/android/src/main/java/app/getbullet/marcus/MarkdownUtils.kt +84 -0
  24. package/android/src/main/java/app/getbullet/marcus/ReactLineHeight.java +29 -0
  25. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundColorSpan.kt +6 -0
  26. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundSpan.kt +105 -0
  27. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBlockIndentSpan.kt +67 -0
  28. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBoldSpan.kt +6 -0
  29. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontFamilySpan.kt +28 -0
  30. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontSizeSpan.kt +7 -0
  31. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownForegroundColorSpan.kt +6 -0
  32. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownGapSpan.kt +57 -0
  33. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownItalicSpan.kt +6 -0
  34. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownLineHeightSpan.kt +21 -0
  35. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownSpan.kt +7 -0
  36. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownStrikethroughSpan.kt +5 -0
  37. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownUnderlineSpan.kt +5 -0
  38. package/android/src/main/new_arch/CMakeLists.txt +70 -0
  39. package/android/src/main/new_arch/RNMarcusSpec.cpp +43 -0
  40. package/android/src/main/new_arch/RNMarcusSpec.h +36 -0
  41. package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextInputDecoratorShadowNode.cpp +218 -0
  42. package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextInputDecoratorShadowNode.h +54 -0
  43. package/android/src/reactNativeVersionPatch/CustomMountingManager/81/app/getbullet/marcus/CustomFabricUIManager.java +156 -0
  44. package/android/src/reactNativeVersionPatch/CustomMountingManager/latest/app/getbullet/marcus/CustomFabricUIManager.java +130 -0
  45. package/android/src/test/java/app/getbullet/marcus/MarkdownFormatterTest.kt +205 -0
  46. package/android/src/test/java/app/getbullet/marcus/RenderModel.kt +78 -0
  47. package/android/src/test/resources/render-model.txt +583 -0
  48. package/apple/MarcusModule.h +8 -0
  49. package/apple/MarcusModule.mm +26 -0
  50. package/apple/MarcusRange.h +15 -0
  51. package/apple/MarcusRange.mm +15 -0
  52. package/apple/MarcusTextInputDecoratorComponentView.h +12 -0
  53. package/apple/MarcusTextInputDecoratorComponentView.mm +121 -0
  54. package/apple/MarcusTextInputDecoratorShadowNode.cpp +251 -0
  55. package/apple/MarcusTextInputDecoratorShadowNode.h +65 -0
  56. package/apple/MarcusTextInputDecoratorShadowNode.mm +204 -0
  57. package/apple/MarcusTextInputDecoratorViewManager.h +8 -0
  58. package/apple/MarcusTextInputDecoratorViewManager.mm +11 -0
  59. package/apple/MarkdownAdaptiveImageGlyph.swift +44 -0
  60. package/apple/MarkdownAttributes.h +31 -0
  61. package/apple/MarkdownAttributes.m +9 -0
  62. package/apple/MarkdownBackedTextInputDelegate.swift +117 -0
  63. package/apple/MarkdownDecorator.swift +316 -0
  64. package/apple/MarkdownFonts.swift +21 -0
  65. package/apple/MarkdownFormatter+React.swift +51 -0
  66. package/apple/MarkdownFormatter.swift +509 -0
  67. package/apple/MarkdownLog.h +10 -0
  68. package/apple/MarkdownLog.mm +6 -0
  69. package/apple/MarkdownParser.swift +200 -0
  70. package/apple/MarkdownSwiftInterop.h +23 -0
  71. package/apple/MarkdownTextBackground.swift +17 -0
  72. package/apple/MarkdownTextFieldObserver.swift +90 -0
  73. package/apple/MarkdownTextLayoutFragment.swift +205 -0
  74. package/apple/MarkdownTextLayoutManagerDelegate.swift +84 -0
  75. package/apple/MarkdownTextStorageDelegate.swift +32 -0
  76. package/apple/MarkdownTextViewObserver.swift +30 -0
  77. package/apple/RCTMarcusStyle+Codegen.h +18 -0
  78. package/apple/RCTMarcusStyle+Codegen.mm +64 -0
  79. package/apple/RCTMarcusStyle.h +41 -0
  80. package/apple/RCTMarcusStyle.m +5 -0
  81. package/apple/RCTMarcusUtils.h +26 -0
  82. package/apple/RCTMarcusUtils.mm +26 -0
  83. package/apple/RCTTextInput+AdaptiveImageGlyph.h +16 -0
  84. package/apple/RCTTextInput+AdaptiveImageGlyph.mm +79 -0
  85. package/apple/RCTTextInputComponentView+Marcus.h +11 -0
  86. package/apple/RCTTextInputComponentView+Marcus.mm +79 -0
  87. package/cpp/MarkdownCxx.modulemap +8 -0
  88. package/cpp/MarkdownGlobal.cpp +48 -0
  89. package/cpp/MarkdownGlobal.h +33 -0
  90. package/cpp/MarkdownWorkletParser.cpp +93 -0
  91. package/cpp/MarkdownWorkletParser.h +45 -0
  92. package/cpp/RuntimeDecorator.cpp +39 -0
  93. package/cpp/RuntimeDecorator.h +14 -0
  94. package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextInputDecoratorState.h +33 -0
  95. package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextInputDecoratorViewComponentDescriptor.h +17 -0
  96. package/lib/commonjs/MarcusTextInputDecoratorViewNativeComponent.ts +77 -0
  97. package/lib/commonjs/MarkdownTextInput.js +99 -0
  98. package/lib/commonjs/MarkdownTextInput.js.map +1 -0
  99. package/lib/commonjs/MarkdownTextInput.web.js +618 -0
  100. package/lib/commonjs/MarkdownTextInput.web.js.map +1 -0
  101. package/lib/commonjs/NativeMarcusModule.js +9 -0
  102. package/lib/commonjs/NativeMarcusModule.js.map +1 -0
  103. package/lib/commonjs/commonTypes.js +2 -0
  104. package/lib/commonjs/commonTypes.js.map +1 -0
  105. package/lib/commonjs/global.d.js +2 -0
  106. package/lib/commonjs/global.d.js.map +1 -0
  107. package/lib/commonjs/index.js +27 -0
  108. package/lib/commonjs/index.js.map +1 -0
  109. package/lib/commonjs/package.json +1 -0
  110. package/lib/commonjs/parser/index.js +7030 -0
  111. package/lib/commonjs/parser/index.js.map +7 -0
  112. package/lib/commonjs/rangeUtils.js +71 -0
  113. package/lib/commonjs/rangeUtils.js.map +1 -0
  114. package/lib/commonjs/react-native-web.d.js +2 -0
  115. package/lib/commonjs/react-native-web.d.js.map +1 -0
  116. package/lib/commonjs/styleUtils.js +91 -0
  117. package/lib/commonjs/styleUtils.js.map +1 -0
  118. package/lib/commonjs/web/InputHistory.js +111 -0
  119. package/lib/commonjs/web/InputHistory.js.map +1 -0
  120. package/lib/commonjs/web/MarkdownTextInput.css +72 -0
  121. package/lib/commonjs/web/utils/blockLayout.js +132 -0
  122. package/lib/commonjs/web/utils/blockLayout.js.map +1 -0
  123. package/lib/commonjs/web/utils/blockUtils.js +219 -0
  124. package/lib/commonjs/web/utils/blockUtils.js.map +1 -0
  125. package/lib/commonjs/web/utils/browserUtils.js +40 -0
  126. package/lib/commonjs/web/utils/browserUtils.js.map +1 -0
  127. package/lib/commonjs/web/utils/cursorUtils.js +157 -0
  128. package/lib/commonjs/web/utils/cursorUtils.js.map +1 -0
  129. package/lib/commonjs/web/utils/inputUtils.js +152 -0
  130. package/lib/commonjs/web/utils/inputUtils.js.map +1 -0
  131. package/lib/commonjs/web/utils/measureUtils.js +0 -0
  132. package/lib/commonjs/web/utils/measureUtils.js.map +1 -0
  133. package/lib/commonjs/web/utils/parserUtils.js +552 -0
  134. package/lib/commonjs/web/utils/parserUtils.js.map +1 -0
  135. package/lib/commonjs/web/utils/treeUtils.js +109 -0
  136. package/lib/commonjs/web/utils/treeUtils.js.map +1 -0
  137. package/lib/commonjs/web/utils/webStyleUtils.js +59 -0
  138. package/lib/commonjs/web/utils/webStyleUtils.js.map +1 -0
  139. package/lib/module/MarcusTextInputDecoratorViewNativeComponent.ts +77 -0
  140. package/lib/module/MarkdownTextInput.js +94 -0
  141. package/lib/module/MarkdownTextInput.js.map +1 -0
  142. package/lib/module/MarkdownTextInput.web.js +612 -0
  143. package/lib/module/MarkdownTextInput.web.js.map +1 -0
  144. package/lib/module/NativeMarcusModule.js +5 -0
  145. package/lib/module/NativeMarcusModule.js.map +1 -0
  146. package/lib/module/commonTypes.js +2 -0
  147. package/lib/module/commonTypes.js.map +1 -0
  148. package/lib/module/global.d.js +2 -0
  149. package/lib/module/global.d.js.map +1 -0
  150. package/lib/module/index.js +5 -0
  151. package/lib/module/index.js.map +1 -0
  152. package/lib/module/package.json +1 -0
  153. package/lib/module/parser/index.js +7029 -0
  154. package/lib/module/parser/index.js.map +7 -0
  155. package/lib/module/rangeUtils.js +66 -0
  156. package/lib/module/rangeUtils.js.map +1 -0
  157. package/lib/module/react-native-web.d.js +2 -0
  158. package/lib/module/react-native-web.d.js.map +1 -0
  159. package/lib/module/styleUtils.js +88 -0
  160. package/lib/module/styleUtils.js.map +1 -0
  161. package/lib/module/web/InputHistory.js +106 -0
  162. package/lib/module/web/InputHistory.js.map +1 -0
  163. package/lib/module/web/MarkdownTextInput.css +72 -0
  164. package/lib/module/web/utils/blockLayout.js +128 -0
  165. package/lib/module/web/utils/blockLayout.js.map +1 -0
  166. package/lib/module/web/utils/blockUtils.js +210 -0
  167. package/lib/module/web/utils/blockUtils.js.map +1 -0
  168. package/lib/module/web/utils/browserUtils.js +36 -0
  169. package/lib/module/web/utils/browserUtils.js.map +1 -0
  170. package/lib/module/web/utils/cursorUtils.js +150 -0
  171. package/lib/module/web/utils/cursorUtils.js.map +1 -0
  172. package/lib/module/web/utils/inputUtils.js +144 -0
  173. package/lib/module/web/utils/inputUtils.js.map +1 -0
  174. package/lib/module/web/utils/measureUtils.js +0 -0
  175. package/lib/module/web/utils/measureUtils.js.map +1 -0
  176. package/lib/module/web/utils/parserUtils.js +547 -0
  177. package/lib/module/web/utils/parserUtils.js.map +1 -0
  178. package/lib/module/web/utils/treeUtils.js +103 -0
  179. package/lib/module/web/utils/treeUtils.js.map +1 -0
  180. package/lib/module/web/utils/webStyleUtils.js +54 -0
  181. package/lib/module/web/utils/webStyleUtils.js.map +1 -0
  182. package/lib/typescript/commonjs/e2e/checks.test.d.ts +2 -0
  183. package/lib/typescript/commonjs/e2e/checks.test.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/e2e/editing.test.d.ts +2 -0
  185. package/lib/typescript/commonjs/e2e/editing.test.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/e2e/helpers.d.ts +23 -0
  187. package/lib/typescript/commonjs/e2e/helpers.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/e2e/smoke.test.d.ts +2 -0
  189. package/lib/typescript/commonjs/e2e/smoke.test.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/package.json +1 -0
  191. package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +63 -0
  192. package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts +22 -0
  194. package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts +41 -0
  196. package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/src/NativeMarcusModule.d.ts +7 -0
  198. package/lib/typescript/commonjs/src/NativeMarcusModule.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/src/commonTypes.d.ts +10 -0
  200. package/lib/typescript/commonjs/src/commonTypes.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/src/index.d.ts +5 -0
  202. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/src/parser/index.d.ts +8 -0
  204. package/lib/typescript/commonjs/src/parser/index.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/src/parser/micromark-extension-mentions.d.ts +8 -0
  206. package/lib/typescript/commonjs/src/parser/micromark-extension-mentions.d.ts.map +1 -0
  207. package/lib/typescript/commonjs/src/rangeUtils.d.ts +6 -0
  208. package/lib/typescript/commonjs/src/rangeUtils.d.ts.map +1 -0
  209. package/lib/typescript/commonjs/src/styleUtils.d.ts +8 -0
  210. package/lib/typescript/commonjs/src/styleUtils.d.ts.map +1 -0
  211. package/lib/typescript/commonjs/src/web/InputHistory.d.ts +24 -0
  212. package/lib/typescript/commonjs/src/web/InputHistory.d.ts.map +1 -0
  213. package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts +41 -0
  214. package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts.map +1 -0
  215. package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts +33 -0
  216. package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts.map +1 -0
  217. package/lib/typescript/commonjs/src/web/utils/browserUtils.d.ts +7 -0
  218. package/lib/typescript/commonjs/src/web/utils/browserUtils.d.ts.map +1 -0
  219. package/lib/typescript/commonjs/src/web/utils/cursorUtils.d.ts +12 -0
  220. package/lib/typescript/commonjs/src/web/utils/cursorUtils.d.ts.map +1 -0
  221. package/lib/typescript/commonjs/src/web/utils/inputUtils.d.ts +12 -0
  222. package/lib/typescript/commonjs/src/web/utils/inputUtils.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/src/web/utils/measureUtils.d.ts +22 -0
  224. package/lib/typescript/commonjs/src/web/utils/measureUtils.d.ts.map +1 -0
  225. package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts +44 -0
  226. package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts.map +1 -0
  227. package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts +25 -0
  228. package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts +7 -0
  230. package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts.map +1 -0
  231. package/lib/typescript/module/e2e/checks.test.d.ts +2 -0
  232. package/lib/typescript/module/e2e/checks.test.d.ts.map +1 -0
  233. package/lib/typescript/module/e2e/editing.test.d.ts +2 -0
  234. package/lib/typescript/module/e2e/editing.test.d.ts.map +1 -0
  235. package/lib/typescript/module/e2e/helpers.d.ts +23 -0
  236. package/lib/typescript/module/e2e/helpers.d.ts.map +1 -0
  237. package/lib/typescript/module/e2e/smoke.test.d.ts +2 -0
  238. package/lib/typescript/module/e2e/smoke.test.d.ts.map +1 -0
  239. package/lib/typescript/module/package.json +1 -0
  240. package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +63 -0
  241. package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -0
  242. package/lib/typescript/module/src/MarkdownTextInput.d.ts +22 -0
  243. package/lib/typescript/module/src/MarkdownTextInput.d.ts.map +1 -0
  244. package/lib/typescript/module/src/MarkdownTextInput.web.d.ts +41 -0
  245. package/lib/typescript/module/src/MarkdownTextInput.web.d.ts.map +1 -0
  246. package/lib/typescript/module/src/NativeMarcusModule.d.ts +7 -0
  247. package/lib/typescript/module/src/NativeMarcusModule.d.ts.map +1 -0
  248. package/lib/typescript/module/src/commonTypes.d.ts +10 -0
  249. package/lib/typescript/module/src/commonTypes.d.ts.map +1 -0
  250. package/lib/typescript/module/src/index.d.ts +5 -0
  251. package/lib/typescript/module/src/index.d.ts.map +1 -0
  252. package/lib/typescript/module/src/parser/index.d.ts +8 -0
  253. package/lib/typescript/module/src/parser/index.d.ts.map +1 -0
  254. package/lib/typescript/module/src/parser/micromark-extension-mentions.d.ts +8 -0
  255. package/lib/typescript/module/src/parser/micromark-extension-mentions.d.ts.map +1 -0
  256. package/lib/typescript/module/src/rangeUtils.d.ts +6 -0
  257. package/lib/typescript/module/src/rangeUtils.d.ts.map +1 -0
  258. package/lib/typescript/module/src/styleUtils.d.ts +8 -0
  259. package/lib/typescript/module/src/styleUtils.d.ts.map +1 -0
  260. package/lib/typescript/module/src/web/InputHistory.d.ts +24 -0
  261. package/lib/typescript/module/src/web/InputHistory.d.ts.map +1 -0
  262. package/lib/typescript/module/src/web/utils/blockLayout.d.ts +41 -0
  263. package/lib/typescript/module/src/web/utils/blockLayout.d.ts.map +1 -0
  264. package/lib/typescript/module/src/web/utils/blockUtils.d.ts +33 -0
  265. package/lib/typescript/module/src/web/utils/blockUtils.d.ts.map +1 -0
  266. package/lib/typescript/module/src/web/utils/browserUtils.d.ts +7 -0
  267. package/lib/typescript/module/src/web/utils/browserUtils.d.ts.map +1 -0
  268. package/lib/typescript/module/src/web/utils/cursorUtils.d.ts +12 -0
  269. package/lib/typescript/module/src/web/utils/cursorUtils.d.ts.map +1 -0
  270. package/lib/typescript/module/src/web/utils/inputUtils.d.ts +12 -0
  271. package/lib/typescript/module/src/web/utils/inputUtils.d.ts.map +1 -0
  272. package/lib/typescript/module/src/web/utils/measureUtils.d.ts +22 -0
  273. package/lib/typescript/module/src/web/utils/measureUtils.d.ts.map +1 -0
  274. package/lib/typescript/module/src/web/utils/parserUtils.d.ts +44 -0
  275. package/lib/typescript/module/src/web/utils/parserUtils.d.ts.map +1 -0
  276. package/lib/typescript/module/src/web/utils/treeUtils.d.ts +25 -0
  277. package/lib/typescript/module/src/web/utils/treeUtils.d.ts.map +1 -0
  278. package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts +7 -0
  279. package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts.map +1 -0
  280. package/package.json +167 -0
  281. package/react-native.config.js +10 -0
  282. package/src/MarcusTextInputDecoratorViewNativeComponent.ts +77 -0
  283. package/src/MarkdownTextInput.tsx +139 -0
  284. package/src/MarkdownTextInput.web.tsx +958 -0
  285. package/src/NativeMarcusModule.ts +8 -0
  286. package/src/commonTypes.ts +30 -0
  287. package/src/global.d.ts +1 -0
  288. package/src/index.tsx +4 -0
  289. package/src/parser/index.ts +556 -0
  290. package/src/parser/micromark-extension-mentions.ts +82 -0
  291. package/src/rangeUtils.ts +68 -0
  292. package/src/react-native-web.d.ts +1 -0
  293. package/src/styleUtils.ts +100 -0
  294. package/src/web/InputHistory.ts +137 -0
  295. package/src/web/MarkdownTextInput.css +72 -0
  296. package/src/web/utils/blockLayout.ts +163 -0
  297. package/src/web/utils/blockUtils.ts +245 -0
  298. package/src/web/utils/browserUtils.ts +41 -0
  299. package/src/web/utils/cursorUtils.ts +204 -0
  300. package/src/web/utils/inputUtils.ts +206 -0
  301. package/src/web/utils/measureUtils.ts +0 -0
  302. package/src/web/utils/parserUtils.ts +813 -0
  303. package/src/web/utils/treeUtils.ts +149 -0
  304. package/src/web/utils/webStyleUtils.ts +69 -0
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ "worklet";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getTagPriority = getTagPriority;
8
+ exports.sortRanges = sortRanges;
9
+ exports.ungroupRanges = ungroupRanges;
10
+ // A range is emitted when the construct it belongs to opens, so the parser's order is already
11
+ // containment order: whatever encloses something opened before it. `sortRanges` keeps that order
12
+ // for ranges it cannot separate, which is just as well, because for two containers of the same size
13
+ // the answer is not a property of their types at all -- `> - a` and `- > a` are the same pair over
14
+ // the same line, nested opposite ways.
15
+ //
16
+ // One pairing breaks the rule, deliberately. `flushLine` emits a container's `block-prefix` before
17
+ // the container itself, because the native formatters lay a line out in one left-to-right walk and
18
+ // hand each marker to the container that follows it; the `syntax` inside that marker is emitted
19
+ // earlier still, when the marker's own token opens. Typing a bare `>` therefore produces three
20
+ // ranges over one character, in exactly the wrong order for a tree.
21
+ //
22
+ // This table exists to invert that one pairing, and nothing else: a block container outranks the
23
+ // `block-prefix` holding its marker, which outranks the `syntax` of the marker itself. `heading`
24
+ // sits above the default so it encloses what a heading line contains, and `emoji` below everything
25
+ // because it is always innermost. A container type left out of the table sorts level with the
26
+ // marker it should contain, and the marker then renders once per range -- see
27
+ // `reportAmbiguousNesting`, which is the check for exactly that.
28
+ function getTagPriority(tag) {
29
+ switch (tag) {
30
+ case "blockquote":
31
+ case "list-ordered":
32
+ case "list-unordered":
33
+ return 3;
34
+ case "block-prefix":
35
+ return 2;
36
+ case "heading":
37
+ return 1;
38
+ case "emoji":
39
+ return -1;
40
+ default:
41
+ return 0;
42
+ }
43
+ }
44
+
45
+ // Sorts into the containment order the web builder nests by: outermost first, and for anything the
46
+ // three keys below cannot separate, the order the parser emitted them in. That last step is load
47
+ // bearing rather than incidental -- `Array.prototype.sort` is required to be stable, and emission
48
+ // order is what decides which of two equally sized containers encloses the other.
49
+ function sortRanges(ranges) {
50
+ // sort ranges by start position, then by length, then by tag hierarchy
51
+ return ranges.sort((a, b) => a.start - b.start || b.length - a.length || getTagPriority(b.type) - getTagPriority(a.type) || 0);
52
+ }
53
+ function ungroupRanges(ranges) {
54
+ const ungroupedRanges = [];
55
+ ranges.forEach(range => {
56
+ if (!range.depth) {
57
+ ungroupedRanges.push(range);
58
+ }
59
+ const {
60
+ depth,
61
+ ...rangeWithoutDepth
62
+ } = range;
63
+ Array.from({
64
+ length: depth
65
+ }).forEach(() => {
66
+ ungroupedRanges.push(rangeWithoutDepth);
67
+ });
68
+ });
69
+ return ungroupedRanges;
70
+ }
71
+ //# sourceMappingURL=rangeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Object","defineProperty","exports","value","getTagPriority","sortRanges","ungroupRanges","tag","ranges","sort","a","b","start","length","type","ungroupedRanges","forEach","range","depth","push","rangeWithoutDepth","Array","from"],"sourceRoot":"../../src","sources":["rangeUtils.ts"],"mappings":";AAAA,SAAS;;AAAAA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,cAAA,GAAAA,cAAA;AAAAF,OAAA,CAAAG,UAAA,GAAAA,UAAA;AAAAH,OAAA,CAAAI,aAAA,GAAAA,aAAA;AAIT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASF,cAAcA,CAACG,GAAW,EAAE;EACnC,QAAQA,GAAG;IACT,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,gBAAgB;MACnB,OAAO,CAAC;IACV,KAAK,cAAc;MACjB,OAAO,CAAC;IACV,KAAK,SAAS;MACZ,OAAO,CAAC;IACV,KAAK,OAAO;MACV,OAAO,CAAC,CAAC;IACX;MACE,OAAO,CAAC;EACZ;AACF;;AAEA;AACA;AACA;AACA;AACA,SAASF,UAAUA,CAACG,MAAuB,EAAE;EAC3C;EACA,OAAOA,MAAM,CAACC,IAAI,CAChB,CAACC,CAAC,EAAEC,CAAC,KACHD,CAAC,CAACE,KAAK,GAAGD,CAAC,CAACC,KAAK,IACjBD,CAAC,CAACE,MAAM,GAAGH,CAAC,CAACG,MAAM,IACnBT,cAAc,CAACO,CAAC,CAACG,IAAI,CAAC,GAAGV,cAAc,CAACM,CAAC,CAACI,IAAI,CAAC,IAC/C,CACJ,CAAC;AACH;AAEA,SAASR,aAAaA,CAACE,MAAuB,EAAmB;EAC/D,MAAMO,eAAgC,GAAG,EAAE;EAC3CP,MAAM,CAACQ,OAAO,CAAEC,KAAK,IAAK;IACxB,IAAI,CAACA,KAAK,CAACC,KAAK,EAAE;MAChBH,eAAe,CAACI,IAAI,CAACF,KAAK,CAAC;IAC7B;IACA,MAAM;MAAEC,KAAK;MAAE,GAAGE;IAAkB,CAAC,GAAGH,KAAK;IAC7CI,KAAK,CAACC,IAAI,CAAC;MAAET,MAAM,EAAEK;IAAO,CAAC,CAAC,CAACF,OAAO,CAAC,MAAM;MAC3CD,eAAe,CAACI,IAAI,CAACC,iBAAiB,CAAC;IACzC,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOL,eAAe;AACxB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=react-native-web.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["react-native-web.d.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mergeMarkdownStyleWithDefault = mergeMarkdownStyleWithDefault;
7
+ var _reactNative = require("react-native");
8
+ const FONT_FAMILY_MONOSPACE = _reactNative.Platform.select({
9
+ ios: "Courier",
10
+ default: "monospace"
11
+ });
12
+ const FONT_FAMILY_EMOJI = _reactNative.Platform.select({
13
+ ios: "System",
14
+ android: "Noto Color Emoji",
15
+ default: "System, Apple Color Emoji, Segoe UI Emoji, Noto Color Emoji"
16
+ });
17
+ function makeDefaultMarkdownStyle() {
18
+ return {
19
+ syntax: {
20
+ color: "gray"
21
+ },
22
+ link: {
23
+ color: "blue"
24
+ },
25
+ heading: {
26
+ fontSize: 38,
27
+ scale: 0.85
28
+ },
29
+ emoji: {
30
+ fontSize: 16,
31
+ fontFamily: FONT_FAMILY_EMOJI
32
+ },
33
+ blockquote: {
34
+ borderColor: "gray",
35
+ borderWidth: 6,
36
+ marginLeft: 6,
37
+ paddingLeft: 6
38
+ },
39
+ orderedList: {
40
+ marginLeft: 6,
41
+ paddingLeft: 18
42
+ },
43
+ unorderedList: {
44
+ marginLeft: 6,
45
+ paddingLeft: 18
46
+ },
47
+ code: {
48
+ fontFamily: FONT_FAMILY_MONOSPACE,
49
+ fontSize: 16,
50
+ color: "black",
51
+ backgroundColor: "lightgray"
52
+ },
53
+ pre: {
54
+ fontFamily: FONT_FAMILY_MONOSPACE,
55
+ fontSize: 16,
56
+ color: "black",
57
+ backgroundColor: "lightgray"
58
+ },
59
+ mentionHere: {
60
+ color: "green",
61
+ backgroundColor: "lime",
62
+ borderRadius: 5
63
+ },
64
+ mentionUser: {
65
+ color: "blue",
66
+ backgroundColor: "cyan",
67
+ borderRadius: 5
68
+ },
69
+ mentionReport: {
70
+ color: "red",
71
+ backgroundColor: "pink",
72
+ borderRadius: 5
73
+ }
74
+ };
75
+ }
76
+ function mergeMarkdownStyleWithDefault(input) {
77
+ const output = makeDefaultMarkdownStyle();
78
+ if (input !== undefined) {
79
+ Object.keys(input).forEach(key => {
80
+ if (!(key in output)) {
81
+ return;
82
+ }
83
+ const outputValue = output[key];
84
+ if (outputValue) {
85
+ Object.assign(outputValue, input[key]);
86
+ }
87
+ });
88
+ }
89
+ return output;
90
+ }
91
+ //# sourceMappingURL=styleUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","FONT_FAMILY_MONOSPACE","Platform","select","ios","default","FONT_FAMILY_EMOJI","android","makeDefaultMarkdownStyle","syntax","color","link","heading","fontSize","scale","emoji","fontFamily","blockquote","borderColor","borderWidth","marginLeft","paddingLeft","orderedList","unorderedList","code","backgroundColor","pre","mentionHere","borderRadius","mentionUser","mentionReport","mergeMarkdownStyleWithDefault","input","output","undefined","Object","keys","forEach","key","outputValue","assign"],"sourceRoot":"../../src","sources":["styleUtils.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,MAAMC,qBAAqB,GAAGC,qBAAQ,CAACC,MAAM,CAAC;EAC5CC,GAAG,EAAE,SAAS;EACdC,OAAO,EAAE;AACX,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAGJ,qBAAQ,CAACC,MAAM,CAAC;EACxCC,GAAG,EAAE,QAAQ;EACbG,OAAO,EAAE,kBAAkB;EAC3BF,OAAO,EAAE;AACX,CAAC,CAAC;AAEF,SAASG,wBAAwBA,CAAA,EAAkB;EACjD,OAAO;IACLC,MAAM,EAAE;MACNC,KAAK,EAAE;IACT,CAAC;IACDC,IAAI,EAAE;MACJD,KAAK,EAAE;IACT,CAAC;IACDE,OAAO,EAAE;MACPC,QAAQ,EAAE,EAAE;MACZC,KAAK,EAAE;IACT,CAAC;IACDC,KAAK,EAAE;MACLF,QAAQ,EAAE,EAAE;MACZG,UAAU,EAAEV;IACd,CAAC;IACDW,UAAU,EAAE;MACVC,WAAW,EAAE,MAAM;MACnBC,WAAW,EAAE,CAAC;MACdC,UAAU,EAAE,CAAC;MACbC,WAAW,EAAE;IACf,CAAC;IACDC,WAAW,EAAE;MACXF,UAAU,EAAE,CAAC;MACbC,WAAW,EAAE;IACf,CAAC;IACDE,aAAa,EAAE;MACbH,UAAU,EAAE,CAAC;MACbC,WAAW,EAAE;IACf,CAAC;IACDG,IAAI,EAAE;MACJR,UAAU,EAAEf,qBAAqB;MACjCY,QAAQ,EAAE,EAAE;MACZH,KAAK,EAAE,OAAO;MACde,eAAe,EAAE;IACnB,CAAC;IACDC,GAAG,EAAE;MACHV,UAAU,EAAEf,qBAAqB;MACjCY,QAAQ,EAAE,EAAE;MACZH,KAAK,EAAE,OAAO;MACde,eAAe,EAAE;IACnB,CAAC;IACDE,WAAW,EAAE;MACXjB,KAAK,EAAE,OAAO;MACde,eAAe,EAAE,MAAM;MACvBG,YAAY,EAAE;IAChB,CAAC;IACDC,WAAW,EAAE;MACXnB,KAAK,EAAE,MAAM;MACbe,eAAe,EAAE,MAAM;MACvBG,YAAY,EAAE;IAChB,CAAC;IACDE,aAAa,EAAE;MACbpB,KAAK,EAAE,KAAK;MACZe,eAAe,EAAE,MAAM;MACvBG,YAAY,EAAE;IAChB;EACF,CAAC;AACH;AAEA,SAASG,6BAA6BA,CAACC,KAAuC,EAAiB;EAC7F,MAAMC,MAAM,GAAGzB,wBAAwB,CAAC,CAAC;EAEzC,IAAIwB,KAAK,KAAKE,SAAS,EAAE;IACvBC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,CAACK,OAAO,CAAEC,GAAG,IAAK;MAClC,IAAI,EAAEA,GAAG,IAAIL,MAAM,CAAC,EAAE;QACpB;MACF;MAEA,MAAMM,WAAW,GAAGN,MAAM,CAACK,GAAG,CAAwB;MACtD,IAAIC,WAAW,EAAE;QACfJ,MAAM,CAACK,MAAM,CAACD,WAAW,EAAEP,KAAK,CAACM,GAAG,CAAwB,CAAC;MAC/D;IACF,CAAC,CAAC;EACJ;EAEA,OAAOL,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ class InputHistory {
8
+ currentText = null;
9
+ timeout = null;
10
+ constructor(depth, debounceTime = 150, startingText = "") {
11
+ this.depth = depth;
12
+ this.items = [{
13
+ text: startingText,
14
+ cursorPosition: startingText.length
15
+ }];
16
+ this.historyIndex = 0;
17
+ this.debounceTime = debounceTime;
18
+ }
19
+ getCurrentItem() {
20
+ return this.items[this.historyIndex] || null;
21
+ }
22
+ setHistory(newHistory) {
23
+ this.items = newHistory.slice(newHistory.length - this.depth);
24
+ this.historyIndex = newHistory.length - 1;
25
+ }
26
+ setHistoryIndex(index) {
27
+ this.historyIndex = index;
28
+ }
29
+ clear() {
30
+ this.items = [];
31
+ this.historyIndex = 0;
32
+ }
33
+ throttledAdd(text, cursorPosition) {
34
+ if (this.timeout) {
35
+ clearTimeout(this.timeout);
36
+ }
37
+ if (this.currentText === null) {
38
+ this.timeout = null;
39
+ this.add(text, cursorPosition);
40
+ } else {
41
+ this.items[this.historyIndex] = {
42
+ text,
43
+ cursorPosition
44
+ };
45
+ }
46
+ this.currentText = text;
47
+ this.timeout = setTimeout(() => {
48
+ this.currentText = null;
49
+ }, this.debounceTime);
50
+ }
51
+ stopTimeout() {
52
+ if (this.timeout) {
53
+ clearTimeout(this.timeout);
54
+ this.timeout = null;
55
+ }
56
+ this.currentText = null;
57
+ }
58
+ add(text, cursorPosition) {
59
+ if (this.items.length > 0) {
60
+ const currentItem = this.items[this.historyIndex];
61
+ if (currentItem && text === currentItem.text) {
62
+ return;
63
+ }
64
+ }
65
+ if (this.historyIndex < this.items.length - 1) {
66
+ this.items.splice(this.historyIndex + 1);
67
+ this.historyIndex = this.items.length - 1;
68
+ }
69
+ this.items.push({
70
+ text,
71
+ cursorPosition
72
+ });
73
+ if (this.items.length > this.depth) {
74
+ this.items.shift();
75
+ } else {
76
+ this.historyIndex += 1;
77
+ }
78
+ }
79
+ undo() {
80
+ this.stopTimeout();
81
+ if (this.items.length === 0 || this.historyIndex - 1 < 0) {
82
+ return null;
83
+ }
84
+ const currentHistoryItem = this.items[this.historyIndex];
85
+ const previousHistoryItem = this.items[this.historyIndex - 1];
86
+ const undoItem = previousHistoryItem ? {
87
+ text: previousHistoryItem.text,
88
+ cursorPosition: Math.min((currentHistoryItem?.cursorPosition ?? 0) - ((currentHistoryItem?.text ?? "").length - (previousHistoryItem?.text ?? "").length), (previousHistoryItem?.text ?? "").length)
89
+ } : null;
90
+ if (this.historyIndex > 0) {
91
+ this.historyIndex -= 1;
92
+ }
93
+ return undoItem;
94
+ }
95
+ redo() {
96
+ if (this.currentText !== null && this.timeout) {
97
+ this.stopTimeout();
98
+ }
99
+ if (this.items.length === 0 || this.historyIndex + 1 > this.items.length) {
100
+ return null;
101
+ }
102
+ if (this.historyIndex < this.items.length - 1) {
103
+ this.historyIndex += 1;
104
+ } else {
105
+ return null;
106
+ }
107
+ return this.items[this.historyIndex] || null;
108
+ }
109
+ }
110
+ exports.default = InputHistory;
111
+ //# sourceMappingURL=InputHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["InputHistory","currentText","timeout","constructor","depth","debounceTime","startingText","items","text","cursorPosition","length","historyIndex","getCurrentItem","setHistory","newHistory","slice","setHistoryIndex","index","clear","throttledAdd","clearTimeout","add","setTimeout","stopTimeout","currentItem","splice","push","shift","undo","currentHistoryItem","previousHistoryItem","undoItem","Math","min","redo","exports","default"],"sourceRoot":"../../../src","sources":["web/InputHistory.ts"],"mappings":";;;;;;AAKe,MAAMA,YAAY,CAAC;EAOhCC,WAAW,GAAkB,IAAI;EAEjCC,OAAO,GAA0B,IAAI;EAIrCC,WAAWA,CAACC,KAAa,EAAEC,YAAY,GAAG,GAAG,EAAEC,YAAY,GAAG,EAAE,EAAE;IAChE,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACG,KAAK,GAAG,CAAC;MAAEC,IAAI,EAAEF,YAAY;MAAEG,cAAc,EAAEH,YAAY,CAACI;IAAO,CAAC,CAAC;IAC1E,IAAI,CAACC,YAAY,GAAG,CAAC;IACrB,IAAI,CAACN,YAAY,GAAGA,YAAY;EAClC;EAEAO,cAAcA,CAAA,EAAuB;IACnC,OAAO,IAAI,CAACL,KAAK,CAAC,IAAI,CAACI,YAAY,CAAC,IAAI,IAAI;EAC9C;EAEAE,UAAUA,CAACC,UAAyB,EAAQ;IAC1C,IAAI,CAACP,KAAK,GAAGO,UAAU,CAACC,KAAK,CAACD,UAAU,CAACJ,MAAM,GAAG,IAAI,CAACN,KAAK,CAAC;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AM,CAAC,EAC7C,CAACoB,mBAAmB,EAAEtB,IAAI,IAAI,EAAE,EAAEE,MACpC;IACF,CAAC,GACD,IAAI;IAER,IAAI,IAAI,CAACC,YAAY,GAAG,CAAC,EAAE;MACzB,IAAI,CAACA,YAAY,IAAI,CAAC;IACxB;IAEA,OAAOoB,QAAQ;EACjB;EAEAG,IAAIA,CAAA,EAAuB;IACzB,IAAI,IAAI,CAACjC,WAAW,KAAK,IAAI,IAAI,IAAI,CAACC,OAAO,EAAE;MAC7C,IAAI,CAACqB,WAAW,CAAC,CAAC;IACpB;IAEA,IAAI,IAAI,CAAChB,KAAK,CAACG,MAAM,KAAK,CAAC,IAAI,IAAI,CAACC,YAAY,GAAG,CAAC,GAAG,IAAI,CAACJ,KAAK,CAACG,MAAM,EAAE;MACxE,OAAO,IAAI;IACb;IAEA,IAAI,IAAI,CAACC,YAAY,GAAG,IAAI,CAACJ,KAAK,CAACG,MAAM,GAAG,CAAC,EAAE;MAC7C,IAAI,CAACC,YAAY,IAAI,CAAC;IACxB,CAAC,MAAM;MACL,OAAO,IAAI;IACb;IAEA,OAAO,IAAI,CAACJ,KAAK,CAAC,IAAI,CAACI,YAAY,CAAC,IAAI,IAAI;EAC9C;AACF;AAACwB,OAAA,CAAAC,OAAA,GAAApC,YAAA","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ .react-native-marcus-input-multiline {
2
+ white-space: pre-wrap;
3
+ }
4
+
5
+ .react-native-marcus-input-singleline p {
6
+ display: inline-block;
7
+ }
8
+
9
+ .react-native-marcus-input-multiline p {
10
+ display: block;
11
+ }
12
+
13
+ .react-native-marcus-input-singleline::-webkit-scrollbar {
14
+ display: none;
15
+ }
16
+
17
+ .react-native-marcus-input-singleline br {
18
+ display: none;
19
+ }
20
+
21
+ .react-native-marcus-input-singleline span[data-type='text'] {
22
+ vertical-align: middle;
23
+ }
24
+
25
+ .react-native-marcus-input-singleline span[data-type='link'] span[data-type='text'] {
26
+ vertical-align: top;
27
+ }
28
+
29
+ .react-native-marcus-input-singleline > p:last-child {
30
+ padding-right: 1px !important;
31
+ }
32
+
33
+ .react-native-marcus-input-singleline:empty::before,
34
+ .react-native-marcus-input-multiline:empty::before {
35
+ pointer-events: none;
36
+ display: block; /* For Firefox */
37
+ content: attr(placeholder);
38
+ }
39
+
40
+ .react-native-marcus-input-multiline *[data-type='pre'] {
41
+ line-height: 1.3;
42
+ display: block;
43
+ width: fit-content;
44
+ max-width: 100%;
45
+ box-sizing: border-box;
46
+ }
47
+
48
+ .react-native-marcus-input-multiline *[data-type='codeblock'] {
49
+ position: relative;
50
+ width: fit-content;
51
+ max-width: 100%;
52
+ box-sizing: border-box;
53
+ z-index: 2;
54
+ display: block;
55
+ }
56
+
57
+ .react-native-marcus-input-singleline *[data-type='code'] > *[data-type='emoji'],
58
+ .react-native-marcus-input-multiline *[data-type='code'] > *[data-type='emoji'] {
59
+ font-size: inherit !important;
60
+ line-height: inherit !important;
61
+ vertical-align: unset !important;
62
+ }
63
+
64
+ .react-native-marcus-input-multiline *[data-type='line'] *[data-type='syntax']:has(+ *[data-type='pre']),
65
+ .react-native-marcus-input-multiline *[data-type='line'] *[data-type='pre'] + *[data-type='syntax'] {
66
+ display: block;
67
+ line-height: 1.3;
68
+ }
69
+
70
+ [class^='react-native-marcus-input'] [data-type='strikethrough'] * {
71
+ text-decoration: inherit;
72
+ }
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.layoutBlocks = layoutBlocks;
7
+ exports.toNumber = toNumber;
8
+ const BLOCK_PREFIX = "block-prefix";
9
+
10
+ /**
11
+ * Where one line's text sits, and what has to be drawn in the space to its left.
12
+ *
13
+ * The same three numbers the native formatters produce: `firstLineIndent` is `firstLineHeadIndent`
14
+ * on iOS and `getLeadingMargin(true)` on Android, `indent` is the head indent the line resumes at
15
+ * when it wraps, and `ribbons` are the offsets `MarkdownTextLayoutFragment` and
16
+ * `MarkdownBlockIndentSpan` fill a blockquote's bars at.
17
+ */
18
+
19
+ function toNumber(value) {
20
+ if (typeof value === "number") {
21
+ return value;
22
+ }
23
+ if (!value) {
24
+ return 0;
25
+ }
26
+ const parsed = parseFloat(value);
27
+ return Number.isFinite(parsed) ? parsed : 0;
28
+ }
29
+
30
+ /** The gutter one level of a container reserves, or null if the type is not one. */
31
+ function stepOf(type, markdownStyle) {
32
+ switch (type) {
33
+ case "blockquote":
34
+ return toNumber(markdownStyle.blockquote?.marginLeft) + toNumber(markdownStyle.blockquote?.borderWidth) + toNumber(markdownStyle.blockquote?.paddingLeft);
35
+ case "list-ordered":
36
+ return toNumber(markdownStyle.orderedList?.marginLeft) + toNumber(markdownStyle.orderedList?.paddingLeft);
37
+ case "list-unordered":
38
+ return toNumber(markdownStyle.unorderedList?.marginLeft) + toNumber(markdownStyle.unorderedList?.paddingLeft);
39
+ default:
40
+ return null;
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Places the containers of every line, left to right -- the web half of `BlockLayout` in
46
+ * `apple/MarkdownFormatter.swift` and `android/.../MarkdownFormatter.kt`, and deliberately the same
47
+ * walk.
48
+ *
49
+ * Each container reserves a gutter and is then followed by its own marker, which is text and so has
50
+ * to be stepped over rather than reserved: the container nested inside it starts after the marker,
51
+ * not in front of it. That is what puts a quote's ribbons after a list bullet, and a list's indent
52
+ * after a quote's `>`.
53
+ *
54
+ * A line continuing a block carries no marker of its own and reuses the one that opened it, which
55
+ * is why this runs across the whole document rather than per line: without it a continuation line
56
+ * would sit a marker's width to the left of the line above and break the block in two.
57
+ *
58
+ * It reads the ranges in the order the parser emits them -- marker, then the container it belongs
59
+ * to -- so it has to run before `sortRanges` rearranges them into the containment order the DOM
60
+ * builder needs.
61
+ */
62
+ function layoutBlocks(text, ranges, markdownStyle, measure) {
63
+ const layouts = new Map();
64
+ /** Last marker seen for each container type, for the lines that continue it. */
65
+ const markers = new Map();
66
+ const ribbonMargin = toNumber(markdownStyle.blockquote?.marginLeft);
67
+ let pendingPrefix = null;
68
+ let line = null;
69
+ let lineStart = -1;
70
+ /** Offset reached so far, from the line's own left edge. */
71
+ let offset = 0;
72
+ /**
73
+ * Where the line's first marker begins, if it has one. The text starts there; everything past it
74
+ * is held open with padding instead.
75
+ */
76
+ let textStart = -1;
77
+ /** Marker of the container placed most recently, if it is on this line and so has something to
78
+ * pad. */
79
+ let padded = null;
80
+ for (let i = 0; i < ranges.length; i++) {
81
+ const range = ranges[i];
82
+ if (range.type === BLOCK_PREFIX) {
83
+ pendingPrefix = range;
84
+ continue;
85
+ }
86
+ const step = stepOf(range.type, markdownStyle);
87
+ if (step === null) {
88
+ continue;
89
+ }
90
+ const depth = range.depth && range.depth > 0 ? range.depth : 1;
91
+ const gutter = step * depth;
92
+ if (range.start !== lineStart) {
93
+ lineStart = range.start;
94
+ offset = 0;
95
+ textStart = -1;
96
+ padded = null;
97
+ line = {
98
+ firstLineIndent: 0,
99
+ indent: 0,
100
+ ribbons: [],
101
+ gaps: new Map()
102
+ };
103
+ layouts.set(lineStart, line);
104
+ }
105
+ const current = line;
106
+ if (padded) {
107
+ current.gaps.set(padded.start, (current.gaps.get(padded.start) ?? 0) + gutter);
108
+ }
109
+ if (range.type === "blockquote") {
110
+ for (let level = 0; level < depth; level++) {
111
+ current.ribbons.push(offset + ribbonMargin + step * level);
112
+ }
113
+ }
114
+ offset += gutter;
115
+ if (pendingPrefix) {
116
+ markers.set(range.type, pendingPrefix);
117
+ if (textStart < 0) {
118
+ textStart = offset;
119
+ }
120
+ }
121
+ const marker = pendingPrefix ?? markers.get(range.type);
122
+ if (marker) {
123
+ offset += measure(text.substring(marker.start, marker.start + marker.length));
124
+ }
125
+ padded = pendingPrefix;
126
+ pendingPrefix = null;
127
+ current.firstLineIndent = textStart >= 0 ? textStart : offset;
128
+ current.indent = offset;
129
+ }
130
+ return layouts;
131
+ }
132
+ //# sourceMappingURL=blockLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BLOCK_PREFIX","toNumber","value","parsed","parseFloat","Number","isFinite","stepOf","type","markdownStyle","blockquote","marginLeft","borderWidth","paddingLeft","orderedList","unorderedList","layoutBlocks","text","ranges","measure","layouts","Map","markers","ribbonMargin","pendingPrefix","line","lineStart","offset","textStart","padded","i","length","range","step","depth","gutter","start","firstLineIndent","indent","ribbons","gaps","set","current","get","level","push","marker","substring"],"sourceRoot":"../../../../src","sources":["web/utils/blockLayout.ts"],"mappings":";;;;;;;AAIA,MAAMA,YAAY,GAAG,cAAc;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASC,QAAQA,CAACC,KAAyC,EAAU;EACnE,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EACA,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,CAAC;EACV;EACA,MAAMC,MAAM,GAAGC,UAAU,CAACF,KAAK,CAAC;EAChC,OAAOG,MAAM,CAACC,QAAQ,CAACH,MAAM,CAAC,GAAGA,MAAM,GAAG,CAAC;AAC7C;;AAEA;AACA,SAASI,MAAMA,CAACC,IAAkB,EAAEC,aAAmC,EAAiB;EACtF,QAAQD,IAAI;IACV,KAAK,YAAY;MACf,OACEP,QAAQ,CAACQ,aAAa,CAACC,UAAU,EAAEC,UAAU,CAAC,GAC9CV,QAAQ,CAACQ,aAAa,CAACC,UAAU,EAAEE,WAAW,CAAC,GAC/CX,QAAQ,CAACQ,aAAa,CAACC,UAAU,EAAEG,WAAW,CAAC;IAEnD,KAAK,cAAc;MACjB,OACEZ,QAAQ,CAACQ,aAAa,CAACK,WAAW,EAAEH,UAAU,CAAC,GAC/CV,QAAQ,CAACQ,aAAa,CAACK,WAAW,EAAED,WAAW,CAAC;IAEpD,KAAK,gBAAgB;MACnB,OACEZ,QAAQ,CAACQ,aAAa,CAACM,aAAa,EAAEJ,UAAU,CAAC,GACjDV,QAAQ,CAACQ,aAAa,CAACM,aAAa,EAAEF,WAAW,CAAC;IAEtD;MACE,OAAO,IAAI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