@syncfusion/ej2-richtexteditor
Version:
Essential JS 2 RichTextEditor component
529 lines (526 loc) • 18 kB
TypeScript
import { KeyboardEventArgs } from '@syncfusion/ej2-base';
import { NodeSelection } from '../../selection';
import { IEditorModel, ITableModel, NotifyArgs, OffsetPosition, ITableNotifyArgs } from '../../common/interface';
import { TablePasting } from './table-pasting';
import { IFrameSettingsModel } from '../../models';
/**
* Link internal component
*
* @hidden
*/
export declare class TableCommand {
private parent;
activeCell: HTMLElement;
curTable: HTMLTableElement;
private resizeBtnStat;
isTableMoveActive: boolean;
private pageX;
private pageY;
helper: HTMLElement;
private isResizeBind;
private tableModel;
private currentColumnResize;
private iframeSettings;
private colIndex;
private columnEle;
private rowEle;
resizeEndTime: number;
private previousTableElement;
ensureInsideTableList: boolean;
private keyDownEventInstance;
dlgDiv: HTMLElement;
tblHeader: HTMLElement;
private resizeIconPositionTime;
tablePastingObj: TablePasting;
/**
* Constructor for creating the Formats plugin
*
* @param {IEditorModel} parent - specifies the parent element
* @param {ITableModel} tableModel - specifies the table model instance
* @param {IFrameSettings} iframeSettings - specifies the table model instance
* @hidden
*/
constructor(parent: IEditorModel, tableModel: ITableModel, iframeSettings: IFrameSettingsModel);
private addEventListener;
private removeEventListener;
/**
* Copies the selected table cells to clipboard.
* Creates a temporary table with only the selected cells' content.
*
* @param {boolean} isCut - Indicates whether the operation is a cut (true) or copy (false).
* @returns {void} Nothing is returned
* @public
* @hidden
*/
copy(isCut: boolean): void;
/**
* Updates the table command object with the latest table model configuration and settings
*
* @param {ITableModel} updatedTableMode - The updated table model with latest configuration
* @returns {void} - This method does not return a value
* @public
* @hidden
*/
updateTableModel(updatedTableMode: ITableModel): void;
private extractSelectedTable;
private buildSelectionMap;
private cleanTableToSelection;
private removeColGroup;
private createTable;
private createTableStructure;
private createInitialColgroup;
private applyTableDimensions;
private calculateCellWidth;
private createRowsAndCells;
private insertTableInDocument;
private handlePostTableInsertion;
private insertElementAfterTableIfNeeded;
private calculateStyleValue;
private insertAfter;
private getSelectedCellMinMaxIndex;
private insertRow;
private addRowWithoutCellSelection;
private addRowWithCellSelection;
private createCellsForNewRow;
private isCellAffectedByRowspan;
private isFirstCellInSpan;
private incrementRowspan;
private createNewCellForRow;
private getReferenceRowIndex;
private insertNewRowAtPosition;
private updateSelectionAfterRowInsertion;
private executeCallback;
private insertColumn;
private prepareTableForColumnInsertion;
private insertCellsInAllRows;
private updateColumnGroup;
private createColumnCell;
private redistributeCellWidths;
private finalizeColumnInsertion;
private setBGColor;
private executeBgColorCallback;
/**
* Applies table styles.
* This method handles various table styling operations like adding dashed borders,
* alternating borders, or custom CSS classes.
*
* @param {IHtmlItem} e - The click event arguments
* @returns {void}
* @private
*/
private tableStyles;
/**
* Applies a specific table style command.
* This helper method handles the actual application of built-in table styles
* such as dashed or alternating borders.
*
* @param {string} command - The style command to apply
* @param {HTMLTableElement} table - The table element to style
* @returns {void}
* @private
*/
private applyTableStyleCommand;
/**
* Applies custom CSS classes to a table.
* This helper method processes any custom CSS classes specified in the
* command arguments and toggles them on the table.
*
* @param {ITableNotifyArgs} args - The table notification arguments
* @param {HTMLTableElement} table - The table element to style
* @returns {void}
* @private
*/
private applyCustomCssClasses;
private deleteColumn;
private updateColgroupAfterColumnDeletion;
private removeEntireTable;
private removeSelectedColumns;
private isCellAffectedByDeletedColumns;
private adjustColspan;
private handleIESpecificSelection;
private updateSelectionAfterColumnDelete;
private executeDeleteColumnCallback;
private deleteRow;
private deleteSelectedRows;
private adjustRowSpans;
private createReplacementCellIfNeeded;
private repositionSpannedCells;
private restoreFocusAfterRowDeletion;
private getMergedRow;
private removeTable;
private tableHeader;
private getTableFromSelection;
private checkIfTableHasHeader;
private createTableHeader;
private createHeaderCells;
private tableVerticalAlign;
private getVerticalAlignmentValue;
private applyVerticalAlignment;
private cellMerge;
private configureFirstCellForMerge;
private updateColgroupAfterMerge;
private isEntireColumnsMerged;
private calculateMaxCellHeight;
private cleanupAfterMerge;
private updateTableStructureAfterMerge;
private updateSelectionAfterMerge;
private updateColSpanStyle;
private getEffectiveColspan;
private isValidColspanStart;
private processRowsForColspan;
private processRowCells;
private updateRowSpanStyle;
private isValidRowspanStart;
private getEffectiveRowspan;
private processColumnsForRowspan;
private processColumnCells;
private updateCellAttribute;
private shouldUpdateCellAttribute;
private updateSpanAttribute;
private mergeCellContent;
private isCellEmpty;
private appendCellContent;
private getSelectedMinMaxIndexes;
private initializeMinMaxData;
private updateMinMaxWithCell;
private horizontalSplit;
private prepareNewCellForSplit;
private getRowSpanValue;
private splitCellWithRowspan;
private updateRowspanAttributes;
private findInsertionColumnIndex;
private insertNewCellIntoRow;
private splitCellWithoutRowspan;
private adjustRowspansInRow;
private verticalSplit;
private updateColgroupAfterVerticalSplit;
private prepareNewCellForVerticalSplit;
private getColSpanValue;
private splitCellWithColspan;
private calculateLeftCellWidth;
private calculateRightCellWidth;
private updateColspanAttributes;
private splitCellWithoutColspan;
private adjustColspansInColumn;
private shouldAdjustColspanForCell;
private incrementColspan;
private getSplitColWidth;
private getColSizes;
private mapRowspanCells;
private storeCellWidth;
private FindIndex;
private isMergedCell;
private adjustBoundary;
private highlightCells;
private restoreRange;
private tableStyle;
private tableMove;
private findContainingCell;
private isValidCellTarget;
private areCellsInSameTable;
private clearPreviousSelection;
private isSameCellSelected;
private selectCellRange;
/**
* Cleans up resources by removing all event listeners
*
* @public
* @returns {void}
*/
destroy(): void;
private cellStyleCleanup;
/**
* Calculates the collection of the minimum width cells from each column in the table,
* considering colSpan and rowSpan for proper cell indexing.
*
* @param {HTMLTableElement} curTable - The current table element to process.
* @returns {HTMLTableDataCellElement[]} - Returns an array of HTMLTableDataCellElement representing each column's minimum width cell.
* @public
*/
calMaxCol(curTable: HTMLTableElement): HTMLTableDataCellElement[];
/**
* Initializes the resize button state for columns, rows, and table box.
*
* @returns {Object} - An object representing the resize button state.
* @public
*/
resizeBtnInit(): {
[key: string]: boolean;
};
/**
* Calculates the offset position of the given element relative to its offset parent.
*
* @param {HTMLElement} elem - The element for which to calculate the position.
* @returns {OffsetPosition} - The top and left offset position of the element.
* @public
*/
calcPos(elem: HTMLElement): OffsetPosition;
private getPointX;
private getPointY;
private getCurrentColWidth;
private resetResizeHelper;
private resizeStart;
private handleColumnResize;
private appendHelper;
private setHelperHeight;
private updateHelper;
private handleRowResize;
/**
* Adds resize-related event handlers to the editor panel.
* Registers touch events for all devices and mouseover for non-mobile devices.
*
* @returns {void} - This method does not return a value
* @private
*/
addResizeEventHandlers(): void;
private resizeHelper;
private resizeEnd;
/**
* Cancels the current table resize operation and cleans up event handlers.
*
* @public
* @returns {void} - This method does not return a value.
*/
cancelResizeAction(): void;
removeResizeElement(): void;
private removeHelper;
private tableResizeEleCreation;
private resizing;
/**
* Handles the resizing logic when a pointer or touch event occurs on the table.
*
* @param {PointerEvent | TouchEvent} e - The pointer or touch event triggering the resize.
* @returns {void} - This function does not return a value.
* @public
*/
perfomResizing(e: PointerEvent | TouchEvent): void;
private getCurrentTableWidth;
private getTableRowsWithoutRowspan;
private createColumnResizers;
private createRowResizers;
private createResizeBox;
/**
* Removes table selection styling and fake selection elements.
* This cleanup method removes the selection class from tables and
* cleans up any fake selection elements that may have been created
* during the table selection process.
*
* @returns {void}
* @public
*/
removeTableSelection(): void;
private removeAllFakeSelectionEles;
/**
* Handles arrow key navigation between table cells
*
* @param {KeyboardEvent} event - The keyboard event
* @param {NodeSelection} selection - The current selection
* @param {HTMLElement} ele - The current table cell element
* @returns {void}
* @public
*/
tableArrowNavigation(event: KeyboardEvent, selection: NodeSelection, ele: HTMLElement): void;
private shouldSkipArrowNavigation;
private clearSelectionState;
private getTargetCellForArrowNavigation;
private getNextRowCell;
private getPreviousRowCell;
/**
* Handles tab key navigation within table cells
*
* @param {KeyboardEvent} event - The keyboard event
* @param {NodeSelection} selection - The current selection
* @param {HTMLElement} ele - The current table cell element
* @returns {void}
* @public
*/
tabSelection(event: KeyboardEvent, selection: NodeSelection, ele: HTMLElement): void;
private cleanTableRows;
private removeEmptyTextNodes;
private shouldSkipTabNavigation;
private insideList;
private getListNodesFromBlocks;
private isSimpleListItem;
private getBlockNodesInSelection;
private handleCollapsedRangeBlockNodes;
private handleExpandedRangeBlockNodes;
private getImmediateBlockNode;
private handleForwardTabNavigation;
private findNextElementForward;
private addNewRowAndNavigate;
/**
* Removes all cell selection-related CSS classes from table cells.
*
* @returns {void} - Does not return a value.
* @public
*/
removeCellSelectClasses(): void;
private handleBackwardTabNavigation;
private findPreviousElementBackward;
private shouldNavigateToTableHeader;
private handleNestedTableNavigation;
private setSelectionForElement;
/**
* Resets all table selection states and visual indicators
*
* This method clears all selection-related CSS classes from table cells,
* resets the active cell reference, and ensures proper selection is applied
* to the current table when needed.
*
* @public
* @returns {void}
*/
resetTableSelection(): void;
/**
* Sets up event handler for shift key table selection
*
* @param {KeyboardEventArgs} event - The keyboard event arguments
* @returns {void}
* @public
*/
handleShiftKeyTableSelection(event: KeyboardEventArgs): void;
/**
* Handles keyboard-based selection of table cells
*
* This method processes the selection changes when using arrow keys with shift key
* for selecting multiple cells in a table.
*
* @param {Event} e - The selection change event
* @returns {void}
* @public
*/
tableCellsKeyboardSelection(e: Event): void;
private handleTableCellArrowNavigation;
private moveToTargetCell;
private setupSelectionState;
private isTableMultiSelectActive;
private handleRightArrowNavigation;
private handleLeftArrowNavigation;
private handleUpArrowNavigation;
private handleDownArrowNavigation;
/**
* Checks if table interaction is possible based on current selection and editor state
*
* @param {KeyboardEventArgs} event - The keyboard event arguments
* @returns {boolean} True if table interaction is possible
* @public
*/
isTableInteractionPossible(event: KeyboardEventArgs): boolean;
/**
* Handles keyboard interactions within table elements
*
* @param {KeyboardEventArgs} event - The keyboard event arguments
* @returns {void}
* @public
*/
handleTableKeyboardInteractions(event: KeyboardEventArgs): void;
private handleTableDeleteOperations;
private findClosestTableCell;
private handleTableCellNavigation;
/**
* Handles global keyboard shortcuts like Ctrl+A
*
* @param {KeyboardEventArgs} event - The keyboard event arguments
* @returns {void}
* @public
*/
handleGlobalKeyboardShortcuts(event: KeyboardEventArgs): void;
private handleSelectAll;
/**
* Handles table deletion with Delete/Backspace keys
*
* @param {KeyboardEventArgs} event - The keyboard event arguments
* @returns {void}
* @public
*/
handleTableDeletion(event: KeyboardEventArgs): void;
private updateTableSelection;
private getAdjacentTableElement;
private shouldSkipForMediaElement;
private shouldSkipForTextNode;
private getAdjacentElementFromDom;
private isBrElement;
private isEmptyTextNode;
private isListElement;
private isLiElement;
private getAdjacentElementFromList;
private getNodeCollection;
private getSelectedTableEle;
private getBrElement;
private setSelection;
private deleteTable;
private isFakeTableSelectionElement;
/**
* Handles deselection when typing or using action keys
*
* @param {KeyboardEventArgs} event - The keyboard event arguments
* @returns {void}
* @public
*/
handleDeselectionOnTyping(event: KeyboardEventArgs): void;
/**
* Sets appropriate default content when the editor is empty based on the configured enter key behavior.
*
* @returns {void} - This method does not return a value
* @public
*/
setDefaultEmptyContent(): void;
/**
* Handles keyboard events after key up in tables.
* This method identifies the current table cell element based on selection,
* applies appropriate CSS classes, and manages selection state transitions
* when navigating between cells.
*
* @param {NotifyArgs} e - The notification arguments containing event data
* @returns {void}
* @private
*/
tableModulekeyUp(e: NotifyArgs): void;
private getSelectedElementFromRange;
private handleTableElementTransition;
/**
* Handles cell selection in a table when a cell is clicked.
*
* @param {ITableNotifyArgs} e - The event arguments containing information about the cell selection event.
* @returns {void} - This method does not return a value.
* @public
*/
cellSelect(e: ITableNotifyArgs): void;
private resetTableSelectionState;
private unwireTableSelectionEvents;
private tableMouseMove;
private tableMouseUp;
private handleTableSelectionEnd;
private tableMouseLeave;
private getTargetCell;
private isShiftKeyTableMove;
private handleShiftKeyTableMove;
private isValidTableCell;
private setActiveCell;
private heightcheck;
private wireTableSelectionEvents;
/**
* Handles table cell selection based on mouse position.
*
* @param {MouseEvent} [e] - The mouse event triggering the selection.
* @returns {void} - Does not return a value.
* @public
*/
tableCellSelect(e?: MouseEvent): void;
/**
* Handles mouse leave event on table cell to reset selection.
*
* @param {MouseEvent} [e] - The mouse event.
* @returns {void} - Does not return a value.
* @public
*/
tableCellLeave(e?: MouseEvent): void;
/**
* Updates the table resize handles after a key is pressed.
*
* @returns {void} - This method does not return a value
* @public
*/
afterKeyDown(): void;
private updateResizeIconPosition;
}