@apollohg/react-native-rich-text-editor 2.0.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.
- package/LICENSE +160 -0
- package/README.md +259 -0
- package/RUST-STANDARD-LIBRARY-NOTICES.html +8266 -0
- package/ReactNativeProseEditor.podspec +59 -0
- package/THIRD_PARTY_NOTICES.md +31155 -0
- package/android/build.gradle +188 -0
- package/android/consumer-rules.pro +18 -0
- package/android/expo/build.gradle +17 -0
- package/android/src/debug/java/com/apollohg/editor/viewer/PreparedProseDrawInstrumentation.kt +7 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.json +2236 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.ttf +0 -0
- package/android/src/main/java/com/apollohg/editor/AndroidApiCompat.kt +19 -0
- package/android/src/main/java/com/apollohg/editor/AndroidCollaborationTransport.kt +860 -0
- package/android/src/main/java/com/apollohg/editor/CaretGeometry.kt +91 -0
- package/android/src/main/java/com/apollohg/editor/CodeHighlighting.kt +141 -0
- package/android/src/main/java/com/apollohg/editor/DecodedBitmapBudget.kt +250 -0
- package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +133 -0
- package/android/src/main/java/com/apollohg/editor/EditorBlockSpacing.kt +51 -0
- package/android/src/main/java/com/apollohg/editor/EditorBoxDrawable.kt +16 -0
- package/android/src/main/java/com/apollohg/editor/EditorBoxDrawing.kt +234 -0
- package/android/src/main/java/com/apollohg/editor/EditorCheckboxSpan.kt +87 -0
- package/android/src/main/java/com/apollohg/editor/EditorCodeHighlighting.kt +120 -0
- package/android/src/main/java/com/apollohg/editor/EditorDecorationLayer.java +18 -0
- package/android/src/main/java/com/apollohg/editor/EditorDocumentLayout.kt +626 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +1042 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextAnnotations.kt +191 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextCaret.kt +100 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextClipboard.kt +101 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextComposition.kt +220 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextConfiguration.kt +316 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextCorrection.kt +303 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDeferredUpdates.kt +327 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDeletion.kt +258 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDiagnostics.kt +83 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDragDrop.kt +67 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextExternalComposition.kt +357 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextHardwareInput.kt +277 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextImages.kt +280 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextInputLifecycle.kt +183 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextInputPreparation.kt +79 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextInputTraits.kt +384 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextLayout.kt +100 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextNativeMutation.kt +243 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextPlaceholder.kt +154 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextRenderPatch.kt +347 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextRendering.kt +313 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextRustCommands.kt +281 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextSelection.kt +352 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextState.kt +113 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextTaskMarkers.kt +92 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextTextCommit.kt +327 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextToolbar.kt +84 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextUpdates.kt +245 -0
- package/android/src/main/java/com/apollohg/editor/EditorGlyphHeightCursorDrawable.kt +42 -0
- package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +13 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +923 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputCoordinates.kt +191 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputCorrection.kt +107 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputCursorGeometry.kt +128 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputSnapshots.kt +134 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputSurroundingDeletion.kt +321 -0
- package/android/src/main/java/com/apollohg/editor/EditorKeyboardToolbarView.kt +851 -0
- package/android/src/main/java/com/apollohg/editor/EditorMentionStyle.kt +192 -0
- package/android/src/main/java/com/apollohg/editor/EditorReconciliationWatcher.kt +46 -0
- package/android/src/main/java/com/apollohg/editor/EditorStyleSheet.kt +303 -0
- package/android/src/main/java/com/apollohg/editor/EditorStyleSheetSpans.kt +253 -0
- package/android/src/main/java/com/apollohg/editor/EditorSurfaceInputConnection.kt +67 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextDecorationDrawing.kt +143 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurface.kt +712 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceDragDrop.kt +94 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceInteraction.kt +708 -0
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +650 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Adapter.kt +912 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2AdapterMutations.kt +402 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2AdapterRendering.kt +123 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2AdapterSelection.kt +203 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Backend.kt +120 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Driver.kt +87 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Registry.kt +97 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2RenderValidation.kt +409 -0
- package/android/src/main/java/com/apollohg/editor/ExpoAutoGrowStyleSizePublisher.kt +34 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +266 -0
- package/android/src/main/java/com/apollohg/editor/ImeTextCoordinateMapper.kt +102 -0
- package/android/src/main/java/com/apollohg/editor/KeyboardToolbarImeAnimationController.kt +101 -0
- package/android/src/main/java/com/apollohg/editor/MentionSuggestionChipView.kt +234 -0
- package/android/src/main/java/com/apollohg/editor/NativeCollaborationTransportRegistry.kt +493 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +813 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewAtoms.kt +68 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewBinding.kt +126 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewDiagnostics.kt +208 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewErrors.kt +146 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewEvents.kt +150 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewExternalComposition.kt +39 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewFocus.kt +176 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewLifecycle.kt +302 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewMentions.kt +259 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewNativeActions.kt +179 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewOutsideTap.kt +214 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewPendingUpdates.kt +376 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewProperties.kt +234 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewPropertyRetries.kt +197 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewToolbar.kt +285 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewTypes.kt +28 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewUpdates.kt +271 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +687 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorOutsideTapDispatcher.kt +380 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorV2Numbers.kt +45 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorViewRegistry.kt +372 -0
- package/android/src/main/java/com/apollohg/editor/NativeImagePipeline.kt +22 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +193 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbarIcons.kt +177 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbarItem.kt +274 -0
- package/android/src/main/java/com/apollohg/editor/OkHttpCollaborationSocket.kt +102 -0
- package/android/src/main/java/com/apollohg/editor/OrderedListMarkerFormatter.kt +130 -0
- package/android/src/main/java/com/apollohg/editor/PointerTransparentView.java +18 -0
- package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +128 -0
- package/android/src/main/java/com/apollohg/editor/ProseViewerView.kt +854 -0
- package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +314 -0
- package/android/src/main/java/com/apollohg/editor/RenderBlockSpans.kt +314 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +224 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeBlockStyles.kt +407 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeElements.kt +544 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeInlineAndAtoms.kt +631 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeParagraphs.kt +215 -0
- package/android/src/main/java/com/apollohg/editor/RenderImageDecoder.kt +748 -0
- package/android/src/main/java/com/apollohg/editor/RenderImageLoader.kt +900 -0
- package/android/src/main/java/com/apollohg/editor/RenderLayoutConstants.kt +117 -0
- package/android/src/main/java/com/apollohg/editor/RenderMediaSpans.kt +337 -0
- package/android/src/main/java/com/apollohg/editor/RenderParagraphSpans.kt +182 -0
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +951 -0
- package/android/src/main/java/com/apollohg/editor/SharedNativeImagePipeline.kt +78 -0
- package/android/src/main/java/com/apollohg/editor/UniffiEditorV2Backend.kt +261 -0
- package/android/src/main/java/com/apollohg/editor/viewer/AndroidProseLayoutEngine.kt +1656 -0
- package/android/src/main/java/com/apollohg/editor/viewer/FabricAttachmentSidecars.kt +80 -0
- package/android/src/main/java/com/apollohg/editor/viewer/FabricLeaseHandleBridge.kt +59 -0
- package/android/src/main/java/com/apollohg/editor/viewer/FallbackSelectionGeometry.kt +450 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseDrawingView.kt +678 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseInstrumentation.kt +608 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayout.kt +186 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayoutCache.kt +393 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayoutRegistry.kt +828 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseTheme.kt +316 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseViewerManager.kt +900 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseViewerPackage.kt +16 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedViewerAtoms.kt +89 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerCodeHighlighting.kt +91 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerDocument.kt +453 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerFontEnvironment.kt +282 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerImagePipeline.kt +460 -0
- package/android/src/main/jni/CMakeLists.txt +85 -0
- package/android/src/main/jni/PreparedProseViewerMeasurementsManager.cpp +334 -0
- package/android/src/main/jni/ReactNativeProseEditorSpec.h +17 -0
- package/android/src/main/jni/reactnativeproseeditor.h +6 -0
- package/android/src/main/res/values/attrs.xml +6 -0
- package/android/src/release/java/com/apollohg/editor/viewer/PreparedProseDrawInstrumentation.kt +9 -0
- package/app.plugin.js +62 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseMeasurementsManager.h +62 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerComponentDescriptor.h +30 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerShadowNode.cpp +192 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerShadowNode.h +46 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerState.h +145 -0
- package/dist/AtomHost.d.ts +17 -0
- package/dist/AtomHost.js +135 -0
- package/dist/DefaultAtomChip.d.ts +2 -0
- package/dist/DefaultAtomChip.js +22 -0
- package/dist/EditorAddon.d.ts +32 -0
- package/dist/EditorAddon.js +29 -0
- package/dist/EditorAddonNormalization.d.ts +6 -0
- package/dist/EditorAddonNormalization.js +48 -0
- package/dist/EditorMentionThemeNormalization.d.ts +8 -0
- package/dist/EditorMentionThemeNormalization.js +22 -0
- package/dist/EditorMentionThemeValidation.d.ts +12 -0
- package/dist/EditorMentionThemeValidation.js +95 -0
- package/dist/EditorStyleSheet.d.ts +4 -0
- package/dist/EditorStyleSheet.js +10 -0
- package/dist/EditorStyleSheetNormalization.d.ts +3 -0
- package/dist/EditorStyleSheetNormalization.js +226 -0
- package/dist/EditorStyleSheetTypes.d.ts +151 -0
- package/dist/EditorStyleSheetTypes.js +2 -0
- package/dist/EditorTheme.d.ts +117 -0
- package/dist/EditorTheme.js +41 -0
- package/dist/EditorToolbar.d.ts +4 -0
- package/dist/EditorToolbar.js +17 -0
- package/dist/EditorToolbarComponent.d.ts +13 -0
- package/dist/EditorToolbarComponent.js +24 -0
- package/dist/EditorToolbarItems.d.ts +9 -0
- package/dist/EditorToolbarItems.js +58 -0
- package/dist/EditorToolbarRegistry.d.ts +59 -0
- package/dist/EditorToolbarRegistry.js +175 -0
- package/dist/EditorToolbarTypes.d.ts +273 -0
- package/dist/EditorToolbarTypes.js +2 -0
- package/dist/EditorToolbarVisuals.d.ts +154 -0
- package/dist/EditorToolbarVisuals.js +228 -0
- package/dist/EditorUpdateRevision.d.ts +8 -0
- package/dist/EditorUpdateRevision.js +22 -0
- package/dist/ExternalTextComposition.d.ts +45 -0
- package/dist/ExternalTextComposition.js +537 -0
- package/dist/ImageLoadingPolicy.d.ts +54 -0
- package/dist/ImageLoadingPolicy.js +60 -0
- package/dist/NativeEditorBoundaryError.d.ts +111 -0
- package/dist/NativeEditorBoundaryError.js +268 -0
- package/dist/NativeEditorBridge.d.ts +9 -0
- package/dist/NativeEditorBridge.js +37 -0
- package/dist/NativeEditorCollaborationTransport.d.ts +154 -0
- package/dist/NativeEditorCollaborationTransport.js +275 -0
- package/dist/NativeEditorCreateConfig.d.ts +16 -0
- package/dist/NativeEditorCreateConfig.js +249 -0
- package/dist/NativeEditorCreateJson.d.ts +76 -0
- package/dist/NativeEditorCreateJson.js +474 -0
- package/dist/NativeEditorCreateValidation.d.ts +32 -0
- package/dist/NativeEditorCreateValidation.js +150 -0
- package/dist/NativeEditorDocumentBridge.d.ts +72 -0
- package/dist/NativeEditorDocumentBridge.js +305 -0
- package/dist/NativeEditorDocumentHandle.d.ts +70 -0
- package/dist/NativeEditorDocumentHandle.js +89 -0
- package/dist/NativeEditorLocalAwareness.d.ts +34 -0
- package/dist/NativeEditorLocalAwareness.js +153 -0
- package/dist/NativeEditorNativeModule.d.ts +48 -0
- package/dist/NativeEditorNativeModule.js +34 -0
- package/dist/NativeEditorRenderNormalization.d.ts +22 -0
- package/dist/NativeEditorRenderNormalization.js +274 -0
- package/dist/NativeEditorResultNormalization.d.ts +108 -0
- package/dist/NativeEditorResultNormalization.js +400 -0
- package/dist/NativeEditorTypes.d.ts +318 -0
- package/dist/NativeEditorTypes.js +15 -0
- package/dist/NativeEditorV2Decimal.d.ts +5 -0
- package/dist/NativeEditorV2Decimal.js +18 -0
- package/dist/NativeProseViewer.d.ts +122 -0
- package/dist/NativeProseViewer.js +130 -0
- package/dist/NativeRichTextEditor.d.ts +3 -0
- package/dist/NativeRichTextEditor.js +6 -0
- package/dist/ResourceLimits.d.ts +100 -0
- package/dist/ResourceLimits.js +80 -0
- package/dist/RichTextEditor.d.ts +4 -0
- package/dist/RichTextEditor.js +25 -0
- package/dist/RichTextEditorNativeTypes.d.ts +122 -0
- package/dist/RichTextEditorNativeTypes.js +2 -0
- package/dist/RichTextEditorNativeView.d.ts +12 -0
- package/dist/RichTextEditorNativeView.js +15 -0
- package/dist/RichTextEditorSerialization.d.ts +53 -0
- package/dist/RichTextEditorSerialization.js +283 -0
- package/dist/RichTextEditorTypes.d.ts +281 -0
- package/dist/RichTextEditorTypes.js +2 -0
- package/dist/ViewerConfiguration.d.ts +22 -0
- package/dist/ViewerConfiguration.js +6 -0
- package/dist/YjsCollaboration.d.ts +146 -0
- package/dist/YjsCollaboration.js +496 -0
- package/dist/addons.d.ts +193 -0
- package/dist/addons.js +122 -0
- package/dist/atomConstants.d.ts +3 -0
- package/dist/atomConstants.js +6 -0
- package/dist/atomInstances.d.ts +35 -0
- package/dist/atomInstances.js +79 -0
- package/dist/atomPolicy.d.ts +4 -0
- package/dist/atomPolicy.js +47 -0
- package/dist/atomUpdates.d.ts +2 -0
- package/dist/atomUpdates.js +38 -0
- package/dist/atoms.d.ts +92 -0
- package/dist/atoms.js +222 -0
- package/dist/attributeValidation.d.ts +4 -0
- package/dist/attributeValidation.js +97 -0
- package/dist/contentExpression.d.ts +6 -0
- package/dist/contentExpression.js +335 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +78 -0
- package/dist/listMarkers.d.ts +15 -0
- package/dist/listMarkers.js +21 -0
- package/dist/schemaDefinition.d.ts +143 -0
- package/dist/schemaDefinition.js +206 -0
- package/dist/schemaDocument.d.ts +17 -0
- package/dist/schemaDocument.js +69 -0
- package/dist/schemaDocumentConstruction.d.ts +5 -0
- package/dist/schemaDocumentConstruction.js +125 -0
- package/dist/schemaNormalization.d.ts +29 -0
- package/dist/schemaNormalization.js +313 -0
- package/dist/schemaPresets.d.ts +68 -0
- package/dist/schemaPresets.js +198 -0
- package/dist/schemaResolution.d.ts +9 -0
- package/dist/schemaResolution.js +211 -0
- package/dist/schemas.d.ts +5 -0
- package/dist/schemas.js +28 -0
- package/dist/specs/PreparedProseViewerNativeComponent.d.ts +37 -0
- package/dist/specs/PreparedProseViewerNativeComponent.js +6 -0
- package/dist/useEditorToolbarInteractions.d.ts +12 -0
- package/dist/useEditorToolbarInteractions.js +218 -0
- package/dist/useEditorToolbarItems.d.ts +8 -0
- package/dist/useEditorToolbarItems.js +280 -0
- package/dist/useEditorToolbarPresentation.d.ts +4 -0
- package/dist/useEditorToolbarPresentation.js +203 -0
- package/dist/useEditorToolbarState.d.ts +63 -0
- package/dist/useEditorToolbarState.js +108 -0
- package/dist/useFocusPreservingFrames.d.ts +17 -0
- package/dist/useFocusPreservingFrames.js +108 -0
- package/dist/useNativeEditor.d.ts +66 -0
- package/dist/useNativeEditor.js +370 -0
- package/dist/useRichTextEditorCommands.d.ts +21 -0
- package/dist/useRichTextEditorCommands.js +299 -0
- package/dist/useRichTextEditorEvents.d.ts +18 -0
- package/dist/useRichTextEditorEvents.js +216 -0
- package/dist/useRichTextEditorMentions.d.ts +11 -0
- package/dist/useRichTextEditorMentions.js +316 -0
- package/dist/useRichTextEditorPresentation.d.ts +5 -0
- package/dist/useRichTextEditorPresentation.js +178 -0
- package/dist/useRichTextEditorState.d.ts +180 -0
- package/dist/useRichTextEditorState.js +405 -0
- package/dist/useRichTextEditorUpdates.d.ts +10 -0
- package/dist/useRichTextEditorUpdates.js +308 -0
- package/dist/useViewerAtoms.d.ts +38 -0
- package/dist/useViewerAtoms.js +288 -0
- package/expo-module.config.json +13 -0
- package/ios/EditorAddons.swift +354 -0
- package/ios/EditorCodeHighlighting.swift +184 -0
- package/ios/EditorCore.xcframework/Info.plist +44 -0
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/EditorInteractionOverlays.swift +697 -0
- package/ios/EditorLayoutManager.swift +971 -0
- package/ios/EditorNodeTypes.swift +37 -0
- package/ios/EditorStyleSheet.swift +461 -0
- package/ios/EditorTextView+AttributedPatch.swift +305 -0
- package/ios/EditorTextView+Binding.swift +61 -0
- package/ios/EditorTextView+Caret.swift +333 -0
- package/ios/EditorTextView+Commands.swift +203 -0
- package/ios/EditorTextView+Delegate.swift +65 -0
- package/ios/EditorTextView+Diagnostics.swift +225 -0
- package/ios/EditorTextView+DragDrop.swift +290 -0
- package/ios/EditorTextView+ExternalComposition.swift +364 -0
- package/ios/EditorTextView+Images.swift +354 -0
- package/ios/EditorTextView+InputTraits.swift +200 -0
- package/ios/EditorTextView+KeyboardInput.swift +318 -0
- package/ios/EditorTextView+Layout.swift +245 -0
- package/ios/EditorTextView+MarkedText.swift +267 -0
- package/ios/EditorTextView+NativeInputLifecycle.swift +372 -0
- package/ios/EditorTextView+NativeMutation.swift +471 -0
- package/ios/EditorTextView+Reconciliation.swift +97 -0
- package/ios/EditorTextView+RenderPatch.swift +573 -0
- package/ios/EditorTextView+Rendering.swift +539 -0
- package/ios/EditorTextView+Selection.swift +542 -0
- package/ios/EditorTextView.swift +953 -0
- package/ios/EditorTheme.swift +626 -0
- package/ios/EditorV2Adapter+Commands.swift +204 -0
- package/ios/EditorV2Adapter+Envelope.swift +238 -0
- package/ios/EditorV2Adapter+Mutation.swift +392 -0
- package/ios/EditorV2Adapter+Registry.swift +185 -0
- package/ios/EditorV2Adapter+RenderState.swift +360 -0
- package/ios/EditorV2Adapter+RenderValidation.swift +420 -0
- package/ios/EditorV2Adapter+Selection.swift +329 -0
- package/ios/EditorV2Adapter+TextCommands.swift +430 -0
- package/ios/EditorV2Adapter.swift +376 -0
- package/ios/EditorV2Shadow.swift +353 -0
- package/ios/Generated_editor_core.swift +2378 -0
- package/ios/NativeCodeHighlighting.swift +159 -0
- package/ios/NativeCollaborationSocket.swift +144 -0
- package/ios/NativeCollaborationTransport+Protocol.swift +258 -0
- package/ios/NativeCollaborationTransport+Socket.swift +379 -0
- package/ios/NativeCollaborationTransport+Validation.swift +103 -0
- package/ios/NativeCollaborationTransport.swift +322 -0
- package/ios/NativeCollaborationTransportRegistry.swift +521 -0
- package/ios/NativeEditorExpoView+AccessoryRetry.swift +219 -0
- package/ios/NativeEditorExpoView+Binding.swift +268 -0
- package/ios/NativeEditorExpoView+Diagnostics.swift +66 -0
- package/ios/NativeEditorExpoView+Events.swift +131 -0
- package/ios/NativeEditorExpoView+Focus.swift +169 -0
- package/ios/NativeEditorExpoView+MentionRetry.swift +288 -0
- package/ios/NativeEditorExpoView+Mentions.swift +288 -0
- package/ios/NativeEditorExpoView+Properties.swift +300 -0
- package/ios/NativeEditorExpoView+Toolbar.swift +86 -0
- package/ios/NativeEditorExpoView+Updates.swift +312 -0
- package/ios/NativeEditorExpoView.swift +349 -0
- package/ios/NativeEditorModule.swift +856 -0
- package/ios/NativeEditorViewRegistry.swift +226 -0
- package/ios/NativeToolbar+ButtonStyle.swift +214 -0
- package/ios/NativeToolbar+Buttons.swift +228 -0
- package/ios/NativeToolbar+Diagnostics.swift +114 -0
- package/ios/NativeToolbar+Menu.swift +101 -0
- package/ios/NativeToolbar+Models.swift +519 -0
- package/ios/NativeToolbar+Placeholder.swift +39 -0
- package/ios/NativeToolbar.swift +612 -0
- package/ios/OrderedListMarkerFormatter.swift +103 -0
- package/ios/PositionBridge.swift +596 -0
- package/ios/ProseViewerView.swift +462 -0
- package/ios/RenderBridge+Atoms.swift +288 -0
- package/ios/RenderBridge+Attachments.swift +246 -0
- package/ios/RenderBridge+BlockBoundaries.swift +313 -0
- package/ios/RenderBridge+Style.swift +343 -0
- package/ios/RenderBridge.swift +704 -0
- package/ios/RichTextEditorView.swift +930 -0
- package/ios/SharedNativeImagePipeline+Cache.swift +189 -0
- package/ios/SharedNativeImagePipeline+Transport.swift +328 -0
- package/ios/SharedNativeImagePipeline.swift +533 -0
- package/ios/Viewer/CoreTextProseLayoutEngine+AttributedText.swift +436 -0
- package/ios/Viewer/CoreTextProseLayoutEngine+Models.swift +322 -0
- package/ios/Viewer/CoreTextProseLayoutEngine.swift +635 -0
- package/ios/Viewer/Fabric/PREPPreparedProseViewerComponentView.h +4 -0
- package/ios/Viewer/Fabric/PREPPreparedProseViewerComponentView.mm +767 -0
- package/ios/Viewer/Fabric/PreparedProseMeasurementsManager.mm +118 -0
- package/ios/Viewer/NativeSVGImageDecoder.h +9 -0
- package/ios/Viewer/NativeSVGImageDecoder.mm +106 -0
- package/ios/Viewer/NativeSVGPreflight.h +11 -0
- package/ios/Viewer/NativeSVGPreflight.mm +219 -0
- package/ios/Viewer/PreparedProseDrawingView.swift +639 -0
- package/ios/Viewer/PreparedProseInstrumentation.swift +387 -0
- package/ios/Viewer/PreparedProseLayout.swift +326 -0
- package/ios/Viewer/PreparedProseLayoutCache.swift +766 -0
- package/ios/Viewer/PreparedProseLayoutRegistry+Artifacts.swift +377 -0
- package/ios/Viewer/PreparedProseLayoutRegistry+Fabric.swift +582 -0
- package/ios/Viewer/PreparedProseLayoutRegistry+FabricOwnership.swift +128 -0
- package/ios/Viewer/PreparedProseLayoutRegistry.swift +381 -0
- package/ios/Viewer/ViewerDocument.swift +575 -0
- package/ios/Viewer/ViewerFontEnvironment.swift +283 -0
- package/ios/Viewer/ViewerImagePipeline.swift +478 -0
- package/ios/editor_coreFFI/editor_coreFFI.h +1023 -0
- package/ios/editor_coreFFI/module.modulemap +7 -0
- package/package.json +151 -0
- package/react-native.config.js +17 -0
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
- package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +3146 -0
- package/src/AtomHost.tsx +180 -0
- package/src/DefaultAtomChip.tsx +27 -0
- package/src/EditorAddon.ts +65 -0
- package/src/EditorAddonNormalization.ts +49 -0
- package/src/EditorMentionThemeNormalization.ts +25 -0
- package/src/EditorMentionThemeValidation.ts +133 -0
- package/src/EditorStyleSheet.ts +9 -0
- package/src/EditorStyleSheetNormalization.ts +219 -0
- package/src/EditorStyleSheetTypes.ts +189 -0
- package/src/EditorTheme.ts +196 -0
- package/src/EditorToolbar.tsx +31 -0
- package/src/EditorToolbarComponent.tsx +23 -0
- package/src/EditorToolbarItems.tsx +64 -0
- package/src/EditorToolbarRegistry.tsx +254 -0
- package/src/EditorToolbarTypes.tsx +322 -0
- package/src/EditorToolbarVisuals.tsx +270 -0
- package/src/EditorUpdateRevision.ts +26 -0
- package/src/ExternalTextComposition.ts +658 -0
- package/src/ImageLoadingPolicy.ts +125 -0
- package/src/NativeEditorBoundaryError.ts +345 -0
- package/src/NativeEditorBridge.ts +93 -0
- package/src/NativeEditorCollaborationTransport.ts +493 -0
- package/src/NativeEditorCreateConfig.ts +326 -0
- package/src/NativeEditorCreateJson.ts +579 -0
- package/src/NativeEditorCreateValidation.ts +178 -0
- package/src/NativeEditorDocumentBridge.ts +485 -0
- package/src/NativeEditorDocumentHandle.ts +168 -0
- package/src/NativeEditorLocalAwareness.ts +168 -0
- package/src/NativeEditorNativeModule.ts +97 -0
- package/src/NativeEditorRenderNormalization.ts +320 -0
- package/src/NativeEditorResultNormalization.ts +469 -0
- package/src/NativeEditorTypes.ts +366 -0
- package/src/NativeEditorV2Decimal.ts +13 -0
- package/src/NativeProseViewer.tsx +356 -0
- package/src/NativeRichTextEditor.tsx +33 -0
- package/src/ResourceLimits.ts +187 -0
- package/src/RichTextEditor.tsx +27 -0
- package/src/RichTextEditorNativeTypes.tsx +144 -0
- package/src/RichTextEditorNativeView.tsx +21 -0
- package/src/RichTextEditorSerialization.tsx +381 -0
- package/src/RichTextEditorTypes.tsx +327 -0
- package/src/ViewerConfiguration.ts +23 -0
- package/src/YjsCollaboration.ts +692 -0
- package/src/addons.ts +311 -0
- package/src/atomConstants.ts +3 -0
- package/src/atomInstances.ts +123 -0
- package/src/atomPolicy.ts +47 -0
- package/src/atomUpdates.ts +52 -0
- package/src/atoms.ts +379 -0
- package/src/attributeValidation.ts +116 -0
- package/src/contentExpression.ts +338 -0
- package/src/index.ts +295 -0
- package/src/listMarkers.ts +18 -0
- package/src/schemaDefinition.ts +395 -0
- package/src/schemaDocument.ts +92 -0
- package/src/schemaDocumentConstruction.ts +148 -0
- package/src/schemaNormalization.ts +367 -0
- package/src/schemaPresets.ts +250 -0
- package/src/schemaResolution.ts +242 -0
- package/src/schemas.ts +43 -0
- package/src/specs/PreparedProseViewerNativeComponent.ts +40 -0
- package/src/useEditorToolbarInteractions.tsx +329 -0
- package/src/useEditorToolbarItems.tsx +390 -0
- package/src/useEditorToolbarPresentation.tsx +483 -0
- package/src/useEditorToolbarState.tsx +172 -0
- package/src/useFocusPreservingFrames.ts +171 -0
- package/src/useNativeEditor.ts +534 -0
- package/src/useRichTextEditorCommands.tsx +478 -0
- package/src/useRichTextEditorEvents.tsx +342 -0
- package/src/useRichTextEditorMentions.tsx +441 -0
- package/src/useRichTextEditorPresentation.tsx +563 -0
- package/src/useRichTextEditorState.tsx +620 -0
- package/src/useRichTextEditorUpdates.tsx +403 -0
- package/src/useViewerAtoms.tsx +427 -0
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
package com.apollohg.editor
|
|
2
|
+
|
|
3
|
+
import android.content.ClipData
|
|
4
|
+
import android.graphics.Canvas
|
|
5
|
+
import android.graphics.Point
|
|
6
|
+
import android.graphics.Rect
|
|
7
|
+
import android.graphics.drawable.Drawable
|
|
8
|
+
import android.os.Bundle
|
|
9
|
+
import android.text.Selection
|
|
10
|
+
import android.text.StaticLayout
|
|
11
|
+
import android.text.TextPaint
|
|
12
|
+
import android.util.AttributeSet
|
|
13
|
+
import android.view.ActionMode
|
|
14
|
+
import android.view.GestureDetector
|
|
15
|
+
import android.view.KeyEvent
|
|
16
|
+
import android.view.Menu
|
|
17
|
+
import android.view.MenuItem
|
|
18
|
+
import android.view.MotionEvent
|
|
19
|
+
import android.view.View
|
|
20
|
+
import android.view.ViewConfiguration
|
|
21
|
+
import android.view.accessibility.AccessibilityEvent
|
|
22
|
+
import android.view.accessibility.AccessibilityNodeInfo
|
|
23
|
+
import android.view.inputmethod.InputMethodManager
|
|
24
|
+
import java.text.BreakIterator
|
|
25
|
+
import kotlin.math.abs
|
|
26
|
+
|
|
27
|
+
internal class EditorTextSurfaceInteraction(
|
|
28
|
+
private val view: EditorTextSurface,
|
|
29
|
+
attrs: AttributeSet? = null,
|
|
30
|
+
defStyleAttr: Int = android.R.attr.editTextStyle
|
|
31
|
+
) {
|
|
32
|
+
private val density get() = view.resources.displayMetrics.density
|
|
33
|
+
private val handleDrawables by lazy {
|
|
34
|
+
val attributes = view.context.obtainStyledAttributes(
|
|
35
|
+
attrs,
|
|
36
|
+
R.styleable.EditorSelectionHandles,
|
|
37
|
+
defStyleAttr,
|
|
38
|
+
0
|
|
39
|
+
)
|
|
40
|
+
try {
|
|
41
|
+
attributes.getDrawable(
|
|
42
|
+
R.styleable.EditorSelectionHandles_android_textSelectHandleLeft
|
|
43
|
+
)?.mutate() to
|
|
44
|
+
attributes.getDrawable(
|
|
45
|
+
R.styleable.EditorSelectionHandles_android_textSelectHandleRight
|
|
46
|
+
)?.mutate()
|
|
47
|
+
} finally {
|
|
48
|
+
attributes.recycle()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
private val handlesVisible get() = view.hasFocus() && view.selectionStart >= 0 &&
|
|
52
|
+
view.selectionEnd >= 0 && view.selectionStart != view.selectionEnd
|
|
53
|
+
private var draggingHandle = 0
|
|
54
|
+
private var handleDragOffsetX = 0f
|
|
55
|
+
private var handleDragOffsetY = 0f
|
|
56
|
+
private var downX = 0f
|
|
57
|
+
private var downY = 0f
|
|
58
|
+
private var lastY = 0f
|
|
59
|
+
private var moved = false
|
|
60
|
+
private var longPressed = false
|
|
61
|
+
private var selectionAnchor = 0
|
|
62
|
+
private val slop = ViewConfiguration.get(view.context).scaledTouchSlop
|
|
63
|
+
private val gestures =
|
|
64
|
+
GestureDetector(
|
|
65
|
+
view.context,
|
|
66
|
+
object : GestureDetector.SimpleOnGestureListener() {
|
|
67
|
+
override fun onDown(e: MotionEvent) = true
|
|
68
|
+
override fun onSingleTapUp(e: MotionEvent): Boolean {
|
|
69
|
+
if (moved || draggingHandle != 0) return true
|
|
70
|
+
view.requestFocus()
|
|
71
|
+
view.setSelection(view.getOffsetForPosition(e.x, e.y))
|
|
72
|
+
endSelectionActionMode()
|
|
73
|
+
showKeyboard()
|
|
74
|
+
view.performClick()
|
|
75
|
+
return true
|
|
76
|
+
}
|
|
77
|
+
override fun onDoubleTap(e: MotionEvent): Boolean {
|
|
78
|
+
selectWord(e.x, e.y)
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
81
|
+
override fun onLongPress(e: MotionEvent) {
|
|
82
|
+
if (draggingHandle != 0 || moved) return
|
|
83
|
+
val offset = view.getOffsetForPosition(e.x, e.y)
|
|
84
|
+
val from = minOf(view.selectionStart, view.selectionEnd)
|
|
85
|
+
val to = maxOf(view.selectionStart, view.selectionEnd)
|
|
86
|
+
if (from >= 0 && from < to && offset in from until to &&
|
|
87
|
+
(view as? EditorEditText)?.isEditable != false
|
|
88
|
+
) {
|
|
89
|
+
val clip = ClipData.newPlainText("", view.text.subSequence(from, to))
|
|
90
|
+
if (view.startDragAndDrop(clip, selectionDragShadow(from, to), view, 0)) {
|
|
91
|
+
endSelectionActionMode()
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
longPressed = true
|
|
96
|
+
selectWord(e.x, e.y)
|
|
97
|
+
selectionAnchor = view.selectionStart
|
|
98
|
+
view.parent?.requestDisallowInterceptTouchEvent(true)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
fun onTouchEvent(event: MotionEvent): Boolean {
|
|
104
|
+
if (!view.isEnabled) return false
|
|
105
|
+
when (event.actionMasked) {
|
|
106
|
+
MotionEvent.ACTION_DOWN -> {
|
|
107
|
+
downX = event.x
|
|
108
|
+
downY = event.y
|
|
109
|
+
lastY = event.y
|
|
110
|
+
moved = false
|
|
111
|
+
longPressed = false
|
|
112
|
+
draggingHandle = hitHandle(event.x, event.y)
|
|
113
|
+
if (draggingHandle != 0) {
|
|
114
|
+
val offset = if (draggingHandle == 1) view.selectionStart else view.selectionEnd
|
|
115
|
+
val (x, bottom) = handlePosition(offset)
|
|
116
|
+
handleDragOffsetX = event.x + view.scrollX - view.totalPaddingLeft - x
|
|
117
|
+
handleDragOffsetY = event.y + view.scrollY - view.totalPaddingTop - bottom
|
|
118
|
+
view.parent?.requestDisallowInterceptTouchEvent(true)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
MotionEvent.ACTION_MOVE -> {
|
|
123
|
+
if (abs(event.x - downX) > slop || abs(event.y - downY) > slop) moved = true
|
|
124
|
+
if (draggingHandle != 0) {
|
|
125
|
+
val current = if (draggingHandle ==
|
|
126
|
+
1
|
|
127
|
+
) {
|
|
128
|
+
view.selectionStart
|
|
129
|
+
} else {
|
|
130
|
+
view.selectionEnd
|
|
131
|
+
}
|
|
132
|
+
val offset = offsetForHandlePosition(
|
|
133
|
+
event.x - handleDragOffsetX,
|
|
134
|
+
event.y - handleDragOffsetY - 1f,
|
|
135
|
+
current
|
|
136
|
+
)
|
|
137
|
+
if (draggingHandle ==
|
|
138
|
+
1
|
|
139
|
+
) {
|
|
140
|
+
view.setSelection(offset, view.selectionEnd.coerceAtLeast(0))
|
|
141
|
+
} else {
|
|
142
|
+
view.setSelection(view.selectionStart.coerceAtLeast(0), offset)
|
|
143
|
+
}
|
|
144
|
+
view.bringPointIntoView(offset)
|
|
145
|
+
} else if (longPressed && moved) {
|
|
146
|
+
val offset = view.getOffsetForPosition(event.x, event.y)
|
|
147
|
+
view.setSelection(selectionAnchor, offset)
|
|
148
|
+
view.bringPointIntoView(offset)
|
|
149
|
+
} else if (moved && !hasScrollContainer() &&
|
|
150
|
+
(view as? EditorEditText)?.heightBehavior == EditorHeightBehavior.FIXED
|
|
151
|
+
) {
|
|
152
|
+
val limit = (
|
|
153
|
+
view.layout.height + view.totalPaddingTop + view.totalPaddingBottom -
|
|
154
|
+
view.height
|
|
155
|
+
).coerceAtLeast(0)
|
|
156
|
+
view.scrollTo(0, (view.scrollY + lastY - event.y).toInt().coerceIn(0, limit))
|
|
157
|
+
}
|
|
158
|
+
lastY = event.y
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
gestures.onTouchEvent(event)
|
|
162
|
+
if (event.actionMasked == MotionEvent.ACTION_UP ||
|
|
163
|
+
event.actionMasked == MotionEvent.ACTION_CANCEL
|
|
164
|
+
) {
|
|
165
|
+
if (draggingHandle != 0 &&
|
|
166
|
+
view.selectionStart != view.selectionEnd
|
|
167
|
+
) {
|
|
168
|
+
startSelectionActionMode()
|
|
169
|
+
}
|
|
170
|
+
draggingHandle = 0
|
|
171
|
+
view.parent?.requestDisallowInterceptTouchEvent(false)
|
|
172
|
+
}
|
|
173
|
+
return true
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
internal fun hasScrollContainer(): Boolean {
|
|
177
|
+
var parent = view.parent
|
|
178
|
+
while (parent != null) {
|
|
179
|
+
if (parent is android.widget.ScrollView) return true
|
|
180
|
+
parent = parent.parent
|
|
181
|
+
}
|
|
182
|
+
return false
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private fun showKeyboard() {
|
|
186
|
+
if (view.showSoftInputOnFocus &&
|
|
187
|
+
(view as? EditorEditText)?.isEditable != false
|
|
188
|
+
) {
|
|
189
|
+
view.inputMethod.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private fun selectWord(x: Float, y: Float) {
|
|
194
|
+
view.requestFocus()
|
|
195
|
+
val text = view.text.toString()
|
|
196
|
+
if (text.isEmpty()) {
|
|
197
|
+
view.setSelection(0)
|
|
198
|
+
startSelectionActionMode()
|
|
199
|
+
showKeyboard()
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
val offset = view.getOffsetForPosition(x, y).coerceAtMost(text.length - 1)
|
|
203
|
+
val iterator = BreakIterator.getWordInstance().apply { setText(text) }
|
|
204
|
+
val start = if (iterator.isBoundary(
|
|
205
|
+
offset
|
|
206
|
+
)
|
|
207
|
+
) {
|
|
208
|
+
offset
|
|
209
|
+
} else {
|
|
210
|
+
iterator.preceding(offset).coerceAtLeast(0)
|
|
211
|
+
}
|
|
212
|
+
val end = iterator.following(offset).let {
|
|
213
|
+
if (it ==
|
|
214
|
+
BreakIterator.DONE
|
|
215
|
+
) {
|
|
216
|
+
text.length
|
|
217
|
+
} else {
|
|
218
|
+
it
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
view.setSelection(start, end)
|
|
222
|
+
view.performHapticFeedback(android.view.HapticFeedbackConstants.LONG_PRESS)
|
|
223
|
+
startSelectionActionMode()
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private fun selectionDragShadow(from: Int, to: Int): View.DragShadowBuilder {
|
|
227
|
+
val text = view.text.subSequence(from, minOf(to, from + 256))
|
|
228
|
+
val layout = StaticLayout.Builder.obtain(
|
|
229
|
+
text,
|
|
230
|
+
0,
|
|
231
|
+
text.length,
|
|
232
|
+
TextPaint(view.paint),
|
|
233
|
+
minOf(
|
|
234
|
+
view.width,
|
|
235
|
+
(
|
|
236
|
+
240 *
|
|
237
|
+
density
|
|
238
|
+
).toInt()
|
|
239
|
+
).coerceAtLeast(1)
|
|
240
|
+
)
|
|
241
|
+
.setMaxLines(3)
|
|
242
|
+
.setIncludePad(false)
|
|
243
|
+
.build()
|
|
244
|
+
return object : View.DragShadowBuilder(view) {
|
|
245
|
+
override fun onProvideShadowMetrics(size: Point, touch: Point) {
|
|
246
|
+
size.set(layout.width, layout.height)
|
|
247
|
+
touch.set(layout.width / 2, layout.height / 2)
|
|
248
|
+
}
|
|
249
|
+
override fun onDrawShadow(canvas: Canvas) {
|
|
250
|
+
layout.draw(canvas)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
private fun handlePosition(offset: Int): Pair<Float, Float> {
|
|
256
|
+
val layout = view.layout
|
|
257
|
+
val safe = offset.coerceIn(0, view.text.length)
|
|
258
|
+
val bounds = CaretGeometry.verticalBounds(layout, safe, view.paint, view.text)
|
|
259
|
+
val isStart = offset == minOf(view.selectionStart, view.selectionEnd)
|
|
260
|
+
val rtl = layout.isRtlCharAt(if (isStart) safe else (safe - 1).coerceAtLeast(0))
|
|
261
|
+
val paragraphRtl = layout.getParagraphDirection(layout.getLineForOffset(safe)) == -1
|
|
262
|
+
val x = if (rtl ==
|
|
263
|
+
paragraphRtl
|
|
264
|
+
) {
|
|
265
|
+
layout.getPrimaryHorizontal(safe)
|
|
266
|
+
} else {
|
|
267
|
+
layout.getSecondaryHorizontal(safe)
|
|
268
|
+
}
|
|
269
|
+
return x to bounds.bottom
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
private fun offsetForHandlePosition(x: Float, y: Float, current: Int): Int {
|
|
273
|
+
val layout = view.layout
|
|
274
|
+
val primary = view.getOffsetForPosition(x, y)
|
|
275
|
+
if (layout.getPrimaryHorizontal(primary) ==
|
|
276
|
+
layout.getSecondaryHorizontal(primary)
|
|
277
|
+
) {
|
|
278
|
+
return primary
|
|
279
|
+
}
|
|
280
|
+
val line = layout.getLineForVertical((y + view.scrollY - view.totalPaddingTop).toInt())
|
|
281
|
+
val localX = x + view.scrollX - view.totalPaddingLeft
|
|
282
|
+
var offset = primary
|
|
283
|
+
var distance = abs(layout.getPrimaryHorizontal(primary) - localX)
|
|
284
|
+
// A bidi boundary can have two offsets at the same visual position.
|
|
285
|
+
for (candidate in layout.getLineStart(
|
|
286
|
+
line
|
|
287
|
+
)..layout.getLineEnd(line).coerceAtMost(view.text.length)) {
|
|
288
|
+
if (layout.getLineForOffset(candidate) != line) continue
|
|
289
|
+
val secondary = layout.getSecondaryHorizontal(candidate)
|
|
290
|
+
if (secondary == layout.getPrimaryHorizontal(candidate)) continue
|
|
291
|
+
val candidateDistance = abs(secondary - localX)
|
|
292
|
+
if (candidateDistance < distance - 0.5f ||
|
|
293
|
+
(
|
|
294
|
+
abs(candidateDistance - distance) <= 0.5f &&
|
|
295
|
+
abs(candidate - current) < abs(offset - current)
|
|
296
|
+
)
|
|
297
|
+
) {
|
|
298
|
+
offset = candidate
|
|
299
|
+
distance = candidateDistance
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return PositionBridge.snapToGraphemeBoundary(offset, view.text.toString())
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private fun handleGeometry(offset: Int): Pair<Drawable, Rect>? {
|
|
306
|
+
val isStart = offset == minOf(view.selectionStart, view.selectionEnd)
|
|
307
|
+
val rtl = view.layout.isRtlCharAt(if (isStart) offset else (offset - 1).coerceAtLeast(0))
|
|
308
|
+
val leftHandle = isStart != rtl
|
|
309
|
+
val drawable =
|
|
310
|
+
(if (leftHandle) handleDrawables.first else handleDrawables.second) ?: return null
|
|
311
|
+
val width = drawable.intrinsicWidth.coerceAtLeast(1)
|
|
312
|
+
val height = drawable.intrinsicHeight.coerceAtLeast(1)
|
|
313
|
+
val hotspot = if (leftHandle) width * 3 / 4 else width / 4
|
|
314
|
+
val (x, bottom) = handlePosition(offset)
|
|
315
|
+
val minX = view.scrollX - view.totalPaddingLeft
|
|
316
|
+
val maxX = maxOf(minX, minX + view.width - width)
|
|
317
|
+
val minY = view.scrollY - view.totalPaddingTop
|
|
318
|
+
val maxY = maxOf(minY, minY + view.height - height)
|
|
319
|
+
if (bottom <= minY || bottom > minY + view.height || x < minX ||
|
|
320
|
+
x > minX + view.width
|
|
321
|
+
) {
|
|
322
|
+
return null
|
|
323
|
+
}
|
|
324
|
+
// Unlike Android's popup handles, these draw inside the editor surface.
|
|
325
|
+
val left = ((x - 0.5f).toInt() - hotspot).coerceIn(minX, maxX)
|
|
326
|
+
val top = bottom.toInt().coerceIn(minY, maxY)
|
|
327
|
+
return drawable to Rect(left, top, left + width, top + height)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private fun hitHandle(x: Float, y: Float): Int {
|
|
331
|
+
if (!handlesVisible) return 0
|
|
332
|
+
val localX = x + view.scrollX - view.totalPaddingLeft
|
|
333
|
+
val localY = y + view.scrollY - view.totalPaddingTop
|
|
334
|
+
val radius = 24f * density
|
|
335
|
+
val offsets = listOf(view.selectionStart, view.selectionEnd)
|
|
336
|
+
for ((index, offset) in offsets.withIndex()) {
|
|
337
|
+
val (_, bounds) = handleGeometry(offset) ?: continue
|
|
338
|
+
if (abs(localX - bounds.exactCenterX()) <= maxOf(radius, bounds.width() / 2f) &&
|
|
339
|
+
abs(localY - bounds.exactCenterY()) <= maxOf(radius, bounds.height() / 2f)
|
|
340
|
+
) {
|
|
341
|
+
return index +
|
|
342
|
+
1
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return 0
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
fun drawHandles(canvas: Canvas) {
|
|
349
|
+
if (!handlesVisible) return
|
|
350
|
+
for (offset in listOf(view.selectionStart, view.selectionEnd).distinct()) {
|
|
351
|
+
val (drawable, bounds) = handleGeometry(offset) ?: continue
|
|
352
|
+
drawable.state = view.drawableState
|
|
353
|
+
drawable.setTint((view as? EditorEditText)?.caretColor ?: view.currentTextColor)
|
|
354
|
+
drawable.bounds = bounds
|
|
355
|
+
drawable.draw(canvas)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
fun selectionChanged() {
|
|
360
|
+
if (view.selectionStart == view.selectionEnd) {
|
|
361
|
+
endSelectionActionMode()
|
|
362
|
+
} else {
|
|
363
|
+
view.selectionActionMode?.invalidateContentRect()
|
|
364
|
+
}
|
|
365
|
+
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED)
|
|
366
|
+
}
|
|
367
|
+
fun viewportChanged() {
|
|
368
|
+
view.selectionActionMode?.invalidateContentRect()
|
|
369
|
+
}
|
|
370
|
+
fun dispose() {
|
|
371
|
+
endSelectionActionMode()
|
|
372
|
+
draggingHandle = 0
|
|
373
|
+
}
|
|
374
|
+
fun endSelectionActionMode() {
|
|
375
|
+
view.selectionActionMode?.finish()
|
|
376
|
+
view.selectionActionMode =
|
|
377
|
+
null
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private fun startSelectionActionMode() {
|
|
381
|
+
if (view.selectionActionMode != null) {
|
|
382
|
+
view.selectionActionMode?.invalidate()
|
|
383
|
+
return
|
|
384
|
+
}
|
|
385
|
+
view.selectionActionMode = view.startActionMode(
|
|
386
|
+
object : ActionMode.Callback2() {
|
|
387
|
+
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
|
388
|
+
menu.add(
|
|
389
|
+
0,
|
|
390
|
+
android.R.id.copy,
|
|
391
|
+
0,
|
|
392
|
+
android.R.string.copy
|
|
393
|
+
).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
|
394
|
+
if ((view as? EditorEditText)?.isEditable != false) {
|
|
395
|
+
menu.add(
|
|
396
|
+
0,
|
|
397
|
+
android.R.id.cut,
|
|
398
|
+
1,
|
|
399
|
+
android.R.string.cut
|
|
400
|
+
).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
|
401
|
+
menu.add(
|
|
402
|
+
0,
|
|
403
|
+
android.R.id.paste,
|
|
404
|
+
2,
|
|
405
|
+
android.R.string.paste
|
|
406
|
+
).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
|
407
|
+
}
|
|
408
|
+
menu.add(0, android.R.id.selectAll, 3, android.R.string.selectAll)
|
|
409
|
+
return true
|
|
410
|
+
}
|
|
411
|
+
override fun onPrepareActionMode(mode: ActionMode, menu: Menu) = false
|
|
412
|
+
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
|
413
|
+
val handled = view.onTextContextMenuItem(item.itemId)
|
|
414
|
+
if (item.itemId != android.R.id.selectAll) mode.finish()
|
|
415
|
+
return handled
|
|
416
|
+
}
|
|
417
|
+
override fun onDestroyActionMode(mode: ActionMode) {
|
|
418
|
+
view.selectionActionMode = null
|
|
419
|
+
}
|
|
420
|
+
override fun onGetContentRect(mode: ActionMode, target: View, outRect: Rect) {
|
|
421
|
+
val layout = view.layout
|
|
422
|
+
val from = minOf(
|
|
423
|
+
view.selectionStart,
|
|
424
|
+
view.selectionEnd
|
|
425
|
+
).coerceIn(0, view.text.length)
|
|
426
|
+
val to = maxOf(
|
|
427
|
+
view.selectionStart,
|
|
428
|
+
view.selectionEnd
|
|
429
|
+
).coerceIn(from, view.text.length)
|
|
430
|
+
val bounds = android.graphics.RectF()
|
|
431
|
+
if (from != to) {
|
|
432
|
+
val path = android.graphics.Path()
|
|
433
|
+
layout.getSelectionPath(from, to, path)
|
|
434
|
+
path.computeBounds(bounds, true)
|
|
435
|
+
} else {
|
|
436
|
+
val line = layout.getLineForOffset(from)
|
|
437
|
+
val x = layout.getPrimaryHorizontal(from)
|
|
438
|
+
bounds.set(
|
|
439
|
+
x,
|
|
440
|
+
layout.editorTextLineTop(line).toFloat(),
|
|
441
|
+
x + 1,
|
|
442
|
+
layout.editorTextLineBottom(line).toFloat()
|
|
443
|
+
)
|
|
444
|
+
}
|
|
445
|
+
bounds.offset(
|
|
446
|
+
(view.totalPaddingLeft - view.scrollX).toFloat(),
|
|
447
|
+
(
|
|
448
|
+
view.totalPaddingTop -
|
|
449
|
+
view.scrollY
|
|
450
|
+
).toFloat()
|
|
451
|
+
)
|
|
452
|
+
bounds.roundOut(outRect)
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
ActionMode.TYPE_FLOATING
|
|
456
|
+
)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
|
460
|
+
if (event.isCtrlPressed) {
|
|
461
|
+
val action = when (keyCode) {
|
|
462
|
+
KeyEvent.KEYCODE_A -> android.R.id.selectAll
|
|
463
|
+
KeyEvent.KEYCODE_C -> android.R.id.copy
|
|
464
|
+
KeyEvent.KEYCODE_X -> android.R.id.cut
|
|
465
|
+
KeyEvent.KEYCODE_V -> android.R.id.paste
|
|
466
|
+
else -> 0
|
|
467
|
+
}
|
|
468
|
+
if (action != 0) return view.onTextContextMenuItem(action)
|
|
469
|
+
}
|
|
470
|
+
val content = view.editableText
|
|
471
|
+
val layout = view.layout
|
|
472
|
+
if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
|
473
|
+
if (event.isShiftPressed) {
|
|
474
|
+
if (keyCode ==
|
|
475
|
+
KeyEvent.KEYCODE_DPAD_UP
|
|
476
|
+
) {
|
|
477
|
+
Selection.extendUp(content, layout)
|
|
478
|
+
} else {
|
|
479
|
+
Selection.extendDown(content, layout)
|
|
480
|
+
}
|
|
481
|
+
} else {
|
|
482
|
+
if (keyCode ==
|
|
483
|
+
KeyEvent.KEYCODE_DPAD_UP
|
|
484
|
+
) {
|
|
485
|
+
Selection.moveUp(content, layout)
|
|
486
|
+
} else {
|
|
487
|
+
Selection.moveDown(content, layout)
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
view.bringPointIntoView(view.selectionEnd.coerceAtLeast(0))
|
|
491
|
+
return true
|
|
492
|
+
}
|
|
493
|
+
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
|
494
|
+
if (event.isShiftPressed) {
|
|
495
|
+
if (keyCode ==
|
|
496
|
+
KeyEvent.KEYCODE_DPAD_LEFT
|
|
497
|
+
) {
|
|
498
|
+
Selection.extendLeft(content, layout)
|
|
499
|
+
} else {
|
|
500
|
+
Selection.extendRight(content, layout)
|
|
501
|
+
}
|
|
502
|
+
} else {
|
|
503
|
+
if (keyCode ==
|
|
504
|
+
KeyEvent.KEYCODE_DPAD_LEFT
|
|
505
|
+
) {
|
|
506
|
+
Selection.moveLeft(content, layout)
|
|
507
|
+
} else {
|
|
508
|
+
Selection.moveRight(content, layout)
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
view.bringPointIntoView(view.selectionEnd.coerceAtLeast(0))
|
|
512
|
+
return true
|
|
513
|
+
}
|
|
514
|
+
val offset = view.selectionEnd.coerceAtLeast(0)
|
|
515
|
+
val line = layout.getLineForOffset(offset)
|
|
516
|
+
val next = when (keyCode) {
|
|
517
|
+
KeyEvent.KEYCODE_MOVE_HOME -> if (event.isCtrlPressed) 0 else layout.getLineStart(line)
|
|
518
|
+
|
|
519
|
+
KeyEvent.KEYCODE_MOVE_END -> if (event.isCtrlPressed) {
|
|
520
|
+
content.length
|
|
521
|
+
} else {
|
|
522
|
+
layout.getLineVisibleEnd(
|
|
523
|
+
line
|
|
524
|
+
)
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
else -> null
|
|
528
|
+
}
|
|
529
|
+
if (next != null) {
|
|
530
|
+
if (event.isShiftPressed) {
|
|
531
|
+
Selection.extendSelection(
|
|
532
|
+
content,
|
|
533
|
+
next
|
|
534
|
+
)
|
|
535
|
+
} else {
|
|
536
|
+
view.setSelection(next)
|
|
537
|
+
}
|
|
538
|
+
view.bringPointIntoView(next)
|
|
539
|
+
return true
|
|
540
|
+
}
|
|
541
|
+
if ((view as? EditorEditText)?.isEditable == false) return false
|
|
542
|
+
return view.keyListener?.onKeyDown(view, content, keyCode, event) == true
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
fun initializeAccessibility(info: AccessibilityNodeInfo) {
|
|
546
|
+
info.className = "android.widget.EditText"
|
|
547
|
+
info.text = view.text
|
|
548
|
+
info.isEditable = (view as? EditorEditText)?.isEditable != false
|
|
549
|
+
info.isMultiLine = true
|
|
550
|
+
info.isClickable = view.isClickable
|
|
551
|
+
if (view.isEnabled) info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK)
|
|
552
|
+
info.setTextSelection(view.selectionStart, view.selectionEnd)
|
|
553
|
+
info.movementGranularities =
|
|
554
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER or
|
|
555
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD or
|
|
556
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE or
|
|
557
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
|
|
558
|
+
info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION)
|
|
559
|
+
info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY)
|
|
560
|
+
info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY)
|
|
561
|
+
info.addAction(AccessibilityNodeInfo.ACTION_COPY)
|
|
562
|
+
if (info.isEditable) {
|
|
563
|
+
info.addAction(AccessibilityNodeInfo.ACTION_SET_TEXT)
|
|
564
|
+
info.addAction(AccessibilityNodeInfo.ACTION_CUT)
|
|
565
|
+
info.addAction(AccessibilityNodeInfo.ACTION_PASTE)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
fun performAccessibilityAction(action: Int, arguments: Bundle?): Boolean {
|
|
570
|
+
when (action) {
|
|
571
|
+
AccessibilityNodeInfo.ACTION_CLICK -> {
|
|
572
|
+
view.requestFocus()
|
|
573
|
+
showKeyboard()
|
|
574
|
+
view.performClick()
|
|
575
|
+
return true
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
AccessibilityNodeInfo.ACTION_SET_SELECTION -> {
|
|
579
|
+
val start =
|
|
580
|
+
arguments?.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, -1)
|
|
581
|
+
?: -1
|
|
582
|
+
val end =
|
|
583
|
+
arguments?.getInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, -1)
|
|
584
|
+
?: -1
|
|
585
|
+
if (start !in 0..view.text.length || end !in 0..view.text.length) return false
|
|
586
|
+
view.setSelection(start, end)
|
|
587
|
+
return true
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
AccessibilityNodeInfo.ACTION_SET_TEXT -> {
|
|
591
|
+
val replacement =
|
|
592
|
+
arguments?.getCharSequence(
|
|
593
|
+
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
|
|
594
|
+
)
|
|
595
|
+
?: return false
|
|
596
|
+
view.editableText.replace(0, view.text.length, replacement)
|
|
597
|
+
view.setSelection(view.text.length)
|
|
598
|
+
return true
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
AccessibilityNodeInfo.ACTION_COPY -> return view.onTextContextMenuItem(
|
|
602
|
+
android.R.id.copy
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
AccessibilityNodeInfo.ACTION_CUT -> return view.onTextContextMenuItem(android.R.id.cut)
|
|
606
|
+
|
|
607
|
+
AccessibilityNodeInfo.ACTION_PASTE -> return view.onTextContextMenuItem(
|
|
608
|
+
android.R.id.paste
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY,
|
|
612
|
+
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY -> {
|
|
613
|
+
val forward = action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY
|
|
614
|
+
val text = view.text.toString()
|
|
615
|
+
val offset = view.selectionEnd.coerceAtLeast(0)
|
|
616
|
+
val granularity =
|
|
617
|
+
arguments?.getInt(
|
|
618
|
+
AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
|
|
619
|
+
)
|
|
620
|
+
?: return false
|
|
621
|
+
val next = when (granularity) {
|
|
622
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER,
|
|
623
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD -> {
|
|
624
|
+
val iterator = (
|
|
625
|
+
if (granularity ==
|
|
626
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
|
|
627
|
+
) {
|
|
628
|
+
BreakIterator.getCharacterInstance()
|
|
629
|
+
} else {
|
|
630
|
+
BreakIterator.getWordInstance()
|
|
631
|
+
}
|
|
632
|
+
).apply { setText(text) }
|
|
633
|
+
var next = if (forward) {
|
|
634
|
+
iterator.following(
|
|
635
|
+
offset
|
|
636
|
+
)
|
|
637
|
+
} else {
|
|
638
|
+
iterator.preceding(offset)
|
|
639
|
+
}
|
|
640
|
+
if (granularity == AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD) {
|
|
641
|
+
while (next != BreakIterator.DONE &&
|
|
642
|
+
text.substring(minOf(offset, next), maxOf(offset, next)).isBlank()
|
|
643
|
+
) {
|
|
644
|
+
next =
|
|
645
|
+
if (forward) {
|
|
646
|
+
iterator.following(
|
|
647
|
+
next
|
|
648
|
+
)
|
|
649
|
+
} else {
|
|
650
|
+
iterator.preceding(next)
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
next
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE -> {
|
|
658
|
+
val line = view.layout.getLineForOffset(offset) + if (forward) 1 else -1
|
|
659
|
+
if (line in
|
|
660
|
+
0 until view.layout.lineCount
|
|
661
|
+
) {
|
|
662
|
+
view.layout.getLineStart(line)
|
|
663
|
+
} else {
|
|
664
|
+
BreakIterator.DONE
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH -> if (forward) {
|
|
669
|
+
text.indexOf('\n', offset).let {
|
|
670
|
+
if (it <
|
|
671
|
+
0
|
|
672
|
+
) {
|
|
673
|
+
text.length
|
|
674
|
+
} else {
|
|
675
|
+
it + 1
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
} else {
|
|
679
|
+
text.lastIndexOf('\n', (offset - 2).coerceAtLeast(0)) +
|
|
680
|
+
1
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
else -> return false
|
|
684
|
+
}
|
|
685
|
+
if (next == BreakIterator.DONE || next == offset) return false
|
|
686
|
+
if (arguments.getBoolean(
|
|
687
|
+
AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
|
|
688
|
+
)
|
|
689
|
+
) {
|
|
690
|
+
view.extendSelection(next)
|
|
691
|
+
} else {
|
|
692
|
+
view.setSelection(next)
|
|
693
|
+
}
|
|
694
|
+
view.bringPointIntoView(next)
|
|
695
|
+
val event = AccessibilityEvent.obtain(
|
|
696
|
+
AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
|
|
697
|
+
)
|
|
698
|
+
event.action = action
|
|
699
|
+
event.movementGranularity = granularity
|
|
700
|
+
event.fromIndex = minOf(offset, next)
|
|
701
|
+
event.toIndex = maxOf(offset, next)
|
|
702
|
+
view.sendSurfaceAccessibilityEvent(event)
|
|
703
|
+
return true
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return false
|
|
707
|
+
}
|
|
708
|
+
}
|