"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TooltipButtonPluginView = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const BaseTooltip_1 = require("../BaseTooltip/index.js");
const TooltipButton_1 = require("./TooltipButton.js");
/** @deprecated */
class TooltipButtonPluginView extends BaseTooltip_1.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 ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: this.forceEdit && this.formContent ? ((0, jsx_runtime_1.jsx)("div", { children: this.formContent(this.view, currentNode, this.changeAttrsCb) })) : ((0, jsx_runtime_1.jsx)(TooltipButton_1.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();
    };
}
exports.TooltipButtonPluginView = TooltipButtonPluginView;
//# sourceMappingURL=index.js.map
