import { MicroEditorBase } from "../../../Views/editor/MicroEditorBase.js";
import * as Tags from "../../../Views/Tags.js";
export class TextAreaEditor extends MicroEditorBase {
    get allowsTags() {
        return this.source.state.get("allowsTags", true);
    }
    get inputNode() {
        return this.node.find("textarea");
    }
    get maskInputNode() {
        return this.node.find("div");
    }
    template() {
        return `<div class="-fb-text-area-editor">
                    <div></div>
                    <textarea ${this.source.readOnly ? "readonly" : ""}></textarea>
                </div>`;
    }
    focus() {
        this.inputNode.focus().select();
    }
    onActivate(e) {
        super.onActivate(e);
        this.inputNode.on(Jade.BrowserEvent.FOCUS, () => {
            this.focus();
        });
        this.inputNode.on(Jade.BrowserEvent.KEYUP, () => {
            this.maskInputNode.html(Tags.replaceTags(this.inputNode.val()));
        });
        this.inputNode.on(Jade.BrowserEvent.SCROLL, () => {
            this.syncScrollPositions();
        });
    }
    syncScrollPositions() {
        this.maskInputNode.scrollLeft(this.inputNode.scrollLeft());
        this.maskInputNode.scrollTop(this.inputNode.scrollTop());
    }
}
