define(["require", "exports", "../base/constant", "./inserthtml", "./../../common/constant"], function (require, exports, CONSTANT, inserthtml_1, EVENTS) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var InsertTextExec = (function () {
function InsertTextExec(parent) {
this.parent = parent;
this.addEventListener();
}
InsertTextExec.prototype.addEventListener = function () {
this.parent.observer.on(CONSTANT.INSERT_TEXT_TYPE, this.insertText, this);
this.parent.observer.on(EVENTS.INTERNAL_DESTROY, this.destroy, this);
};
InsertTextExec.prototype.removeEventListener = function () {
this.parent.observer.off(CONSTANT.INSERT_TEXT_TYPE, this.insertText);
this.parent.observer.off(EVENTS.INTERNAL_DESTROY, this.destroy);
};
InsertTextExec.prototype.insertText = function (e) {
var node = document.createTextNode(e.value);
inserthtml_1.InsertHtml.Insert(this.parent.currentDocument, node, this.parent.editableElement);
if (e.callBack) {
e.callBack({
requestType: e.subCommand,
editorMode: 'HTML',
event: e.event,
range: this.parent.nodeSelection.getRange(this.parent.currentDocument),
elements: this.parent.nodeSelection.getSelectedNodes(this.parent.currentDocument)
});
}
};
InsertTextExec.prototype.destroy = function () {
this.removeEventListener();
};
return InsertTextExec;
}());
exports.InsertTextExec = InsertTextExec;
});
|