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,109 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addNodeToTree = addNodeToTree;
7
+ exports.createRootTreeNode = createRootTreeNode;
8
+ exports.findHTMLElementInTree = findHTMLElementInTree;
9
+ exports.getTreeNodeByIndex = getTreeNodeByIndex;
10
+ function createRootTreeNode(target, length = 0, start = 0) {
11
+ return {
12
+ element: target,
13
+ start,
14
+ length,
15
+ parentNode: null,
16
+ childNodes: [],
17
+ type: "root",
18
+ orderIndex: "",
19
+ isGeneratingNewline: false
20
+ };
21
+ }
22
+
23
+ /**
24
+ * @param start Where the node begins in the text, when the caller knows it. A markdown range
25
+ * carries its own offset, and taking it is the only way to be right when ranges do not tile the
26
+ * line -- overlapping emphasis split across lines leaves gaps, and a node placed at wherever its
27
+ * previous sibling happened to end then reports an offset the text never had. Text and line breaks
28
+ * genuinely do follow on from what precedes them, so they still accumulate.
29
+ */
30
+ function addNodeToTree(element, parentTreeNode, type, length = null, start = null) {
31
+ const contentLength = length || (element.nodeName === "BR" || type === "br" ? 1 : element.value?.length) || 0;
32
+ const isGeneratingNewline = type === "line" && !(element.childNodes.length === 1 && element.childNodes[0]?.getAttribute?.("data-type") === "br");
33
+ const parentChildrenCount = parentTreeNode?.childNodes.length || 0;
34
+ let startIndex = parentTreeNode.start;
35
+ if (start !== null) {
36
+ startIndex = start;
37
+ } else if (parentChildrenCount > 0) {
38
+ const lastParentChild = parentTreeNode.childNodes[parentChildrenCount - 1];
39
+ if (lastParentChild) {
40
+ startIndex = lastParentChild.start + lastParentChild.length;
41
+ startIndex += lastParentChild.isGeneratingNewline || element.style.display === "block" ? 1 : 0;
42
+ }
43
+ }
44
+ const item = {
45
+ element,
46
+ parentNode: parentTreeNode,
47
+ childNodes: [],
48
+ start: startIndex,
49
+ length: contentLength,
50
+ type,
51
+ orderIndex: parentTreeNode.parentNode === null ? `${parentChildrenCount}` : `${parentTreeNode.orderIndex},${parentChildrenCount}`,
52
+ isGeneratingNewline
53
+ };
54
+ element.setAttribute("data-id", item.orderIndex);
55
+ parentTreeNode.childNodes.push(item);
56
+ return item;
57
+ }
58
+ function findHTMLElementInTree(treeRoot, element) {
59
+ if (element.hasAttribute?.("contenteditable")) {
60
+ return treeRoot;
61
+ }
62
+ if (!element || !element.hasAttribute?.("data-id")) {
63
+ return null;
64
+ }
65
+ const indexes = element.getAttribute("data-id")?.split(",");
66
+ let el = treeRoot;
67
+ while (el && indexes && indexes.length > 0) {
68
+ const index = Number(indexes.shift() || -1);
69
+ if (index < 0) {
70
+ break;
71
+ }
72
+ if (el) {
73
+ el = el.childNodes[index] || null;
74
+ }
75
+ }
76
+ return el;
77
+ }
78
+ function getTreeNodeByIndex(treeRoot, index) {
79
+ let el = treeRoot;
80
+ let i = 0;
81
+ let newLineGenerated = false;
82
+ if (treeRoot.length === 0) {
83
+ return treeRoot;
84
+ }
85
+ while (el && el.childNodes.length > 0 && i < el.childNodes.length) {
86
+ const child = el.childNodes[i];
87
+ if (!child) {
88
+ break;
89
+ }
90
+ if (index >= child.start && index < child.start + child.length) {
91
+ if (child.childNodes.length === 0) {
92
+ return child;
93
+ }
94
+ el = child;
95
+ i = 0;
96
+ } else if ((child.isGeneratingNewline || newLineGenerated || i === el.childNodes.length - 1) && index === child.start + child.length) {
97
+ newLineGenerated = true;
98
+ if (child.childNodes.length === 0) {
99
+ return child;
100
+ }
101
+ el = child;
102
+ i = 0;
103
+ } else {
104
+ i++;
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+ //# sourceMappingURL=treeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createRootTreeNode","target","length","start","element","parentNode","childNodes","type","orderIndex","isGeneratingNewline","addNodeToTree","parentTreeNode","contentLength","nodeName","value","getAttribute","parentChildrenCount","startIndex","lastParentChild","style","display","item","setAttribute","push","findHTMLElementInTree","treeRoot","hasAttribute","indexes","split","el","index","Number","shift","getTreeNodeByIndex","i","newLineGenerated","child"],"sourceRoot":"../../../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AC,EAAE;IACL;EACF;EACA,OAAO,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.idGenerator = void 0;
7
+ exports.parseToReactDOMStyle = parseToReactDOMStyle;
8
+ exports.processMarkdownStyle = processMarkdownStyle;
9
+ var _styleUtils = require("../../styleUtils.js");
10
+ /* eslint-disable @typescript-eslint/no-explicit-any */
11
+
12
+ let createReactDOMStyle;
13
+ try {
14
+ createReactDOMStyle =
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
16
+ require("react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle").default;
17
+ } catch {
18
+ throw new Error("[react-native-marcus] Function `createReactDOMStyle` from react-native-web not found. Please make sure that you are using React Native Web 0.18 or newer.");
19
+ }
20
+ let preprocessStyle;
21
+ try {
22
+ preprocessStyle =
23
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
24
+ require("react-native-web/dist/exports/StyleSheet/preprocess").default;
25
+ } catch {
26
+ throw new Error("[react-native-marcus] Function `preprocessStyle` from react-native-web not found.");
27
+ }
28
+ let dangerousStyleValue;
29
+ try {
30
+ dangerousStyleValue =
31
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
32
+ require("react-native-web/dist/modules/setValueForStyles/dangerousStyleValue").default;
33
+ } catch {
34
+ throw new Error("[react-native-marcus] Function `dangerousStyleValue` from react-native-web not found.");
35
+ }
36
+ function processUnitsInMarkdownStyle(input) {
37
+ const output = JSON.parse(JSON.stringify(input));
38
+ Object.keys(output).forEach(key => {
39
+ const obj = output[key];
40
+ Object.keys(obj).forEach(prop => {
41
+ obj[prop] = dangerousStyleValue(prop, obj[prop], false);
42
+ });
43
+ });
44
+ return output;
45
+ }
46
+ function processMarkdownStyle(input) {
47
+ return processUnitsInMarkdownStyle((0, _styleUtils.mergeMarkdownStyleWithDefault)(input));
48
+ }
49
+ function parseToReactDOMStyle(style) {
50
+ return createReactDOMStyle(preprocessStyle(style));
51
+ }
52
+ function* generateUniqueId() {
53
+ let idCounter = 0;
54
+ while (true) {
55
+ yield `marcus-input-${idCounter++}`;
56
+ }
57
+ }
58
+ const idGenerator = exports.idGenerator = generateUniqueId();
59
+ //# sourceMappingURL=webStyleUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_styleUtils","require","createReactDOMStyle","default","Error","preprocessStyle","dangerousStyleValue","processUnitsInMarkdownStyle","input","output","JSON","parse","stringify","Object","keys","forEach","key","obj","prop","processMarkdownStyle","mergeMarkdownStyleWithDefault","parseToReactDOMStyle","style","generateUniqueId","idCounter","idGenerator","exports"],"sourceRoot":"../../../../src","sources":["web/utils/webStyleUtils.ts"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAHA;;AAKA,IAAIC,mBAAwC;AAC5C,IAAI;EACFA,mBAAmB;EACjB;EACAD,OAAO,CAAC,uEAAuE,CAAC,CAACE,OAAO;AAC5F,CAAC,CAAC,MAAM;EACN,MAAM,IAAIC,KAAK,CACb,2JACF,CAAC;AACH;AAEA,IAAIC,eAAoC;AACxC,IAAI;EACFA,eAAe;EACb;EACAJ,OAAO,CAAC,qDAAqD,CAAC,CAACE,OAAO;AAC1E,CAAC,CAAC,MAAM;EACN,MAAM,IAAIC,KAAK,CACb,mFACF,CAAC;AACH;AAEA,IAAIE,mBAAiF;AACrF,IAAI;EACFA,mBAAmB;EACjB;EACAL,OAAO,CAAC,qEAAqE,CAAC,CAACE,OAAO;AAC1F,CAAC,CAAC,MAAM;EACN,MAAM,IAAIC,KAAK,CACb,uFACF,CAAC;AACH;AAEA,SAASG,2BAA2BA,CAACC,KAAoB,EAAiB;EACxE,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACJ,KAAK,CAAC,CAAC;EAEhDK,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC,CAACM,OAAO,CAAEC,GAAG,IAAK;IACnC,MAAMC,GAAG,GAAGR,MAAM,CAACO,GAAG,CAAC;IACvBH,MAAM,CAACC,IAAI,CAACG,GAAG,CAAC,CAACF,OAAO,CAAEG,IAAI,IAAK;MACjCD,GAAG,CAACC,IAAI,CAAC,GAAGZ,mBAAmB,CAACY,IAAI,EAAED,GAAG,CAACC,IAAI,CAAC,EAAE,KAAK,CAAC;IACzD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAOT,MAAM;AACf;AAEA,SAASU,oBAAoBA,CAACX,KAAgC,EAAiB;EAC7E,OAAOD,2BAA2B,CAAC,IAAAa,yCAA6B,EAACZ,KAAK,CAAC,CAAC;AAC1E;AAEA,SAASa,oBAAoBA,CAACC,KAAgB,EAAO;EACnD,OAAOpB,mBAAmB,CAACG,eAAe,CAACiB,KAAK,CAAC,CAAC;AACpD;AAEA,UAAUC,gBAAgBA,CAAA,EAAG;EAC3B,IAAIC,SAAS,GAAG,CAAC;EACjB,OAAO,IAAI,EAAE;IACX,MAAM,gBAAgBA,SAAS,EAAE,EAAE;EACrC;AACF;AAEA,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGF,gBAAgB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,77 @@
1
+ import { codegenNativeComponent } from "react-native"
2
+ import type { ColorValue, ViewProps } from "react-native"
3
+
4
+ import type { Float, Int32 } from "react-native/Libraries/Types/CodegenTypes"
5
+
6
+ // Font, colour and background, and nothing else: neither formatter draws a
7
+ // border or reserves padding around a code run, so there is nothing to
8
+ // configure.
9
+ interface CodeBlockStyle {
10
+ fontFamily: string
11
+ fontSize: Float
12
+ color: ColorValue
13
+ backgroundColor: ColorValue
14
+ }
15
+
16
+ interface MarkdownStyle {
17
+ syntax: {
18
+ color: ColorValue
19
+ }
20
+ emoji: {
21
+ fontSize: Float
22
+ fontFamily: string
23
+ }
24
+ link: {
25
+ color: ColorValue
26
+ }
27
+ heading: {
28
+ fontSize: Float
29
+ // Each level down multiplies the one above, so level N is
30
+ // fontSize * scale^(N - 1). Six levels, matching HTML.
31
+ scale: Float
32
+ }
33
+ blockquote: {
34
+ borderColor: ColorValue
35
+ borderWidth: Float
36
+ marginLeft: Float
37
+ paddingLeft: Float
38
+ }
39
+ // Indent only, no gutter decoration. Kept as two separate entries so a
40
+ // renderer can style ordered and unordered lists differently.
41
+ orderedList: {
42
+ marginLeft: Float
43
+ paddingLeft: Float
44
+ }
45
+ unorderedList: {
46
+ marginLeft: Float
47
+ paddingLeft: Float
48
+ }
49
+ code: CodeBlockStyle
50
+ pre: CodeBlockStyle
51
+ mentionHere: {
52
+ color: ColorValue
53
+ backgroundColor: ColorValue
54
+ borderRadius?: Float
55
+ }
56
+ mentionUser: {
57
+ color: ColorValue
58
+ backgroundColor: ColorValue
59
+ borderRadius?: Float
60
+ }
61
+ mentionReport: {
62
+ color: ColorValue
63
+ backgroundColor: ColorValue
64
+ borderRadius?: Float
65
+ }
66
+ }
67
+
68
+ interface NativeProps extends ViewProps {
69
+ markdownStyle: MarkdownStyle
70
+ parserId: Int32
71
+ }
72
+
73
+ export default codegenNativeComponent<NativeProps>("MarcusTextInputDecoratorView", {
74
+ interfaceOnly: true,
75
+ })
76
+
77
+ export type { MarkdownStyle }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ import { StyleSheet, TextInput, processColor } from "react-native";
4
+ import React from "react";
5
+ import { createSerializable, createWorkletRuntime } from "react-native-worklets";
6
+ import MarcusTextInputDecoratorViewNativeComponent from "./MarcusTextInputDecoratorViewNativeComponent";
7
+ import NativeMarcusModule from "./NativeMarcusModule.js";
8
+ import { mergeMarkdownStyleWithDefault } from "./styleUtils.js";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ let initialized = false;
11
+ let workletRuntime;
12
+ function getWorkletRuntime() {
13
+ if (workletRuntime === undefined) {
14
+ throw new Error("[react-native-marcus] Worklet runtime hasn't been created yet. Please avoid calling `getWorkletRuntime()` in top-level scope. Instead, call `getWorkletRuntime()` directly in `runOnRuntime` arguments list.");
15
+ }
16
+ return workletRuntime;
17
+ }
18
+ function initializeMarcusIfNeeded() {
19
+ if (initialized) {
20
+ return;
21
+ }
22
+ if (NativeMarcusModule) {
23
+ NativeMarcusModule.install();
24
+ }
25
+ if (!global.jsi_setMarcusRuntime) {
26
+ throw new Error("[react-native-marcus] global.jsi_setMarcusRuntime is not available");
27
+ }
28
+ workletRuntime = createWorkletRuntime({
29
+ name: "MarcusRuntime"
30
+ });
31
+ global.jsi_setMarcusRuntime(workletRuntime);
32
+ initialized = true;
33
+ }
34
+ function registerParser(parser) {
35
+ initializeMarcusIfNeeded();
36
+ const serializableWorklet = createSerializable(parser);
37
+ const parserId = global.jsi_registerMarcusWorklet(serializableWorklet);
38
+ return parserId;
39
+ }
40
+ function unregisterParser(parserId) {
41
+ global.jsi_unregisterMarcusWorklet(parserId);
42
+ }
43
+ function processColorsInMarkdownStyle(input) {
44
+ const output = JSON.parse(JSON.stringify(input));
45
+ Object.keys(output).forEach(key => {
46
+ const obj = output[key];
47
+ Object.keys(obj).forEach(prop => {
48
+ // TODO: use ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes'
49
+ if (!(prop === "color" || prop.endsWith("Color"))) {
50
+ return;
51
+ }
52
+ obj[prop] = processColor(obj[prop]);
53
+ });
54
+ });
55
+ return output;
56
+ }
57
+ function processMarkdownStyle(input) {
58
+ return processColorsInMarkdownStyle(mergeMarkdownStyleWithDefault(input));
59
+ }
60
+ const MarkdownTextInput = /*#__PURE__*/React.forwardRef((props, ref) => {
61
+ const markdownStyle = React.useMemo(() => processMarkdownStyle(props.markdownStyle), [props.markdownStyle]);
62
+ if (props.parser === undefined) {
63
+ throw new Error("[react-native-marcus] `parser` is undefined");
64
+ }
65
+
66
+ // eslint-disable-next-line no-underscore-dangle
67
+ const workletHash = props.parser.__workletHash;
68
+ if (workletHash === undefined) {
69
+ throw new Error("[react-native-marcus] `parser` is not a worklet");
70
+ }
71
+ const parserId = React.useMemo(() => {
72
+ return registerParser(props.parser);
73
+ }, [props.parser]);
74
+ React.useEffect(() => {
75
+ return () => unregisterParser(parserId);
76
+ }, [parserId]);
77
+ return /*#__PURE__*/_jsx(MarcusTextInputDecoratorViewNativeComponent, {
78
+ style: styles.displayContents,
79
+ markdownStyle: markdownStyle,
80
+ parserId: parserId,
81
+ children: /*#__PURE__*/_jsx(TextInput, {
82
+ ...props,
83
+ ref: ref
84
+ })
85
+ });
86
+ });
87
+ const styles = StyleSheet.create({
88
+ displayContents: {
89
+ display: "contents"
90
+ }
91
+ });
92
+ export default MarkdownTextInput;
93
+ export { getWorkletRuntime };
94
+ //# sourceMappingURL=MarkdownTextInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StyleSheet","TextInput","processColor","React","createSerializable","createWorkletRuntime","MarcusTextInputDecoratorViewNativeComponent","NativeMarcusModule","mergeMarkdownStyleWithDefault","jsx","_jsx","initialized","workletRuntime","getWorkletRuntime","undefined","Error","initializeMarcusIfNeeded","install","global","jsi_setMarcusRuntime","name","registerParser","parser","serializableWorklet","parserId","jsi_registerMarcusWorklet","unregisterParser","jsi_unregisterMarcusWorklet","processColorsInMarkdownStyle","input","output","JSON","parse","stringify","Object","keys","forEach","key","obj","prop","endsWith","processMarkdownStyle","MarkdownTextInput","forwardRef","props","ref","markdownStyle","useMemo","workletHash","__workletHash","useEffect","style","styles","displayContents","children","create","display"],"sourceRoot":"../../src","sources":["MarkdownTextInput.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,YAAY,QAAQ,cAAc;AAClE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,kBAAkB,EAAEC,oBAAoB,QAAQ,uBAAuB;AAEhF,OAAOC,2CAA2C,MAAM,+CAA+C;AAEvG,OAAOC,kBAAkB,MAAM,yBAAsB;AACrD,SAASC,6BAA6B,QAAQ,iBAAc;AAAA,SAA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