msgBox: function (settings) {
var callback = settings.callback || function () {
function createButton(text, status, primary) {
subtype: primary ? 'primary' : '',
e.control.parents()[1].close();
switch (settings.buttons) {
case MessageBox.OK_CANCEL:
createButton('Ok', true, true),
createButton('Cancel', false)
case MessageBox.YES_NO_CANCEL:
createButton('Yes', 1, true),
if (settings.buttons === MessageBox.YES_NO_CANCEL) {
buttons.push(createButton('Cancel', -1));
buttons = [createButton('Ok', true, true)];
onPostRender: function () {
this.aria('describedby', this.items()[0]._id);
onClose: settings.onClose,
}).renderTo(domGlobals.document.body).reflow();
alert: function (settings, callback) {
if (typeof settings === 'string') {
settings = { text: settings };
settings.callback = callback;
return MessageBox.msgBox(settings);
confirm: function (settings, callback) {
if (typeof settings === 'string') {
settings = { text: settings };
settings.callback = callback;
settings.buttons = MessageBox.OK_CANCEL;
return MessageBox.msgBox(settings);
function WindowManagerImpl (editor) {
var open = function (args, params, closeCallback) {
args.title = args.title || ' ';
args.url = args.url || args.file;
args.width = parseInt(args.width || 320, 10);
args.height = parseInt(args.height || 240, 10);
type: args.bodyType || 'form',
if (!args.url && !args.buttons) {
win.find('form')[0].submit();
win.on('close', function () {
win.on('postRender', function () {
this.find('*').each(function (ctrl) {
ctrl.value(args.data[name]);
win.features = args || {};
win.params = params || {};
win = win.renderTo(domGlobals.document.body).reflow();
var alert = function (message, choiceCallback, closeCallback) {
win = MessageBox.alert(message, function () {
win.on('close', function () {
var confirm = function (message, choiceCallback, closeCallback) {
win = MessageBox.confirm(message, function (state) {
win.on('close', function () {
var close = function (window) {
var getParams = function (window) {
var setParams = function (window, params) {
var get = function (editor, panel) {
var renderUI = function () {
return Render.renderUI(editor, panel);
getNotificationManagerImpl: function () {
return NotificationManagerImpl(editor);
getWindowManagerImpl: function () {
return WindowManagerImpl();
var ThemeApi = { get: get };
var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
var path = function (parts, scope) {
var o = scope !== undefined && scope !== null ? scope : Global;
for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
var resolve = function (p, scope) {
var parts = p.split('.');
return path(parts, scope);
var unsafe = function (name, scope) {
return resolve(name, scope);
var getOrDie = function (name, scope) {
var actual = unsafe(name, scope);
if (actual === undefined || actual === null) {
throw new Error(name + ' not available on this browser');
var Global$1 = { getOrDie: getOrDie };
var f = Global$1.getOrDie('FileReader');
var global$c = tinymce.util.Tools.resolve('tinymce.util.Promise');
var blobToBase64 = function (blob) {
return new global$c(function (resolve) {
var reader = FileReader();
reader.onloadend = function () {
resolve(reader.result.split(',')[1]);
reader.readAsDataURL(blob);
var Conversions = { blobToBase64: blobToBase64 };
var pickFile = function () {
return new global$c(function (resolve) {
fileInput = domGlobals.document.createElement('input');
fileInput.style.position = 'fixed';
fileInput.style.left = 0;
fileInput.style.opacity = 0.001;
domGlobals.document.body.appendChild(fileInput);
fileInput.onchange = function (e) {
resolve(Array.prototype.slice.call(e.target.files));
fileInput.parentNode.removeChild(fileInput);
var Picker = { pickFile: pickFile };
return Math.round(Math.random() * 4294967295).toString(36);
return 's' + Date.now().toString(36) + rnd() + rnd() + rnd();
var uuid = function (prefix) {
return prefix + count$1++ + seed();
var Uuid = { uuid: uuid };
var create$1 = function (dom, rng) {
function setupEndPoint(start) {
var offsetNode, container, offset;
container = rng[start ? 'startContainer' : 'endContainer'];
offset = rng[start ? 'startOffset' : 'endOffset'];
if (container.nodeType === 1) {
offsetNode = dom.create('span', { 'data-mce-type': 'bookmark' });
if (container.hasChildNodes()) {
offset = Math.min(offset, container.childNodes.length - 1);
container.insertBefore(offsetNode, container.childNodes[offset]);
dom.insertAfter(offsetNode, container.childNodes[offset]);
container.appendChild(offsetNode);
bookmark[start ? 'startContainer' : 'endContainer'] = container;
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
var resolve$1 = function (dom, bookmark) {
function restoreEndPoint(start) {
var container, offset, node;
function nodeIndex(container) {
var node = container.parentNode.firstChild, idx = 0;
if (node === container) {
if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
container = node = bookmark[start ? 'startContainer' : 'endContainer'];
offset = bookmark[start ? 'startOffset' : 'endOffset'];
if (container.nodeType === 1) {
offset = nodeIndex(container);
container = container.parentNode;
bookmark[start ? 'startContainer' : 'endContainer'] = container;
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
var rng = dom.createRng();
rng.setStart(bookmark.startContainer, bookmark.startOffset);
if (bookmark.endContainer) {
rng.setEnd(bookmark.endContainer, bookmark.endOffset);
var global$d = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
var global$e = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
var getSelectedElements = function (rootElm, startNode, endNode) {
walker = new global$d(startNode, rootElm);
for (node = startNode; node; node = walker.next()) {
if (node.nodeType === 1) {
var unwrapElements = function (editor, elms) {
var bookmark, dom, selection;
selection = editor.selection;
bookmark = Bookmark.create(dom, selection.getRng());
global$4.each(elms, function (elm) {
editor.dom.remove(elm, true);
selection.setRng(Bookmark.resolve(dom, bookmark));
var isLink = function (elm) {
return elm.nodeName === 'A' && elm.hasAttribute('href');
var getParentAnchorOrSelf = function (dom, elm) {
var anchorElm = dom.getParent(elm, isLink);
return anchorElm ? anchorElm : elm;
var getSelectedAnchors = function (editor) {
var startElm, endElm, rootElm, anchorElms, selection, dom, rng;
selection = editor.selection;
rng = selection.getRng();
startElm = getParentAnchorOrSelf(dom, global$e.getNode(rng.startContainer, rng.startOffset));
endElm = global$e.getNode(rng.endContainer, rng.endOffset);
rootElm = editor.getBody();
anchorElms = global$4.grep(getSelectedElements(rootElm, startElm, endElm), isLink);
var unlinkSelection = function (editor) {
unwrapElements(editor, getSelectedAnchors(editor));
var Unlink = { unlinkSelection: unlinkSelection };
var createTableHtml = function (cols, rows) {
html = '<table data-mce-id="mce" style="width: 100%">';
for (y = 0; y < rows; y++) {
for (x = 0; x < cols; x++) {
var getInsertedElement = function (editor) {
var elms = editor.dom.select('*[data-mce-id]');
var insertTableHtml = function (editor, cols, rows) {
editor.undoManager.transact(function () {
editor.insertContent(createTableHtml(cols, rows));
tableElm = getInsertedElement(editor);
tableElm.removeAttribute('data-mce-id');
cellElm = editor.dom.select('td,th', tableElm);
editor.selection.setCursorLocation(cellElm[0], 0);
var insertTable = function (editor, cols, rows) {
editor.plugins.table ? editor.plugins.table.insertTable(cols, rows) : insertTableHtml(editor, cols, rows);
var formatBlock = function (editor, formatName) {
editor.execCommand('FormatBlock', false, formatName);
var insertBlob = function (editor, base64, blob) {
blobCache = editor.editorUpload.blobCache;
blobInfo = blobCache.create(Uuid.uuid('mceu'), blob, base64);
editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() }));
var collapseSelectionToEnd = function (editor) {
editor.selection.collapse(false);
var unlink = function (editor) {
Unlink.unlinkSelection(editor);
collapseSelectionToEnd(editor);
var changeHref = function (editor, elm, url) {
editor.dom.setAttrib(elm, 'href', url);
collapseSelectionToEnd(editor);
var insertLink = function (editor, url) {
editor.execCommand('mceInsertLink', false, { href: url });
collapseSelectionToEnd(editor);
var updateOrInsertLink = function (editor, url) {
var elm = editor.dom.getParent(editor.selection.getStart(), 'a[href]');
elm ? changeHref(editor, elm, url) : insertLink(editor, url);
var createLink = function (editor, url) {
url.trim().length === 0 ? unlink(editor) : updateOrInsertLink(editor, url);
insertTable: insertTable,
formatBlock: formatBlock,
var addHeaderButtons = function (editor) {
var formatBlock = function (name) {
Actions.formatBlock(editor, name);
for (var i = 1; i < 6; i++) {
text: name.toUpperCase(),
onclick: formatBlock(name),
onPostRender: function () {
var span = this.getEl().firstChild.firstChild;
span.style.fontWeight = 'bold';
var addToEditor = function (editor, panel) {
editor.addButton('quicklink', {
tooltip: 'Insert/Edit link',
stateSelector: 'a[href]',
panel.showForm(editor, 'quicklink');