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
@@ -55,6 +55,67 @@
55
55
  NSArray<NSString *> *pasteboardTypes = pasteboard.pasteboardTypes;
56
56
  NSRange currentRange = typedInput->textView.selectedRange;
57
57
 
58
+ // Check the pasteboard for supported image formats. If found, save them to
59
+ // temporary storage then emit the 'onPasteImages' event and stop processing
60
+ // further (ignoring any HTML/Text).
61
+ NSMutableArray<NSDictionary *> *foundImages = [NSMutableArray new];
62
+
63
+ for (NSDictionary<NSString *, id> *item in pasteboard.items) {
64
+ NSData *imageData = nil;
65
+ BOOL added = NO;
66
+ NSString *ext = nil;
67
+ NSString *mimeType = nil;
68
+
69
+ for (int j = 0; j < item.allKeys.count; j++) {
70
+ if (added) {
71
+ break;
72
+ }
73
+
74
+ NSString *type = item.allKeys[j];
75
+ if ([type isEqual:UTTypeJPEG.identifier] ||
76
+ [type isEqual:UTTypePNG.identifier] ||
77
+ [type isEqual:UTTypeWebP.identifier] ||
78
+ [type isEqual:UTTypeHEIC.identifier] ||
79
+ [type isEqual:UTTypeTIFF.identifier]) {
80
+ imageData = [self getDataForImageItem:item[type] type:type];
81
+ } else if ([type isEqual:UTTypeGIF.identifier]) {
82
+ // gifs
83
+ imageData = [pasteboard dataForPasteboardType:type];
84
+ }
85
+ if (!imageData) {
86
+ continue;
87
+ }
88
+
89
+ NSDictionary *info = [self detectImageFormat:type];
90
+ if (!info) {
91
+ continue;
92
+ }
93
+ ext = info[@"ext"];
94
+ mimeType = info[@"mime"];
95
+
96
+ UIImage *imageInfo = [UIImage imageWithData:imageData];
97
+
98
+ if (imageInfo) {
99
+ NSString *path = [self saveToTempFile:imageData extension:ext];
100
+
101
+ if (path) {
102
+ added = YES;
103
+ [foundImages addObject:@{
104
+ @"uri" : path,
105
+ @"type" : mimeType,
106
+ @"width" : @(imageInfo.size.width),
107
+ @"height" : @(imageInfo.size.height)
108
+ }];
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ if (foundImages.count > 0) {
115
+ [typedInput emitOnPasteImagesEvent:foundImages];
116
+ return;
117
+ }
118
+
58
119
  if ([pasteboardTypes containsObject:UTTypeHTML.identifier]) {
59
120
  // we try processing the html contents
60
121
 
@@ -94,6 +155,52 @@
94
155
  [typedInput anyTextMayHaveBeenModified];
95
156
  }
96
157
 
158
+ - (NSDictionary *)detectImageFormat:(NSString *)type {
159
+ if ([type isEqual:UTTypeJPEG.identifier]) {
160
+ return @{@"ext" : @"jpg", @"mime" : @"image/jpeg"};
161
+ } else if ([type isEqual:UTTypePNG.identifier]) {
162
+ return @{@"ext" : @"png", @"mime" : @"image/png"};
163
+ } else if ([type isEqual:UTTypeGIF.identifier]) {
164
+ return @{@"ext" : @"gif", @"mime" : @"image/gif"};
165
+ } else if ([type isEqual:UTTypeHEIC.identifier]) {
166
+ return @{@"ext" : @"heic", @"mime" : @"image/heic"};
167
+ } else if ([type isEqual:UTTypeWebP.identifier]) {
168
+ return @{@"ext" : @"webp", @"mime" : @"image/webp"};
169
+ } else if ([type isEqual:UTTypeTIFF.identifier]) {
170
+ return @{@"ext" : @"tiff", @"mime" : @"image/tiff"};
171
+ } else {
172
+ return nil;
173
+ }
174
+ }
175
+
176
+ - (NSData *)getDataForImageItem:(NSData *)imageData type:(NSString *)type {
177
+ UIImage *image = (UIImage *)imageData;
178
+
179
+ if ([type isEqual:UTTypePNG.identifier]) {
180
+ return UIImagePNGRepresentation(image);
181
+ } else if ([type isEqual:UTTypeHEIC.identifier]) {
182
+ return UIImageHEICRepresentation(image);
183
+ } else {
184
+ return UIImageJPEGRepresentation(image, 1.0);
185
+ }
186
+ }
187
+
188
+ - (NSString *)saveToTempFile:(NSData *)data extension:(NSString *)ext {
189
+ if (!data)
190
+ return nil;
191
+ NSString *fileName =
192
+ [NSString stringWithFormat:@"%@.%@", [NSUUID UUID].UUIDString, ext];
193
+
194
+ NSString *filePath =
195
+ [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
196
+
197
+ if ([data writeToFile:filePath atomically:YES]) {
198
+ return [NSURL fileURLWithPath:filePath].absoluteString;
199
+ }
200
+
201
+ return nil;
202
+ }
203
+
97
204
  - (void)tryHandlingPlainTextItemsIn:(UIPasteboard *)pasteboard
98
205
  range:(NSRange)range
99
206
  input:(EnrichedTextInputView *)input {
@@ -153,4 +260,15 @@
153
260
  [typedInput anyTextMayHaveBeenModified];
154
261
  }
155
262
 
263
+ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
264
+ if (action == @selector(paste:)) {
265
+ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
266
+ // Enable Paste if clipboard has Text OR Images
267
+ if (pasteboard.hasStrings || pasteboard.hasImages) {
268
+ return YES;
269
+ }
270
+ }
271
+ return [super canPerformAction:action withSender:sender];
272
+ }
273
+
156
274
  @end
@@ -4,6 +4,7 @@
4
4
  @interface ImageAttachment : MediaAttachment
5
5
 
6
6
  @property(nonatomic, strong) ImageData *imageData;
7
+ @property(nonatomic, strong) UIImage *storedAnimatedImage;
7
8
 
8
9
  - (instancetype)initWithImageData:(ImageData *)data;
9
10
 
@@ -0,0 +1,46 @@
1
+ #import "ImageAttachment.h"
2
+ #import "ImageExtension.h"
3
+
4
+ @implementation ImageAttachment
5
+
6
+ - (instancetype)initWithImageData:(ImageData *)data {
7
+ self = [super initWithURI:data.uri width:data.width height:data.height];
8
+ if (!self)
9
+ return nil;
10
+
11
+ _imageData = data;
12
+
13
+ // Assign an empty image to reserve layout space within the text system.
14
+ // The actual image is not drawn here; it is rendered and overlaid by a
15
+ // separate ImageView.
16
+ self.image = [UIImage new];
17
+
18
+ [self loadAsync];
19
+ return self;
20
+ }
21
+
22
+ - (void)loadAsync {
23
+ NSURL *url = [NSURL URLWithString:self.uri];
24
+ if (!url) {
25
+ self.storedAnimatedImage = [UIImage systemImageNamed:@"photo"];
26
+ return;
27
+ }
28
+
29
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
30
+ NSData *bytes = [NSData dataWithContentsOfURL:url];
31
+
32
+ // We pass all image data (including static formats like PNG or JPEG)
33
+ // through the GIF parser. It safely acts as a universal parser, returning
34
+ // a single-frame UIImage for static formats and an animated UIImage for
35
+ // GIFs.
36
+ UIImage *img = bytes ? [UIImage animatedImageWithAnimatedGIFData:bytes]
37
+ : [UIImage systemImageNamed:@"photo"];
38
+
39
+ dispatch_async(dispatch_get_main_queue(), ^{
40
+ self.storedAnimatedImage = img;
41
+ [self notifyUpdate];
42
+ });
43
+ });
44
+ }
45
+
46
+ @end
@@ -0,0 +1,19 @@
1
+ #pragma once
2
+ #import <ReactNativeEnriched/Props.h>
3
+ #import <UIKit/UIKit.h>
4
+
5
+ using namespace facebook::react;
6
+
7
+ @interface LinkRegexConfig : NSObject
8
+
9
+ @property NSString *pattern;
10
+ @property BOOL caseInsensitive;
11
+ @property BOOL dotAll;
12
+ @property BOOL isDisabled;
13
+ @property BOOL isDefault;
14
+
15
+ - (instancetype)initWithLinkRegexProp:
16
+ (EnrichedTextInputViewLinkRegexStruct)prop;
17
+ - (BOOL)isEqualToConfig:(LinkRegexConfig *)otherObj;
18
+
19
+ @end
@@ -0,0 +1,37 @@
1
+ #import "LinkRegexConfig.h"
2
+ #import "StringExtension.h"
3
+
4
+ @implementation LinkRegexConfig
5
+
6
+ - (instancetype)initWithLinkRegexProp:
7
+ (EnrichedTextInputViewLinkRegexStruct)prop {
8
+ if (!self)
9
+ return nil;
10
+
11
+ _pattern = [NSString fromCppString:prop.pattern];
12
+ _caseInsensitive = prop.caseInsensitive;
13
+ _dotAll = prop.dotAll;
14
+ _isDefault = prop.isDefault;
15
+ _isDisabled = prop.isDisabled;
16
+
17
+ return self;
18
+ }
19
+
20
+ - (id)copyWithZone:(NSZone *)zone {
21
+ LinkRegexConfig *copy = [[[self class] allocWithZone:zone] init];
22
+ copy->_pattern = [_pattern copy];
23
+ copy->_caseInsensitive = _caseInsensitive;
24
+ copy->_dotAll = _dotAll;
25
+ copy->_isDefault = _isDefault;
26
+ copy->_isDisabled = _isDisabled;
27
+ return copy;
28
+ }
29
+
30
+ - (BOOL)isEqualToConfig:(LinkRegexConfig *)otherObj {
31
+ return [_pattern isEqualToString:otherObj.pattern] &&
32
+ _caseInsensitive == otherObj.caseInsensitive &&
33
+ _dotAll == otherObj.dotAll && _isDefault == otherObj.isDefault &&
34
+ _isDisabled == otherObj.isDisabled;
35
+ }
36
+
37
+ @end
@@ -10,7 +10,7 @@
10
10
 
11
11
  if (folly["color"].isNumber()) {
12
12
  facebook::react::SharedColor color = facebook::react::SharedColor(
13
- facebook::react::Color(folly["color"].asInt()));
13
+ facebook::react::Color(int32_t(folly["color"].asInt())));
14
14
  nativeProps.color = RCTUIColorFromSharedColor(color);
15
15
  } else {
16
16
  nativeProps.color = [UIColor blueColor];
@@ -18,7 +18,7 @@
18
18
 
19
19
  if (folly["backgroundColor"].isNumber()) {
20
20
  facebook::react::SharedColor bgColor = facebook::react::SharedColor(
21
- facebook::react::Color(folly["backgroundColor"].asInt()));
21
+ facebook::react::Color(int32_t(folly["backgroundColor"].asInt())));
22
22
  nativeProps.backgroundColor = RCTUIColorFromSharedColor(bgColor);
23
23
  } else {
24
24
  nativeProps.backgroundColor = [UIColor yellowColor];
@@ -55,9 +55,10 @@
55
55
  id input;
56
56
  }
57
57
  - (CGFloat)getHeadingFontSize;
58
+ - (NSString *)getHeadingLevelString;
58
59
  - (BOOL)isHeadingBold;
59
60
  - (BOOL)handleNewlinesInRange:(NSRange)range replacementText:(NSString *)text;
60
- - (void)handleImproperHeadings;
61
+ - (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text;
61
62
  @end
62
63
 
63
64
  @interface H1Style : HeadingStyleBase
@@ -69,6 +70,15 @@
69
70
  @interface H3Style : HeadingStyleBase
70
71
  @end
71
72
 
73
+ @interface H4Style : HeadingStyleBase
74
+ @end
75
+
76
+ @interface H5Style : HeadingStyleBase
77
+ @end
78
+
79
+ @interface H6Style : HeadingStyleBase
80
+ @end
81
+
72
82
  @interface UnorderedListStyle : NSObject <BaseStyleProtocol>
73
83
  - (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text;
74
84
  - (BOOL)tryHandlingListShorcutInRange:(NSRange)range
@@ -81,6 +91,17 @@
81
91
  replacementText:(NSString *)text;
82
92
  @end
83
93
 
94
+ @interface CheckboxListStyle : NSObject <BaseStyleProtocol>
95
+ - (void)applyStyleWithCheckedValue:(BOOL)checked inRange:(NSRange)range;
96
+ - (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text;
97
+ - (BOOL)getCheckboxStateAt:(NSUInteger)location;
98
+ - (void)toggleCheckedAt:(NSUInteger)location;
99
+ - (BOOL)handleNewlinesInRange:(NSRange)range replacementText:(NSString *)text;
100
+ - (void)addAttributesWithCheckedValue:(BOOL)checked
101
+ inRange:(NSRange)range
102
+ withTypingAttr:(BOOL)withTypingAttr;
103
+ @end
104
+
84
105
  @interface BlockQuoteStyle : NSObject <BaseStyleProtocol>
85
106
  - (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text;
86
107
  - (void)manageBlockquoteColor;
@@ -7,9 +7,13 @@ typedef NS_ENUM(NSInteger, StyleType) {
7
7
  CodeBlock,
8
8
  UnorderedList,
9
9
  OrderedList,
10
+ CheckboxList,
10
11
  H1,
11
12
  H2,
12
13
  H3,
14
+ H4,
15
+ H5,
16
+ H6,
13
17
  Link,
14
18
  Mention,
15
19
  Image,
@@ -1,10 +1,10 @@
1
1
  #include "EnrichedTextInputViewState.h"
2
2
 
3
3
  namespace facebook::react {
4
- int EnrichedTextInputViewState::getForceHeightRecalculationCounter() const {
5
- return forceHeightRecalculationCounter_;
6
- }
7
- std::shared_ptr<void> EnrichedTextInputViewState::getComponentViewRef() const {
8
- return componentViewRef_;
9
- }
4
+ int EnrichedTextInputViewState::getForceHeightRecalculationCounter() const {
5
+ return forceHeightRecalculationCounter_;
6
+ }
7
+ std::shared_ptr<void> EnrichedTextInputViewState::getComponentViewRef() const {
8
+ return componentViewRef_;
9
+ }
10
10
  } // namespace facebook::react
@@ -186,7 +186,7 @@
186
186
  return NO;
187
187
  }
188
188
 
189
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
189
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
190
190
  NSParagraphStyle *pStyle = (NSParagraphStyle *)value;
191
191
  return pStyle != nullptr && pStyle.headIndent == [self getHeadIndent] &&
192
192
  pStyle.firstLineHeadIndent == [self getHeadIndent] &&
@@ -199,7 +199,7 @@
199
199
  withInput:_input
200
200
  inRange:range
201
201
  withCondition:^BOOL(id _Nullable value, NSRange range) {
202
- return [self styleCondition:value:range];
202
+ return [self styleCondition:value range:range];
203
203
  }];
204
204
  } else {
205
205
  return [OccurenceUtils detect:NSParagraphStyleAttributeName
@@ -207,7 +207,7 @@
207
207
  atIndex:range.location
208
208
  checkPrevious:YES
209
209
  withCondition:^BOOL(id _Nullable value, NSRange range) {
210
- return [self styleCondition:value:range];
210
+ return [self styleCondition:value range:range];
211
211
  }];
212
212
  }
213
213
  }
@@ -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
 
@@ -226,7 +226,7 @@
226
226
  withInput:_input
227
227
  inRange:range
228
228
  withCondition:^BOOL(id _Nullable value, NSRange range) {
229
- return [self styleCondition:value:range];
229
+ return [self styleCondition:value range:range];
230
230
  }];
231
231
  }
232
232
 
@@ -104,6 +104,18 @@
104
104
  if (![_input->config h3Bold]) {
105
105
  return NO;
106
106
  }
107
+ } else if (type == H4) {
108
+ if (![_input->config h4Bold]) {
109
+ return NO;
110
+ }
111
+ } else if (type == H5) {
112
+ if (![_input->config h5Bold]) {
113
+ return NO;
114
+ }
115
+ } else if (type == H6) {
116
+ if (![_input->config h6Bold]) {
117
+ return NO;
118
+ }
107
119
  }
108
120
 
109
121
  id<BaseStyleProtocol> headingStyle = _input->stylesDict[@(type)];
@@ -111,12 +123,15 @@
111
123
  : [headingStyle detectStyle:range];
112
124
  }
113
125
 
114
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
126
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
115
127
  UIFont *font = (UIFont *)value;
116
128
  return font != nullptr && [font isBold] &&
117
129
  ![self boldHeadingConflictsInRange:range type:H1] &&
118
130
  ![self boldHeadingConflictsInRange:range type:H2] &&
119
- ![self boldHeadingConflictsInRange:range type:H3];
131
+ ![self boldHeadingConflictsInRange:range type:H3] &&
132
+ ![self boldHeadingConflictsInRange:range type:H4] &&
133
+ ![self boldHeadingConflictsInRange:range type:H5] &&
134
+ ![self boldHeadingConflictsInRange:range type:H6];
120
135
  }
121
136
 
122
137
  - (BOOL)detectStyle:(NSRange)range {
@@ -125,7 +140,7 @@
125
140
  withInput:_input
126
141
  inRange:range
127
142
  withCondition:^BOOL(id _Nullable value, NSRange range) {
128
- return [self styleCondition:value:range];
143
+ return [self styleCondition:value range:range];
129
144
  }];
130
145
  } else {
131
146
  return [OccurenceUtils detect:NSFontAttributeName
@@ -133,7 +148,7 @@
133
148
  atIndex:range.location
134
149
  checkPrevious:NO
135
150
  withCondition:^BOOL(id _Nullable value, NSRange range) {
136
- return [self styleCondition:value:range];
151
+ return [self styleCondition:value range:range];
137
152
  }];
138
153
  }
139
154
  }
@@ -143,7 +158,7 @@
143
158
  withInput:_input
144
159
  inRange:range
145
160
  withCondition:^BOOL(id _Nullable value, NSRange range) {
146
- return [self styleCondition:value:range];
161
+ return [self styleCondition:value range:range];
147
162
  }];
148
163
  }
149
164
 
@@ -152,7 +167,7 @@
152
167
  withInput:_input
153
168
  inRange:range
154
169
  withCondition:^BOOL(id _Nullable value, NSRange range) {
155
- return [self styleCondition:value:range];
170
+ return [self styleCondition:value range:range];
156
171
  }];
157
172
  }
158
173