define(["require", "exports", "../base/enum", "../base/constant", "@syncfusion/ej2-base"], function (require, exports, enum_1, events, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Render = (function () {
function Render(parent, locator) {
this.parent = parent;
this.locator = locator;
this.renderer = this.locator.getService('rendererFactory');
this.addEventListener();
}
Render.prototype.render = function () {
var rteObj = this.parent;
this.contentRenderer = this.renderer.getRenderer(enum_1.RenderType.Content);
this.contentRenderer.renderPanel();
};
Render.prototype.refresh = function (e) {
if (e === void 0) { e = { requestType: 'refresh' }; }
this.parent.notify(e.requestType + "-begin", e);
};
Render.prototype.destroy = function () {
Iif (ej2_base_1.isNullOrUndefined(this.parent)) {
return;
}
this.removeEventListener();
this.locator.destroy();
this.renderer.destroy();
};
Render.prototype.addEventListener = function () {
if (this.parent.isDestroyed) {
return;
}
this.parent.on(events.modelChanged, this.refresh, this);
this.parent.on(events.keyUp, this.keyUp, this);
};
Render.prototype.removeEventListener = function () {
if (this.parent.isDestroyed) {
return;
}
this.parent.off(events.modelChanged, this.refresh);
this.parent.off(events.keyUp, this.keyUp);
};
Render.prototype.keyUp = function (e) {
if (this.parent.editorMode === 'HTML') {
switch (e.args.which) {
case 46:
case 8:
var childNodes = this.parent.contentModule.getEditPanel().childNodes;
if ((childNodes.length === 0) ||
(childNodes.length === 1 && childNodes[0].childNodes.length === 0 && ((childNodes[0].tagName === 'BR') ||
((childNodes[0].tagName === 'P' || childNodes[0].tagName === 'DIV') && childNodes[0].textContent === '')))) {
var node = this.parent.contentModule.getEditPanel();
if (this.parent.enterKey === 'DIV') {
node.innerHTML = '<div><br/></div>';
}
else if (this.parent.enterKey === 'BR') {
node.innerHTML = '<br/>';
}
else {
node.innerHTML = '<p><br/></p>';
}
this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), node.childNodes[0], 0);
}
break;
}
}
};
return Render;
}());
exports.Render = Render;
});
|