/** * Copyright 2023-present DreamNum Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { DocumentDataModel, Nullable } from '@univerjs/core'; import type { IDocSelectionInnerParam, IMouseEvent, INodePosition, IPointerEvent, IRenderContext, IRenderModule, ISuccinctDocRangeParam, ITextRangeWithStyle } from '@univerjs/engine-render'; import type { RectRange } from './rect-range'; import { IContextService, ILogService, IUniverInstanceService, RxDisposable } from '@univerjs/core'; import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs'; import { ILayoutService } from '@univerjs/ui'; import { IDocEmbedInteractionBoundaryService, IDocEmbedRuntimeFocusCoordinator } from '../doc-embed-integration.service'; import { TextRange } from './text-range'; export interface IEditorInputConfig { event: Event | CompositionEvent | KeyboardEvent; content?: string; activeRange?: Nullable; rangeList?: ITextRangeWithStyle[]; } export declare class DocSelectionRenderService extends RxDisposable implements IRenderModule { protected readonly _context: IRenderContext; private readonly _layoutService; private readonly _logService; private readonly _contextService; private readonly _univerInstanceService; private readonly _docSkeletonManagerService; private readonly _docSelectionManagerService; private readonly _embedInteractionBoundaryService?; private readonly _embedRuntimeFocusCoordinator?; private readonly _onInputBefore$; readonly onInputBefore$: import("rxjs").Observable>; private readonly _onKeydown$; readonly onKeydown$: import("rxjs").Observable; private readonly _onInput$; readonly onInput$: import("rxjs").Observable; private readonly _onCompositionstart$; readonly onCompositionstart$: import("rxjs").Observable>; private readonly _onCompositionupdate$; readonly onCompositionupdate$: import("rxjs").Observable>; private readonly _onCompositionend$; readonly onCompositionend$: import("rxjs").Observable>; private readonly _onSelectionStart$; readonly onSelectionStart$: import("rxjs").Observable>; readonly onChangeByEvent$: import("rxjs").Observable>; private readonly _onPaste$; readonly onPaste$: import("rxjs").Observable; private readonly _textSelectionInner$; readonly textSelectionInner$: import("rxjs").Observable>; private readonly _movingSelection$; readonly movingSelection$: import("rxjs").Observable; private readonly _onFocus$; readonly onFocus$: import("rxjs").Observable; private readonly _onBlur$; readonly onBlur$: import("rxjs").Observable; private readonly _onPointerDown$; readonly onPointerDown$: import("rxjs").Observable; protected _container: HTMLDivElement; private _inputParent; private _input; private _scrollTimers; protected _rangeList: TextRange[]; protected _rangeListCache: TextRange[]; private _rectRangeList; protected _rectRangeListCache: RectRange[]; protected _anchorNodePosition: Nullable; protected _focusNodePosition: Nullable; private _currentSegmentId; private _currentSegmentPage; private readonly _segmentContext$; readonly segmentContext$: import("rxjs").Observable<{ segmentId: string; segmentPage: number; }>; private _selectionStyle; protected _onPointerEvent: boolean; private _viewPortObserverMap; private _isIMEInputApply; private _scenePointerMoveSubs; private _scenePointerUpSubs; private _reserveRanges; private _pendingSelection; get hasPendingSelection(): boolean; get isOnPointerEvent(): boolean; get isFocusing(): boolean; get isEditing(): boolean; get canFocusing(): boolean; cancelPointerSelection(): void; constructor(_context: IRenderContext, _layoutService: ILayoutService, _logService: ILogService, _contextService: IContextService, _univerInstanceService: IUniverInstanceService, _docSkeletonManagerService: DocSkeletonManagerService, _docSelectionManagerService: DocSelectionManagerService, _embedInteractionBoundaryService?: IDocEmbedInteractionBoundaryService | undefined, _embedRuntimeFocusCoordinator?: IDocEmbedRuntimeFocusCoordinator | undefined); private _listenCurrentUnitChange; get activeViewPort(): import("@univerjs/engine-render").Viewport; setSegment(id: string): void; getSegment(): string; setSegmentPage(pageIndex: number): void; getSegmentPage(): number; setReserveRangesStatus(status: boolean): void; refreshRanges(): void; private _setRangeStyle; replaceDocRanges(ranges: ISuccinctDocRangeParam[], isEditing?: boolean, options?: { [key: string]: boolean; }): boolean; private _syncNoteSegment; private _getPendingSelection; private _canResolveCollapsedRanges; addDocRanges(ranges: ISuccinctDocRangeParam[], isEditing?: boolean, options?: { [key: string]: boolean; }, replace?: boolean): boolean; setCursorManually(evtOffsetX: number, evtOffsetY: number, isEditing?: boolean, shouldFocusInput?: boolean, options?: { strict?: boolean; }): void; sync(): void; setInputPosition(x: number, y: number): void; activate(x: number, y: number, force?: boolean): void; protected _positionInput(x: number, y: number): void; hasFocus(): boolean; focus(): void; blur(): void; deactivate(): void; __handleDblClick(evt: IPointerEvent | IMouseEvent, isEditing?: boolean, shouldFocusInput?: boolean): void; __handleTripleClick(evt: IPointerEvent | IMouseEvent): void; __onPointDown(evt: IPointerEvent | IMouseEvent, shouldFocusInput?: boolean): void; private _clearUnresolvedSelection; enterEditing(): boolean; exitEditing(): void; removeAllRanges(): void; getActiveTextRange(): TextRange | undefined; protected _setEditing(isEditing: boolean): void; protected _emitCurrentSelection(isEditing: boolean): void; private _disposeScrollTimers; private _setSystemHighlightColorToStyle; private _getAllTextRanges; private _getAllRectRanges; getAllTextRanges(): ITextRangeWithStyle[]; getAllRectRanges(): import("@univerjs/engine-render").IRectRangeWithStyle[]; private _getActiveRange; protected _getActiveRangeInstance(): TextRange | undefined; dispose(): void; private _initDOM; private _registerContainer; private _initInput; protected _ensureHostContainer(): void; private _getOwnerDocument; private _getNodePosition; private _interactTextRanges; private _interactRectRanges; private _removeAllRanges; protected _removeAllCacheRanges(): void; private _removeAllTextRanges; private _removeAllRectRanges; private _removeAllCollapsedTextRanges; private _hideCollapsedCaretsForVisibleSelection; private _deactivateAllTextRanges; private _deactivateAllRectRanges; private _addTextRangesToCache; protected _addTextRange(textRange: TextRange): void; private _addRectRangesToCache; protected _addRectRanges(rectRanges: RectRange[]): void; private _createTextRangeByAnchorPosition; private _updateActiveRangePosition; private _isEmpty; private _getCanvasOffset; protected _updateInputPosition({ forceFocus, preserveFocus }?: { forceFocus?: boolean | undefined; preserveFocus?: boolean | undefined; }): void; protected _tryMoving(moveOffsetX: number, moveOffsetY: number): void; private _moving; private _hasVisibleSelectionRanges; private _shouldSnapBackwardFocusToGlyphStart; private _isBeforeNodePosition; private _isFirstSelectableGlyphInDivide; __attachScrollEvent(): void; private _initInputEvents; private _refreshMissingInputRange; protected _handleInputFocus(event: Event): void; protected _handleInputBlur(event: Event): void; protected _emitInputBlur(event: Event): void; private _eventHandle; private _shouldSuppressHostHiddenEditorEvent; private _stopEmbedOwnedEditorShortcutPropagation; private _getTransformCoordForDocumentOffset; private _findNodeByCoord; private _shouldPreserveExternalFocus; private _isAnotherEditorFocused; private _containsCurrentEmbedRuntimeElement; private _getCurrentEmbedOwner; private _getElementEmbedOwner; private _containsOwnEditorElement; private _containsCurrentLayoutElement; private _detachEvent; }