pp-editor
Version:
## Overview
180 lines (177 loc) • 5.45 kB
TypeScript
import * as i0 from '@angular/core';
import { OnInit } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
/**
* A rich text editor component built on top of Quill.js with enhanced features.
* Supports multiple editor instances, floating menus, and custom content blocks.
* Implements ControlValueAccessor for seamless integration with Angular forms.
*
* @example
* // Basic usage
* <pp-editor [(ngModel)]="content"></pp-editor>
*
* // With custom configuration
* <pp-editor
* [theme]="'snow'"
* [toolbar]="customToolbar"
* [placeholder]="'Start writing...'"
* [(ngModel)]="content">
* </pp-editor>
*/
declare class PpEditor implements OnInit, ControlValueAccessor {
private platformId;
/**
* Tracks timestamps of recent Enter key presses for triple-enter detection
* @private
*/
private enterPressTimes;
/**
* Number of consecutive Enter presses required to trigger a new section
* @private
*/
private enterPressThreshold;
/**
* Time window (in ms) for detecting consecutive Enter presses
* @private
*/
private enterPressWindow;
/**
* Placeholder text displayed when editor is empty
* @default 'Type here...'
*/
placeholder: string;
/**
* Editor theme ('bubble' or 'snow')
* @default 'bubble'
*/
theme: 'bubble' | 'snow';
/**
* Whether the editor is in read-only mode
* @default false
*/
readOnly: boolean;
/**
* Custom toolbar configuration for Quill.js
* @default See component implementation
*/
toolbar: any[];
/**
* History configuration for undo/redo functionality
* @default { delay: 2000, maxStack: 500, userOnly: true }
*/
history: {
delay: number;
maxStack: number;
userOnly: boolean;
};
/**
* Clipboard handling configuration
* @default { matchVisual: false }
*/
clipboard: {
matchVisual: boolean;
};
/**
* Keyboard bindings configuration
* @default { bindings: {} }
*/
keyboard: {
bindings: {};
};
/** Combined modules configuration for Quill.js */
modules: {
toolbar: any[];
history: {
delay: number;
maxStack: number;
userOnly: boolean;
};
clipboard: {
matchVisual: boolean;
};
keyboard: {
bindings: {};
};
};
/** Whether the floating menu is visible */
showMenu: boolean;
/** Array of content blocks in the editor */
content: any[];
/** Flag indicating if the code is running in a browser environment */
isBrowser: boolean;
/** Array of Quill editor instances */
private quillEditor;
private onChange;
private onTouched;
/**
* Creates an instance of the editor component
* @param platformId - The platform ID injected by Angular
*/
constructor(platformId: Object);
/**
* Writes a new value from the form model into the view
* @param value - The new value from the model
*/
writeValue(value: any[]): void;
/**
* Registers a callback function that should be called when the control's value changes
* @param fn - The callback function
*/
registerOnChange(fn: any): void;
/**
* Registers a callback function that should be called when the control is touched
* @param fn - The callback function
*/
registerOnTouched(fn: any): void;
/**
* Sets the disabled state of the control
* @param isDisabled - Whether the control should be disabled
*/
setDisabledState?(isDisabled: boolean): void;
/**
* Angular lifecycle hook for initialization
*/
ngOnInit(): void;
/**
* Callback when a Quill editor instance is created
* @param quill - The Quill editor instance
*/
editorCreated(quill: any): void;
/**
* Toggles the visibility of the floating menu
*/
toggleMenu(): void;
/**
* Handles document click events to close the menu when clicking outside
* @param event - The mouse event
*/
handleClick(event: MouseEvent): void;
/**
* Adds a new section to the editor
*/
addSection(): void;
/**
* Adds a code block to the editor
*/
addCodeBlock(): void;
/**
* Adds a decorative divider to the editor
*/
addDivider(): void;
/**
* Prompts the user for a URL and adds an iframe to the editor
*/
addIframe(): Promise<void>;
/**
* Removes a content block from the editor
* @param index - The index of the content block to remove
*/
removeContent(index: number): void;
/**
* Notifies the form control when content changes
*/
onContentChange(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<PpEditor, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<PpEditor, "pp-editor", never, { "placeholder": { "alias": "placeholder"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; "readOnly": { "alias": "readOnly"; "required": false; }; "toolbar": { "alias": "toolbar"; "required": false; }; "history": { "alias": "history"; "required": false; }; "clipboard": { "alias": "clipboard"; "required": false; }; "keyboard": { "alias": "keyboard"; "required": false; }; }, {}, never, never, true, never>;
}
export { PpEditor };