import { jsx as _jsx } from "react/jsx-runtime";
// @ts-ignore // TODO: fix cjs build
import { findParentDomRefOfType } from 'prosemirror-utils';
import { ErrorLoggerBoundary } from "../../../../../react-utils/ErrorBoundary.js";
import { getReactRendererFromState } from "../../../../behavior/ReactRenderer/index.js";
import { TableCellFloatingButton } from "./floating.js";
export class TableCellContextView {
    static findCellDom(view, nodeType) {
        return findParentDomRefOfType(nodeType, view.domAtPos.bind(view))(view.state.selection);
    }
    #view;
    #actions;
    #nodeType;
    #renderItem;
    constructor(view, actions, cellNodeType) {
        this.#view = view;
        this.#actions = actions;
        this.#nodeType = cellNodeType;
        this.#renderItem = getReactRendererFromState(view.state).createItem('table-cell-tooltip', () => (_jsx(ErrorLoggerBoundary, { children: _jsx(TableCellFloatingButton, { actions: this.#actions, dom: TableCellContextView.findCellDom(this.#view, this.#nodeType) }) })));
    }
    update(view) {
        this.#view = view;
        this.#renderItem.rerender();
    }
    destroy() {
        this.#renderItem.remove();
    }
}
//# sourceMappingURL=view.js.map
