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,66 @@
1
+ "use strict";
2
+ "worklet";
3
+
4
+ // A range is emitted when the construct it belongs to opens, so the parser's order is already
5
+ // containment order: whatever encloses something opened before it. `sortRanges` keeps that order
6
+ // for ranges it cannot separate, which is just as well, because for two containers of the same size
7
+ // the answer is not a property of their types at all -- `> - a` and `- > a` are the same pair over
8
+ // the same line, nested opposite ways.
9
+ //
10
+ // One pairing breaks the rule, deliberately. `flushLine` emits a container's `block-prefix` before
11
+ // the container itself, because the native formatters lay a line out in one left-to-right walk and
12
+ // hand each marker to the container that follows it; the `syntax` inside that marker is emitted
13
+ // earlier still, when the marker's own token opens. Typing a bare `>` therefore produces three
14
+ // ranges over one character, in exactly the wrong order for a tree.
15
+ //
16
+ // This table exists to invert that one pairing, and nothing else: a block container outranks the
17
+ // `block-prefix` holding its marker, which outranks the `syntax` of the marker itself. `heading`
18
+ // sits above the default so it encloses what a heading line contains, and `emoji` below everything
19
+ // because it is always innermost. A container type left out of the table sorts level with the
20
+ // marker it should contain, and the marker then renders once per range -- see
21
+ // `reportAmbiguousNesting`, which is the check for exactly that.
22
+ function getTagPriority(tag) {
23
+ switch (tag) {
24
+ case "blockquote":
25
+ case "list-ordered":
26
+ case "list-unordered":
27
+ return 3;
28
+ case "block-prefix":
29
+ return 2;
30
+ case "heading":
31
+ return 1;
32
+ case "emoji":
33
+ return -1;
34
+ default:
35
+ return 0;
36
+ }
37
+ }
38
+
39
+ // Sorts into the containment order the web builder nests by: outermost first, and for anything the
40
+ // three keys below cannot separate, the order the parser emitted them in. That last step is load
41
+ // bearing rather than incidental -- `Array.prototype.sort` is required to be stable, and emission
42
+ // order is what decides which of two equally sized containers encloses the other.
43
+ function sortRanges(ranges) {
44
+ // sort ranges by start position, then by length, then by tag hierarchy
45
+ return ranges.sort((a, b) => a.start - b.start || b.length - a.length || getTagPriority(b.type) - getTagPriority(a.type) || 0);
46
+ }
47
+ function ungroupRanges(ranges) {
48
+ const ungroupedRanges = [];
49
+ ranges.forEach(range => {
50
+ if (!range.depth) {
51
+ ungroupedRanges.push(range);
52
+ }
53
+ const {
54
+ depth,
55
+ ...rangeWithoutDepth
56
+ } = range;
57
+ Array.from({
58
+ length: depth
59
+ }).forEach(() => {
60
+ ungroupedRanges.push(rangeWithoutDepth);
61
+ });
62
+ });
63
+ return ungroupedRanges;
64
+ }
65
+ export { getTagPriority, sortRanges, ungroupRanges };
66
+ //# sourceMappingURL=rangeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getTagPriority","tag","sortRanges","ranges","sort","a","b","start","length","type","ungroupRanges","ungroupedRanges","forEach","range","depth","push","rangeWithoutDepth","Array","from"],"sourceRoot":"../../src","sources":["rangeUtils.ts"],"mappings":";AAAA,SAAS;;AAIT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAcA,CAACC,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,SAASC,UAAUA,CAACC,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,IACnBR,cAAc,CAACM,CAAC,CAACG,IAAI,CAAC,GAAGT,cAAc,CAACK,CAAC,CAACI,IAAI,CAAC,IAC/C,CACJ,CAAC;AACH;AAEA,SAASC,aAAaA,CAACP,MAAuB,EAAmB;EAC/D,MAAMQ,eAAgC,GAAG,EAAE;EAC3CR,MAAM,CAACS,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;MAAEV,MAAM,EAAEM;IAAO,CAAC,CAAC,CAACF,OAAO,CAAC,MAAM;MAC3CD,eAAe,CAACI,IAAI,CAACC,iBAAiB,CAAC;IACzC,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOL,eAAe;AACxB;AACA,SAASX,cAAc,EAAEE,UAAU,EAAEQ,aAAa","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,88 @@
1
+ "use strict";
2
+
3
+ import { Platform } from "react-native";
4
+ const FONT_FAMILY_MONOSPACE = Platform.select({
5
+ ios: "Courier",
6
+ default: "monospace"
7
+ });
8
+ const FONT_FAMILY_EMOJI = Platform.select({
9
+ ios: "System",
10
+ android: "Noto Color Emoji",
11
+ default: "System, Apple Color Emoji, Segoe UI Emoji, Noto Color Emoji"
12
+ });
13
+ function makeDefaultMarkdownStyle() {
14
+ return {
15
+ syntax: {
16
+ color: "gray"
17
+ },
18
+ link: {
19
+ color: "blue"
20
+ },
21
+ heading: {
22
+ fontSize: 38,
23
+ scale: 0.85
24
+ },
25
+ emoji: {
26
+ fontSize: 16,
27
+ fontFamily: FONT_FAMILY_EMOJI
28
+ },
29
+ blockquote: {
30
+ borderColor: "gray",
31
+ borderWidth: 6,
32
+ marginLeft: 6,
33
+ paddingLeft: 6
34
+ },
35
+ orderedList: {
36
+ marginLeft: 6,
37
+ paddingLeft: 18
38
+ },
39
+ unorderedList: {
40
+ marginLeft: 6,
41
+ paddingLeft: 18
42
+ },
43
+ code: {
44
+ fontFamily: FONT_FAMILY_MONOSPACE,
45
+ fontSize: 16,
46
+ color: "black",
47
+ backgroundColor: "lightgray"
48
+ },
49
+ pre: {
50
+ fontFamily: FONT_FAMILY_MONOSPACE,
51
+ fontSize: 16,
52
+ color: "black",
53
+ backgroundColor: "lightgray"
54
+ },
55
+ mentionHere: {
56
+ color: "green",
57
+ backgroundColor: "lime",
58
+ borderRadius: 5
59
+ },
60
+ mentionUser: {
61
+ color: "blue",
62
+ backgroundColor: "cyan",
63
+ borderRadius: 5
64
+ },
65
+ mentionReport: {
66
+ color: "red",
67
+ backgroundColor: "pink",
68
+ borderRadius: 5
69
+ }
70
+ };
71
+ }
72
+ function mergeMarkdownStyleWithDefault(input) {
73
+ const output = makeDefaultMarkdownStyle();
74
+ if (input !== undefined) {
75
+ Object.keys(input).forEach(key => {
76
+ if (!(key in output)) {
77
+ return;
78
+ }
79
+ const outputValue = output[key];
80
+ if (outputValue) {
81
+ Object.assign(outputValue, input[key]);
82
+ }
83
+ });
84
+ }
85
+ return output;
86
+ }
87
+ export { mergeMarkdownStyleWithDefault };
88
+ //# sourceMappingURL=styleUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","FONT_FAMILY_MONOSPACE","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,SAASA,QAAQ,QAAQ,cAAc;AAOvC,MAAMC,qBAAqB,GAAGD,QAAQ,CAACE,MAAM,CAAC;EAC5CC,GAAG,EAAE,SAAS;EACdC,OAAO,EAAE;AACX,CAAC,CAAC;AA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F,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;AAIA,SAASF,6BAA6B","ignoreList":[]}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ export default class InputHistory {
4
+ currentText = null;
5
+ timeout = null;
6
+ constructor(depth, debounceTime = 150, startingText = "") {
7
+ this.depth = depth;
8
+ this.items = [{
9
+ text: startingText,
10
+ cursorPosition: startingText.length
11
+ }];
12
+ this.historyIndex = 0;
13
+ this.debounceTime = debounceTime;
14
+ }
15
+ getCurrentItem() {
16
+ return this.items[this.historyIndex] || null;
17
+ }
18
+ setHistory(newHistory) {
19
+ this.items = newHistory.slice(newHistory.length - this.depth);
20
+ this.historyIndex = newHistory.length - 1;
21
+ }
22
+ setHistoryIndex(index) {
23
+ this.historyIndex = index;
24
+ }
25
+ clear() {
26
+ this.items = [];
27
+ this.historyIndex = 0;
28
+ }
29
+ throttledAdd(text, cursorPosition) {
30
+ if (this.timeout) {
31
+ clearTimeout(this.timeout);
32
+ }
33
+ if (this.currentText === null) {
34
+ this.timeout = null;
35
+ this.add(text, cursorPosition);
36
+ } else {
37
+ this.items[this.historyIndex] = {
38
+ text,
39
+ cursorPosition
40
+ };
41
+ }
42
+ this.currentText = text;
43
+ this.timeout = setTimeout(() => {
44
+ this.currentText = null;
45
+ }, this.debounceTime);
46
+ }
47
+ stopTimeout() {
48
+ if (this.timeout) {
49
+ clearTimeout(this.timeout);
50
+ this.timeout = null;
51
+ }
52
+ this.currentText = null;
53
+ }
54
+ add(text, cursorPosition) {
55
+ if (this.items.length > 0) {
56
+ const currentItem = this.items[this.historyIndex];
57
+ if (currentItem && text === currentItem.text) {
58
+ return;
59
+ }
60
+ }
61
+ if (this.historyIndex < this.items.length - 1) {
62
+ this.items.splice(this.historyIndex + 1);
63
+ this.historyIndex = this.items.length - 1;
64
+ }
65
+ this.items.push({
66
+ text,
67
+ cursorPosition
68
+ });
69
+ if (this.items.length > this.depth) {
70
+ this.items.shift();
71
+ } else {
72
+ this.historyIndex += 1;
73
+ }
74
+ }
75
+ undo() {
76
+ this.stopTimeout();
77
+ if (this.items.length === 0 || this.historyIndex - 1 < 0) {
78
+ return null;
79
+ }
80
+ const currentHistoryItem = this.items[this.historyIndex];
81
+ const previousHistoryItem = this.items[this.historyIndex - 1];
82
+ const undoItem = previousHistoryItem ? {
83
+ text: previousHistoryItem.text,
84
+ cursorPosition: Math.min((currentHistoryItem?.cursorPosition ?? 0) - ((currentHistoryItem?.text ?? "").length - (previousHistoryItem?.text ?? "").length), (previousHistoryItem?.text ?? "").length)
85
+ } : null;
86
+ if (this.historyIndex > 0) {
87
+ this.historyIndex -= 1;
88
+ }
89
+ return undoItem;
90
+ }
91
+ redo() {
92
+ if (this.currentText !== null && this.timeout) {
93
+ this.stopTimeout();
94
+ }
95
+ if (this.items.length === 0 || this.historyIndex + 1 > this.items.length) {
96
+ return null;
97
+ }
98
+ if (this.historyIndex < this.items.length - 1) {
99
+ this.historyIndex += 1;
100
+ } else {
101
+ return null;
102
+ }
103
+ return this.items[this.historyIndex] || null;
104
+ }
105
+ }
106
+ //# 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"],"sourceRoot":"../../../src","sources":["web/InputHistory.ts"],"mappings":";;AAKA,eAAe,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;IAC7D,IAAI,CAACO,YAAY,GAAGG,UAAU,CAACJ,MAAM,GAAG,CAAC;EAC3C;EAEAM,eAAeA,CAACC,KAAa,EAAQ;IACnC,IAAI,CAACN,YAAY,GAAGM,KAAK;EAC3B;EAEAC,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACX,KAAK,GAAG,EAAE;IACf,IAAI,CAACI,YAAY,GAAG,CAAC;EACvB;EAEAQ,YAAYA,CAACX,IAAY,EAAEC,cAAsB,EAAQ;IACvD,IAAI,IAAI,CAACP,OAAO,EAAE;MAChBkB,YAAY,CAAC,IAAI,CAAClB,OAAO,CAAC;IAC5B;IAEA,IAAI,I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,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","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,128 @@
1
+ "use strict";
2
+
3
+ const BLOCK_PREFIX = "block-prefix";
4
+
5
+ /**
6
+ * Where one line's text sits, and what has to be drawn in the space to its left.
7
+ *
8
+ * The same three numbers the native formatters produce: `firstLineIndent` is `firstLineHeadIndent`
9
+ * on iOS and `getLeadingMargin(true)` on Android, `indent` is the head indent the line resumes at
10
+ * when it wraps, and `ribbons` are the offsets `MarkdownTextLayoutFragment` and
11
+ * `MarkdownBlockIndentSpan` fill a blockquote's bars at.
12
+ */
13
+
14
+ function toNumber(value) {
15
+ if (typeof value === "number") {
16
+ return value;
17
+ }
18
+ if (!value) {
19
+ return 0;
20
+ }
21
+ const parsed = parseFloat(value);
22
+ return Number.isFinite(parsed) ? parsed : 0;
23
+ }
24
+
25
+ /** The gutter one level of a container reserves, or null if the type is not one. */
26
+ function stepOf(type, markdownStyle) {
27
+ switch (type) {
28
+ case "blockquote":
29
+ return toNumber(markdownStyle.blockquote?.marginLeft) + toNumber(markdownStyle.blockquote?.borderWidth) + toNumber(markdownStyle.blockquote?.paddingLeft);
30
+ case "list-ordered":
31
+ return toNumber(markdownStyle.orderedList?.marginLeft) + toNumber(markdownStyle.orderedList?.paddingLeft);
32
+ case "list-unordered":
33
+ return toNumber(markdownStyle.unorderedList?.marginLeft) + toNumber(markdownStyle.unorderedList?.paddingLeft);
34
+ default:
35
+ return null;
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Places the containers of every line, left to right -- the web half of `BlockLayout` in
41
+ * `apple/MarkdownFormatter.swift` and `android/.../MarkdownFormatter.kt`, and deliberately the same
42
+ * walk.
43
+ *
44
+ * Each container reserves a gutter and is then followed by its own marker, which is text and so has
45
+ * to be stepped over rather than reserved: the container nested inside it starts after the marker,
46
+ * not in front of it. That is what puts a quote's ribbons after a list bullet, and a list's indent
47
+ * after a quote's `>`.
48
+ *
49
+ * A line continuing a block carries no marker of its own and reuses the one that opened it, which
50
+ * is why this runs across the whole document rather than per line: without it a continuation line
51
+ * would sit a marker's width to the left of the line above and break the block in two.
52
+ *
53
+ * It reads the ranges in the order the parser emits them -- marker, then the container it belongs
54
+ * to -- so it has to run before `sortRanges` rearranges them into the containment order the DOM
55
+ * builder needs.
56
+ */
57
+ function layoutBlocks(text, ranges, markdownStyle, measure) {
58
+ const layouts = new Map();
59
+ /** Last marker seen for each container type, for the lines that continue it. */
60
+ const markers = new Map();
61
+ const ribbonMargin = toNumber(markdownStyle.blockquote?.marginLeft);
62
+ let pendingPrefix = null;
63
+ let line = null;
64
+ let lineStart = -1;
65
+ /** Offset reached so far, from the line's own left edge. */
66
+ let offset = 0;
67
+ /**
68
+ * Where the line's first marker begins, if it has one. The text starts there; everything past it
69
+ * is held open with padding instead.
70
+ */
71
+ let textStart = -1;
72
+ /** Marker of the container placed most recently, if it is on this line and so has something to
73
+ * pad. */
74
+ let padded = null;
75
+ for (let i = 0; i < ranges.length; i++) {
76
+ const range = ranges[i];
77
+ if (range.type === BLOCK_PREFIX) {
78
+ pendingPrefix = range;
79
+ continue;
80
+ }
81
+ const step = stepOf(range.type, markdownStyle);
82
+ if (step === null) {
83
+ continue;
84
+ }
85
+ const depth = range.depth && range.depth > 0 ? range.depth : 1;
86
+ const gutter = step * depth;
87
+ if (range.start !== lineStart) {
88
+ lineStart = range.start;
89
+ offset = 0;
90
+ textStart = -1;
91
+ padded = null;
92
+ line = {
93
+ firstLineIndent: 0,
94
+ indent: 0,
95
+ ribbons: [],
96
+ gaps: new Map()
97
+ };
98
+ layouts.set(lineStart, line);
99
+ }
100
+ const current = line;
101
+ if (padded) {
102
+ current.gaps.set(padded.start, (current.gaps.get(padded.start) ?? 0) + gutter);
103
+ }
104
+ if (range.type === "blockquote") {
105
+ for (let level = 0; level < depth; level++) {
106
+ current.ribbons.push(offset + ribbonMargin + step * level);
107
+ }
108
+ }
109
+ offset += gutter;
110
+ if (pendingPrefix) {
111
+ markers.set(range.type, pendingPrefix);
112
+ if (textStart < 0) {
113
+ textStart = offset;
114
+ }
115
+ }
116
+ const marker = pendingPrefix ?? markers.get(range.type);
117
+ if (marker) {
118
+ offset += measure(text.substring(marker.start, marker.start + marker.length));
119
+ }
120
+ padded = pendingPrefix;
121
+ pendingPrefix = null;
122
+ current.firstLineIndent = textStart >= 0 ? textStart : offset;
123
+ current.indent = offset;
124
+ }
125
+ return layouts;
126
+ }
127
+ export { layoutBlocks, toNumber };
128
+ //# 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,MA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