direction = direction.split('-')[0];
if (direction === 'column') {
innerSizeName = 'innerH';
deltaSizeName = 'deltaH';
contentSizeName = 'contentH';
alignBeforeName = 'left';
alignInnerSizeName = 'innerW';
alignMinSizeName = 'minW';
alignAfterName = 'right';
alignDeltaSizeName = 'deltaW';
alignContentSizeName = 'contentW';
innerSizeName = 'innerW';
deltaSizeName = 'deltaW';
contentSizeName = 'contentW';
alignInnerSizeName = 'innerH';
alignMinSizeName = 'minH';
alignAfterName = 'bottom';
alignDeltaSizeName = 'deltaH';
alignContentSizeName = 'contentH';
availableSpace = contLayoutRect[innerSizeName] - contPaddingBox[beforeName] - contPaddingBox[beforeName];
maxAlignEndPos = totalFlex = 0;
for (i = 0, l = items.length; i < l; i++) {
ctrlLayoutRect = ctrl.layoutRect();
ctrlSettings = ctrl.settings;
flex = ctrlSettings.flex;
availableSpace -= i < l - 1 ? spacing : 0;
if (ctrlLayoutRect[maxSizeName]) {
ctrlLayoutRect.flex = flex;
availableSpace -= ctrlLayoutRect[minSizeName];
size = contPaddingBox[alignBeforeName] + ctrlLayoutRect[alignMinSizeName] + contPaddingBox[alignAfterName];
if (size > maxAlignEndPos) {
if (availableSpace < 0) {
rect[minSizeName] = contLayoutRect[minSizeName] - availableSpace + contLayoutRect[deltaSizeName];
rect[minSizeName] = contLayoutRect[innerSizeName] - availableSpace + contLayoutRect[deltaSizeName];
rect[alignMinSizeName] = maxAlignEndPos + contLayoutRect[alignDeltaSizeName];
rect[contentSizeName] = contLayoutRect[innerSizeName] - availableSpace;
rect[alignContentSizeName] = maxAlignEndPos;
rect.minW = min(rect.minW, contLayoutRect.maxW);
rect.minH = min(rect.minH, contLayoutRect.maxH);
rect.minW = max(rect.minW, contLayoutRect.startMinWidth);
rect.minH = max(rect.minH, contLayoutRect.startMinHeight);
if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) {
container.layoutRect(rect);
if (container._lastRect === null) {
var parentCtrl = container.parent();
parentCtrl._lastRect = null;
ratio = availableSpace / totalFlex;
for (i = 0, l = maxSizeItems.length; i < l; i++) {
ctrlLayoutRect = ctrl.layoutRect();
maxSize = ctrlLayoutRect[maxSizeName];
size = ctrlLayoutRect[minSizeName] + ctrlLayoutRect.flex * ratio;
availableSpace -= ctrlLayoutRect[maxSizeName] - ctrlLayoutRect[minSizeName];
totalFlex -= ctrlLayoutRect.flex;
ctrlLayoutRect.maxFlexSize = maxSize;
ctrlLayoutRect.maxFlexSize = 0;
ratio = availableSpace / totalFlex;
pos = contPaddingBox[beforeName];
pos = availableSpace + contPaddingBox[beforeName];
} else if (pack === 'center') {
pos = Math.round(contLayoutRect[innerSizeName] / 2 - (contLayoutRect[innerSizeName] - availableSpace) / 2) + contPaddingBox[beforeName];
pos = contPaddingBox[beforeName];
} else if (pack === 'justify') {
pos = contPaddingBox[beforeName];
spacing = Math.floor(availableSpace / (items.length - 1));
rect[alignAxisName] = contPaddingBox[alignBeforeName];
for (i = 0, l = items.length; i < l; i++) {
ctrlLayoutRect = ctrl.layoutRect();
size = ctrlLayoutRect.maxFlexSize || ctrlLayoutRect[minSizeName];
if (align === 'center') {
rect[alignAxisName] = Math.round(contLayoutRect[alignInnerSizeName] / 2 - ctrlLayoutRect[alignSizeName] / 2);
} else if (align === 'stretch') {
rect[alignSizeName] = max(ctrlLayoutRect[alignMinSizeName] || 0, contLayoutRect[alignInnerSizeName] - contPaddingBox[alignBeforeName] - contPaddingBox[alignAfterName]);
rect[alignAxisName] = contPaddingBox[alignBeforeName];
} else if (align === 'end') {
rect[alignAxisName] = contLayoutRect[alignInnerSizeName] - ctrlLayoutRect[alignSizeName] - contPaddingBox.top;
if (ctrlLayoutRect.flex > 0) {
size += ctrlLayoutRect.flex * ratio;
var FlowLayout = Layout$1.extend({
containerClass: 'flow-layout',
controlClass: 'flow-layout-item',
recalc: function (container) {
container.items().filter(':visible').each(function (ctrl) {
var descendant = function (scope, selector) {
return one(selector, scope);
var toggleFormat = function (editor, fmt) {
editor.execCommand('mceToggleFormat', false, fmt);
var addFormatChangedListener = function (editor, name, changed) {
var handler = function (state) {
editor.formatter.formatChanged(name, handler);
editor.on('init', function () {
editor.formatter.formatChanged(name, handler);
var postRenderFormatToggle = function (editor, name) {
addFormatChangedListener(editor, name, function (state) {
var register = function (editor) {
var defaultAlign = 'alignleft';
onclick: toggleFormat(editor, 'alignleft')
onclick: toggleFormat(editor, 'aligncenter')
onclick: toggleFormat(editor, 'alignright')
onclick: toggleFormat(editor, 'alignjustify')
editor.addMenuItem('align', {
editor.addButton('align', {
onShowMenu: function (e) {
var menu = e.control.menu;
global$4.each(alignFormats, function (formatName, idx) {
menu.items().eq(idx).each(function (item) {
return item.active(editor.formatter.match(formatName));
onPostRender: function (e) {
global$4.each(alignFormats, function (formatName, idx) {
addFormatChangedListener(editor, formatName, function (state) {
}, function (item, name) {
onPostRender: postRenderFormatToggle(editor, name)
var Align = { register: register };
var getFirstFont = function (fontFamily) {
return fontFamily ? fontFamily.split(',')[0] : '';
var findMatchingValue = function (items, fontFamily) {
var font = fontFamily ? fontFamily.toLowerCase() : '';
global$4.each(items, function (item) {
if (item.value.toLowerCase() === font) {
global$4.each(items, function (item) {
if (!value && getFirstFont(item.value).toLowerCase() === getFirstFont(font).toLowerCase()) {
var createFontNameListBoxChangeHandler = function (editor, items) {
self.state.set('value', null);
editor.on('init nodeChange', function (e) {
var fontFamily = editor.queryCommandValue('FontName');
var match = findMatchingValue(items, fontFamily);
self.value(match ? match : null);
if (!match && fontFamily) {
self.text(getFirstFont(fontFamily));
var createFormats = function (formats) {
formats = formats.replace(/;$/, '').split(';');
formats[i] = formats[i].split('=');
var getFontItems = function (editor) {
var defaultFontsFormats = 'Andale Mono=andale mono,monospace;' + 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,sans-serif;' + 'Book Antiqua=book antiqua,palatino,serif;' + 'Comic Sans MS=comic sans ms,sans-serif;' + 'Courier New=courier new,courier,monospace;' + 'Georgia=georgia,palatino,serif;' + 'Helvetica=helvetica,arial,sans-serif;' + 'Impact=impact,sans-serif;' + 'Symbol=symbol;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Terminal=terminal,monaco,monospace;' + 'Times New Roman=times new roman,times,serif;' + 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' + 'Verdana=verdana,geneva,sans-serif;' + 'Webdings=webdings;' + 'Wingdings=wingdings,zapf dingbats';
var fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
return global$4.map(fonts, function (font) {
textStyle: font[1].indexOf('dings') === -1 ? 'font-family:' + font[1] : ''
var registerButtons = function (editor) {
editor.addButton('fontselect', function () {
var items = getFontItems(editor);
onPostRender: createFontNameListBoxChangeHandler(editor, items),
if (e.control.settings.value) {
editor.execCommand('FontName', false, e.control.settings.value);
var register$1 = function (editor) {
var FontSelect = { register: register$1 };
var round = function (number, precision) {
var factor = Math.pow(10, precision);
return Math.round(number * factor) / factor;
var toPt = function (fontSize, precision) {
if (/[0-9.]+px$/.test(fontSize)) {
return round(parseInt(fontSize, 10) * 72 / 96, precision || 0) + 'pt';
var findMatchingValue$1 = function (items, pt, px) {
global$4.each(items, function (item) {
} else if (item.value === pt) {
var createFontSizeListBoxChangeHandler = function (editor, items) {
editor.on('init nodeChange', function (e) {
var px, pt, precision, match;
px = editor.queryCommandValue('FontSize');
for (precision = 3; !match && precision >= 0; precision--) {
pt = toPt(px, precision);
match = findMatchingValue$1(items, pt, px);
self.value(match ? match : null);
var getFontSizeItems = function (editor) {
var defaultFontsizeFormats = '8pt 10pt 12pt 14pt 18pt 24pt 36pt';
var fontsizeFormats = editor.settings.fontsize_formats || defaultFontsizeFormats;
return global$4.map(fontsizeFormats.split(' '), function (item) {
var text = item, value = item;
var values = item.split('=');
var registerButtons$1 = function (editor) {
editor.addButton('fontsizeselect', function () {
var items = getFontSizeItems(editor);
onPostRender: createFontSizeListBoxChangeHandler(editor, items),
if (e.control.settings.value) {
editor.execCommand('FontSize', false, e.control.settings.value);
var register$2 = function (editor) {
registerButtons$1(editor);
var FontSizeSelect = { register: register$2 };
var hideMenuObjects = function (editor, menu) {
global$4.each(menu, function (item) {
item.hidden = hideMenuObjects(editor, item.menu) === 0;
var formatName = item.format;
item.hidden = !editor.formatter.canApply(formatName);
var hideFormatMenuItems = function (editor, menu) {
var count = menu.items().length;
menu.items().each(function (item) {
item.visible(hideFormatMenuItems(editor, item.menu) > 0);
if (!item.menu && item.settings.menu) {
item.visible(hideMenuObjects(editor, item.settings.menu) > 0);
var formatName = item.settings.format;
item.visible(editor.formatter.canApply(formatName));
var createFormatMenu = function (editor) {
var defaultStyleFormats = [