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
@@ -23,6 +23,49 @@ static NSString *const AutomaticLinkAttributeName =
23
23
  return NO;
24
24
  }
25
25
 
26
+ + (NSRegularExpression *)fullRegex {
27
+ static NSRegularExpression *regex;
28
+ static dispatch_once_t onceToken;
29
+ dispatch_once(&onceToken, ^{
30
+ regex =
31
+ [NSRegularExpression regularExpressionWithPattern:
32
+ @"http(s)?:\\/\\/"
33
+ @"www\\.[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-"
34
+ @"z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
35
+ options:0
36
+ error:nullptr];
37
+ });
38
+ return regex;
39
+ }
40
+
41
+ + (NSRegularExpression *)wwwRegex {
42
+ static NSRegularExpression *regex;
43
+ static dispatch_once_t onceToken;
44
+ dispatch_once(&onceToken, ^{
45
+ regex =
46
+ [NSRegularExpression regularExpressionWithPattern:
47
+ @"www\\.[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-"
48
+ @"z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
49
+ options:0
50
+ error:nullptr];
51
+ });
52
+ return regex;
53
+ }
54
+
55
+ + (NSRegularExpression *)bareRegex {
56
+ static NSRegularExpression *regex;
57
+ static dispatch_once_t onceToken;
58
+ dispatch_once(&onceToken, ^{
59
+ regex =
60
+ [NSRegularExpression regularExpressionWithPattern:
61
+ @"[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-z]{2,"
62
+ @"6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
63
+ options:0
64
+ error:nullptr];
65
+ });
66
+ return regex;
67
+ }
68
+
26
69
  - (instancetype)initWithInput:(id)input {
27
70
  self = [super init];
28
71
  _input = (EnrichedTextInputView *)input;
@@ -121,7 +164,7 @@ static NSString *const AutomaticLinkAttributeName =
121
164
  _input->textView.typingAttributes = newTypingAttrs;
122
165
  }
123
166
 
124
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
167
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
125
168
  NSString *linkValue = (NSString *)value;
126
169
  return linkValue != nullptr;
127
170
  }
@@ -133,7 +176,7 @@ static NSString *const AutomaticLinkAttributeName =
133
176
  withInput:_input
134
177
  inRange:range
135
178
  withCondition:^BOOL(id _Nullable value, NSRange range) {
136
- return [self styleCondition:value:range];
179
+ return [self styleCondition:value range:range];
137
180
  }];
138
181
  return onlyLinks ? [self isSingleLinkIn:range] : NO;
139
182
  } else {
@@ -147,7 +190,7 @@ static NSString *const AutomaticLinkAttributeName =
147
190
  withInput:_input
148
191
  inRange:range
149
192
  withCondition:^BOOL(id _Nullable value, NSRange range) {
150
- return [self styleCondition:value:range];
193
+ return [self styleCondition:value range:range];
151
194
  }];
152
195
  }
153
196
 
@@ -157,7 +200,7 @@ static NSString *const AutomaticLinkAttributeName =
157
200
  withInput:_input
158
201
  inRange:range
159
202
  withCondition:^BOOL(id _Nullable value, NSRange range) {
160
- return [self styleCondition:value:range];
203
+ return [self styleCondition:value range:range];
161
204
  }];
162
205
  }
163
206
 
@@ -346,6 +389,13 @@ static NSString *const AutomaticLinkAttributeName =
346
389
 
347
390
  // handles detecting and removing automatic links
348
391
  - (void)handleAutomaticLinks:(NSString *)word inRange:(NSRange)wordRange {
392
+ LinkRegexConfig *linkRegexConfig = [_input->config linkRegexConfig];
393
+
394
+ // no automatic links with isDisabled
395
+ if (linkRegexConfig.isDisabled) {
396
+ return;
397
+ }
398
+
349
399
  InlineCodeStyle *inlineCodeStyle =
350
400
  [_input->stylesDict objectForKey:@([InlineCodeStyle getStyleType])];
351
401
  MentionStyle *mentionStyle =
@@ -392,42 +442,28 @@ static NSString *const AutomaticLinkAttributeName =
392
442
  return;
393
443
  }
394
444
 
395
- NSRegularExpression *fullRegex = [NSRegularExpression
396
- regularExpressionWithPattern:@"http(s)?:\\/\\/"
397
- @"www\\.[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-"
398
- @"z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
399
- options:0
400
- error:nullptr];
401
- NSRegularExpression *wwwRegex = [NSRegularExpression
402
- regularExpressionWithPattern:@"www\\.[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-"
403
- @"z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
404
- options:0
405
- error:nullptr];
406
- NSRegularExpression *bareRegex = [NSRegularExpression
407
- regularExpressionWithPattern:@"[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-z]{2,"
408
- @"6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
409
- options:0
410
- error:nullptr];
445
+ // all conditions are met; try matching the word to a proper regex
411
446
 
412
447
  NSString *regexPassedUrl = nullptr;
448
+ NSRange matchingRange = NSMakeRange(0, word.length);
413
449
 
414
- if ([fullRegex numberOfMatchesInString:word
415
- options:0
416
- range:NSMakeRange(0, word.length)]) {
417
- regexPassedUrl = word;
418
- } else if ([wwwRegex numberOfMatchesInString:word
419
- options:0
420
- range:NSMakeRange(0, word.length)]) {
421
- regexPassedUrl = word;
422
- } else if ([bareRegex numberOfMatchesInString:word
423
- options:0
424
- range:NSMakeRange(0, word.length)]) {
425
- regexPassedUrl = word;
426
- } else if ([self anyOccurence:wordRange]) {
427
- // there was some automatic link (because anyOccurence is true and we are
428
- // sure there are no manual links) still, it didn't pass any regex - needs
429
- // to be removed
430
- [self removeAttributes:wordRange];
450
+ if (linkRegexConfig.isDefault) {
451
+ // use default regex
452
+ regexPassedUrl = [self tryMatchingDefaultLinkRegex:word
453
+ matchRange:matchingRange];
454
+ } else {
455
+ // use user defined regex if it exists
456
+ NSRegularExpression *userRegex = [_input->config parsedLinkRegex];
457
+
458
+ if (userRegex == nullptr) {
459
+ // fallback to default regex
460
+ regexPassedUrl = [self tryMatchingDefaultLinkRegex:word
461
+ matchRange:matchingRange];
462
+ } else if ([userRegex numberOfMatchesInString:word
463
+ options:0
464
+ range:matchingRange]) {
465
+ regexPassedUrl = word;
466
+ }
431
467
  }
432
468
 
433
469
  if (regexPassedUrl != nullptr) {
@@ -449,7 +485,29 @@ static NSString *const AutomaticLinkAttributeName =
449
485
  // emit onLinkDetected if style was added
450
486
  [_input emitOnLinkDetectedEvent:word url:regexPassedUrl range:wordRange];
451
487
  }
488
+ } else if ([self anyOccurence:wordRange]) {
489
+ // there was some automatic link (because anyOccurence is true and we are
490
+ // sure there are no manual links) still, it didn't pass any regex - needs
491
+ // to be removed
492
+ [self removeAttributes:wordRange];
493
+ }
494
+ }
495
+
496
+ - (NSString *)tryMatchingDefaultLinkRegex:(NSString *)word
497
+ matchRange:(NSRange)range {
498
+ if ([[LinkStyle fullRegex] numberOfMatchesInString:word
499
+ options:0
500
+ range:range] ||
501
+ [[LinkStyle wwwRegex] numberOfMatchesInString:word
502
+ options:0
503
+ range:range] ||
504
+ [[LinkStyle bareRegex] numberOfMatchesInString:word
505
+ options:0
506
+ range:range]) {
507
+ return word;
452
508
  }
509
+
510
+ return nullptr;
453
511
  }
454
512
 
455
513
  // handles refreshing manual links
@@ -556,14 +614,14 @@ static NSString *const AutomaticLinkAttributeName =
556
614
  withInput:_input
557
615
  inRange:wordRange
558
616
  withCondition:^BOOL(id _Nullable value, NSRange range) {
559
- return [self styleCondition:value:range];
617
+ return [self styleCondition:value range:range];
560
618
  }];
561
619
  BOOL anyManual =
562
620
  [OccurenceUtils any:ManualLinkAttributeName
563
621
  withInput:_input
564
622
  inRange:wordRange
565
623
  withCondition:^BOOL(id _Nullable value, NSRange range) {
566
- return [self styleCondition:value:range];
624
+ return [self styleCondition:value range:range];
567
625
  }];
568
626
 
569
627
  // both manual and automatic links are somewhere - delete!
@@ -579,7 +637,7 @@ static NSString *const AutomaticLinkAttributeName =
579
637
  withInput:_input
580
638
  inRange:wordRange
581
639
  withCondition:^BOOL(id _Nullable value, NSRange range) {
582
- return [self styleCondition:value:range];
640
+ return [self styleCondition:value range:range];
583
641
  }];
584
642
 
585
643
  // only one link might be present!
@@ -136,7 +136,7 @@ static NSString *const MentionAttributeName = @"MentionAttributeName";
136
136
  _input->textView.typingAttributes = newTypingAttrs;
137
137
  }
138
138
 
139
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
139
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
140
140
  MentionParams *params = (MentionParams *)value;
141
141
  return params != nullptr;
142
142
  }
@@ -147,7 +147,7 @@ static NSString *const MentionAttributeName = @"MentionAttributeName";
147
147
  withInput:_input
148
148
  inRange:range
149
149
  withCondition:^BOOL(id _Nullable value, NSRange range) {
150
- return [self styleCondition:value:range];
150
+ return [self styleCondition:value range:range];
151
151
  }];
152
152
  } else {
153
153
  return [self getMentionParamsAt:range.location] != nullptr;
@@ -159,7 +159,7 @@ static NSString *const MentionAttributeName = @"MentionAttributeName";
159
159
  withInput:_input
160
160
  inRange:range
161
161
  withCondition:^BOOL(id _Nullable value, NSRange range) {
162
- return [self styleCondition:value:range];
162
+ return [self styleCondition:value range:range];
163
163
  }];
164
164
  }
165
165
 
@@ -168,7 +168,7 @@ static NSString *const MentionAttributeName = @"MentionAttributeName";
168
168
  withInput:_input
169
169
  inRange:range
170
170
  withCondition:^BOOL(id _Nullable value, NSRange range) {
171
- return [self styleCondition:value:range];
171
+ return [self styleCondition:value range:range];
172
172
  }];
173
173
  }
174
174
 
@@ -235,7 +235,7 @@
235
235
  return NO;
236
236
  }
237
237
 
238
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
238
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
239
239
  NSParagraphStyle *paragraph = (NSParagraphStyle *)value;
240
240
  return paragraph != nullptr && paragraph.textLists.count == 1 &&
241
241
  paragraph.textLists.firstObject.markerFormat ==
@@ -248,7 +248,7 @@
248
248
  withInput:_input
249
249
  inRange:range
250
250
  withCondition:^BOOL(id _Nullable value, NSRange range) {
251
- return [self styleCondition:value:range];
251
+ return [self styleCondition:value range:range];
252
252
  }];
253
253
  } else {
254
254
  return [OccurenceUtils detect:NSParagraphStyleAttributeName
@@ -256,7 +256,7 @@
256
256
  atIndex:range.location
257
257
  checkPrevious:YES
258
258
  withCondition:^BOOL(id _Nullable value, NSRange range) {
259
- return [self styleCondition:value:range];
259
+ return [self styleCondition:value range:range];
260
260
  }];
261
261
  }
262
262
  }
@@ -266,7 +266,7 @@
266
266
  withInput:_input
267
267
  inRange:range
268
268
  withCondition:^BOOL(id _Nullable value, NSRange range) {
269
- return [self styleCondition:value:range];
269
+ return [self styleCondition:value range:range];
270
270
  }];
271
271
  }
272
272
 
@@ -275,7 +275,7 @@
275
275
  withInput:_input
276
276
  inRange:range
277
277
  withCondition:^BOOL(id _Nullable value, NSRange range) {
278
- return [self styleCondition:value:range];
278
+ return [self styleCondition:value range:range];
279
279
  }];
280
280
  }
281
281
 
@@ -56,7 +56,7 @@
56
56
  _input->textView.typingAttributes = newTypingAttrs;
57
57
  }
58
58
 
59
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
59
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
60
60
  NSNumber *strikethroughStyle = (NSNumber *)value;
61
61
  return strikethroughStyle != nullptr &&
62
62
  [strikethroughStyle intValue] != NSUnderlineStyleNone;
@@ -68,7 +68,7 @@
68
68
  withInput:_input
69
69
  inRange:range
70
70
  withCondition:^BOOL(id _Nullable value, NSRange range) {
71
- return [self styleCondition:value:range];
71
+ return [self styleCondition:value range:range];
72
72
  }];
73
73
  } else {
74
74
  return [OccurenceUtils detect:NSStrikethroughStyleAttributeName
@@ -76,7 +76,7 @@
76
76
  atIndex:range.location
77
77
  checkPrevious:NO
78
78
  withCondition:^BOOL(id _Nullable value, NSRange range) {
79
- return [self styleCondition:value:range];
79
+ return [self styleCondition:value range:range];
80
80
  }];
81
81
  }
82
82
  }
@@ -86,7 +86,7 @@
86
86
  withInput:_input
87
87
  inRange:range
88
88
  withCondition:^BOOL(id _Nullable value, NSRange range) {
89
- return [self styleCondition:value:range];
89
+ return [self styleCondition:value range:range];
90
90
  }];
91
91
  }
92
92
 
@@ -95,7 +95,7 @@
95
95
  withInput:_input
96
96
  inRange:range
97
97
  withCondition:^BOOL(id _Nullable value, NSRange range) {
98
- return [self styleCondition:value:range];
98
+ return [self styleCondition:value range:range];
99
99
  }];
100
100
  }
101
101
 
@@ -91,7 +91,7 @@
91
91
  return conflicted;
92
92
  }
93
93
 
94
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
94
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
95
95
  NSNumber *underlineStyle = (NSNumber *)value;
96
96
  return underlineStyle != nullptr &&
97
97
  [underlineStyle intValue] != NSUnderlineStyleNone &&
@@ -105,7 +105,7 @@
105
105
  withInput:_input
106
106
  inRange:range
107
107
  withCondition:^BOOL(id _Nullable value, NSRange range) {
108
- return [self styleCondition:value:range];
108
+ return [self styleCondition:value range:range];
109
109
  }];
110
110
  } else {
111
111
  return [OccurenceUtils detect:NSUnderlineStyleAttributeName
@@ -113,7 +113,7 @@
113
113
  atIndex:range.location
114
114
  checkPrevious:NO
115
115
  withCondition:^BOOL(id _Nullable value, NSRange range) {
116
- return [self styleCondition:value:range];
116
+ return [self styleCondition:value range:range];
117
117
  }];
118
118
  }
119
119
  }
@@ -123,7 +123,7 @@
123
123
  withInput:_input
124
124
  inRange:range
125
125
  withCondition:^BOOL(id _Nullable value, NSRange range) {
126
- return [self styleCondition:value:range];
126
+ return [self styleCondition:value range:range];
127
127
  }];
128
128
  }
129
129
 
@@ -132,7 +132,7 @@
132
132
  withInput:_input
133
133
  inRange:range
134
134
  withCondition:^BOOL(id _Nullable value, NSRange range) {
135
- return [self styleCondition:value:range];
135
+ return [self styleCondition:value range:range];
136
136
  }];
137
137
  }
138
138
 
@@ -234,7 +234,7 @@
234
234
  return NO;
235
235
  }
236
236
 
237
- - (BOOL)styleCondition:(id _Nullable)value:(NSRange)range {
237
+ - (BOOL)styleCondition:(id _Nullable)value range:(NSRange)range {
238
238
  NSParagraphStyle *paragraph = (NSParagraphStyle *)value;
239
239
  return paragraph != nullptr && paragraph.textLists.count == 1 &&
240
240
  paragraph.textLists.firstObject.markerFormat == NSTextListMarkerDisc;
@@ -246,7 +246,7 @@
246
246
  withInput:_input
247
247
  inRange:range
248
248
  withCondition:^BOOL(id _Nullable value, NSRange range) {
249
- return [self styleCondition:value:range];
249
+ return [self styleCondition:value range:range];
250
250
  }];
251
251
  } else {
252
252
  return [OccurenceUtils detect:NSParagraphStyleAttributeName
@@ -254,7 +254,7 @@
254
254
  atIndex:range.location
255
255
  checkPrevious:YES
256
256
  withCondition:^BOOL(id _Nullable value, NSRange range) {
257
- return [self styleCondition:value:range];
257
+ return [self styleCondition:value range:range];
258
258
  }];
259
259
  }
260
260
  }
@@ -264,7 +264,7 @@
264
264
  withInput:_input
265
265
  inRange:range
266
266
  withCondition:^BOOL(id _Nullable value, NSRange range) {
267
- return [self styleCondition:value:range];
267
+ return [self styleCondition:value range:range];
268
268
  }];
269
269
  }
270
270
 
@@ -273,7 +273,7 @@
273
273
  withInput:_input
274
274
  inRange:range
275
275
  withCondition:^BOOL(id _Nullable value, NSRange range) {
276
- return [self styleCondition:value:range];
276
+ return [self styleCondition:value range:range];
277
277
  }];
278
278
  }
279
279
 
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ @class EnrichedTextInputView;
4
+
5
+ @interface CheckboxHitTestUtils : NSObject
6
+
7
+ + (NSInteger)hitTestCheckboxAtPoint:(CGPoint)pt
8
+ inInput:(EnrichedTextInputView *)input;
9
+
10
+ @end
@@ -0,0 +1,123 @@
1
+ #import "CheckboxHitTestUtils.h"
2
+ #import "EnrichedTextInputView.h"
3
+ #import "InputConfig.h"
4
+ #import "StyleHeaders.h"
5
+
6
+ static const CGFloat kCheckboxHitSlopLeft = 8.0;
7
+ static const CGFloat kCheckboxHitSlopVertical = 6.0;
8
+
9
+ @implementation CheckboxHitTestUtils
10
+
11
+ // MARK: - Coordinate helpers
12
+
13
+ + (CGPoint)containerPointFromViewPoint:(CGPoint)point
14
+ textView:(UITextView *)textView {
15
+ return CGPointMake(point.x - textView.textContainerInset.left,
16
+ point.y - textView.textContainerInset.top);
17
+ }
18
+
19
+ // MARK: - Glyph lookup
20
+
21
+ + (NSUInteger)glyphIndexAtContainerPoint:(CGPoint)point
22
+ textView:(UITextView *)textView {
23
+ return [textView.layoutManager glyphIndexForPoint:point
24
+ inTextContainer:textView.textContainer
25
+ fractionOfDistanceThroughGlyph:nil];
26
+ }
27
+
28
+ // MARK: - Checkbox detection
29
+
30
+ + (BOOL)isCheckboxGlyph:(NSUInteger)glyphIndex
31
+ inInput:(EnrichedTextInputView *)input {
32
+ UITextView *textView = input->textView;
33
+ NSLayoutManager *layoutManager = textView.layoutManager;
34
+ NSTextStorage *storage = textView.textStorage;
35
+
36
+ NSUInteger charIndex =
37
+ [layoutManager characterIndexForGlyphAtIndex:glyphIndex];
38
+
39
+ if (charIndex >= storage.length) {
40
+ return NO;
41
+ }
42
+
43
+ CheckboxListStyle *checkboxListStyle =
44
+ (CheckboxListStyle *)
45
+ input->stylesDict[@([CheckboxListStyle getStyleType])];
46
+
47
+ if (!checkboxListStyle) {
48
+ return NO;
49
+ }
50
+
51
+ return [checkboxListStyle detectStyle:NSMakeRange(charIndex, 0)];
52
+ }
53
+
54
+ // MARK: - Checkbox rect
55
+
56
+ + (CGRect)checkboxRectForGlyphIndex:(NSUInteger)glyphIndex
57
+ inInput:(EnrichedTextInputView *)input {
58
+ UITextView *textView = input->textView;
59
+ NSLayoutManager *layoutManager = textView.layoutManager;
60
+ InputConfig *config = input->config;
61
+
62
+ if (!config) {
63
+ return CGRectNull;
64
+ }
65
+
66
+ CGRect lineRect = [layoutManager lineFragmentRectForGlyphAtIndex:glyphIndex
67
+ effectiveRange:nil];
68
+
69
+ CGFloat originX = lineRect.origin.x + config.checkboxListMarginLeft;
70
+
71
+ CGFloat originY = lineRect.origin.y +
72
+ (lineRect.size.height - config.checkboxListBoxSize) / 2.0;
73
+
74
+ return CGRectMake(originX, originY, config.checkboxListBoxSize,
75
+ config.checkboxListBoxSize);
76
+ }
77
+
78
+ // MARK: - Hit rect
79
+
80
+ + (CGRect)expandedHitRectFromCheckboxRect:(CGRect)rect {
81
+ if (CGRectIsNull(rect))
82
+ return rect;
83
+
84
+ return CGRectInset(rect, -kCheckboxHitSlopLeft, -kCheckboxHitSlopVertical);
85
+ }
86
+
87
+ // MARK: - Public API
88
+
89
+ + (NSInteger)hitTestCheckboxAtPoint:(CGPoint)point
90
+ inInput:(EnrichedTextInputView *)input {
91
+ UITextView *textView = input->textView;
92
+
93
+ CGPoint containerPoint = [self containerPointFromViewPoint:point
94
+ textView:textView];
95
+
96
+ NSUInteger glyphIndex = [self glyphIndexAtContainerPoint:containerPoint
97
+ textView:textView];
98
+
99
+ if (glyphIndex == NSNotFound) {
100
+ return -1;
101
+ }
102
+
103
+ if (![self isCheckboxGlyph:glyphIndex inInput:input]) {
104
+ return -1;
105
+ }
106
+
107
+ CGRect checkboxRect = [self checkboxRectForGlyphIndex:glyphIndex
108
+ inInput:input];
109
+
110
+ if (CGRectIsNull(checkboxRect)) {
111
+ return -1;
112
+ }
113
+
114
+ CGRect hitRect = [self expandedHitRectFromCheckboxRect:checkboxRect];
115
+
116
+ if (!CGRectContainsPoint(hitRect, containerPoint)) {
117
+ return -1;
118
+ }
119
+
120
+ return [textView.layoutManager characterIndexForGlyphAtIndex:glyphIndex];
121
+ }
122
+
123
+ @end
@@ -8,4 +8,8 @@
8
8
  + (BOOL)handleParagraphStylesMergeOnBackspace:(NSRange)range
9
9
  replacementText:(NSString *)text
10
10
  input:(id)input;
11
+ + (BOOL)handleResetTypingAttributesOnBackspace:(NSRange)range
12
+ replacementText:(NSString *)text
13
+ input:(id)input;
14
+ + (BOOL)isParagraphEmpty:(NSRange)range inString:(NSString *)string;
11
15
  @end