import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { BaseTooltipPluginView, } from "../BaseTooltip/index.js";
import { TooltipButton } from "./TooltipButton.js";
/** @deprecated */
export class TooltipButtonPluginView extends BaseTooltipPluginView {
    enableHideOnBlur;
    forceEdit = false;
    buttonContent;
    formContent;
    constructor(view, options) {
        super(view, options);
        this.enableHideOnBlur = options.disableHideOnBlur !== true;
        this.buttonContent = options.buttonContent;
        this.formContent = options.formContent;
        if (this.enableHideOnBlur) {
            this.view.dom.addEventListener('focus', this.onViewFocus);
        }
    }
    toggleEdit = () => {
        this.forceEdit = !this.forceEdit;
        this.render();
    };
    destroy() {
        super.destroy();
        this.view.dom.removeEventListener('focus', this.onViewFocus);
    }
    renderContent(currentNode) {
        return (_jsx(_Fragment, { children: this.forceEdit && this.formContent ? (_jsx("div", { children: this.formContent(this.view, currentNode, this.changeAttrsCb) })) : (_jsx(TooltipButton, { domElem: currentNode.dom, onOutsideClick: this.onOutsideClick, children: this.buttonContent(this.view, currentNode, this.toggleEdit) })) }));
    }
    setCurrentNode(node) {
        super.setCurrentNode(node);
        this.currentNode?.dom?.addEventListener('dblclick', this.toggleEdit);
    }
    updateTooltipView() {
        this.currentNode?.dom?.removeEventListener('dblclick', this.toggleEdit);
        super.updateTooltipView();
    }
    onViewFocus = () => {
        this.forceEdit = false;
        this.manualHidden = false;
        this.render();
    };
}
//# sourceMappingURL=index.js.map
