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,552 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeLines = normalizeLines;
7
+ exports.parseRangesToHTMLNodes = parseRangesToHTMLNodes;
8
+ exports.updateInputStructure = updateInputStructure;
9
+ var _treeUtils = require("./treeUtils.js");
10
+ var _cursorUtils = require("./cursorUtils.js");
11
+ var _blockUtils = require("./blockUtils.js");
12
+ var _blockLayout = require("./blockLayout.js");
13
+ var _measureUtils = require("./measureUtils.js");
14
+ var _rangeUtils = require("../../rangeUtils.js");
15
+ function splitTextIntoLines(text) {
16
+ let lineStartIndex = 0;
17
+ const lines = text.split("\n").map(line => {
18
+ const lineObject = {
19
+ text: line,
20
+ start: lineStartIndex,
21
+ length: line.length,
22
+ markdownRanges: []
23
+ };
24
+ lineStartIndex += line.length + 1; // Adding 1 for the newline character
25
+ return lineObject;
26
+ });
27
+ return lines;
28
+ }
29
+
30
+ /**
31
+ * Merges lines with multiline markdown tags (like `pre`) into a single line.
32
+ * The main line will contain the text and all markdown ranges from the other lines.
33
+ */
34
+ function mergeLinesWithMultilineTags(lines, currentLine, range, correspondingLineIndexes) {
35
+ const mainLine = currentLine;
36
+ currentLine.markdownRanges.push(range);
37
+ correspondingLineIndexes.forEach(lineIndex => {
38
+ const otherLine = lines[lineIndex];
39
+ mainLine.text += `\n${otherLine.text}`;
40
+ mainLine.length += otherLine.length + 1;
41
+ mainLine.markdownRanges.push(...otherLine.markdownRanges);
42
+ });
43
+ if (correspondingLineIndexes.length > 0 && correspondingLineIndexes[0] !== undefined) {
44
+ lines.splice(correspondingLineIndexes[0], correspondingLineIndexes.length);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Splits a markdown range that spans multiple lines into separate lines.
50
+ */
51
+ function splitRangeIntoSeparateLines(lines, currentLine, range, correspondingLineIndexes) {
52
+ const mainLineRangeLength = currentLine.start + currentLine.length - range.start;
53
+ // A range starting exactly at the newline has nothing on this line. Pushing the empty portion
54
+ // anyway made the builder render an empty span, and an empty span is given a `<br>` to keep the
55
+ // line height -- a line break in the text that the user never typed.
56
+ if (mainLineRangeLength > 0) {
57
+ currentLine.markdownRanges.push({
58
+ ...range,
59
+ length: mainLineRangeLength
60
+ });
61
+ }
62
+ let rangeLength = range.length - mainLineRangeLength;
63
+ correspondingLineIndexes.forEach(lineIndex => {
64
+ const otherLine = lines[lineIndex];
65
+ let currentLength = otherLine.length;
66
+ if (rangeLength <= currentLength) {
67
+ currentLength = rangeLength - 1;
68
+ }
69
+ if (currentLength > 0) {
70
+ lines[lineIndex]?.markdownRanges.push({
71
+ ...range,
72
+ start: otherLine.start,
73
+ length: currentLength
74
+ });
75
+ }
76
+ rangeLength -= currentLength;
77
+ });
78
+ }
79
+
80
+ /**
81
+ * For singleline markdown types, the function splits markdown ranges that spread beyond the line length into separate lines.
82
+ * For multiline markdown types (like `pre`), it merges them and corresponding text into one line.
83
+ */
84
+ function normalizeLines(lines, ranges) {
85
+ const mergedLines = [...lines];
86
+ const lineIndexes = mergedLines.map((_line, index) => index);
87
+ ranges.forEach(range => {
88
+ const beginLineIndex = mergedLines.findLastIndex(line => line.start <= range.start);
89
+ const endLineIndex = mergedLines.findIndex(line => line.start + line.length >= range.start + range.length);
90
+ const correspondingLineIndexes = lineIndexes.slice(beginLineIndex, endLineIndex + 1);
91
+ if (correspondingLineIndexes.length > 0) {
92
+ const mainLineIndex = correspondingLineIndexes[0];
93
+ const mainLine = mergedLines[mainLineIndex];
94
+ const otherLineIndexes = correspondingLineIndexes.slice(1);
95
+ if ((0, _blockUtils.isMultilineMarkdownType)(range.type)) {
96
+ mergeLinesWithMultilineTags(mergedLines, mainLine, range, otherLineIndexes);
97
+ } else if (otherLineIndexes.length > 0) {
98
+ splitRangeIntoSeparateLines(mergedLines, mainLine, range, otherLineIndexes);
99
+ } else {
100
+ mainLine.markdownRanges.push(range);
101
+ }
102
+ }
103
+ });
104
+ return mergedLines;
105
+ }
106
+
107
+ /** Adds a value prop to the element and appends the value to the parent node element */
108
+ function appendValueToElement(element, parentTreeNode, value) {
109
+ const targetElement = element;
110
+ const parentNode = parentTreeNode;
111
+ targetElement.value = value;
112
+ parentNode.element.value = (parentNode.element.value || "") + value;
113
+ }
114
+ function appendNode(element, parentTreeNode, type, length, start = null) {
115
+ const node = (0, _treeUtils.addNodeToTree)(element, parentTreeNode, type, length, start);
116
+ parentTreeNode.element.appendChild(element);
117
+ return node;
118
+ }
119
+ function addBrElement(node) {
120
+ const span = document.createElement("span");
121
+ span.setAttribute("data-type", "br");
122
+ appendValueToElement(span, node, "\n");
123
+ const spanNode = appendNode(span, node, "br", 1);
124
+ appendNode(document.createElement("br"), spanNode, "br", 1);
125
+ return spanNode;
126
+ }
127
+ function addTextToElement(node, text, isMultiline = true) {
128
+ const lines = text.split("\n");
129
+ lines.forEach((line, index) => {
130
+ if (line !== "") {
131
+ const span = document.createElement("span");
132
+ appendValueToElement(span, node, line);
133
+ span.setAttribute("data-type", "text");
134
+ span.appendChild(document.createTextNode(line));
135
+ appendNode(span, node, "text", line.length);
136
+ const parentType = span.parentElement?.dataset.type;
137
+ if (!isMultiline && parentType && ["pre", "code", "mention-here", "mention-user", "mention-report"].includes(parentType)) {
138
+ // this is a fix to background colors being shifted downwards in a singleline input
139
+ (0, _blockUtils.addStyleToBlock)(span, "text", {}, false);
140
+ }
141
+ }
142
+
143
+ // Only add BR elements for multiline inputs or when there are actual line breaks
144
+ if (isMultiline && (index < lines.length - 1 || index === 0 && line === "")) {
145
+ addBrElement(node);
146
+ }
147
+ });
148
+ }
149
+ function addParagraph(node, text, length, layout, markdownStyle, disableInlineStyles = false) {
150
+ const p = document.createElement("p");
151
+ p.setAttribute("data-type", "line");
152
+ if (!disableInlineStyles) {
153
+ (0, _blockUtils.addLineLayout)(p, layout, markdownStyle);
154
+ }
155
+ const pNode = appendNode(p, node, "line", length);
156
+ if (text === "") {
157
+ // If the line is empty, we still need to add a br element to keep the line height
158
+ addBrElement(pNode);
159
+ } else if (text) {
160
+ addTextToElement(pNode, text);
161
+ }
162
+ return pNode;
163
+ }
164
+
165
+ /**
166
+ * `syntax`, `block-prefix` and `emoji` decorate whatever they sit in, so where ranges cover exactly
167
+ * the same text those three have to come last: the container, then the `block-prefix` holding its
168
+ * marker, then the `syntax` of the marker itself. Typing a bare `>` produces all three over one
169
+ * character, and the parser emits them in precisely the wrong order -- `flushLine` hands the marker
170
+ * over before the container it belongs to, because that is the pairing the native formatters read.
171
+ * Inverting that is the whole job of `getTagPriority`.
172
+ *
173
+ * Every other tie is already right. A range is emitted when its construct opens, so emission order
174
+ * is containment order, and a stable sort leaves it alone. That is also the only thing that *can*
175
+ * order two containers of the same size: `> - a` and `- > a` are the same pair of containers over
176
+ * the same line, nested opposite ways, and no table of types can say which.
177
+ *
178
+ * So the one thing worth checking is a decoration that sorted ahead of something it belongs to --
179
+ * which is what a container type missing from `getTagPriority` produces. The builder then renders
180
+ * that text once per range, silently, multiplying with every keystroke. Nothing about that failure
181
+ * points at the missing table entry, so say it out loud instead.
182
+ */
183
+ const INNERMOST_TYPES = new Set(["block-prefix", "syntax", "emoji"]);
184
+ function reportAmbiguousNesting(ranges) {
185
+ for (let i = 1; i < ranges.length; i++) {
186
+ const previous = ranges[i - 1];
187
+ const current = ranges[i];
188
+ if (previous.start === current.start && previous.length === current.length && INNERMOST_TYPES.has(previous.type) && !INNERMOST_TYPES.has(current.type)) {
189
+ // eslint-disable-next-line no-console
190
+ console.error(`[react-native-marcus] \`${previous.type}\` sorts ahead of \`${current.type}\` over the same text, so the marker ends up outside what it belongs to and renders once per range. Give \`${current.type}\` a higher priority in src/rangeUtils.ts.`);
191
+ }
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Builds one `<p data-type="line">` under `rootNode`.
197
+ *
198
+ * Lines are independent: nothing carries across from the previous one, which is what lets an update
199
+ * rebuild a single line and leave the rest of the document alone.
200
+ */
201
+ function addLine(rootNode, line, textLength, hasRanges, isMultiline, markdownStyle, disableInlineStyles) {
202
+ if (!hasRanges) {
203
+ return addParagraph(rootNode, line.text, line.length, line.layout, markdownStyle, disableInlineStyles);
204
+ }
205
+ const lineNode = addParagraph(rootNode, null, line.length, line.layout, markdownStyle, disableInlineStyles);
206
+ let currentParentNode = lineNode;
207
+ if (line.markdownRanges.length === 0) {
208
+ addTextToElement(currentParentNode, line.text, isMultiline);
209
+ }
210
+ let lastRangeEndIndex = line.start;
211
+ const lineMarkdownRanges = [...line.markdownRanges];
212
+ // go through all markdown ranges in the line
213
+ while (lineMarkdownRanges.length > 0) {
214
+ const range = lineMarkdownRanges.shift();
215
+ if (!range) {
216
+ break;
217
+ }
218
+ const endOfCurrentRange = range.start + range.length;
219
+ const nextRangeStartIndex = lineMarkdownRanges.length > 0 && !!lineMarkdownRanges[0] ? lineMarkdownRanges[0].start || 0 : textLength;
220
+
221
+ // add text before the markdown range. Ranges that start behind the cursor are already
222
+ // rendered; without the guard `substring` would swap its arguments and emit that text again.
223
+ const textBeforeRange = range.start > lastRangeEndIndex ? line.text.substring(lastRangeEndIndex - line.start, range.start - line.start) : "";
224
+ if (textBeforeRange) {
225
+ addTextToElement(currentParentNode, textBeforeRange, isMultiline);
226
+ }
227
+
228
+ // create markdown span element
229
+ const span = document.createElement("span");
230
+ span.setAttribute("data-type", range.type);
231
+ const spanNode = appendNode(span, currentParentNode, range.type, range.length, range.start);
232
+
233
+ // Styled once it is in the tree, not before: a heading's size depends on how many heading
234
+ // levels enclose it, and an element with no parent looks like the outermost one.
235
+ if (!disableInlineStyles) {
236
+ (0, _blockUtils.addStyleToBlock)(span, range.type, markdownStyle, isMultiline);
237
+ if (range.type === "block-prefix") {
238
+ (0, _blockUtils.addBlockPrefixGap)(span, line.layout?.gaps.get(range.start));
239
+ }
240
+ }
241
+ if (lineMarkdownRanges.length > 0 && nextRangeStartIndex < endOfCurrentRange && range.type !== "syntax") {
242
+ // tag nesting
243
+ currentParentNode = spanNode;
244
+ lastRangeEndIndex = range.start;
245
+ } else {
246
+ // adding markdown tag
247
+ addTextToElement(spanNode, line.text.substring(range.start - line.start, endOfCurrentRange - line.start), isMultiline);
248
+ currentParentNode.element.value = (currentParentNode.element.value || "") + (spanNode.element.value || "");
249
+ lastRangeEndIndex = endOfCurrentRange;
250
+ // tag unnesting and adding text after the tag
251
+ while (currentParentNode.parentNode !== null && nextRangeStartIndex >= currentParentNode.start + currentParentNode.length) {
252
+ const parentEndIndex = currentParentNode.start + currentParentNode.length;
253
+ const textAfterRange = parentEndIndex > lastRangeEndIndex ? line.text.substring(lastRangeEndIndex - line.start, parentEndIndex - line.start) : "";
254
+ if (textAfterRange) {
255
+ addTextToElement(currentParentNode, textAfterRange, isMultiline);
256
+ }
257
+ // Never backwards: an enclosing range can end before the text already consumed inside it
258
+ // -- a list whose item holds a code block runs to the end of its marker line while the
259
+ // block inside it runs on for several more. Letting it rewind made the paragraph re-emit
260
+ // everything from there, so the line rendered twice.
261
+ lastRangeEndIndex = parentEndIndex > lastRangeEndIndex ? parentEndIndex : lastRangeEndIndex;
262
+ // A line's content never escapes its own paragraph. Without this the walk could reach the
263
+ // root, and every later range on the line was appended there instead -- a stray top-level
264
+ // element between the paragraphs, which shifts every `data-id` after it and leaves the
265
+ // line it belonged to rendered in two places.
266
+ if (currentParentNode === lineNode) {
267
+ break;
268
+ }
269
+ if (currentParentNode.parentNode.type !== "root") {
270
+ currentParentNode.parentNode.element.value = currentParentNode.element.value || "";
271
+ }
272
+ currentParentNode = currentParentNode.parentNode || rootNode;
273
+ }
274
+ }
275
+ }
276
+ return lineNode;
277
+ }
278
+
279
+ /** Splits the text into lines and hands each the markdown ranges that fall inside it. */
280
+ function prepareLines(text, ranges, markdownStyle, measure) {
281
+ const lines = splitTextIntoLines(text);
282
+ if (ranges.length === 0) {
283
+ return lines;
284
+ }
285
+
286
+ // Before anything reorders them: the block walk reads the ranges in the order the parser emits
287
+ // them -- each marker immediately before the container it belongs to -- and `sortRanges` sorts
288
+ // that order away in place.
289
+ const layouts = (0, _blockLayout.layoutBlocks)(text, ranges, markdownStyle, measure);
290
+
291
+ // Sort all ranges by start position, length, and by tag hierarchy so the styles and text are applied in correct order
292
+ const sortedRanges = (0, _rangeUtils.sortRanges)(ranges);
293
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
294
+ reportAmbiguousNesting(sortedRanges);
295
+ }
296
+ const normalized = normalizeLines(lines, (0, _rangeUtils.ungroupRanges)(sortedRanges));
297
+
298
+ // Ranges reach a line in document order, but a range spanning several lines hands its tail to
299
+ // those lines as it is processed -- ahead of ranges that start later on the same line and should
300
+ // have come first. `1. *l\nd**` puts an italic that opened on line 1 in front of the list its
301
+ // second half sits inside, and the builder then nests the list *within* the italic and renders
302
+ // the overlap twice. Restoring the order per line costs nothing on lines that were already
303
+ // sorted, which is nearly all of them.
304
+ normalized.forEach(paragraph => {
305
+ const line = paragraph;
306
+ (0, _rangeUtils.sortRanges)(line.markdownRanges);
307
+ line.layout = layouts.get(line.start);
308
+ });
309
+ return normalized;
310
+ }
311
+
312
+ /** Builds HTML DOM structure based on passed text and markdown ranges */
313
+ function parseRangesToHTMLNodes(text, ranges, isMultiline = true, markdownStyle = {}, disableInlineStyles = false, measure = (0, _measureUtils.createTextMeasurer)(null)) {
314
+ const rootElement = document.createElement("span");
315
+ const textLength = text.length;
316
+ const rootNode = (0, _treeUtils.createRootTreeNode)(rootElement, textLength);
317
+
318
+ // Built line by line, exactly as an update builds the lines it has to replace, so the two agree
319
+ // by construction and each line sits at the offset the text gives it rather than at wherever the
320
+ // line before it happened to end.
321
+ prepareLines(text, ranges, markdownStyle, measure).forEach((line, index) => {
322
+ const node = buildLine(line, index, textLength, ranges.length > 0, isMultiline, markdownStyle, disableInlineStyles);
323
+ node.parentNode = rootNode;
324
+ rootNode.childNodes.push(node);
325
+ rootElement.appendChild(node.element);
326
+ });
327
+ return {
328
+ dom: rootElement,
329
+ tree: rootNode
330
+ };
331
+ }
332
+
333
+ /**
334
+ * A line as it was last rendered: what it was built from, the markup it produced, and its subtree.
335
+ */
336
+
337
+ /**
338
+ * Everything a line's markup depends on, as a string.
339
+ *
340
+ * A line is rendered from its own text and the ranges falling inside it, and nothing else -- so two
341
+ * lines with equal signatures render identically and the second one need not be built at all. Range
342
+ * offsets go in relative to the line, so a line that only moved still matches.
343
+ */
344
+ function signatureOf(line, hasRanges) {
345
+ let signature = hasRanges ? "r" : "-";
346
+ signature += line.text;
347
+ line.markdownRanges.forEach(range => {
348
+ signature += `\u0000${range.start - line.start},${range.length},${range.type},${range.depth ?? ""}`;
349
+ });
350
+
351
+ // The layout is not derived from this line alone -- a continuation line indents past a marker
352
+ // that belongs to the line that opened the block, and every width comes out of the font the
353
+ // input happens to be rendering in. Both reach the line only through these numbers, so they are
354
+ // what the signature has to compare.
355
+ const layout = line.layout;
356
+ if (layout) {
357
+ signature += `\u0000${layout.firstLineIndent},${layout.indent},${layout.ribbons.join(":")}`;
358
+ layout.gaps.forEach((gap, start) => {
359
+ signature += `,${start - line.start}:${gap}`;
360
+ });
361
+ }
362
+ return signature;
363
+ }
364
+
365
+ /** Moves a subtree along the text by `delta`, for a line that shifted without changing. */
366
+ function shiftSubtree(node, delta) {
367
+ const target = node;
368
+ target.start += delta;
369
+ target.childNodes.forEach(child => shiftSubtree(child, delta));
370
+ }
371
+
372
+ /** Renumbers a subtree, for a line whose index changed because lines were added or removed above. */
373
+ function restampSubtree(node, orderIndex) {
374
+ const target = node;
375
+ target.orderIndex = orderIndex;
376
+ target.element.setAttribute("data-id", orderIndex);
377
+ target.childNodes.forEach((child, index) => restampSubtree(child, `${orderIndex},${index}`));
378
+ }
379
+
380
+ /**
381
+ * Grows every node to at least cover its children.
382
+ *
383
+ * A container range can be shorter than what the builder puts inside it -- a list item's own range
384
+ * stops at the end of its marker line, while a fenced code block opened there runs on for several
385
+ * more. The tree is what maps a text offset onto a node, so a parent that does not reach the end of
386
+ * its own children leaves that overhang mapping to nothing and the caret cannot be placed in it.
387
+ *
388
+ * It runs once the line is built, never during: a node's length decides where its next sibling
389
+ * starts and how far the builder thinks it has got, so growing one mid-build changes the markup.
390
+ */
391
+ function coverChildren(node) {
392
+ const target = node;
393
+ let end = target.start + target.length;
394
+ target.childNodes.forEach(child => {
395
+ coverChildren(child);
396
+ const childEnd = child.start + child.length;
397
+ if (childEnd > end) {
398
+ end = childEnd;
399
+ }
400
+ });
401
+ target.length = end - target.start;
402
+ }
403
+
404
+ /** Builds one line on its own, then places it at the offset and index it occupies in the document. */
405
+ function buildLine(line, index, textLength, hasRanges, isMultiline, markdownStyle, disableInlineStyles = false) {
406
+ // The scratch root carries the line's offset, so the subtree comes out with the absolute `start`
407
+ // values the builder compares against range offsets -- the same ones it would get if the whole
408
+ // document had been built in one pass.
409
+ const scratch = (0, _treeUtils.createRootTreeNode)(document.createElement("span"), line.length, line.start);
410
+ const node = addLine(scratch, line, textLength, hasRanges, isMultiline, markdownStyle, disableInlineStyles);
411
+ coverChildren(node);
412
+ restampSubtree(node, `${index}`);
413
+ return node;
414
+ }
415
+
416
+ /**
417
+ * A cached line can be reused only if it would be rebuilt identically *and* the live element is
418
+ * still exactly what was put there.
419
+ *
420
+ * The identity check matters as much as the signature: the browser edits the input directly as the
421
+ * user types, and it is free to merge, split or wrap the top-level elements. Requiring the live
422
+ * node to be the very one this entry rendered means anything the browser introduced falls outside
423
+ * the reusable prefix and suffix, and so lands in the run that gets replaced.
424
+ */
425
+ function canReuseLine(cached, signature, liveNode) {
426
+ return !!cached && cached.signature === signature && liveNode === cached.node.element && liveNode.outerHTML === cached.html;
427
+ }
428
+
429
+ /**
430
+ * Renders `lines` into the input, building only the ones that changed.
431
+ *
432
+ * Rebuilding every line and then diffing meant the expensive half of an update happened whatever
433
+ * the edit was -- construction is the dominant cost, not applying the result. Matching lines are
434
+ * skipped from both ends by signature, so a keystroke builds one line and the rest of the document
435
+ * keeps the elements and the subtrees it already had. Lines after the edit are shifted along the
436
+ * text, and renumbered if lines were added or removed above them; both are cheap walks that touch
437
+ * no element beyond a `data-id`.
438
+ */
439
+ function reconcileLines(targetElement, lines, textLength, hasRanges, isMultiline, markdownStyle, shouldForceDOMUpdate) {
440
+ const signatures = lines.map(line => signatureOf(line, hasRanges));
441
+ const cache = targetElement.lineCache;
442
+ const previous = !shouldForceDOMUpdate && cache && cache.markdownStyle === markdownStyle && cache.isMultiline === isMultiline ? cache.lines : [];
443
+ const live = Array.from(targetElement.childNodes);
444
+ let head = 0;
445
+ while (head < lines.length && head < previous.length && canReuseLine(previous[head], signatures[head], live[head])) {
446
+ head += 1;
447
+ }
448
+ let tail = lines.length;
449
+ let previousTail = previous.length;
450
+ let liveTail = live.length;
451
+ while (tail > head && previousTail > head && liveTail > head && canReuseLine(previous[previousTail - 1], signatures[tail - 1], live[liveTail - 1])) {
452
+ tail -= 1;
453
+ previousTail -= 1;
454
+ liveTail -= 1;
455
+ }
456
+ const fresh = [];
457
+ for (let i = head; i < tail; i += 1) {
458
+ fresh.push(buildLine(lines[i], i, textLength, hasRanges, isMultiline, markdownStyle));
459
+ }
460
+
461
+ // Read before removing anything: this is the first live node of the matching tail, which stays.
462
+ const anchor = live[liveTail] ?? null;
463
+ for (let i = head; i < liveTail; i += 1) {
464
+ live[i]?.remove();
465
+ }
466
+ if (fresh.length > 0) {
467
+ const fragment = document.createDocumentFragment();
468
+ fresh.forEach(node => fragment.appendChild(node.element));
469
+ targetElement.insertBefore(fragment, anchor);
470
+ }
471
+ const rootNode = (0, _treeUtils.createRootTreeNode)(targetElement, textLength);
472
+ const nextCache = [];
473
+ for (let i = 0; i < lines.length; i += 1) {
474
+ const line = lines[i];
475
+ let node;
476
+ let html;
477
+ if (i < head) {
478
+ const cached = previous[i];
479
+ node = cached.node;
480
+ html = cached.html;
481
+ } else if (i < tail) {
482
+ node = fresh[i - head];
483
+ html = node.element.outerHTML;
484
+ } else {
485
+ const cached = previous[previousTail + (i - tail)];
486
+ node = cached.node;
487
+ const delta = line.start - node.start;
488
+ if (delta !== 0) {
489
+ shiftSubtree(node, delta);
490
+ }
491
+ if (node.orderIndex !== `${i}`) {
492
+ restampSubtree(node, `${i}`);
493
+ html = node.element.outerHTML;
494
+ } else {
495
+ html = cached.html;
496
+ }
497
+ }
498
+ node.parentNode = rootNode;
499
+ rootNode.childNodes.push(node);
500
+ nextCache.push({
501
+ signature: signatures[i],
502
+ html,
503
+ node
504
+ });
505
+ }
506
+ targetElement.lineCache = {
507
+ markdownStyle,
508
+ isMultiline,
509
+ lines: nextCache
510
+ };
511
+ return rootNode;
512
+ }
513
+ function moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, target, shouldScrollIntoView = false) {
514
+ if (!isFocused) {
515
+ return;
516
+ }
517
+ if (alwaysMoveCursorToTheEnd || cursorPosition === null) {
518
+ (0, _cursorUtils.moveCursorToEnd)(target);
519
+ } else if (cursorPosition !== null) {
520
+ (0, _cursorUtils.setCursorPosition)(target, cursorPosition, null, shouldScrollIntoView);
521
+ }
522
+ }
523
+ function updateInputStructure(parserFunction, target, text, cursorPositionIndex, isMultiline = true, markdownStyle = {}, alwaysMoveCursorToTheEnd = false, shouldForceDOMUpdate = false, shouldScrollIntoView = false) {
524
+ const targetElement = target;
525
+
526
+ // in case the cursorPositionIndex is larger than text length, cursorPosition will be null, i.e: move the caret to the end
527
+ let cursorPosition = cursorPositionIndex !== null && cursorPositionIndex <= text.length ? cursorPositionIndex : null;
528
+ const isFocused = document.activeElement === target;
529
+ if (isFocused && cursorPositionIndex === null) {
530
+ const selection = (0, _cursorUtils.getCurrentCursorPosition)(target);
531
+ cursorPosition = selection ? selection.start : null;
532
+ }
533
+ const markdownRanges = parserFunction(text);
534
+ if (!text || targetElement.innerHTML === "<br>" || targetElement && targetElement.innerHTML === "\n") {
535
+ targetElement.innerHTML = "";
536
+ targetElement.innerText = "";
537
+ }
538
+
539
+ // We don't want to parse text with single '\n', because contentEditable represents it as invisible <br />
540
+ if (text) {
541
+ targetElement.tree = reconcileLines(targetElement, prepareLines(text, markdownRanges, markdownStyle, (0, _measureUtils.createTextMeasurer)(targetElement)), text.length, markdownRanges.length > 0, isMultiline, markdownStyle, shouldForceDOMUpdate);
542
+ moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, targetElement, shouldScrollIntoView);
543
+ } else {
544
+ targetElement.tree = (0, _treeUtils.createRootTreeNode)(targetElement);
545
+ targetElement.lineCache = undefined;
546
+ }
547
+ return {
548
+ text,
549
+ cursorPosition: cursorPosition || 0
550
+ };
551
+ }
552
+ //# sourceMappingURL=parserUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_treeUtils","require","_cursorUtils","_blockUtils","_blockLayout","_measureUtils","_rangeUtils","splitTextIntoLines","text","lineStartIndex","lines","split","map","line","lineObject","start","length","markdownRanges","mergeLinesWithMultilineTags","currentLine","range","correspondingLineIndexes","mainLine","push","forEach","lineIndex","otherLine","undefined","splice","splitRangeIntoSeparateLines","mainLineRangeLength","rangeLength","currentLength","normalizeLines","ranges","mergedLines","lineIndexes","_line","index","beginLineIndex","findLastIndex","endLineIndex","findIndex","slice","mainLineIndex","otherLineIndexes","isMultilineMarkdownType","type","appendValueToElement","element","parentTreeNode","value","targetElement","parentNode","appendNode","node","addNodeToTree","appendChild","addBrElement","span","document","createElement","setAttribute","spanNode","addTextToElement","isMultiline","createTextNode","parentType","parentElement","dataset","includes","addStyleToBlock","addParagraph","layout","markdownStyle","disableInlineStyles","p","addLineLayout","pNode","INNERMOST_TYPES","Set","reportAmbiguousNesting","i","previous","current","has","console","error","addLine","rootNode","textLength","hasRanges","lineNode","currentParentNode","lastRangeEndIndex","lineMarkdownRanges","shift","endOfCurrentRange","nextRangeStartIndex","textBeforeRange","substring","addBlockPrefixGap","gaps","get","parentEndIndex","textAfterRange","prepareLines","measure","layouts","layoutBlocks","sortedRanges","sortRanges","__DEV__","normalized","ungroupRanges","paragraph","parseRangesToHTMLNodes","createTextMeasurer","rootElement","createRootTreeNode","buildLine","childNodes","dom","tree","signatureOf","signature","depth","firstLineIndent","indent","ribbons","join","gap","shiftSubtree","delta","target","child","restampSubtree","orderIndex","coverChildren","end","childEnd","scratch","canReuseLine","cached","liveNode","outerHTML","html","reconcileLines","shouldForceDOMUpdate","signatures","cache","lineCache","live","Array","from","head","tail","previousTail","liveTail","fresh","anchor","remove","fragment","createDocumentFragment","insertBefore","nextCache","moveCursor","isFocused","alwaysMoveCursorToTheEnd","cursorPosition","shouldScrollIntoView","moveCursorToEnd","setCursorPosition","updateInputStructure","parserFunction","cursorPositionIndex","activeElement","selection","getCurrentCursorPosition","innerHTML","innerText"],"sourceRoot":"../../../../src","sources":["web/utils/parserUtils.ts"],"mappings":";;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AAGA,IAAAK,WAAA,GAAAL,OAAA;AAWA,SAASM,kBAAkBA,CAACC,IAAY,EAAe;EACrD,IAAIC,cAAc,GAAG,CAAC;EACtB,MAAMC,KAAkB,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC,CAACC,GAAG,CAAEC,IAAI,IAAK;IACxD,MAAMC,UAAqB,GAAG;MAC5BN,IAAI,EAAEK,IAAI;MACVE,KAAK,EAAEN,cAAc;MACrBO,MAAM,EAAEH,IAAI,CAACG,MAAM;MACnBC,cAAc,EAAE;IAClB,CAAC;IACDR,cAAc,IAAII,IAAI,CAACG,MAAM,GAAG,CAAC,EAAC;IAClC,OAAOF,UAAU;EACnB,CAAC,CAAC;EAEF,OAAOJ,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA,SAASQ,2BAA2BA,CAClCR,KAAkB,EAClBS,WAAsB,EACtBC,KAAoB,EACpBC,wBAAkC,EAClC;EACA,MAAMC,QAAQ,GAAGH,WAAW;EAC5BA,WAAW,CAACF,cAAc,CAACM,IAAI,CAACH,KAAK,CAAC;EAEtCC,wBAAwB,CAACG,OAAO,CAAEC,SAAS,IAAK;IAC9C,MAAMC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