@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,712 @@
|
|
|
1
|
+
package com.apollohg.editor
|
|
2
|
+
|
|
3
|
+
import android.content.ClipData
|
|
4
|
+
import android.content.ClipboardManager
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.res.ColorStateList
|
|
7
|
+
import android.graphics.Canvas
|
|
8
|
+
import android.graphics.Color
|
|
9
|
+
import android.graphics.Paint
|
|
10
|
+
import android.graphics.Path
|
|
11
|
+
import android.graphics.Rect
|
|
12
|
+
import android.graphics.Typeface
|
|
13
|
+
import android.graphics.drawable.Drawable
|
|
14
|
+
import android.os.Bundle
|
|
15
|
+
import android.text.Editable
|
|
16
|
+
import android.text.InputType
|
|
17
|
+
import android.text.Layout
|
|
18
|
+
import android.text.NoCopySpan
|
|
19
|
+
import android.text.Selection
|
|
20
|
+
import android.text.SpanWatcher
|
|
21
|
+
import android.text.Spannable
|
|
22
|
+
import android.text.SpannableStringBuilder
|
|
23
|
+
import android.text.Spanned
|
|
24
|
+
import android.text.TextPaint
|
|
25
|
+
import android.text.TextUtils
|
|
26
|
+
import android.text.TextWatcher
|
|
27
|
+
import android.text.method.KeyListener
|
|
28
|
+
import android.text.method.TextKeyListener
|
|
29
|
+
import android.util.AttributeSet
|
|
30
|
+
import android.util.TypedValue
|
|
31
|
+
import android.view.ActionMode
|
|
32
|
+
import android.view.KeyEvent
|
|
33
|
+
import android.view.MotionEvent
|
|
34
|
+
import android.view.View
|
|
35
|
+
import android.view.accessibility.AccessibilityEvent
|
|
36
|
+
import android.view.accessibility.AccessibilityNodeInfo
|
|
37
|
+
import android.view.inputmethod.EditorInfo
|
|
38
|
+
import android.view.inputmethod.InputConnection
|
|
39
|
+
import android.view.inputmethod.InputMethodManager
|
|
40
|
+
import android.widget.TextView.BufferType
|
|
41
|
+
|
|
42
|
+
open class EditorTextSurface @JvmOverloads constructor(
|
|
43
|
+
context: Context,
|
|
44
|
+
attrs: AttributeSet? = null,
|
|
45
|
+
defStyleAttr: Int = 0
|
|
46
|
+
) : View(context, attrs, defStyleAttr) {
|
|
47
|
+
val paint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
48
|
+
density = resources.displayMetrics.density
|
|
49
|
+
textSize =
|
|
50
|
+
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16f, resources.displayMetrics)
|
|
51
|
+
color = Color.BLACK
|
|
52
|
+
}
|
|
53
|
+
private var buffer = SpannableStringBuilder()
|
|
54
|
+
private val watchers = mutableListOf<TextWatcher>()
|
|
55
|
+
private var cachedLayout: EditorDocumentLayout? = null
|
|
56
|
+
private var layoutDirty = true
|
|
57
|
+
private var layoutWidth = -1
|
|
58
|
+
private var textChangeDepth = 0
|
|
59
|
+
private var batchDepth = 0
|
|
60
|
+
private var pendingInputState = false
|
|
61
|
+
private var textBeforeAccessibilityChange: CharSequence = ""
|
|
62
|
+
private var lastSelectionStart = -1
|
|
63
|
+
private var lastSelectionEnd = -1
|
|
64
|
+
private var replacingBuffer = false
|
|
65
|
+
private var baseInputConnection: EditorSurfaceInputConnection? = null
|
|
66
|
+
private var monitorCursor = false
|
|
67
|
+
private var cursorPublicationPosted = false
|
|
68
|
+
internal var documentLayoutBuildCount = 0
|
|
69
|
+
private set
|
|
70
|
+
private val publishCursor = Runnable {
|
|
71
|
+
cursorPublicationPosted = false
|
|
72
|
+
if (monitorCursor) publishSurfaceCursor()
|
|
73
|
+
}
|
|
74
|
+
private var blinkVisible = true
|
|
75
|
+
internal var selectionActionMode: ActionMode? = null
|
|
76
|
+
internal val interaction by lazy { EditorTextSurfaceInteraction(this, attrs, defStyleAttr) }
|
|
77
|
+
private val dragDrop by lazy { EditorTextSurfaceDragDrop(this) }
|
|
78
|
+
private val selectionPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
|
79
|
+
private val selectionPath = Path()
|
|
80
|
+
|
|
81
|
+
var text: Editable
|
|
82
|
+
get() = buffer
|
|
83
|
+
set(value) {
|
|
84
|
+
setText(value as CharSequence)
|
|
85
|
+
}
|
|
86
|
+
val editableText: Editable get() = buffer
|
|
87
|
+
val selectionStart: Int get() = Selection.getSelectionStart(buffer)
|
|
88
|
+
val selectionEnd: Int get() = Selection.getSelectionEnd(buffer)
|
|
89
|
+
val layout: Layout
|
|
90
|
+
get() {
|
|
91
|
+
val available = (
|
|
92
|
+
(
|
|
93
|
+
if (measuredWidth >
|
|
94
|
+
0
|
|
95
|
+
) {
|
|
96
|
+
measuredWidth
|
|
97
|
+
} else {
|
|
98
|
+
width
|
|
99
|
+
}
|
|
100
|
+
) - compoundPaddingLeft -
|
|
101
|
+
compoundPaddingRight
|
|
102
|
+
).coerceAtLeast(1)
|
|
103
|
+
if (layoutDirty || layoutWidth != available || cachedLayout == null) {
|
|
104
|
+
documentLayoutBuildCount++
|
|
105
|
+
cachedLayout =
|
|
106
|
+
EditorDocumentLayout(
|
|
107
|
+
buffer,
|
|
108
|
+
paint,
|
|
109
|
+
available,
|
|
110
|
+
includeFontPadding,
|
|
111
|
+
lineSpacingMultiplier,
|
|
112
|
+
lineSpacingExtra,
|
|
113
|
+
cachedLayout
|
|
114
|
+
)
|
|
115
|
+
layoutWidth = available
|
|
116
|
+
layoutDirty = false
|
|
117
|
+
}
|
|
118
|
+
return requireNotNull(cachedLayout)
|
|
119
|
+
}
|
|
120
|
+
var textSize: Float
|
|
121
|
+
get() = paint.textSize
|
|
122
|
+
set(value) {
|
|
123
|
+
paint.textSize = value
|
|
124
|
+
invalidateTextLayout()
|
|
125
|
+
}
|
|
126
|
+
var typeface: Typeface?
|
|
127
|
+
get() = paint.typeface
|
|
128
|
+
set(value) {
|
|
129
|
+
paint.typeface = value
|
|
130
|
+
invalidateTextLayout()
|
|
131
|
+
}
|
|
132
|
+
var letterSpacing: Float
|
|
133
|
+
get() = paint.letterSpacing
|
|
134
|
+
set(value) {
|
|
135
|
+
paint.letterSpacing = value
|
|
136
|
+
invalidateTextLayout()
|
|
137
|
+
}
|
|
138
|
+
var inputType: Int = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
|
139
|
+
var imeOptions: Int = EditorInfo.IME_FLAG_NO_EXTRACT_UI or EditorInfo.IME_FLAG_NO_FULLSCREEN
|
|
140
|
+
var privateImeOptions: String? = null
|
|
141
|
+
var keyListener: KeyListener? = TextKeyListener.getInstance()
|
|
142
|
+
var gravity: Int = android.view.Gravity.TOP or android.view.Gravity.START
|
|
143
|
+
var linksClickable = false
|
|
144
|
+
var showSoftInputOnFocus = true
|
|
145
|
+
var includeFontPadding = false
|
|
146
|
+
set(value) {
|
|
147
|
+
if (field != value) {
|
|
148
|
+
field = value
|
|
149
|
+
invalidateTextLayout()
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
var isCursorVisible = true
|
|
153
|
+
set(value) {
|
|
154
|
+
field = value
|
|
155
|
+
invalidate()
|
|
156
|
+
}
|
|
157
|
+
var textCursorDrawable: Drawable? = null
|
|
158
|
+
var highlightColor: Int = context.obtainStyledAttributes(
|
|
159
|
+
attrs,
|
|
160
|
+
intArrayOf(android.R.attr.textColorHighlight),
|
|
161
|
+
defStyleAttr,
|
|
162
|
+
0
|
|
163
|
+
).let { attributes ->
|
|
164
|
+
try {
|
|
165
|
+
attributes.getColor(0, 0x6633B5E5)
|
|
166
|
+
} finally {
|
|
167
|
+
attributes.recycle()
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
set(value) {
|
|
171
|
+
field = value
|
|
172
|
+
invalidate()
|
|
173
|
+
}
|
|
174
|
+
var textColors: ColorStateList = ColorStateList.valueOf(Color.BLACK)
|
|
175
|
+
private set
|
|
176
|
+
var hintTextColors: ColorStateList = ColorStateList.valueOf(Color.GRAY)
|
|
177
|
+
private set
|
|
178
|
+
val currentTextColor get() = textColors.getColorForState(drawableState, textColors.defaultColor)
|
|
179
|
+
val currentHintTextColor get() = hintTextColors.getColorForState(
|
|
180
|
+
drawableState,
|
|
181
|
+
hintTextColors.defaultColor
|
|
182
|
+
)
|
|
183
|
+
var hint: CharSequence? = null
|
|
184
|
+
var minHeight: Int
|
|
185
|
+
get() = minimumHeight
|
|
186
|
+
set(value) {
|
|
187
|
+
minimumHeight = value
|
|
188
|
+
}
|
|
189
|
+
var minLines = 1
|
|
190
|
+
set(value) {
|
|
191
|
+
field = value.coerceAtLeast(0)
|
|
192
|
+
requestLayout()
|
|
193
|
+
}
|
|
194
|
+
var maxLines = Int.MAX_VALUE
|
|
195
|
+
set(value) {
|
|
196
|
+
field = value.coerceAtLeast(1)
|
|
197
|
+
requestLayout()
|
|
198
|
+
}
|
|
199
|
+
var lineSpacingMultiplier = 1f
|
|
200
|
+
private set
|
|
201
|
+
var lineSpacingExtra = 0f
|
|
202
|
+
private set
|
|
203
|
+
val lineHeight get() = (
|
|
204
|
+
paint.fontMetricsInt.run { descent - ascent } * lineSpacingMultiplier +
|
|
205
|
+
lineSpacingExtra
|
|
206
|
+
).toInt().coerceAtLeast(1)
|
|
207
|
+
val lineCount get() = layout.lineCount
|
|
208
|
+
val compoundPaddingLeft get() = paddingLeft
|
|
209
|
+
val compoundPaddingRight get() = paddingRight
|
|
210
|
+
val compoundPaddingTop get() = paddingTop
|
|
211
|
+
val compoundPaddingBottom get() = paddingBottom
|
|
212
|
+
val totalPaddingLeft get() = paddingLeft
|
|
213
|
+
val totalPaddingRight get() = paddingRight
|
|
214
|
+
val totalPaddingTop get() = paddingTop
|
|
215
|
+
val totalPaddingBottom get() = paddingBottom
|
|
216
|
+
val extendedPaddingTop get() = paddingTop
|
|
217
|
+
val extendedPaddingBottom get() = paddingBottom
|
|
218
|
+
|
|
219
|
+
private val changeWatcher = object : TextWatcher, SpanWatcher, NoCopySpan {
|
|
220
|
+
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
|
221
|
+
textBeforeAccessibilityChange = s?.toString() ?: ""
|
|
222
|
+
textChangeDepth++
|
|
223
|
+
watchers.toList().forEach { it.beforeTextChanged(s, start, count, after) }
|
|
224
|
+
}
|
|
225
|
+
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
|
226
|
+
invalidateTextLayout()
|
|
227
|
+
watchers.toList().forEach { it.onTextChanged(s, start, before, count) }
|
|
228
|
+
val event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)
|
|
229
|
+
event.beforeText = textBeforeAccessibilityChange
|
|
230
|
+
event.fromIndex = start
|
|
231
|
+
event.removedCount = before
|
|
232
|
+
event.addedCount = count
|
|
233
|
+
sendSurfaceAccessibilityEvent(event)
|
|
234
|
+
}
|
|
235
|
+
override fun afterTextChanged(s: Editable?) {
|
|
236
|
+
try {
|
|
237
|
+
watchers.toList().forEach { it.afterTextChanged(s) }
|
|
238
|
+
} finally {
|
|
239
|
+
textChangeDepth = (textChangeDepth - 1).coerceAtLeast(0)
|
|
240
|
+
notifySelectionChanged()
|
|
241
|
+
notifyInputStateChanged()
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
override fun onSpanAdded(text: Spannable?, what: Any?, start: Int, end: Int) =
|
|
245
|
+
spanChanged(text, what)
|
|
246
|
+
override fun onSpanRemoved(text: Spannable?, what: Any?, start: Int, end: Int) =
|
|
247
|
+
spanChanged(text, what)
|
|
248
|
+
override fun onSpanChanged(
|
|
249
|
+
text: Spannable?,
|
|
250
|
+
what: Any?,
|
|
251
|
+
oldStart: Int,
|
|
252
|
+
oldEnd: Int,
|
|
253
|
+
newStart: Int,
|
|
254
|
+
newEnd: Int
|
|
255
|
+
) = spanChanged(text, what)
|
|
256
|
+
private fun spanChanged(text: Spannable?, what: Any?) {
|
|
257
|
+
if (what === this || replacingBuffer) return
|
|
258
|
+
if (what === Selection.SELECTION_START || what === Selection.SELECTION_END) {
|
|
259
|
+
if ((text?.getSpanFlags(what) ?: 0) and Spanned.SPAN_INTERMEDIATE ==
|
|
260
|
+
0
|
|
261
|
+
) {
|
|
262
|
+
notifySelectionChanged()
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
invalidateTextLayout()
|
|
266
|
+
notifyInputStateChanged()
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private val blink = object : Runnable {
|
|
272
|
+
override fun run() {
|
|
273
|
+
blinkVisible = !blinkVisible
|
|
274
|
+
if (hasFocus() && isCursorVisible) invalidate()
|
|
275
|
+
if (isAttachedToWindow && hasFocus()) postDelayed(this, 500)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
init {
|
|
280
|
+
isFocusable = true
|
|
281
|
+
isFocusableInTouchMode = true
|
|
282
|
+
isClickable = true
|
|
283
|
+
importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_YES
|
|
284
|
+
Selection.setSelection(buffer, 0)
|
|
285
|
+
lastSelectionStart = 0
|
|
286
|
+
lastSelectionEnd = 0
|
|
287
|
+
buffer.setSpan(changeWatcher, 0, 0, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@JvmOverloads
|
|
291
|
+
fun setText(value: CharSequence?, type: BufferType = BufferType.EDITABLE) {
|
|
292
|
+
val previousText = buffer.toString()
|
|
293
|
+
val next = SpannableStringBuilder(value ?: "")
|
|
294
|
+
watchers.toList().forEach { it.beforeTextChanged(buffer, 0, buffer.length, next.length) }
|
|
295
|
+
val before = buffer.length
|
|
296
|
+
replacingBuffer = true
|
|
297
|
+
try {
|
|
298
|
+
buffer.removeSpan(changeWatcher)
|
|
299
|
+
buffer = next
|
|
300
|
+
buffer.setSpan(changeWatcher, 0, buffer.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
|
|
301
|
+
if (Selection.getSelectionStart(buffer) < 0) Selection.setSelection(buffer, 0)
|
|
302
|
+
} finally {
|
|
303
|
+
replacingBuffer = false
|
|
304
|
+
}
|
|
305
|
+
invalidateTextLayout()
|
|
306
|
+
textChangeDepth++
|
|
307
|
+
try {
|
|
308
|
+
watchers.toList().forEach { it.onTextChanged(buffer, 0, before, buffer.length) }
|
|
309
|
+
watchers.toList().forEach { it.afterTextChanged(buffer) }
|
|
310
|
+
} finally {
|
|
311
|
+
textChangeDepth--
|
|
312
|
+
}
|
|
313
|
+
if (previousText != buffer.toString()) {
|
|
314
|
+
val event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)
|
|
315
|
+
event.beforeText = previousText
|
|
316
|
+
event.fromIndex = 0
|
|
317
|
+
event.removedCount = previousText.length
|
|
318
|
+
event.addedCount = buffer.length
|
|
319
|
+
sendSurfaceAccessibilityEvent(event)
|
|
320
|
+
}
|
|
321
|
+
notifySelectionChanged()
|
|
322
|
+
notifyInputStateChanged()
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
fun length() = buffer.length
|
|
326
|
+
fun setSelection(index: Int) = setSelection(index, index)
|
|
327
|
+
fun setSelection(start: Int, end: Int) {
|
|
328
|
+
require(start in 0..buffer.length && end in 0..buffer.length)
|
|
329
|
+
Selection.setSelection(buffer, start, end)
|
|
330
|
+
}
|
|
331
|
+
fun selectAll() = setSelection(0, buffer.length)
|
|
332
|
+
fun extendSelection(index: Int) = Selection.extendSelection(buffer, index)
|
|
333
|
+
fun addTextChangedListener(watcher: TextWatcher) {
|
|
334
|
+
if (watcher !in
|
|
335
|
+
watchers
|
|
336
|
+
) {
|
|
337
|
+
watchers += watcher
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
fun removeTextChangedListener(watcher: TextWatcher) {
|
|
341
|
+
watchers -= watcher
|
|
342
|
+
}
|
|
343
|
+
fun setRawInputType(value: Int) {
|
|
344
|
+
inputType = value
|
|
345
|
+
}
|
|
346
|
+
fun setTextColor(value: Int) {
|
|
347
|
+
textColors = ColorStateList.valueOf(value)
|
|
348
|
+
paint.color = value
|
|
349
|
+
invalidateTextLayout()
|
|
350
|
+
}
|
|
351
|
+
fun setTextColor(value: ColorStateList) {
|
|
352
|
+
textColors = value
|
|
353
|
+
paint.color = currentTextColor
|
|
354
|
+
invalidateTextLayout()
|
|
355
|
+
}
|
|
356
|
+
fun setHintTextColor(value: Int) {
|
|
357
|
+
hintTextColors = ColorStateList.valueOf(value)
|
|
358
|
+
invalidate()
|
|
359
|
+
}
|
|
360
|
+
fun setTextSize(unit: Int, value: Float) {
|
|
361
|
+
textSize =
|
|
362
|
+
TypedValue.applyDimension(unit, value, resources.displayMetrics)
|
|
363
|
+
}
|
|
364
|
+
fun setTypeface(value: Typeface?, style: Int) {
|
|
365
|
+
typeface = Typeface.create(value, style)
|
|
366
|
+
}
|
|
367
|
+
fun setLineSpacing(add: Float, mult: Float) {
|
|
368
|
+
lineSpacingExtra = add
|
|
369
|
+
lineSpacingMultiplier =
|
|
370
|
+
mult
|
|
371
|
+
invalidateTextLayout()
|
|
372
|
+
}
|
|
373
|
+
fun setCompoundDrawablesRelativeWithIntrinsicBounds(
|
|
374
|
+
start: Drawable?,
|
|
375
|
+
top: Drawable?,
|
|
376
|
+
end: Drawable?,
|
|
377
|
+
bottom: Drawable?
|
|
378
|
+
) {
|
|
379
|
+
require(start == null && top == null && end == null && bottom == null) {
|
|
380
|
+
"Editor content insets own text padding."
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
internal fun invalidateTextLayout() {
|
|
385
|
+
layoutDirty = true
|
|
386
|
+
requestLayout()
|
|
387
|
+
invalidate()
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
private fun notifySelectionChanged() {
|
|
391
|
+
if (replacingBuffer || textChangeDepth > 0) return
|
|
392
|
+
val start = selectionStart
|
|
393
|
+
val end = selectionEnd
|
|
394
|
+
if (start == lastSelectionStart && end == lastSelectionEnd) return
|
|
395
|
+
lastSelectionStart = start
|
|
396
|
+
lastSelectionEnd = end
|
|
397
|
+
blinkVisible = true
|
|
398
|
+
onSelectionChanged(start, end)
|
|
399
|
+
interaction.selectionChanged()
|
|
400
|
+
notifyInputStateChanged()
|
|
401
|
+
invalidate()
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
protected open fun onSelectionChanged(selStart: Int, selEnd: Int) = Unit
|
|
405
|
+
protected open fun onSurfaceInputStateChanged() = Unit
|
|
406
|
+
|
|
407
|
+
fun beginBatchEdit(): Boolean {
|
|
408
|
+
batchDepth++
|
|
409
|
+
return true
|
|
410
|
+
}
|
|
411
|
+
fun endBatchEdit(): Boolean {
|
|
412
|
+
if (batchDepth == 0) return false
|
|
413
|
+
batchDepth--
|
|
414
|
+
if (batchDepth == 0 && pendingInputState) notifyInputStateChanged()
|
|
415
|
+
return batchDepth > 0
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
internal fun notifyInputStateChanged() {
|
|
419
|
+
if (batchDepth > 0 || textChangeDepth > 0 ||
|
|
420
|
+
replacingBuffer
|
|
421
|
+
) {
|
|
422
|
+
pendingInputState = true
|
|
423
|
+
return
|
|
424
|
+
}
|
|
425
|
+
pendingInputState = false
|
|
426
|
+
onSurfaceInputStateChanged()
|
|
427
|
+
scheduleSurfaceCursorPublication()
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
internal fun requestSurfaceCursorUpdates(mode: Int): Boolean {
|
|
431
|
+
if (mode and
|
|
432
|
+
(InputConnection.CURSOR_UPDATE_IMMEDIATE or InputConnection.CURSOR_UPDATE_MONITOR)
|
|
433
|
+
.inv() !=
|
|
434
|
+
0
|
|
435
|
+
) {
|
|
436
|
+
return false
|
|
437
|
+
}
|
|
438
|
+
monitorCursor = mode and InputConnection.CURSOR_UPDATE_MONITOR != 0
|
|
439
|
+
if (mode and InputConnection.CURSOR_UPDATE_IMMEDIATE != 0) publishSurfaceCursor()
|
|
440
|
+
return true
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
internal fun surfaceViewportChanged() {
|
|
444
|
+
scheduleSurfaceCursorPublication()
|
|
445
|
+
interaction.viewportChanged()
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
private fun scheduleSurfaceCursorPublication() {
|
|
449
|
+
if (!monitorCursor || cursorPublicationPosted || !isAttachedToWindow) return
|
|
450
|
+
cursorPublicationPosted = true
|
|
451
|
+
postOnAnimation(publishCursor)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
private fun publishSurfaceCursor() {
|
|
455
|
+
if (!isAttachedToWindow || !hasFocus()) return
|
|
456
|
+
val editor = this as? EditorEditText ?: return
|
|
457
|
+
val info = editor.buildSurfaceCursorAnchorInfo()
|
|
458
|
+
inputMethod.updateCursorAnchorInfo(this, info)
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
internal val inputMethod get() = context.getSystemService(
|
|
462
|
+
Context.INPUT_METHOD_SERVICE
|
|
463
|
+
) as InputMethodManager
|
|
464
|
+
|
|
465
|
+
override fun onCheckIsTextEditor() = true
|
|
466
|
+
|
|
467
|
+
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? {
|
|
468
|
+
if (!isEnabled) return null
|
|
469
|
+
baseInputConnection?.closeConnection()
|
|
470
|
+
monitorCursor = false
|
|
471
|
+
outAttrs.inputType = inputType
|
|
472
|
+
outAttrs.imeOptions = imeOptions
|
|
473
|
+
outAttrs.privateImeOptions = privateImeOptions
|
|
474
|
+
outAttrs.initialSelStart = selectionStart.coerceAtLeast(0)
|
|
475
|
+
outAttrs.initialSelEnd = selectionEnd.coerceAtLeast(0)
|
|
476
|
+
outAttrs.initialCapsMode =
|
|
477
|
+
TextUtils.getCapsMode(buffer, outAttrs.initialSelStart, inputType)
|
|
478
|
+
outAttrs.packageName = context.packageName
|
|
479
|
+
outAttrs.fieldId = id
|
|
480
|
+
androidx.core.view.inputmethod.EditorInfoCompat.setInitialSurroundingText(outAttrs, buffer)
|
|
481
|
+
return EditorSurfaceInputConnection(this).also { baseInputConnection = it }
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
485
|
+
val measured = resolveSize(suggestedMinimumWidth.coerceAtLeast(1), widthMeasureSpec)
|
|
486
|
+
val available = (measured - compoundPaddingLeft - compoundPaddingRight).coerceAtLeast(1)
|
|
487
|
+
if (layoutDirty || layoutWidth != available || cachedLayout == null) {
|
|
488
|
+
documentLayoutBuildCount++
|
|
489
|
+
cachedLayout =
|
|
490
|
+
EditorDocumentLayout(
|
|
491
|
+
buffer,
|
|
492
|
+
paint,
|
|
493
|
+
available,
|
|
494
|
+
includeFontPadding,
|
|
495
|
+
lineSpacingMultiplier,
|
|
496
|
+
lineSpacingExtra,
|
|
497
|
+
cachedLayout
|
|
498
|
+
)
|
|
499
|
+
layoutDirty = false
|
|
500
|
+
layoutWidth = available
|
|
501
|
+
}
|
|
502
|
+
val content = requireNotNull(cachedLayout)
|
|
503
|
+
val textHeight = if (content.lineCount >
|
|
504
|
+
maxLines
|
|
505
|
+
) {
|
|
506
|
+
content.getLineTop(maxLines)
|
|
507
|
+
} else {
|
|
508
|
+
content.height
|
|
509
|
+
}
|
|
510
|
+
val desired =
|
|
511
|
+
maxOf(textHeight, minLines * lineHeight) + compoundPaddingTop + compoundPaddingBottom
|
|
512
|
+
setMeasuredDimension(
|
|
513
|
+
measured,
|
|
514
|
+
resolveSize(maxOf(desired, suggestedMinimumHeight), heightMeasureSpec)
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
override fun onDraw(canvas: Canvas) {
|
|
519
|
+
super.onDraw(canvas)
|
|
520
|
+
val layout = layout
|
|
521
|
+
val save = canvas.save()
|
|
522
|
+
canvas.translate(compoundPaddingLeft.toFloat(), compoundPaddingTop.toFloat())
|
|
523
|
+
val start = selectionStart
|
|
524
|
+
val end = selectionEnd
|
|
525
|
+
val selection = if (start >= 0 && end >= 0 && start != end && hasFocus()) {
|
|
526
|
+
selectionPath.reset()
|
|
527
|
+
layout.getSelectionPath(minOf(start, end), maxOf(start, end), selectionPath)
|
|
528
|
+
selectionPaint.color = highlightColor
|
|
529
|
+
selectionPath
|
|
530
|
+
} else {
|
|
531
|
+
null
|
|
532
|
+
}
|
|
533
|
+
layout.draw(canvas, selection, selectionPaint, 0)
|
|
534
|
+
if (isCursorVisible && blinkVisible && start >= 0 && start == end && hasFocus() &&
|
|
535
|
+
hasWindowFocus()
|
|
536
|
+
) {
|
|
537
|
+
val editor = this as? EditorEditText
|
|
538
|
+
editor?.nativeCursorDrawRect()?.let { rect ->
|
|
539
|
+
selectionPaint.color = editor.caretColor
|
|
540
|
+
canvas.drawRect(rect, selectionPaint)
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
interaction.drawHandles(canvas)
|
|
544
|
+
canvas.restoreToCount(save)
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
fun getOffsetForPosition(x: Float, y: Float): Int {
|
|
548
|
+
val layout = layout
|
|
549
|
+
val line = layout.getLineForVertical((y + scrollY - totalPaddingTop).toInt())
|
|
550
|
+
return PositionBridge.snapToGraphemeBoundary(
|
|
551
|
+
layout.getOffsetForHorizontal(
|
|
552
|
+
line,
|
|
553
|
+
x + scrollX - totalPaddingLeft
|
|
554
|
+
),
|
|
555
|
+
buffer.toString()
|
|
556
|
+
)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
fun bringPointIntoView(offset: Int): Boolean {
|
|
560
|
+
val layout = layout
|
|
561
|
+
val safe = offset.coerceIn(0, buffer.length)
|
|
562
|
+
val line = layout.getLineForOffset(safe)
|
|
563
|
+
val x = layout.getPrimaryHorizontal(safe).toInt() + totalPaddingLeft
|
|
564
|
+
val rect = Rect(
|
|
565
|
+
x,
|
|
566
|
+
layout.editorTextLineTop(line) + totalPaddingTop,
|
|
567
|
+
x + 2,
|
|
568
|
+
layout.editorTextLineBottom(line) + totalPaddingTop
|
|
569
|
+
)
|
|
570
|
+
var scrolled = false
|
|
571
|
+
if (!interaction.hasScrollContainer() && height > 0) {
|
|
572
|
+
val limit =
|
|
573
|
+
(layout.height + totalPaddingTop + totalPaddingBottom - height).coerceAtLeast(
|
|
574
|
+
0
|
|
575
|
+
)
|
|
576
|
+
val next = when {
|
|
577
|
+
rect.top < scrollY + totalPaddingTop -> rect.top - totalPaddingTop
|
|
578
|
+
|
|
579
|
+
rect.bottom > scrollY + height - totalPaddingBottom ->
|
|
580
|
+
rect.bottom - height +
|
|
581
|
+
totalPaddingBottom
|
|
582
|
+
|
|
583
|
+
else -> scrollY
|
|
584
|
+
}.coerceIn(0, limit)
|
|
585
|
+
scrolled = next != scrollY
|
|
586
|
+
if (scrolled) scrollTo(scrollX, next)
|
|
587
|
+
}
|
|
588
|
+
return requestRectangleOnScreen(rect) || scrolled
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
override fun onDragEvent(event: android.view.DragEvent) = dragDrop.onDragEvent(event)
|
|
592
|
+
override fun onTouchEvent(event: MotionEvent) = interaction.onTouchEvent(event)
|
|
593
|
+
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean =
|
|
594
|
+
interaction.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event)
|
|
595
|
+
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean =
|
|
596
|
+
keyListener?.onKeyUp(this, buffer, keyCode, event) == true || super.onKeyUp(keyCode, event)
|
|
597
|
+
override fun performClick(): Boolean {
|
|
598
|
+
super.performClick()
|
|
599
|
+
return true
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
open fun onTextContextMenuItem(id: Int): Boolean = when (id) {
|
|
603
|
+
android.R.id.selectAll -> {
|
|
604
|
+
selectAll()
|
|
605
|
+
true
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
android.R.id.copy, android.R.id.cut -> {
|
|
609
|
+
val from = minOf(selectionStart, selectionEnd).coerceAtLeast(0)
|
|
610
|
+
val to = maxOf(selectionStart, selectionEnd).coerceAtLeast(from)
|
|
611
|
+
(
|
|
612
|
+
context.getSystemService(
|
|
613
|
+
Context.CLIPBOARD_SERVICE
|
|
614
|
+
) as ClipboardManager
|
|
615
|
+
).setPrimaryClip(
|
|
616
|
+
ClipData.newPlainText("", buffer.subSequence(from, to))
|
|
617
|
+
)
|
|
618
|
+
if (id == android.R.id.cut) buffer.delete(from, to)
|
|
619
|
+
true
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
android.R.id.paste, android.R.id.pasteAsPlainText -> {
|
|
623
|
+
val clip = (
|
|
624
|
+
context.getSystemService(
|
|
625
|
+
Context.CLIPBOARD_SERVICE
|
|
626
|
+
) as ClipboardManager
|
|
627
|
+
).primaryClip
|
|
628
|
+
val value = if (clip != null &&
|
|
629
|
+
clip.itemCount > 0
|
|
630
|
+
) {
|
|
631
|
+
clip.getItemAt(0).coerceToText(context)
|
|
632
|
+
} else {
|
|
633
|
+
null
|
|
634
|
+
}
|
|
635
|
+
if (value == null) {
|
|
636
|
+
false
|
|
637
|
+
} else {
|
|
638
|
+
val from = minOf(selectionStart, selectionEnd).coerceAtLeast(0)
|
|
639
|
+
val to = maxOf(selectionStart, selectionEnd).coerceAtLeast(from)
|
|
640
|
+
buffer.replace(from, to, value)
|
|
641
|
+
setSelection(from + value.length)
|
|
642
|
+
true
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
else -> false
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
internal fun sendSurfaceAccessibilityEvent(event: AccessibilityEvent) {
|
|
650
|
+
val manager = context.getSystemService(
|
|
651
|
+
Context.ACCESSIBILITY_SERVICE
|
|
652
|
+
) as android.view.accessibility.AccessibilityManager
|
|
653
|
+
if (manager.isEnabled) sendAccessibilityEventUnchecked(event) else event.recycle()
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
override fun onInitializeAccessibilityEvent(event: AccessibilityEvent) {
|
|
657
|
+
super.onInitializeAccessibilityEvent(event)
|
|
658
|
+
event.className = "android.widget.EditText"
|
|
659
|
+
event.text.add(buffer.toString())
|
|
660
|
+
if (event.eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED) {
|
|
661
|
+
event.fromIndex = selectionStart
|
|
662
|
+
event.toIndex = selectionEnd
|
|
663
|
+
event.itemCount = buffer.length
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo) {
|
|
668
|
+
super.onInitializeAccessibilityNodeInfo(info)
|
|
669
|
+
interaction.initializeAccessibility(info)
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
override fun performAccessibilityAction(action: Int, arguments: Bundle?): Boolean =
|
|
673
|
+
interaction.performAccessibilityAction(action, arguments) ||
|
|
674
|
+
super.performAccessibilityAction(action, arguments)
|
|
675
|
+
|
|
676
|
+
override fun onFocusChanged(gainFocus: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
|
|
677
|
+
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect)
|
|
678
|
+
blinkVisible = true
|
|
679
|
+
removeCallbacks(blink)
|
|
680
|
+
if (gainFocus && isAttachedToWindow) postDelayed(blink, 500)
|
|
681
|
+
if (!gainFocus) interaction.endSelectionActionMode()
|
|
682
|
+
invalidate()
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
override fun onAttachedToWindow() {
|
|
686
|
+
super.onAttachedToWindow()
|
|
687
|
+
if (hasFocus()) postDelayed(blink, 500)
|
|
688
|
+
}
|
|
689
|
+
override fun onDetachedFromWindow() {
|
|
690
|
+
removeCallbacks(blink)
|
|
691
|
+
removeCallbacks(publishCursor)
|
|
692
|
+
cursorPublicationPosted = false
|
|
693
|
+
baseInputConnection?.closeConnection()
|
|
694
|
+
baseInputConnection = null
|
|
695
|
+
monitorCursor = false
|
|
696
|
+
interaction.dispose()
|
|
697
|
+
dragDrop.dispose()
|
|
698
|
+
super.onDetachedFromWindow()
|
|
699
|
+
}
|
|
700
|
+
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
|
|
701
|
+
super.onScrollChanged(l, t, oldl, oldt)
|
|
702
|
+
surfaceViewportChanged()
|
|
703
|
+
}
|
|
704
|
+
override fun computeVerticalScrollRange() = if (width <= 0 &&
|
|
705
|
+
measuredWidth <= 0
|
|
706
|
+
) {
|
|
707
|
+
height
|
|
708
|
+
} else {
|
|
709
|
+
layout.height + totalPaddingTop + totalPaddingBottom
|
|
710
|
+
}
|
|
711
|
+
override fun computeHorizontalScrollRange() = width
|
|
712
|
+
}
|