"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableCellContextView = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
// @ts-ignore // TODO: fix cjs build
const prosemirror_utils_1 = require("prosemirror-utils");
const ErrorBoundary_1 = require("../../../../../react-utils/ErrorBoundary.js");
const ReactRenderer_1 = require("../../../../behavior/ReactRenderer/index.js");
const floating_1 = require("./floating.js");
class TableCellContextView {
    static findCellDom(view, nodeType) {
        return (0, prosemirror_utils_1.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 = (0, ReactRenderer_1.getReactRendererFromState)(view.state).createItem('table-cell-tooltip', () => ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorLoggerBoundary, { children: (0, jsx_runtime_1.jsx)(floating_1.TableCellFloatingButton, { actions: this.#actions, dom: TableCellContextView.findCellDom(this.#view, this.#nodeType) }) })));
    }
    update(view) {
        this.#view = view;
        this.#renderItem.rerender();
    }
    destroy() {
        this.#renderItem.remove();
    }
}
exports.TableCellContextView = TableCellContextView;
//# sourceMappingURL=view.js.map
