react-native-enriched 0.2.1 → 0.4.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 (263) hide show
  1. package/README.md +21 -16
  2. package/android/build.gradle +77 -72
  3. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +21 -0
  4. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +7 -0
  5. package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.cpp +1 -1
  6. package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.h +1 -1
  7. package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.cpp +276 -0
  8. package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.h +239 -0
  9. package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.cpp +10 -0
  10. package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.h +251 -0
  11. package/android/gradle.properties +5 -5
  12. package/android/lint.gradle +70 -0
  13. package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewPackage.kt → ReactNativeEnrichedPackage.kt} +4 -5
  14. package/android/src/main/java/com/swmansion/enriched/{utils → common}/AsyncDrawable.kt +50 -15
  15. package/android/src/main/java/com/swmansion/enriched/common/CheckboxDrawable.kt +81 -0
  16. package/android/src/main/java/com/swmansion/enriched/common/EnrichedConstants.kt +11 -0
  17. package/android/src/main/java/com/swmansion/enriched/common/EnrichedStyle.kt +57 -0
  18. package/android/src/main/java/com/swmansion/enriched/{spans/utils → common}/ForceRedrawSpan.kt +3 -2
  19. package/android/src/main/java/com/swmansion/enriched/common/MentionStyle.kt +7 -0
  20. package/android/src/main/java/com/swmansion/enriched/{utils → common}/ResourceManager.kt +1 -1
  21. package/android/src/main/java/com/swmansion/enriched/{utils → common/parser}/EnrichedParser.java +228 -160
  22. package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +79 -0
  23. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedBlockQuoteSpan.kt +53 -0
  24. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedBoldSpan.kt +12 -0
  25. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCheckboxListSpan.kt +91 -0
  26. package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedCodeBlockSpan.kt +12 -14
  27. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH1Span.kt +20 -0
  28. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH2Span.kt +20 -0
  29. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH3Span.kt +20 -0
  30. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH4Span.kt +21 -0
  31. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH5Span.kt +20 -0
  32. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH6Span.kt +20 -0
  33. package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedImageSpan.kt +68 -51
  34. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedInlineCodeSpan.kt +24 -0
  35. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedItalicSpan.kt +12 -0
  36. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedLinkSpan.kt +26 -0
  37. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedMentionSpan.kt +35 -0
  38. package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedOrderedListSpan.kt +21 -29
  39. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedStrikeThroughSpan.kt +11 -0
  40. package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedUnderlineSpan.kt +11 -0
  41. package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/EnrichedUnorderedListSpan.kt +13 -17
  42. package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedBlockSpan.kt +5 -0
  43. package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedHeadingSpan.kt +3 -0
  44. package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedInlineSpan.kt +3 -0
  45. package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedParagraphSpan.kt +5 -0
  46. package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedSpan.kt +3 -0
  47. package/android/src/main/java/com/swmansion/enriched/{spans → common/spans}/interfaces/EnrichedZeroWidthSpaceSpan.kt +2 -3
  48. package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputConnectionWrapper.kt +140 -0
  49. package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt +83 -0
  50. package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputView.kt → textinput/EnrichedTextInputView.kt} +322 -157
  51. package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewLayoutManager.kt → textinput/EnrichedTextInputViewLayoutManager.kt} +4 -2
  52. package/android/src/main/java/com/swmansion/enriched/{EnrichedTextInputViewManager.kt → textinput/EnrichedTextInputViewManager.kt} +182 -66
  53. package/android/src/main/java/com/swmansion/enriched/{MeasurementStore.kt → textinput/MeasurementStore.kt} +75 -25
  54. package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/MentionHandler.kt +22 -12
  55. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeHtmlEvent.kt +27 -0
  56. package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnChangeSelectionEvent.kt +11 -10
  57. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeStateEvent.kt +21 -0
  58. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeTextEvent.kt +30 -0
  59. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputBlurEvent.kt +25 -0
  60. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputFocusEvent.kt +25 -0
  61. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputKeyPressEvent.kt +27 -0
  62. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnLinkDetectedEvent.kt +32 -0
  63. package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnMentionDetectedEvent.kt +11 -10
  64. package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnMentionEvent.kt +10 -9
  65. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnPasteImagesEvent.kt +47 -0
  66. package/android/src/main/java/com/swmansion/enriched/{events → textinput/events}/OnRequestHtmlResultEvent.kt +2 -3
  67. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputBlockQuoteSpan.kt +14 -0
  68. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputBoldSpan.kt +14 -0
  69. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCheckboxListSpan.kt +15 -0
  70. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCodeBlockSpan.kt +14 -0
  71. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH1Span.kt +14 -0
  72. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH2Span.kt +14 -0
  73. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH3Span.kt +14 -0
  74. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH4Span.kt +14 -0
  75. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH5Span.kt +14 -0
  76. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH6Span.kt +14 -0
  77. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputImageSpan.kt +36 -0
  78. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputInlineCodeSpan.kt +14 -0
  79. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputItalicSpan.kt +14 -0
  80. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputLinkSpan.kt +15 -0
  81. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputMentionSpan.kt +18 -0
  82. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputOrderedListSpan.kt +21 -0
  83. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputStrikeThroughSpan.kt +14 -0
  84. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputUnderlineSpan.kt +14 -0
  85. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputUnorderedListSpan.kt +14 -0
  86. package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedSpans.kt +241 -0
  87. package/android/src/main/java/com/swmansion/enriched/textinput/spans/interfaces/EnrichedInputSpan.kt +10 -0
  88. package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/HtmlStyle.kt +129 -57
  89. package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/InlineStyles.kt +30 -13
  90. package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +263 -0
  91. package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ParagraphStyles.kt +94 -34
  92. package/android/src/main/java/com/swmansion/enriched/{styles → textinput/styles}/ParametrizedStyles.kt +143 -67
  93. package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedEditableFactory.kt +17 -0
  94. package/android/src/main/java/com/swmansion/enriched/{utils → textinput/utils}/EnrichedSelection.kt +84 -54
  95. package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt +304 -0
  96. package/android/src/main/java/com/swmansion/enriched/{utils/Utils.kt → textinput/utils/EnrichedSpannable.kt} +22 -31
  97. package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannableStringBuilder.kt +16 -0
  98. package/android/src/main/java/com/swmansion/enriched/textinput/utils/RichContentReceiver.kt +127 -0
  99. package/android/src/main/java/com/swmansion/enriched/textinput/utils/Utils.kt +106 -0
  100. package/android/src/main/java/com/swmansion/enriched/{watchers → textinput/watchers}/EnrichedSpanWatcher.kt +56 -24
  101. package/android/src/main/java/com/swmansion/enriched/{watchers → textinput/watchers}/EnrichedTextWatcher.kt +37 -14
  102. package/android/src/main/new_arch/CMakeLists.txt +7 -1
  103. package/android/src/main/new_arch/ReactNativeEnrichedSpec.cpp +11 -0
  104. package/android/src/main/new_arch/ReactNativeEnrichedSpec.h +15 -0
  105. package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputMeasurementManager.h +1 -1
  106. package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputShadowNode.h +2 -2
  107. package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h +46 -0
  108. package/ios/EnrichedTextInputView.h +2 -1
  109. package/ios/EnrichedTextInputView.mm +603 -60
  110. package/ios/config/InputConfig.h +28 -0
  111. package/ios/config/InputConfig.mm +237 -8
  112. package/ios/extensions/ImageExtension.h +35 -0
  113. package/ios/extensions/ImageExtension.mm +156 -0
  114. package/ios/{utils → extensions}/LayoutManagerExtension.mm +115 -95
  115. package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.cpp +1 -1
  116. package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ComponentDescriptors.h +1 -1
  117. package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.cpp +276 -0
  118. package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.h +239 -0
  119. package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.cpp +10 -0
  120. package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/Props.h +251 -0
  121. package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/RCTComponentViewHelpers.h +95 -0
  122. package/ios/inputParser/InputParser.mm +218 -18
  123. package/ios/inputTextView/InputTextView.mm +118 -0
  124. package/ios/{attachments → interfaces}/ImageAttachment.h +1 -0
  125. package/ios/interfaces/ImageAttachment.mm +46 -0
  126. package/ios/interfaces/LinkRegexConfig.h +19 -0
  127. package/ios/interfaces/LinkRegexConfig.mm +37 -0
  128. package/ios/{utils → interfaces}/MentionStyleProps.mm +2 -2
  129. package/ios/{utils → interfaces}/StyleHeaders.h +22 -1
  130. package/ios/{utils → interfaces}/StyleTypeEnum.h +4 -0
  131. package/ios/internals/EnrichedTextInputViewState.cpp +6 -6
  132. package/ios/styles/BlockQuoteStyle.mm +5 -5
  133. package/ios/styles/BoldStyle.mm +21 -6
  134. package/ios/styles/CheckboxListStyle.mm +321 -0
  135. package/ios/styles/CodeBlockStyle.mm +5 -5
  136. package/ios/styles/H1Style.mm +3 -0
  137. package/ios/styles/H2Style.mm +3 -0
  138. package/ios/styles/H3Style.mm +3 -0
  139. package/ios/styles/H4Style.mm +20 -0
  140. package/ios/styles/H5Style.mm +20 -0
  141. package/ios/styles/H6Style.mm +20 -0
  142. package/ios/styles/HeadingStyleBase.mm +161 -72
  143. package/ios/styles/ImageStyle.mm +5 -5
  144. package/ios/styles/InlineCodeStyle.mm +30 -19
  145. package/ios/styles/ItalicStyle.mm +5 -5
  146. package/ios/styles/LinkStyle.mm +98 -40
  147. package/ios/styles/MentionStyle.mm +4 -4
  148. package/ios/styles/OrderedListStyle.mm +5 -5
  149. package/ios/styles/StrikethroughStyle.mm +5 -5
  150. package/ios/styles/UnderlineStyle.mm +5 -5
  151. package/ios/styles/UnorderedListStyle.mm +5 -5
  152. package/ios/utils/CheckboxHitTestUtils.h +10 -0
  153. package/ios/utils/CheckboxHitTestUtils.mm +123 -0
  154. package/ios/utils/ParagraphAttributesUtils.h +4 -0
  155. package/ios/utils/ParagraphAttributesUtils.mm +142 -45
  156. package/ios/utils/ParagraphsUtils.mm +4 -4
  157. package/ios/utils/TextBlockTapGestureRecognizer.h +17 -0
  158. package/ios/utils/TextBlockTapGestureRecognizer.mm +56 -0
  159. package/ios/utils/ZeroWidthSpaceUtils.mm +14 -3
  160. package/lib/module/EnrichedTextInput.js +57 -11
  161. package/lib/module/EnrichedTextInput.js.map +1 -1
  162. package/lib/module/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts} +175 -18
  163. package/lib/module/types.js +4 -0
  164. package/lib/module/types.js.map +1 -0
  165. package/lib/module/{normalizeHtmlStyle.js → utils/normalizeHtmlStyle.js} +18 -0
  166. package/lib/module/utils/normalizeHtmlStyle.js.map +1 -0
  167. package/lib/module/utils/nullthrows.js +9 -0
  168. package/lib/module/utils/nullthrows.js.map +1 -0
  169. package/lib/module/utils/regexParser.js +46 -0
  170. package/lib/module/utils/regexParser.js.map +1 -0
  171. package/lib/typescript/src/EnrichedTextInput.d.ts +20 -51
  172. package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
  173. package/lib/typescript/src/index.d.ts +2 -1
  174. package/lib/typescript/src/index.d.ts.map +1 -1
  175. package/lib/typescript/src/{EnrichedTextInputNativeComponent.d.ts → spec/EnrichedTextInputNativeComponent.d.ts} +154 -18
  176. package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts.map +1 -0
  177. package/lib/typescript/src/types.d.ts +58 -0
  178. package/lib/typescript/src/types.d.ts.map +1 -0
  179. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +4 -0
  180. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -0
  181. package/lib/typescript/src/utils/nullthrows.d.ts +2 -0
  182. package/lib/typescript/src/utils/nullthrows.d.ts.map +1 -0
  183. package/lib/typescript/src/utils/regexParser.d.ts +3 -0
  184. package/lib/typescript/src/utils/regexParser.d.ts.map +1 -0
  185. package/package.json +13 -9
  186. package/src/EnrichedTextInput.tsx +88 -63
  187. package/src/index.tsx +5 -1
  188. package/src/{EnrichedTextInputNativeComponent.ts → spec/EnrichedTextInputNativeComponent.ts} +175 -18
  189. package/src/types.ts +59 -0
  190. package/src/{normalizeHtmlStyle.ts → utils/normalizeHtmlStyle.ts} +20 -5
  191. package/src/utils/nullthrows.ts +7 -0
  192. package/src/utils/regexParser.ts +56 -0
  193. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +0 -128
  194. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +0 -102
  195. package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +0 -28
  196. package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +0 -24
  197. package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +0 -30
  198. package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +0 -27
  199. package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +0 -27
  200. package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +0 -30
  201. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +0 -44
  202. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +0 -16
  203. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +0 -23
  204. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +0 -23
  205. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +0 -23
  206. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +0 -27
  207. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +0 -15
  208. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +0 -30
  209. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +0 -42
  210. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +0 -136
  211. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +0 -14
  212. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +0 -14
  213. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +0 -4
  214. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +0 -4
  215. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +0 -4
  216. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +0 -4
  217. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +0 -8
  218. package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +0 -172
  219. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +0 -204
  220. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +0 -22
  221. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +0 -26
  222. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +0 -26
  223. package/ios/attachments/ImageAttachment.mm +0 -34
  224. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +0 -128
  225. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +0 -102
  226. package/lib/module/normalizeHtmlStyle.js.map +0 -1
  227. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +0 -1
  228. package/lib/typescript/src/normalizeHtmlStyle.d.ts +0 -4
  229. package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +0 -1
  230. /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.cpp +0 -0
  231. /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.h +0 -0
  232. /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.cpp +0 -0
  233. /package/android/generated/jni/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.h +0 -0
  234. /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputComponentDescriptor.h +0 -0
  235. /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputMeasurementManager.cpp +0 -0
  236. /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputShadowNode.cpp +0 -0
  237. /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputState.cpp +0 -0
  238. /package/android/src/main/new_arch/react/renderer/components/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/EnrichedTextInputState.h +0 -0
  239. /package/ios/{utils → extensions}/ColorExtension.h +0 -0
  240. /package/ios/{utils → extensions}/ColorExtension.mm +0 -0
  241. /package/ios/{utils → extensions}/FontExtension.h +0 -0
  242. /package/ios/{utils → extensions}/FontExtension.mm +0 -0
  243. /package/ios/{utils → extensions}/LayoutManagerExtension.h +0 -0
  244. /package/ios/{utils → extensions}/StringExtension.h +0 -0
  245. /package/ios/{utils → extensions}/StringExtension.mm +0 -0
  246. /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.cpp +0 -0
  247. /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/ShadowNodes.h +0 -0
  248. /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.cpp +0 -0
  249. /package/ios/generated/{RNEnrichedTextInputViewSpec → ReactNativeEnrichedSpec}/States.h +0 -0
  250. /package/ios/{utils → interfaces}/BaseStyleProtocol.h +0 -0
  251. /package/ios/{utils → interfaces}/ImageData.h +0 -0
  252. /package/ios/{utils → interfaces}/ImageData.mm +0 -0
  253. /package/ios/{utils → interfaces}/LinkData.h +0 -0
  254. /package/ios/{utils → interfaces}/LinkData.mm +0 -0
  255. /package/ios/{attachments → interfaces}/MediaAttachment.h +0 -0
  256. /package/ios/{attachments → interfaces}/MediaAttachment.mm +0 -0
  257. /package/ios/{utils → interfaces}/MentionParams.h +0 -0
  258. /package/ios/{utils → interfaces}/MentionParams.mm +0 -0
  259. /package/ios/{utils → interfaces}/MentionStyleProps.h +0 -0
  260. /package/ios/{utils → interfaces}/StylePair.h +0 -0
  261. /package/ios/{utils → interfaces}/StylePair.mm +0 -0
  262. /package/ios/{utils → interfaces}/TextDecorationLineEnum.h +0 -0
  263. /package/ios/{utils → interfaces}/TextDecorationLineEnum.mm +0 -0
@@ -0,0 +1,321 @@
1
+ #import "EnrichedTextInputView.h"
2
+ #import "FontExtension.h"
3
+ #import "OccurenceUtils.h"
4
+ #import "ParagraphsUtils.h"
5
+ #import "StyleHeaders.h"
6
+ #import "TextInsertionUtils.h"
7
+
8
+ @implementation CheckboxListStyle {
9
+ EnrichedTextInputView *_input;
10
+ }
11
+
12
+ + (StyleType)getStyleType {
13
+ return CheckboxList;
14
+ }
15
+
16
+ + (BOOL)isParagraphStyle {
17
+ return YES;
18
+ }
19
+
20
+ - (CGFloat)getHeadIndent {
21
+ return [_input->config checkboxListMarginLeft] +
22
+ [_input->config checkboxListGapWidth] +
23
+ [_input->config checkboxListBoxSize];
24
+ }
25
+
26
+ - (instancetype)initWithInput:(id)input {
27
+ self = [super init];
28
+ _input = (EnrichedTextInputView *)input;
29
+ return self;
30
+ }
31
+
32
+ - (void)applyStyle:(NSRange)range {
33
+ // Applying a checkbox list style requires a checked value,
34
+ // which is why this method is not implemented.
35
+ // Use 'applyStyleWithCheckedValue' and provide the checked value instead.
36
+ }
37
+
38
+ - (void)applyStyleWithCheckedValue:(BOOL)checked inRange:(NSRange)range {
39
+ BOOL isStylePresent = [self detectStyle:range];
40
+ if (range.length >= 1) {
41
+ isStylePresent ? [self removeAttributes:range]
42
+ : [self addAttributesWithCheckedValue:checked
43
+ inRange:range
44
+ withTypingAttr:YES];
45
+ } else {
46
+ isStylePresent
47
+ ? [self removeTypingAttributes]
48
+ : [self addAttributesWithCheckedValue:checked
49
+ inRange:_input->textView.selectedRange
50
+ withTypingAttr:YES];
51
+ ;
52
+ }
53
+ }
54
+
55
+ - (void)addAttributes:(NSRange)range withTypingAttr:(BOOL)withTypingAttr {
56
+ [self addAttributesWithCheckedValue:NO
57
+ inRange:range
58
+ withTypingAttr:withTypingAttr];
59
+ }
60
+
61
+ - (void)addTypingAttributes {
62
+ }
63
+
64
+ - (void)removeAttributes:(NSRange)range {
65
+ NSArray *paragraphs =
66
+ [ParagraphsUtils getSeparateParagraphsRangesIn:_input->textView
67
+ range:range];
68
+
69
+ [_input->textView.textStorage beginEditing];
70
+
71
+ for (NSValue *value in paragraphs) {
72
+ NSRange range = [value rangeValue];
73
+ [_input->textView.textStorage
74
+ enumerateAttribute:NSParagraphStyleAttributeName
75
+ inRange:range
76
+ options:0
77
+ usingBlock:^(id _Nullable value, NSRange range,
78
+ BOOL *_Nonnull stop) {
79
+ NSMutableParagraphStyle *pStyle =
80
+ [(NSParagraphStyle *)value mutableCopy];
81
+ pStyle.textLists = @[];
82
+ pStyle.headIndent = 0;
83
+ pStyle.firstLineHeadIndent = 0;
84
+ [_input->textView.textStorage
85
+ addAttribute:NSParagraphStyleAttributeName
86
+ value:pStyle
87
+ range:range];
88
+ }];
89
+ }
90
+
91
+ [_input->textView.textStorage endEditing];
92
+
93
+ // also remove typing attributes
94
+ NSMutableDictionary *typingAttrs =
95
+ [_input->textView.typingAttributes mutableCopy];
96
+ NSMutableParagraphStyle *pStyle =
97
+ [typingAttrs[NSParagraphStyleAttributeName] mutableCopy];
98
+ pStyle.textLists = @[];
99
+ pStyle.headIndent = 0;
100
+ pStyle.firstLineHeadIndent = 0;
101
+ typingAttrs[NSParagraphStyleAttributeName] = pStyle;
102
+ _input->textView.typingAttributes = typingAttrs;
103
+ }
104
+
105
+ - (void)removeTypingAttributes {
106
+ [self removeAttributes:_input->textView.selectedRange];
107
+ }
108
+
109
+ - (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text {
110
+ if ([self detectStyle:_input->textView.selectedRange] && text.length == 0) {
111
+ // backspace while the style is active
112
+
113
+ NSRange paragraphRange = [_input->textView.textStorage.string
114
+ paragraphRangeForRange:_input->textView.selectedRange];
115
+
116
+ if (NSEqualRanges(_input->textView.selectedRange, NSMakeRange(0, 0))) {
117
+ // a backspace on the very first input's line list point
118
+ // it doesn't run textVieDidChange so we need to manually remove
119
+ // attributes
120
+ [self removeAttributes:paragraphRange];
121
+ return YES;
122
+ } else if (range.location == paragraphRange.location - 1) {
123
+ // same case in other lines; here, the removed range location will be
124
+ // exactly 1 less than paragraph range location
125
+ [self removeAttributes:paragraphRange];
126
+ return YES;
127
+ }
128
+ }
129
+ return NO;
130
+ }
131
+
132
+ // used to make sure checkbox marker is correct when a newline is placed
133
+ - (BOOL)handleNewlinesInRange:(NSRange)range replacementText:(NSString *)text {
134
+ // in a checkbox list and a new text ends with a newline
135
+ if ([self detectStyle:_input->textView.selectedRange] && text.length > 0 &&
136
+ [[NSCharacterSet newlineCharacterSet]
137
+ characterIsMember:[text characterAtIndex:text.length - 1]]) {
138
+ // do the replacement manually
139
+ [TextInsertionUtils replaceText:text
140
+ at:range
141
+ additionalAttributes:nullptr
142
+ input:_input
143
+ withSelection:YES];
144
+ // apply checkbox attributes to the new paragraph
145
+ [self addAttributes:_input->textView.selectedRange withTypingAttr:YES];
146
+ return YES;
147
+ }
148
+ return NO;
149
+ }
150
+
151
+ - (void)toggleCheckedAt:(NSUInteger)location {
152
+ if (location >= _input->textView.textStorage.length) {
153
+ return;
154
+ }
155
+
156
+ NSParagraphStyle *pStyle =
157
+ [_input->textView.textStorage attribute:NSParagraphStyleAttributeName
158
+ atIndex:location
159
+ effectiveRange:NULL];
160
+ NSTextList *list = pStyle.textLists.firstObject;
161
+
162
+ BOOL isCurrentlyChecked = [list.markerFormat isEqualToString:@"{checkbox:1}"];
163
+
164
+ NSString *fullText = _input->textView.textStorage.string;
165
+ NSRange paragraphRange =
166
+ [fullText paragraphRangeForRange:NSMakeRange(location, 0)];
167
+
168
+ [self addAttributesWithCheckedValue:!isCurrentlyChecked
169
+ inRange:paragraphRange
170
+ withTypingAttr:NO];
171
+ }
172
+
173
+ - (void)addAttributesWithCheckedValue:(BOOL)checked
174
+ inRange:(NSRange)range
175
+ withTypingAttr:(BOOL)withTypingAttr {
176
+ NSString *markerFormat = checked ? @"{checkbox:1}" : @"{checkbox:0}";
177
+ NSTextList *checkboxMarker =
178
+ [[NSTextList alloc] initWithMarkerFormat:markerFormat options:0];
179
+ NSArray *paragraphs =
180
+ [ParagraphsUtils getSeparateParagraphsRangesIn:_input->textView
181
+ range:range];
182
+ // if we fill empty lines with zero width spaces, we need to offset later
183
+ // ranges
184
+ NSInteger offset = 0;
185
+ // needed for range adjustments
186
+ NSRange preModificationRange = _input->textView.selectedRange;
187
+
188
+ // let's not emit some weird selection changes or text/html changes
189
+ _input->blockEmitting = YES;
190
+
191
+ for (NSValue *value in paragraphs) {
192
+ // take previous offsets into consideration
193
+ NSRange fixedRange = NSMakeRange([value rangeValue].location + offset,
194
+ [value rangeValue].length);
195
+
196
+ // length 0 with first line, length 1 and newline with some empty lines in
197
+ // the middle
198
+ if (fixedRange.length == 0 ||
199
+ (fixedRange.length == 1 &&
200
+ [[NSCharacterSet newlineCharacterSet]
201
+ characterIsMember:[_input->textView.textStorage.string
202
+ characterAtIndex:fixedRange.location]])) {
203
+ [TextInsertionUtils insertText:@"\u200B"
204
+ at:fixedRange.location
205
+ additionalAttributes:nullptr
206
+ input:_input
207
+ withSelection:NO];
208
+ fixedRange = NSMakeRange(fixedRange.location, fixedRange.length + 1);
209
+ offset += 1;
210
+ }
211
+
212
+ [_input->textView.textStorage
213
+ enumerateAttribute:NSParagraphStyleAttributeName
214
+ inRange:fixedRange
215
+ options:0
216
+ usingBlock:^(id _Nullable value, NSRange range,
217
+ BOOL *_Nonnull stop) {
218
+ NSMutableParagraphStyle *pStyle =
219
+ [(NSParagraphStyle *)value mutableCopy];
220
+ pStyle.textLists = @[ checkboxMarker ];
221
+ pStyle.headIndent = [self getHeadIndent];
222
+ pStyle.firstLineHeadIndent = [self getHeadIndent];
223
+ [_input->textView.textStorage
224
+ addAttribute:NSParagraphStyleAttributeName
225
+ value:pStyle
226
+ range:range];
227
+ }];
228
+ }
229
+
230
+ // back to emitting
231
+ _input->blockEmitting = NO;
232
+
233
+ if (preModificationRange.length == 0) {
234
+ // fix selection if only one line was possibly made a list and filled with a
235
+ // space
236
+ _input->textView.selectedRange = preModificationRange;
237
+ } else {
238
+ // in other cases, fix the selection with newly made offsets
239
+ _input->textView.selectedRange = NSMakeRange(
240
+ preModificationRange.location, preModificationRange.length + offset);
241
+ }
242
+
243
+ // also add typing attributes
244
+ if (withTypingAttr) {
245
+ NSMutableDictionary *typingAttrs =
246
+ [_input->textView.typingAttributes mutableCopy];
247
+ NSMutableParagraphStyle *pStyle =
248
+ [typingAttrs[NSParagraphStyleAttributeName] mutableCopy];
249
+ pStyle.textLists = @[ checkboxMarker ];
250
+ pStyle.headIndent = [self getHeadIndent];
251
+ pStyle.firstLineHeadIndent = [self getHeadIndent];
252
+ typingAttrs[NSParagraphStyleAttributeName] = pStyle;
253
+ _input->textView.typingAttributes = typingAttrs;
254
+ }
255
+ }
256
+
257
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
258
+ NSParagraphStyle *paragraph = (NSParagraphStyle *)value;
259
+ return paragraph != nullptr && paragraph.textLists.count == 1 &&
260
+ [paragraph.textLists.firstObject.markerFormat hasPrefix:@"{checkbox"];
261
+ }
262
+
263
+ - (BOOL)detectStyle:(NSRange)range {
264
+ if (range.length >= 1) {
265
+ return [OccurenceUtils detect:NSParagraphStyleAttributeName
266
+ withInput:_input
267
+ inRange:range
268
+ withCondition:^BOOL(id _Nullable value, NSRange range) {
269
+ return [self styleCondition:value range:range];
270
+ }];
271
+ } else {
272
+ return [OccurenceUtils detect:NSParagraphStyleAttributeName
273
+ withInput:_input
274
+ atIndex:range.location
275
+ checkPrevious:YES
276
+ withCondition:^BOOL(id _Nullable value, NSRange range) {
277
+ return [self styleCondition:value range:range];
278
+ }];
279
+ }
280
+ }
281
+
282
+ - (BOOL)anyOccurence:(NSRange)range {
283
+ return [OccurenceUtils any:NSParagraphStyleAttributeName
284
+ withInput:_input
285
+ inRange:range
286
+ withCondition:^BOOL(id _Nullable value, NSRange range) {
287
+ return [self styleCondition:value range:range];
288
+ }];
289
+ }
290
+
291
+ - (NSArray<StylePair *> *_Nullable)findAllOccurences:(NSRange)range {
292
+ return [OccurenceUtils all:NSParagraphStyleAttributeName
293
+ withInput:_input
294
+ inRange:range
295
+ withCondition:^BOOL(id _Nullable value, NSRange range) {
296
+ return [self styleCondition:value range:range];
297
+ }];
298
+ }
299
+
300
+ - (BOOL)getCheckboxStateAt:(NSUInteger)location {
301
+ if (location >= _input->textView.textStorage.length) {
302
+ return NO;
303
+ }
304
+
305
+ NSParagraphStyle *style =
306
+ [_input->textView.textStorage attribute:NSParagraphStyleAttributeName
307
+ atIndex:location
308
+ effectiveRange:NULL];
309
+
310
+ if (style && style.textLists.count > 0) {
311
+ NSTextList *list = style.textLists.firstObject;
312
+
313
+ if ([list.markerFormat isEqualToString:@"{checkbox:1}"]) {
314
+ return YES;
315
+ }
316
+ }
317
+
318
+ return NO;
319
+ }
320
+
321
+ @end
@@ -177,7 +177,7 @@
177
177
  return NO;
178
178
  }
179
179
 
180
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
180
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
181
181
  NSParagraphStyle *paragraph = (NSParagraphStyle *)value;
182
182
  return paragraph != nullptr && paragraph.textLists.count == 1 &&
183
183
  [paragraph.textLists.firstObject.markerFormat
@@ -190,7 +190,7 @@
190
190
  withInput:_input
191
191
  inRange:range
192
192
  withCondition:^BOOL(id _Nullable value, NSRange range) {
193
- return [self styleCondition:value:range];
193
+ return [self styleCondition:value range:range];
194
194
  }];
195
195
  } else {
196
196
  return [OccurenceUtils detect:NSParagraphStyleAttributeName
@@ -198,7 +198,7 @@
198
198
  atIndex:range.location
199
199
  checkPrevious:YES
200
200
  withCondition:^BOOL(id _Nullable value, NSRange range) {
201
- return [self styleCondition:value:range];
201
+ return [self styleCondition:value range:range];
202
202
  }];
203
203
  }
204
204
  }
@@ -208,7 +208,7 @@
208
208
  withInput:_input
209
209
  inRange:range
210
210
  withCondition:^BOOL(id _Nullable value, NSRange range) {
211
- return [self styleCondition:value:range];
211
+ return [self styleCondition:value range:range];
212
212
  }];
213
213
  }
214
214
 
@@ -217,7 +217,7 @@
217
217
  withInput:_input
218
218
  inRange:range
219
219
  withCondition:^BOOL(id _Nullable value, NSRange range) {
220
- return [self styleCondition:value:range];
220
+ return [self styleCondition:value range:range];
221
221
  }];
222
222
  }
223
223
 
@@ -5,6 +5,9 @@
5
5
  + (StyleType)getStyleType {
6
6
  return H1;
7
7
  }
8
+ - (NSString *)getHeadingLevelString {
9
+ return @"H1";
10
+ }
8
11
  + (BOOL)isParagraphStyle {
9
12
  return YES;
10
13
  }
@@ -5,6 +5,9 @@
5
5
  + (StyleType)getStyleType {
6
6
  return H2;
7
7
  }
8
+ - (NSString *)getHeadingLevelString {
9
+ return @"H2";
10
+ }
8
11
  + (BOOL)isParagraphStyle {
9
12
  return YES;
10
13
  }
@@ -5,6 +5,9 @@
5
5
  + (StyleType)getStyleType {
6
6
  return H3;
7
7
  }
8
+ - (NSString *)getHeadingLevelString {
9
+ return @"H3";
10
+ }
8
11
  + (BOOL)isParagraphStyle {
9
12
  return YES;
10
13
  }
@@ -0,0 +1,20 @@
1
+ #import "EnrichedTextInputView.h"
2
+ #import "StyleHeaders.h"
3
+
4
+ @implementation H4Style
5
+ + (StyleType)getStyleType {
6
+ return H4;
7
+ }
8
+ - (NSString *)getHeadingLevelString {
9
+ return @"H4";
10
+ }
11
+ + (BOOL)isParagraphStyle {
12
+ return YES;
13
+ }
14
+ - (CGFloat)getHeadingFontSize {
15
+ return [((EnrichedTextInputView *)input)->config h4FontSize];
16
+ }
17
+ - (BOOL)isHeadingBold {
18
+ return [((EnrichedTextInputView *)input)->config h4Bold];
19
+ }
20
+ @end
@@ -0,0 +1,20 @@
1
+ #import "EnrichedTextInputView.h"
2
+ #import "StyleHeaders.h"
3
+
4
+ @implementation H5Style
5
+ + (StyleType)getStyleType {
6
+ return H5;
7
+ }
8
+ - (NSString *)getHeadingLevelString {
9
+ return @"H5";
10
+ }
11
+ + (BOOL)isParagraphStyle {
12
+ return YES;
13
+ }
14
+ - (CGFloat)getHeadingFontSize {
15
+ return [((EnrichedTextInputView *)input)->config h5FontSize];
16
+ }
17
+ - (BOOL)isHeadingBold {
18
+ return [((EnrichedTextInputView *)input)->config h5Bold];
19
+ }
20
+ @end
@@ -0,0 +1,20 @@
1
+ #import "EnrichedTextInputView.h"
2
+ #import "StyleHeaders.h"
3
+
4
+ @implementation H6Style
5
+ + (StyleType)getStyleType {
6
+ return H6;
7
+ }
8
+ - (NSString *)getHeadingLevelString {
9
+ return @"H6";
10
+ }
11
+ + (BOOL)isParagraphStyle {
12
+ return YES;
13
+ }
14
+ - (CGFloat)getHeadingFontSize {
15
+ return [((EnrichedTextInputView *)input)->config h6FontSize];
16
+ }
17
+ - (BOOL)isHeadingBold {
18
+ return [((EnrichedTextInputView *)input)->config h6Bold];
19
+ }
20
+ @end