import * as _shival99_z_ui_utils from '@shival99/z-ui/utils'; import { ZEvent, ZEmojiCategory } from '@shival99/z-ui/utils'; import * as _angular_core from '@angular/core'; import { Signal, OnInit } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; import { ZIcon } from '@shival99/z-ui/components/z-icon'; import { ZInputValidator } from '@shival99/z-ui/components/z-input'; import { ZPopoverControl } from '@shival99/z-ui/components/z-popover'; import { Content, Editor, Extension } from '@tiptap/core'; import { ClassValue } from 'clsx'; import { LinkOptions } from '@tiptap/extension-link'; import { MentionOptions } from '@tiptap/extension-mention'; import { PlaceholderOptions } from '@tiptap/extension-placeholder'; import { StarterKitOptions } from '@tiptap/starter-kit'; import * as class_variance_authority_types from 'class-variance-authority/types'; import { VariantProps } from 'class-variance-authority'; type ZEditorSize = 'sm' | 'default' | 'lg'; type ZEditorContentType = 'html' | 'json' | 'markdown'; type ZEditorToolbarCommand = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'blockStyle' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'small' | 'paragraph' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'horizontalRule' | 'link' | 'image' | 'emoji' | 'textColor' | 'backgroundColor' | 'align' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'undo' | 'redo' | 'clearFormatting'; interface ZEditorToolbarItem { id: ZEditorToolbarCommand; icon: ZIcon; label: string; } interface ZEditorSlashCommandItem { id: string; command: ZEditorToolbarCommand; icon: ZIcon; label: string; description: string; group: string; aliases: readonly string[]; } interface ZEditorSlashCommandViewItem extends ZEditorSlashCommandItem { showGroupLabel: boolean; } interface ZEditorResolvedToolbarItem extends ZEditorToolbarItem { active: boolean; disabled: boolean; } interface ZEditorControl { /** Focus the editor */ focus: () => void; /** Blur the editor */ blur: () => void; /** Clear the editor content */ clear: () => void; /** Set content programmatically */ setContent: (content: Content) => void; /** Get current serialized content */ getContent: () => string | Content; /** Get current HTML content */ getHTML: () => string; /** Get current JSON content */ getJSON: () => Content; /** Get current Markdown content when markdown mode is enabled */ getMarkdown: () => string; /** Get plain text content */ getText: () => string; /** Get content length */ getLength: () => number; /** Access the TipTap editor instance */ getEditor: () => Editor | null; /** Trigger validation and return true if valid */ valid: () => boolean; /** * Trigger validation and return true if has error. * @deprecated Use `valid()` for boolean form-submit checks. */ validate: () => boolean; /** Reset component to initial state */ reset: () => void; /** Set value programmatically (alias for setContent) */ setValue: (content: Content) => void; /** Set custom error message (useful for server-side validation). Pass null to clear. */ setErrorMessage: (message: string | null) => void; /** Signal indicating if component has validation error */ hasError: Signal; /** Signal with current serialized value */ value: Signal; /** Signal with current error message */ errorMessage: Signal; } interface ZEditorValidator { error: string; message: string; pattern?: RegExp; minLength?: number; maxLength?: number; } interface ZEditorPlaceholderOptions extends Partial { mode?: 'firstLine' | 'everyLine'; } interface ZEditorTipTapOptions { starterKit?: Partial; placeholder?: string | ZEditorPlaceholderOptions; image?: boolean | Record; link?: Partial; mention?: boolean | Partial>; extensions?: Extension[]; } declare class ZEditorComponent implements OnInit, ControlValueAccessor { private static readonly _bubbleMenuOffset; private readonly _injector; private readonly _destroyRef; private readonly _zTranslate; private readonly _editorHost; private readonly _floatingToolbar; private readonly _slashMenuTrigger; private readonly _linkPopoverTrigger; private readonly _slashMenuScrollHost; readonly zOnChange: _angular_core.OutputEmitterRef; readonly zOnFocus: _angular_core.OutputEmitterRef; readonly zOnBlur: _angular_core.OutputEmitterRef; readonly zControl: _angular_core.OutputEmitterRef; readonly zEvent: _angular_core.OutputEmitterRef; readonly class: _angular_core.InputSignal; readonly zSize: _angular_core.InputSignal; readonly zLabel: _angular_core.InputSignal; readonly zLabelClass: _angular_core.InputSignal; readonly zPlaceholder: _angular_core.InputSignal; readonly zRequired: _angular_core.InputSignalWithTransform; readonly zDisabled: _angular_core.InputSignalWithTransform; readonly zReadonly: _angular_core.InputSignalWithTransform; readonly zContentType: _angular_core.InputSignal; readonly zToolbar: _angular_core.InputSignal; readonly zTipTap: _angular_core.InputSignal; readonly zValidators: _angular_core.InputSignal; protected readonly editorId: string; protected readonly linkInputId: string; protected readonly _value: _angular_core.WritableSignal; private readonly _disabled; private readonly _formControl; private readonly _formStateVersion; private readonly _isNgModel; private readonly _selectionVersion; private readonly _plainText; protected readonly slashMenuState: _angular_core.WritableSignal<{ visible: boolean; query: string; from: number; to: number; left: number; top: number; }>; protected readonly slashMenuActiveIndex: _angular_core.WritableSignal; protected readonly linkPopoverState: _angular_core.WritableSignal<{ visible: boolean; left: number; top: number; width: number; height: number; }>; protected readonly linkUrl: _angular_core.WritableSignal; protected readonly activeLinkHref: _angular_core.WritableSignal; protected readonly linkValidators: ZInputValidator[]; protected readonly textColorSwatches: readonly string[]; protected readonly backgroundColorSwatches: readonly string[]; protected readonly slashCommands: readonly ZEditorSlashCommandItem[]; protected readonly blockStyleOptions: readonly { command: Extract; icon: ZEditorToolbarItem['icon']; label: string; }[]; protected readonly alignOptions: readonly { command: Extract; icon: ZEditorToolbarItem['icon']; label: string; }[]; private readonly _toolbarShortcutLabels; protected readonly uiState: _angular_core.WritableSignal<{ touched: boolean; dirty: boolean; }>; private readonly _customError; private _onChange; private _onTouched; private _ngControl; private _editor; private _pendingValue; private _linkSelection; private _linkAnchorElement; private _emojiPopoverControl; private _blockStylePopoverControl; private _alignPopoverControl; private _textColorPopoverControl; private _backgroundColorPopoverControl; private _slashMenuPopoverControl; private _dismissedSlashMenu; private _linkPopoverControl; private _resizeObserver; private _resizeListenerCleanup; private _bubbleMenuPositionFrame; protected readonly emojiCategories: readonly (Omit & { icon: ZIcon; })[]; protected readonly activeEmojiCategoryId: _angular_core.WritableSignal; protected readonly emojiSearch: _angular_core.WritableSignal; protected readonly activeEmojiCategory: _angular_core.Signal & { icon: ZIcon; }>; protected readonly activeEmojiCategoryLabel: _angular_core.Signal; protected readonly emojiSearchQuery: _angular_core.Signal; protected readonly activeEmojis: _angular_core.Signal; protected readonly hasEmojiResults: _angular_core.Signal; protected readonly isDisabled: _angular_core.Signal; protected readonly showToolbar: _angular_core.Signal; protected readonly normalizedLinkUrl: _angular_core.Signal; protected readonly activeTextColor: _angular_core.Signal; protected readonly activeBackgroundColor: _angular_core.Signal; protected readonly activeBlockStyle: _angular_core.Signal<"heading1" | "heading2" | "heading3" | "heading4" | "paragraph">; protected readonly activeBlockStyleLabel: _angular_core.Signal; protected readonly activeAlign: _angular_core.Signal<"alignLeft" | "alignCenter" | "alignRight" | "alignJustify">; protected readonly activeAlignLabel: _angular_core.Signal; protected readonly activeAlignIcon: _angular_core.Signal; protected readonly filteredSlashCommands: _angular_core.Signal; protected readonly canApplyLink: _angular_core.Signal; protected readonly effectivePlaceholder: _angular_core.Signal; protected readonly toolbarItems: _angular_core.Signal; protected readonly floatingToolbarItems: _angular_core.Signal<(ZEditorResolvedToolbarItem & { shortcut: string; tooltip: string; })[]>; private readonly _shouldShowValidation; private _getValidationErrors; protected readonly hasError: _angular_core.Signal; protected readonly errorMessage: _angular_core.Signal; protected readonly currentStatus: _angular_core.Signal<"default" | "disabled" | "readonly" | "error">; protected readonly wrapperClasses: _angular_core.Signal; protected readonly editorClasses: _angular_core.Signal; constructor(); ngOnInit(): void; writeValue(value: string | Content): void; registerOnChange(fn: (value: string | Content) => void): void; registerOnTouched(fn: () => void): void; setDisabledState(isDisabled: boolean): void; protected onToolbarClick(command: ZEditorToolbarCommand): void; private _createEditor; private _handleEditorUpdate; private _handleFocus; private _handleBlur; private _emitControl; private _setEditorContent; private _validateControl; private _getSerializedContent; private _getMarkdown; private _serializeValueAsText; private _refreshEditorState; private _searchEmojis; private _setupBubbleMenuPositionUpdates; private _listenWindowResize; private _teardownBubbleMenuPositionUpdates; private _requestBubbleMenuPositionUpdate; private _isAnyBubbleMenuPopoverOpen; private _syncLinkPopoverPosition; private _getSelectionFloatingElement; private _getFrozenBubbleMenuReferenceRect; private _createVirtualElement; private _isEditorEmpty; private _isCurrentEditorContent; private _isToolbarCommandActive; private _isToolbarCommandDisabled; protected onFloatingToolbarClick(command: ZEditorToolbarCommand): void; private _getToolbarTooltip; protected applySlashCommand(item: ZEditorSlashCommandItem): void; protected applyBlockStyle(command: Extract, closePopover?: () => void): void; protected applyAlign(command: Extract, closePopover?: () => void): void; protected insertEmoji(emoji: string): void; protected setEmojiCategory(categoryId: string): void; protected onEmojiPopoverControl(control: ZPopoverControl): void; protected onEmojiPopoverShow(): void; protected onBlockStylePopoverControl(control: ZPopoverControl): void; protected onAlignPopoverControl(control: ZPopoverControl): void; protected onTextColorPopoverControl(control: ZPopoverControl): void; protected onBackgroundColorPopoverControl(control: ZPopoverControl): void; protected onSlashMenuPopoverControl(control: ZPopoverControl): void; protected onSlashMenuPopoverHide(): void; protected onLinkPopoverControl(control: ZPopoverControl): void; protected onLinkPopoverHide(): void; protected onFloatingPopoverHide(): void; protected setTextColor(color: string, closePopover?: () => void): void; protected setTextColorFromEvent(event: Event, closePopover?: () => void): void; protected unsetTextColor(closePopover?: () => void): void; protected setBackgroundColor(color: string, closePopover?: () => void): void; protected setBackgroundColorFromEvent(event: Event, closePopover?: () => void): void; protected unsetBackgroundColor(closePopover?: () => void): void; private _closePopover; private _handleSlashMenuKeyDown; private _handleEditorShortcutKeyDown; private _getShortcutCommand; private _isPrimaryShortcut; private _syncSlashMenu; private _scrollActiveSlashMenuItemIntoView; private _hideSlashMenu; private _dismissCurrentSlashMenu; private _getCurrentSlashMenuMatch; private _isDismissedSlashStillPresent; private _toggleLink; protected closeLinkPopover(): void; protected onLinkUrlChange(value: string | number | null): void; protected applyLink(): void; private _normalizeUrl; protected removeLink(): void; protected openActiveLink(): void; private _handleEditorClick; private _showLinkPopover; private _alignFixedTrigger; private _getLinkPopoverReferenceRect; private _getLinkAnchorRect; private _insertImage; private _setTextAlign; private _collapseSelectionToAnchor; private _getTextStyleAttribute; private _getActiveBlockStyle; private _getActiveAlign; private _getActiveAlignFromEditor; private _createImageExtension; private static _getImageAlignStyle; private _placeholderConfig; private _placeholderMode; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } declare const Z_EDITOR_DEFAULT_TOOLBAR: readonly ZEditorToolbarItem[]; declare const zEditorVariants: (props?: ({ zSize?: "sm" | "default" | "lg" | null | undefined; zStatus?: "default" | "error" | "disabled" | "readonly" | null | undefined; zPlaceholderMode?: "firstLine" | "everyLine" | null | undefined; } & class_variance_authority_types.ClassProp) | undefined) => string; type ZEditorVariants = VariantProps; export { ZEditorComponent, Z_EDITOR_DEFAULT_TOOLBAR, zEditorVariants }; export type { ZEditorContentType, ZEditorControl, ZEditorResolvedToolbarItem, ZEditorSize, ZEditorTipTapOptions, ZEditorToolbarCommand, ZEditorToolbarItem, ZEditorValidator, ZEditorVariants };