@syncfusion/ej2-richtexteditor
Version:
Essential JS 2 RichTextEditor component
159 lines (156 loc) • 6.37 kB
TypeScript
import { CodeBlockPosition } from '../base/interface';
import { IEditorModel } from '../../common/interface';
/**
* Code Block internal component
*
* @hidden
*/
export declare class CodeBlockPlugin {
private parent;
/**
* Constructor for creating the Code Block plugin
*
* @param {EditorManager} parent - specifies the parent element
* @hidden
*/
constructor(parent: IEditorModel);
private addEventListener;
private removeEventListener;
destroy(): void;
private applyCodeBlockHandler;
private callBack;
/**
* Determines if a node is inside a valid code block structure
*
* This method checks if the given node is within a proper code block structure
* (a PRE element containing a CODE element as its first child).
*
* @param {Node} node - The node to check
* @returns {HTMLElement|null} - The PRE element if the node is inside a valid code block, otherwise null
* @public
*/
isValidCodeBlockStructure(node: Node): HTMLElement | null;
isCodeBlockEnterAction(range: Range, e: KeyboardEvent): boolean;
private codeBlockBackSpaceAction;
private handleKeyUpBackspace;
private isCodeBlockElement;
private handleKeyDownBackspace;
private handleSelectionAcrossCodeBlockBoundary;
private moveContentToParent;
private setCursorAfterBoundaryOperation;
private cleanupEmptyElements;
private handleSelectionFromCodeBlockToRegular;
private addBrElementIfMissing;
private handleSinglePointDeletion;
private handleDeleteKeyAtCodeBlockBoundary;
private isBrAsLastChildInCodeBlock;
private handleActionWhenNextSiblingIsNull;
private handleActionWhenNextSiblingExists;
private processListElement;
private findNextValidSibling;
private findFirstListItem;
private isValidNode;
private nodeCreateBasedOnEnterAction;
private mergeNextContentIntoCodeBlock;
private processInlineNextSiblings;
private handleNextSiblingCodeBlockDeletion;
private mergeCodeBlockWithCurrentNode;
private handleBackspaceAtCodeBlockStart;
private mergePreviousElementWithCodeBlock;
private handleBackspaceAfterCodeBlock;
private mergePreviousCodeBlockWithCurrent;
private processMergeBlockNode;
private processMergeInlineNode;
private codeBlockEnterAction;
private isCodeBlockPointSelection;
private isFirstAppendScenario;
private isLastAppendScenario;
private handleCodeBlockPointSelection;
private setNewRangeBeforeBrElement;
isSelectionWithinCodeBlock(range: Range, startContainer: Node, endContainer: Node): boolean;
private handleSelectionWithinCodeBlock;
private isSelectionOutsideToInside;
private handleOutsideToInsideSelection;
private isSelectionInsideToOutside;
private handleInsideToOutsideSelection;
private findFirstTextNode;
private getSelectionRange;
private codeBlockPasteAction;
private isPointSelection;
private isSameCodeBlockSelection;
private handlePointSelectionPaste;
private handleSameCodeBlockPaste;
private handleCrossCodeBlockPaste;
private extractAndWrapCodeBlockContent;
private isRevertCodeBlock;
private codeBlockCreation;
private revertCodeBlockToNormalText;
private createNewCodeBlock;
private checkTableElementInsideSelection;
private isRangeInsideTable;
private getBlockNodes;
private getTextAndBrNodes;
private includeFullNodeForRange;
private wrapTableElementToList;
private processNodeForBlockNodes;
private processCodeBlockAction;
private formatCodeBlock;
private disableToolbarItems;
private insertFragmentAtNode;
private removeNodes;
private processNode;
private setCursorMarkers;
private restoreCursorFromMarkers;
/**
* Searches for code block elements that are siblings or parents of the current selection
*
* This method traverses up the DOM tree from the selection's start container,
* checking each next sibling to find code block structures. It's used primarily
* for delete operations to determine if pressing Delete at the end of content
* should merge with a following code block.
*
* @param {Range} range - The current selection range
* @returns {Object|null} - Object containing current node and its next sibling code block,
* with properties currentNode (Node) and nextSibling (Node), or null if no code block is found
* @public
*/
findParentOrNextSiblingCodeBlock(range: Range): {
currentNode: Node;
nextSibling: Node;
} | null;
/**
* Searches for code block elements that are siblings or parents before the current selection
*
* This method traverses up the DOM tree from the selection's start container,
* checking each previous sibling to find code block structures. It's used primarily
* for backspace operations to determine if pressing Backspace at the beginning of content
* should merge with a preceding code block.
*
* @param {Range} range - The current selection range
* @returns {Object|null} - Object containing current node and its previous sibling code block,
* with properties currentNode (Node) and previousSibling (Node), or null if no code block is found
* @public
*/
findParentOrPreviousSiblingCodeBlock(range: Range): {
currentNode: Node;
previousSibling: Node;
} | null;
getCodeBlockPosition(range: Range): CodeBlockPosition;
/**
* Determines if a keyboard action should be disallowed within a code block
*
* This method checks if the current selection is within a code block and if the
* keyboard action being performed is not in the list of allowed actions for code blocks.
* It helps maintain proper code block behavior by preventing formatting operations
* that would break code block structure.
*
* @param {KeyboardEvent} e - The keyboard event being processed
* @param {Range} range - The current selection range
* @returns {boolean} - True if the action should be disallowed, false otherwise
* @public
*/
isActionDisallowedInCodeBlock(e: KeyboardEvent, range: Range): boolean;
private codeBlockTabAction;
private codeBlockShiftTabAction;
private handleCodeBlockIndentation;
}