Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ export class TableEditor {
true /*isHorizontal*/,
this.onStartCellResize,
this.onFinishEditing,
this.anchorContainer
this.anchorContainer,
this.onTableEditorCreated
);
this.verticalResizer = createCellResizer(
this.editor,
Expand All @@ -266,7 +267,8 @@ export class TableEditor {
false /*isHorizontal*/,
this.onStartCellResize,
this.onFinishEditing,
this.anchorContainer
this.anchorContainer,
this.onTableEditorCreated
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from 'roosterjs-content-model-dom';
import type { DragAndDropHandler } from '../../../pluginUtils/DragAndDrop/DragAndDropHandler';
import type { IEditor, ReadonlyContentModelTable } from 'roosterjs-content-model-types';
import type { OnTableEditorCreatedCallback } from '../../OnTableEditorCreatedCallback';

const CELL_RESIZER_WIDTH = 4;
/**
Expand All @@ -34,7 +35,8 @@ export function createCellResizer(
isHorizontal: boolean,
onStart: () => void,
onEnd: () => false,
anchorContainer?: HTMLElement
anchorContainer?: HTMLElement,
onTableEditorCreated?: OnTableEditorCreatedCallback
): TableEditFeature | null {
const document = td.ownerDocument;
const createElementData = {
Expand Down Expand Up @@ -66,18 +68,42 @@ export function createCellResizer(
onDragEnd: onEnd,
};

const featureHandler = new DragAndDropHelper<CellResizerContext, CellResizerInitValue>(
const featureHandler = new CellResizer(
div,
context,
setPosition,
handler,
zoomScale,
editor.getEnvironment().isMobileOrTablet
editor.getEnvironment().isMobileOrTablet,
onTableEditorCreated
);

return { node: td, div, featureHandler };
}

class CellResizer extends DragAndDropHelper<CellResizerContext, CellResizerInitValue> {
private disposer: undefined | (() => void);

constructor(
trigger: HTMLElement,
context: CellResizerContext,
onSubmit: (context: CellResizerContext, trigger: HTMLElement) => void,
handler: DragAndDropHandler<CellResizerContext, CellResizerInitValue>,
zoomScale: number,
forceMobile?: boolean,
onTableEditorCreated?: OnTableEditorCreatedCallback
) {
super(trigger, context, onSubmit, handler, zoomScale, forceMobile);
this.disposer = onTableEditorCreated?.('CellResizer', trigger);
}

dispose(): void {
this.disposer?.();
this.disposer = undefined;
super.dispose();
}
}

/**
* @internal
* Exported for testing
Expand Down
Loading