communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
45 lines • 1.37 kB
JavaScript
import { getTableEditContextMenuItems } from '../../utils/RichTextTableUtils';
/**
* Provides a context menu for editing tables in the rich text editor.
*/
export class TableEditContextMenuProvider {
constructor() {
this.editor = null;
this.strings = {};
this.items = null;
}
updateStrings(strings) {
this.strings = strings;
if (this.editor) {
this.items = getTableEditContextMenuItems(this.editor, this.strings);
}
}
getName() {
return 'TableEditContextMenuProvider';
}
initialize(editor) {
this.editor = editor;
this.items = getTableEditContextMenuItems(editor, this.strings);
}
/**
* Dispose this plugin
*/
dispose() {
this.editor = null;
}
getContextMenuItems(node) {
if (this.editor && isTableEditable(this.editor, node)) {
return this.items;
}
else {
return null;
}
}
}
const isTableEditable = (editor, node) => {
const domHelper = editor.getDOMHelper();
const td = domHelper.findClosestElementAncestor(node, 'TD,TH');
const table = td && domHelper.findClosestElementAncestor(td, 'table');
return (table === null || table === void 0 ? void 0 : table.isContentEditable) === true;
};
//# sourceMappingURL=TableEditContextMenuProvider.js.map