define(["require", "exports", "../base/constant", "../../editor-manager/plugin/toolbar-status", "../../common/util"], function (require, exports, events, toolbar_status_1, util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var HtmlToolbarStatus = (function () {
function HtmlToolbarStatus(parent) {
this.parent = parent;
this.toolbarStatus = this.prevToolbarStatus = util_1.getDefaultHtmlTbStatus();
this.addEventListener();
}
HtmlToolbarStatus.prototype.addEventListener = function () {
this.parent.on(events.toolbarRefresh, this.onRefreshHandler, this);
this.parent.on(events.destroy, this.removeEventListener, this);
};
HtmlToolbarStatus.prototype.removeEventListener = function () {
this.toolbarStatus = null;
this.prevToolbarStatus = null;
this.parent.off(events.toolbarRefresh, this.onRefreshHandler);
this.parent.off(events.destroy, this.removeEventListener);
};
HtmlToolbarStatus.prototype.onRefreshHandler = function (args) {
if (this.parent.readonly) {
return;
}
var fontsize = [];
var fontName = [];
var formats = [];
this.parent.fontSize.items.forEach(function (item) {
fontsize.push(item.value);
});
this.parent.fontFamily.items.forEach(function (item) {
fontName.push(item.value);
});
this.parent.format.types.forEach(function (item) {
formats.push(item.value.toLocaleLowerCase());
});
this.toolbarStatus = toolbar_status_1.ToolbarStatus.get(this.parent.contentModule.getDocument(), this.parent.contentModule.getEditPanel(), formats, fontsize, fontName, args.documentNode);
var tbStatusString = JSON.stringify(this.toolbarStatus);
this.parent.notify(events.toolbarUpdated, this.toolbarStatus);
if (JSON.stringify(this.prevToolbarStatus) !== tbStatusString) {
this.parent.notify(events.updateTbItemsStatus, { html: JSON.parse(tbStatusString), markdown: null });
this.prevToolbarStatus = JSON.parse(tbStatusString);
}
};
return HtmlToolbarStatus;
}());
exports.HtmlToolbarStatus = HtmlToolbarStatus;
});
|