Current Path : /home/ephorei/www/wp-includes/images/media/q2m9hb/ |
Current File : /home/ephorei/www/wp-includes/images/media/q2m9hb/plugin.js.tar |
home/ephorei/www/wp-includes/js/tinymce/plugins/lists/plugin.js 0000644 00000211417 15006100253 0020742 0 ustar 00 (function () { var lists = (function (domGlobals) { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var global$1 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); var global$2 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK'); var global$4 = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager'); var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var global$6 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var isTextNode = function (node) { return node && node.nodeType === 3; }; var isListNode = function (node) { return node && /^(OL|UL|DL)$/.test(node.nodeName); }; var isOlUlNode = function (node) { return node && /^(OL|UL)$/.test(node.nodeName); }; var isListItemNode = function (node) { return node && /^(LI|DT|DD)$/.test(node.nodeName); }; var isDlItemNode = function (node) { return node && /^(DT|DD)$/.test(node.nodeName); }; var isTableCellNode = function (node) { return node && /^(TH|TD)$/.test(node.nodeName); }; var isBr = function (node) { return node && node.nodeName === 'BR'; }; var isFirstChild = function (node) { return node.parentNode.firstChild === node; }; var isLastChild = function (node) { return node.parentNode.lastChild === node; }; var isTextBlock = function (editor, node) { return node && !!editor.schema.getTextBlockElements()[node.nodeName]; }; var isBlock = function (node, blockElements) { return node && node.nodeName in blockElements; }; var isBogusBr = function (dom, node) { if (!isBr(node)) { return false; } if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) { return true; } return false; }; var isEmpty = function (dom, elm, keepBookmarks) { var empty = dom.isEmpty(elm); if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) { return false; } return empty; }; var isChildOfBody = function (dom, elm) { return dom.isChildOf(elm, dom.getRoot()); }; var NodeType = { isTextNode: isTextNode, isListNode: isListNode, isOlUlNode: isOlUlNode, isDlItemNode: isDlItemNode, isListItemNode: isListItemNode, isTableCellNode: isTableCellNode, isBr: isBr, isFirstChild: isFirstChild, isLastChild: isLastChild, isTextBlock: isTextBlock, isBlock: isBlock, isBogusBr: isBogusBr, isEmpty: isEmpty, isChildOfBody: isChildOfBody }; var getNormalizedPoint = function (container, offset) { if (NodeType.isTextNode(container)) { return { container: container, offset: offset }; } var node = global$1.getNode(container, offset); if (NodeType.isTextNode(node)) { return { container: node, offset: offset >= container.childNodes.length ? node.data.length : 0 }; } else if (node.previousSibling && NodeType.isTextNode(node.previousSibling)) { return { container: node.previousSibling, offset: node.previousSibling.data.length }; } else if (node.nextSibling && NodeType.isTextNode(node.nextSibling)) { return { container: node.nextSibling, offset: 0 }; } return { container: container, offset: offset }; }; var normalizeRange = function (rng) { var outRng = rng.cloneRange(); var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset); outRng.setStart(rangeStart.container, rangeStart.offset); var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset); outRng.setEnd(rangeEnd.container, rangeEnd.offset); return outRng; }; var Range = { getNormalizedPoint: getNormalizedPoint, normalizeRange: normalizeRange }; var DOM = global$6.DOM; var createBookmark = function (rng) { var bookmark = {}; var setupEndPoint = function (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); if (start) { container.insertBefore(offsetNode, container.childNodes[offset]); } else { DOM.insertAfter(offsetNode, container.childNodes[offset]); } } else { container.appendChild(offsetNode); } container = offsetNode; offset = 0; } bookmark[start ? 'startContainer' : 'endContainer'] = container; bookmark[start ? 'startOffset' : 'endOffset'] = offset; }; setupEndPoint(true); if (!rng.collapsed) { setupEndPoint(); } return bookmark; }; var resolveBookmark = function (bookmark) { function restoreEndPoint(start) { var container, offset, node; var nodeIndex = function (container) { var node = container.parentNode.firstChild, idx = 0; while (node) { if (node === container) { return idx; } if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') { idx++; } node = node.nextSibling; } return -1; }; container = node = bookmark[start ? 'startContainer' : 'endContainer']; offset = bookmark[start ? 'startOffset' : 'endOffset']; if (!container) { return; } if (container.nodeType === 1) { offset = nodeIndex(container); container = container.parentNode; DOM.remove(node); if (!container.hasChildNodes() && DOM.isBlock(container)) { container.appendChild(DOM.create('br')); } } bookmark[start ? 'startContainer' : 'endContainer'] = container; bookmark[start ? 'startOffset' : 'endOffset'] = offset; } restoreEndPoint(true); restoreEndPoint(); var rng = DOM.createRng(); rng.setStart(bookmark.startContainer, bookmark.startOffset); if (bookmark.endContainer) { rng.setEnd(bookmark.endContainer, bookmark.endOffset); } return Range.normalizeRange(rng); }; var Bookmark = { createBookmark: createBookmark, resolveBookmark: resolveBookmark }; var noop = function () { }; var constant = function (value) { return function () { return value; }; }; var not = function (f) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return !f.apply(null, args); }; }; var never = constant(false); var always = constant(true); var none = function () { return NONE; }; var NONE = function () { var eq = function (o) { return o.isNone(); }; var call = function (thunk) { return thunk(); }; var id = function (n) { return n; }; var me = { fold: function (n, s) { return n(); }, is: never, isSome: never, isNone: always, getOr: id, getOrThunk: call, getOrDie: function (msg) { throw new Error(msg || 'error: getOrDie called on none.'); }, getOrNull: constant(null), getOrUndefined: constant(undefined), or: id, orThunk: call, map: none, each: noop, bind: none, exists: never, forall: always, filter: none, equals: eq, equals_: eq, toArray: function () { return []; }, toString: constant('none()') }; if (Object.freeze) { Object.freeze(me); } return me; }(); var some = function (a) { var constant_a = constant(a); var self = function () { return me; }; var bind = function (f) { return f(a); }; var me = { fold: function (n, s) { return s(a); }, is: function (v) { return a === v; }, isSome: always, isNone: never, getOr: constant_a, getOrThunk: constant_a, getOrDie: constant_a, getOrNull: constant_a, getOrUndefined: constant_a, or: self, orThunk: self, map: function (f) { return some(f(a)); }, each: function (f) { f(a); }, bind: bind, exists: bind, forall: bind, filter: function (f) { return f(a) ? me : NONE; }, toArray: function () { return [a]; }, toString: function () { return 'some(' + a + ')'; }, equals: function (o) { return o.is(a); }, equals_: function (o, elementEq) { return o.fold(never, function (b) { return elementEq(a, b); }); } }; return me; }; var from = function (value) { return value === null || value === undefined ? NONE : some(value); }; var Option = { some: some, none: none, from: from }; var typeOf = function (x) { if (x === null) { return 'null'; } var t = typeof x; if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { return 'array'; } if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { return 'string'; } return t; }; var isType = function (type) { return function (value) { return typeOf(value) === type; }; }; var isString = isType('string'); var isArray = isType('array'); var isBoolean = isType('boolean'); var isFunction = isType('function'); var isNumber = isType('number'); var nativeSlice = Array.prototype.slice; var nativePush = Array.prototype.push; var map = function (xs, f) { var len = xs.length; var r = new Array(len); for (var i = 0; i < len; i++) { var x = xs[i]; r[i] = f(x, i); } return r; }; var each = function (xs, f) { for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; f(x, i); } }; var filter = function (xs, pred) { var r = []; for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; if (pred(x, i)) { r.push(x); } } return r; }; var groupBy = function (xs, f) { if (xs.length === 0) { return []; } else { var wasType = f(xs[0]); var r = []; var group = []; for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; var type = f(x); if (type !== wasType) { r.push(group); group = []; } wasType = type; group.push(x); } if (group.length !== 0) { r.push(group); } return r; } }; var foldl = function (xs, f, acc) { each(xs, function (x) { acc = f(acc, x); }); return acc; }; var find = function (xs, pred) { for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; if (pred(x, i)) { return Option.some(x); } } return Option.none(); }; var flatten = function (xs) { var r = []; for (var i = 0, len = xs.length; i < len; ++i) { if (!isArray(xs[i])) { throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); } nativePush.apply(r, xs[i]); } return r; }; var bind = function (xs, f) { var output = map(xs, f); return flatten(output); }; var reverse = function (xs) { var r = nativeSlice.call(xs, 0); r.reverse(); return r; }; var head = function (xs) { return xs.length === 0 ? Option.none() : Option.some(xs[0]); }; var last = function (xs) { return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]); }; var from$1 = isFunction(Array.from) ? Array.from : function (x) { return nativeSlice.call(x); }; 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) { o = o[parts[i]]; } return o; }; 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'); } return actual; }; var Global$1 = { getOrDie: getOrDie }; var htmlElement = function (scope) { return Global$1.getOrDie('HTMLElement', scope); }; var isPrototypeOf = function (x) { var scope = resolve('ownerDocument.defaultView', x); return htmlElement(scope).prototype.isPrototypeOf(x); }; var HTMLElement = { isPrototypeOf: isPrototypeOf }; var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery'); var getParentList = function (editor) { var selectionStart = editor.selection.getStart(true); return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart)); }; var isParentListSelected = function (parentList, selectedBlocks) { return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList; }; var findSubLists = function (parentList) { return global$5.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm) { return NodeType.isListNode(elm); }); }; var getSelectedSubLists = function (editor) { var parentList = getParentList(editor); var selectedBlocks = editor.selection.getSelectedBlocks(); if (isParentListSelected(parentList, selectedBlocks)) { return findSubLists(parentList); } else { return global$5.grep(selectedBlocks, function (elm) { return NodeType.isListNode(elm) && parentList !== elm; }); } }; var findParentListItemsNodes = function (editor, elms) { var listItemsElms = global$5.map(elms, function (elm) { var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm)); return parentLi ? parentLi : elm; }); return global$7.unique(listItemsElms); }; var getSelectedListItems = function (editor) { var selectedBlocks = editor.selection.getSelectedBlocks(); return global$5.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) { return NodeType.isListItemNode(block); }); }; var getSelectedDlItems = function (editor) { return filter(getSelectedListItems(editor), NodeType.isDlItemNode); }; var getClosestListRootElm = function (editor, elm) { var parentTableCell = editor.dom.getParents(elm, 'TD,TH'); var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody(); return root; }; var findLastParentListNode = function (editor, elm) { var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm)); return last(parentLists); }; var getSelectedLists = function (editor) { var firstList = findLastParentListNode(editor, editor.selection.getStart()); var subsequentLists = filter(editor.selection.getSelectedBlocks(), NodeType.isOlUlNode); return firstList.toArray().concat(subsequentLists); }; var getSelectedListRoots = function (editor) { var selectedLists = getSelectedLists(editor); return getUniqueListRoots(editor, selectedLists); }; var getUniqueListRoots = function (editor, lists) { var listRoots = map(lists, function (list) { return findLastParentListNode(editor, list).getOr(list); }); return global$7.unique(listRoots); }; var isList = function (editor) { var list = getParentList(editor); return HTMLElement.isPrototypeOf(list); }; var Selection = { isList: isList, getParentList: getParentList, getSelectedSubLists: getSelectedSubLists, getSelectedListItems: getSelectedListItems, getClosestListRootElm: getClosestListRootElm, getSelectedDlItems: getSelectedDlItems, getSelectedListRoots: getSelectedListRoots }; var fromHtml = function (html, scope) { var doc = scope || domGlobals.document; var div = doc.createElement('div'); div.innerHTML = html; if (!div.hasChildNodes() || div.childNodes.length > 1) { domGlobals.console.error('HTML does not have a single root node', html); throw new Error('HTML must have a single root node'); } return fromDom(div.childNodes[0]); }; var fromTag = function (tag, scope) { var doc = scope || domGlobals.document; var node = doc.createElement(tag); return fromDom(node); }; var fromText = function (text, scope) { var doc = scope || domGlobals.document; var node = doc.createTextNode(text); return fromDom(node); }; var fromDom = function (node) { if (node === null || node === undefined) { throw new Error('Node cannot be null or undefined'); } return { dom: constant(node) }; }; var fromPoint = function (docElm, x, y) { var doc = docElm.dom(); return Option.from(doc.elementFromPoint(x, y)).map(fromDom); }; var Element = { fromHtml: fromHtml, fromTag: fromTag, fromText: fromText, fromDom: fromDom, fromPoint: fromPoint }; var lift2 = function (oa, ob, f) { return oa.isSome() && ob.isSome() ? Option.some(f(oa.getOrDie(), ob.getOrDie())) : Option.none(); }; var fromElements = function (elements, scope) { var doc = scope || domGlobals.document; var fragment = doc.createDocumentFragment(); each(elements, function (element) { fragment.appendChild(element.dom()); }); return Element.fromDom(fragment); }; var Immutable = function () { var fields = []; for (var _i = 0; _i < arguments.length; _i++) { fields[_i] = arguments[_i]; } return function () { var values = []; for (var _i = 0; _i < arguments.length; _i++) { values[_i] = arguments[_i]; } if (fields.length !== values.length) { throw new Error('Wrong number of arguments to struct. Expected "[' + fields.length + ']", got ' + values.length + ' arguments'); } var struct = {}; each(fields, function (name, i) { struct[name] = constant(values[i]); }); return struct; }; }; var keys = Object.keys; var each$1 = function (obj, f) { var props = keys(obj); for (var k = 0, len = props.length; k < len; k++) { var i = props[k]; var x = obj[i]; f(x, i); } }; var node = function () { var f = Global$1.getOrDie('Node'); return f; }; var compareDocumentPosition = function (a, b, match) { return (a.compareDocumentPosition(b) & match) !== 0; }; var documentPositionPreceding = function (a, b) { return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_PRECEDING); }; var documentPositionContainedBy = function (a, b) { return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY); }; var Node = { documentPositionPreceding: documentPositionPreceding, documentPositionContainedBy: documentPositionContainedBy }; var cached = function (f) { var called = false; var r; return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (!called) { called = true; r = f.apply(null, args); } return r; }; }; var firstMatch = function (regexes, s) { for (var i = 0; i < regexes.length; i++) { var x = regexes[i]; if (x.test(s)) { return x; } } return undefined; }; var find$1 = function (regexes, agent) { var r = firstMatch(regexes, agent); if (!r) { return { major: 0, minor: 0 }; } var group = function (i) { return Number(agent.replace(r, '$' + i)); }; return nu(group(1), group(2)); }; var detect = function (versionRegexes, agent) { var cleanedAgent = String(agent).toLowerCase(); if (versionRegexes.length === 0) { return unknown(); } return find$1(versionRegexes, cleanedAgent); }; var unknown = function () { return nu(0, 0); }; var nu = function (major, minor) { return { major: major, minor: minor }; }; var Version = { nu: nu, detect: detect, unknown: unknown }; var edge = 'Edge'; var chrome = 'Chrome'; var ie = 'IE'; var opera = 'Opera'; var firefox = 'Firefox'; var safari = 'Safari'; var isBrowser = function (name, current) { return function () { return current === name; }; }; var unknown$1 = function () { return nu$1({ current: undefined, version: Version.unknown() }); }; var nu$1 = function (info) { var current = info.current; var version = info.version; return { current: current, version: version, isEdge: isBrowser(edge, current), isChrome: isBrowser(chrome, current), isIE: isBrowser(ie, current), isOpera: isBrowser(opera, current), isFirefox: isBrowser(firefox, current), isSafari: isBrowser(safari, current) }; }; var Browser = { unknown: unknown$1, nu: nu$1, edge: constant(edge), chrome: constant(chrome), ie: constant(ie), opera: constant(opera), firefox: constant(firefox), safari: constant(safari) }; var windows = 'Windows'; var ios = 'iOS'; var android = 'Android'; var linux = 'Linux'; var osx = 'OSX'; var solaris = 'Solaris'; var freebsd = 'FreeBSD'; var isOS = function (name, current) { return function () { return current === name; }; }; var unknown$2 = function () { return nu$2({ current: undefined, version: Version.unknown() }); }; var nu$2 = function (info) { var current = info.current; var version = info.version; return { current: current, version: version, isWindows: isOS(windows, current), isiOS: isOS(ios, current), isAndroid: isOS(android, current), isOSX: isOS(osx, current), isLinux: isOS(linux, current), isSolaris: isOS(solaris, current), isFreeBSD: isOS(freebsd, current) }; }; var OperatingSystem = { unknown: unknown$2, nu: nu$2, windows: constant(windows), ios: constant(ios), android: constant(android), linux: constant(linux), osx: constant(osx), solaris: constant(solaris), freebsd: constant(freebsd) }; var DeviceType = function (os, browser, userAgent) { var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true; var isiPhone = os.isiOS() && !isiPad; var isAndroid3 = os.isAndroid() && os.version.major === 3; var isAndroid4 = os.isAndroid() && os.version.major === 4; var isTablet = isiPad || isAndroid3 || isAndroid4 && /mobile/i.test(userAgent) === true; var isTouch = os.isiOS() || os.isAndroid(); var isPhone = isTouch && !isTablet; var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false; return { isiPad: constant(isiPad), isiPhone: constant(isiPhone), isTablet: constant(isTablet), isPhone: constant(isPhone), isTouch: constant(isTouch), isAndroid: os.isAndroid, isiOS: os.isiOS, isWebView: constant(iOSwebview) }; }; var detect$1 = function (candidates, userAgent) { var agent = String(userAgent).toLowerCase(); return find(candidates, function (candidate) { return candidate.search(agent); }); }; var detectBrowser = function (browsers, userAgent) { return detect$1(browsers, userAgent).map(function (browser) { var version = Version.detect(browser.versionRegexes, userAgent); return { current: browser.name, version: version }; }); }; var detectOs = function (oses, userAgent) { return detect$1(oses, userAgent).map(function (os) { var version = Version.detect(os.versionRegexes, userAgent); return { current: os.name, version: version }; }); }; var UaString = { detectBrowser: detectBrowser, detectOs: detectOs }; var contains = function (str, substr) { return str.indexOf(substr) !== -1; }; var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; var checkContains = function (target) { return function (uastring) { return contains(uastring, target); }; }; var browsers = [ { name: 'Edge', versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], search: function (uastring) { return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit'); } }, { name: 'Chrome', versionRegexes: [ /.*?chrome\/([0-9]+)\.([0-9]+).*/, normalVersionRegex ], search: function (uastring) { return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe'); } }, { name: 'IE', versionRegexes: [ /.*?msie\ ?([0-9]+)\.([0-9]+).*/, /.*?rv:([0-9]+)\.([0-9]+).*/ ], search: function (uastring) { return contains(uastring, 'msie') || contains(uastring, 'trident'); } }, { name: 'Opera', versionRegexes: [ normalVersionRegex, /.*?opera\/([0-9]+)\.([0-9]+).*/ ], search: checkContains('opera') }, { name: 'Firefox', versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/], search: checkContains('firefox') }, { name: 'Safari', versionRegexes: [ normalVersionRegex, /.*?cpu os ([0-9]+)_([0-9]+).*/ ], search: function (uastring) { return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit'); } } ]; var oses = [ { name: 'Windows', search: checkContains('win'), versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] }, { name: 'iOS', search: function (uastring) { return contains(uastring, 'iphone') || contains(uastring, 'ipad'); }, versionRegexes: [ /.*?version\/\ ?([0-9]+)\.([0-9]+).*/, /.*cpu os ([0-9]+)_([0-9]+).*/, /.*cpu iphone os ([0-9]+)_([0-9]+).*/ ] }, { name: 'Android', search: checkContains('android'), versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/] }, { name: 'OSX', search: checkContains('os x'), versionRegexes: [/.*?os\ x\ ?([0-9]+)_([0-9]+).*/] }, { name: 'Linux', search: checkContains('linux'), versionRegexes: [] }, { name: 'Solaris', search: checkContains('sunos'), versionRegexes: [] }, { name: 'FreeBSD', search: checkContains('freebsd'), versionRegexes: [] } ]; var PlatformInfo = { browsers: constant(browsers), oses: constant(oses) }; var detect$2 = function (userAgent) { var browsers = PlatformInfo.browsers(); var oses = PlatformInfo.oses(); var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu); var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu); var deviceType = DeviceType(os, browser, userAgent); return { browser: browser, os: os, deviceType: deviceType }; }; var PlatformDetection = { detect: detect$2 }; var detect$3 = cached(function () { var userAgent = domGlobals.navigator.userAgent; return PlatformDetection.detect(userAgent); }); var PlatformDetection$1 = { detect: detect$3 }; var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE; var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE; var COMMENT = domGlobals.Node.COMMENT_NODE; var DOCUMENT = domGlobals.Node.DOCUMENT_NODE; var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE; var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE; var ELEMENT = domGlobals.Node.ELEMENT_NODE; var TEXT = domGlobals.Node.TEXT_NODE; var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE; var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE; var ENTITY = domGlobals.Node.ENTITY_NODE; var NOTATION = domGlobals.Node.NOTATION_NODE; var ELEMENT$1 = ELEMENT; var is = function (element, selector) { var dom = element.dom(); if (dom.nodeType !== ELEMENT$1) { return false; } else { var elem = dom; if (elem.matches !== undefined) { return elem.matches(selector); } else if (elem.msMatchesSelector !== undefined) { return elem.msMatchesSelector(selector); } else if (elem.webkitMatchesSelector !== undefined) { return elem.webkitMatchesSelector(selector); } else if (elem.mozMatchesSelector !== undefined) { return elem.mozMatchesSelector(selector); } else { throw new Error('Browser lacks native selectors'); } } }; var eq = function (e1, e2) { return e1.dom() === e2.dom(); }; var regularContains = function (e1, e2) { var d1 = e1.dom(); var d2 = e2.dom(); return d1 === d2 ? false : d1.contains(d2); }; var ieContains = function (e1, e2) { return Node.documentPositionContainedBy(e1.dom(), e2.dom()); }; var browser = PlatformDetection$1.detect().browser; var contains$1 = browser.isIE() ? ieContains : regularContains; var is$1 = is; var parent = function (element) { return Option.from(element.dom().parentNode).map(Element.fromDom); }; var children = function (element) { return map(element.dom().childNodes, Element.fromDom); }; var child = function (element, index) { var cs = element.dom().childNodes; return Option.from(cs[index]).map(Element.fromDom); }; var firstChild = function (element) { return child(element, 0); }; var lastChild = function (element) { return child(element, element.dom().childNodes.length - 1); }; var spot = Immutable('element', 'offset'); var before = function (marker, element) { var parent$1 = parent(marker); parent$1.each(function (v) { v.dom().insertBefore(element.dom(), marker.dom()); }); }; var append = function (parent, element) { parent.dom().appendChild(element.dom()); }; var before$1 = function (marker, elements) { each(elements, function (x) { before(marker, x); }); }; var append$1 = function (parent, elements) { each(elements, function (x) { append(parent, x); }); }; var remove = function (element) { var dom = element.dom(); if (dom.parentNode !== null) { dom.parentNode.removeChild(dom); } }; var name = function (element) { var r = element.dom().nodeName; return r.toLowerCase(); }; var type = function (element) { return element.dom().nodeType; }; var isType$1 = function (t) { return function (element) { return type(element) === t; }; }; var isElement = isType$1(ELEMENT); var rawSet = function (dom, key, value) { if (isString(value) || isBoolean(value) || isNumber(value)) { dom.setAttribute(key, value + ''); } else { domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom); throw new Error('Attribute value was not simple'); } }; var setAll = function (element, attrs) { var dom = element.dom(); each$1(attrs, function (v, k) { rawSet(dom, k, v); }); }; var clone = function (element) { return foldl(element.dom().attributes, function (acc, attr) { acc[attr.name] = attr.value; return acc; }, {}); }; var isSupported = function (dom) { return dom.style !== undefined && isFunction(dom.style.getPropertyValue); }; var internalSet = function (dom, property, value) { if (!isString(value)) { domGlobals.console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom); throw new Error('CSS value must be a string: ' + value); } if (isSupported(dom)) { dom.style.setProperty(property, value); } }; var set = function (element, property, value) { var dom = element.dom(); internalSet(dom, property, value); }; var clone$1 = function (original, isDeep) { return Element.fromDom(original.dom().cloneNode(isDeep)); }; var deep = function (original) { return clone$1(original, true); }; var shallowAs = function (original, tag) { var nu = Element.fromTag(tag); var attributes = clone(original); setAll(nu, attributes); return nu; }; var mutate = function (original, tag) { var nu = shallowAs(original, tag); before(original, nu); var children$1 = children(original); append$1(nu, children$1); remove(original); return nu; }; var joinSegment = function (parent, child) { append(parent.item, child.list); }; var joinSegments = function (segments) { for (var i = 1; i < segments.length; i++) { joinSegment(segments[i - 1], segments[i]); } }; var appendSegments = function (head$1, tail) { lift2(last(head$1), head(tail), joinSegment); }; var createSegment = function (scope, listType) { var segment = { list: Element.fromTag(listType, scope), item: Element.fromTag('li', scope) }; append(segment.list, segment.item); return segment; }; var createSegments = function (scope, entry, size) { var segments = []; for (var i = 0; i < size; i++) { segments.push(createSegment(scope, entry.listType)); } return segments; }; var populateSegments = function (segments, entry) { for (var i = 0; i < segments.length - 1; i++) { set(segments[i].item, 'list-style-type', 'none'); } last(segments).each(function (segment) { setAll(segment.list, entry.listAttributes); setAll(segment.item, entry.itemAttributes); append$1(segment.item, entry.content); }); }; var normalizeSegment = function (segment, entry) { if (name(segment.list) !== entry.listType) { segment.list = mutate(segment.list, entry.listType); } setAll(segment.list, entry.listAttributes); }; var createItem = function (scope, attr, content) { var item = Element.fromTag('li', scope); setAll(item, attr); append$1(item, content); return item; }; var appendItem = function (segment, item) { append(segment.list, item); segment.item = item; }; var writeShallow = function (scope, cast, entry) { var newCast = cast.slice(0, entry.depth); last(newCast).each(function (segment) { var item = createItem(scope, entry.itemAttributes, entry.content); appendItem(segment, item); normalizeSegment(segment, entry); }); return newCast; }; var writeDeep = function (scope, cast, entry) { var segments = createSegments(scope, entry, entry.depth - cast.length); joinSegments(segments); populateSegments(segments, entry); appendSegments(cast, segments); return cast.concat(segments); }; var composeList = function (scope, entries) { var cast = foldl(entries, function (cast, entry) { return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry); }, []); return head(cast).map(function (segment) { return segment.list; }); }; var isList$1 = function (el) { return is$1(el, 'OL,UL'); }; var hasFirstChildList = function (el) { return firstChild(el).map(isList$1).getOr(false); }; var hasLastChildList = function (el) { return lastChild(el).map(isList$1).getOr(false); }; var isIndented = function (entry) { return entry.depth > 0; }; var isSelected = function (entry) { return entry.isSelected; }; var cloneItemContent = function (li) { var children$1 = children(li); var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1; return map(content, deep); }; var createEntry = function (li, depth, isSelected) { return parent(li).filter(isElement).map(function (list) { return { depth: depth, isSelected: isSelected, content: cloneItemContent(li), itemAttributes: clone(li), listAttributes: clone(list), listType: name(list) }; }); }; var indentEntry = function (indentation, entry) { switch (indentation) { case 'Indent': entry.depth++; break; case 'Outdent': entry.depth--; break; case 'Flatten': entry.depth = 0; } }; var hasOwnProperty = Object.prototype.hasOwnProperty; var shallow = function (old, nu) { return nu; }; var baseMerge = function (merger) { return function () { var objects = new Array(arguments.length); for (var i = 0; i < objects.length; i++) { objects[i] = arguments[i]; } if (objects.length === 0) { throw new Error('Can\'t merge zero objects'); } var ret = {}; for (var j = 0; j < objects.length; j++) { var curObject = objects[j]; for (var key in curObject) { if (hasOwnProperty.call(curObject, key)) { ret[key] = merger(ret[key], curObject[key]); } } } return ret; }; }; var merge = baseMerge(shallow); var cloneListProperties = function (target, source) { target.listType = source.listType; target.listAttributes = merge({}, source.listAttributes); }; var previousSiblingEntry = function (entries, start) { var depth = entries[start].depth; for (var i = start - 1; i >= 0; i--) { if (entries[i].depth === depth) { return Option.some(entries[i]); } if (entries[i].depth < depth) { break; } } return Option.none(); }; var normalizeEntries = function (entries) { each(entries, function (entry, i) { previousSiblingEntry(entries, i).each(function (matchingEntry) { cloneListProperties(entry, matchingEntry); }); }); }; var Cell = function (initial) { var value = initial; var get = function () { return value; }; var set = function (v) { value = v; }; var clone = function () { return Cell(get()); }; return { get: get, set: set, clone: clone }; }; var parseItem = function (depth, itemSelection, selectionState, item) { return firstChild(item).filter(isList$1).fold(function () { itemSelection.each(function (selection) { if (eq(selection.start, item)) { selectionState.set(true); } }); var currentItemEntry = createEntry(item, depth, selectionState.get()); itemSelection.each(function (selection) { if (eq(selection.end, item)) { selectionState.set(false); } }); var childListEntries = lastChild(item).filter(isList$1).map(function (list) { return parseList(depth, itemSelection, selectionState, list); }).getOr([]); return currentItemEntry.toArray().concat(childListEntries); }, function (list) { return parseList(depth, itemSelection, selectionState, list); }); }; var parseList = function (depth, itemSelection, selectionState, list) { return bind(children(list), function (element) { var parser = isList$1(element) ? parseList : parseItem; var newDepth = depth + 1; return parser(newDepth, itemSelection, selectionState, element); }); }; var parseLists = function (lists, itemSelection) { var selectionState = Cell(false); var initialDepth = 0; return map(lists, function (list) { return { sourceList: list, entries: parseList(initialDepth, itemSelection, selectionState, list) }; }); }; var global$8 = tinymce.util.Tools.resolve('tinymce.Env'); var createTextBlock = function (editor, contentNode) { var dom = editor.dom; var blockElements = editor.schema.getBlockElements(); var fragment = dom.createFragment(); var node, textBlock, blockName, hasContentNode; if (editor.settings.forced_root_block) { blockName = editor.settings.forced_root_block; } if (blockName) { textBlock = dom.create(blockName); if (textBlock.tagName === editor.settings.forced_root_block) { dom.setAttribs(textBlock, editor.settings.forced_root_block_attrs); } if (!NodeType.isBlock(contentNode.firstChild, blockElements)) { fragment.appendChild(textBlock); } } if (contentNode) { while (node = contentNode.firstChild) { var nodeName = node.nodeName; if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) { hasContentNode = true; } if (NodeType.isBlock(node, blockElements)) { fragment.appendChild(node); textBlock = null; } else { if (blockName) { if (!textBlock) { textBlock = dom.create(blockName); fragment.appendChild(textBlock); } textBlock.appendChild(node); } else { fragment.appendChild(node); } } } } if (!editor.settings.forced_root_block) { fragment.appendChild(dom.create('br')); } else { if (!hasContentNode && (!global$8.ie || global$8.ie > 10)) { textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' })); } } return fragment; }; var outdentedComposer = function (editor, entries) { return map(entries, function (entry) { var content = fromElements(entry.content); return Element.fromDom(createTextBlock(editor, content.dom())); }); }; var indentedComposer = function (editor, entries) { normalizeEntries(entries); return composeList(editor.contentDocument, entries).toArray(); }; var composeEntries = function (editor, entries) { return bind(groupBy(entries, isIndented), function (entries) { var groupIsIndented = head(entries).map(isIndented).getOr(false); return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries); }); }; var indentSelectedEntries = function (entries, indentation) { each(filter(entries, isSelected), function (entry) { return indentEntry(indentation, entry); }); }; var getItemSelection = function (editor) { var selectedListItems = map(Selection.getSelectedListItems(editor), Element.fromDom); return lift2(find(selectedListItems, not(hasFirstChildList)), find(reverse(selectedListItems), not(hasFirstChildList)), function (start, end) { return { start: start, end: end }; }); }; var listsIndentation = function (editor, lists, indentation) { var entrySets = parseLists(lists, getItemSelection(editor)); each(entrySets, function (entrySet) { indentSelectedEntries(entrySet.entries, indentation); before$1(entrySet.sourceList, composeEntries(editor, entrySet.entries)); remove(entrySet.sourceList); }); }; var DOM$1 = global$6.DOM; var splitList = function (editor, ul, li) { var tmpRng, fragment, bookmarks, node, newBlock; var removeAndKeepBookmarks = function (targetNode) { global$5.each(bookmarks, function (node) { targetNode.parentNode.insertBefore(node, li.parentNode); }); DOM$1.remove(targetNode); }; bookmarks = DOM$1.select('span[data-mce-type="bookmark"]', ul); newBlock = createTextBlock(editor, li); tmpRng = DOM$1.createRng(); tmpRng.setStartAfter(li); tmpRng.setEndAfter(ul); fragment = tmpRng.extractContents(); for (node = fragment.firstChild; node; node = node.firstChild) { if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) { DOM$1.remove(node); break; } } if (!editor.dom.isEmpty(fragment)) { DOM$1.insertAfter(fragment, ul); } DOM$1.insertAfter(newBlock, ul); if (NodeType.isEmpty(editor.dom, li.parentNode)) { removeAndKeepBookmarks(li.parentNode); } DOM$1.remove(li); if (NodeType.isEmpty(editor.dom, ul)) { DOM$1.remove(ul); } }; var SplitList = { splitList: splitList }; var outdentDlItem = function (editor, item) { if (is$1(item, 'dd')) { mutate(item, 'dt'); } else if (is$1(item, 'dt')) { parent(item).each(function (dl) { return SplitList.splitList(editor, dl.dom(), item.dom()); }); } }; var indentDlItem = function (item) { if (is$1(item, 'dt')) { mutate(item, 'dd'); } }; var dlIndentation = function (editor, indentation, dlItems) { if (indentation === 'Indent') { each(dlItems, indentDlItem); } else { each(dlItems, function (item) { return outdentDlItem(editor, item); }); } }; var selectionIndentation = function (editor, indentation) { var lists = map(Selection.getSelectedListRoots(editor), Element.fromDom); var dlItems = map(Selection.getSelectedDlItems(editor), Element.fromDom); var isHandled = false; if (lists.length || dlItems.length) { var bookmark = editor.selection.getBookmark(); listsIndentation(editor, lists, indentation); dlIndentation(editor, indentation, dlItems); editor.selection.moveToBookmark(bookmark); editor.selection.setRng(Range.normalizeRange(editor.selection.getRng())); editor.nodeChanged(); isHandled = true; } return isHandled; }; var indentListSelection = function (editor) { return selectionIndentation(editor, 'Indent'); }; var outdentListSelection = function (editor) { return selectionIndentation(editor, 'Outdent'); }; var flattenListSelection = function (editor) { return selectionIndentation(editor, 'Flatten'); }; var updateListStyle = function (dom, el, detail) { var type = detail['list-style-type'] ? detail['list-style-type'] : null; dom.setStyle(el, 'list-style-type', type); }; var setAttribs = function (elm, attrs) { global$5.each(attrs, function (value, key) { elm.setAttribute(key, value); }); }; var updateListAttrs = function (dom, el, detail) { setAttribs(el, detail['list-attributes']); global$5.each(dom.select('li', el), function (li) { setAttribs(li, detail['list-item-attributes']); }); }; var updateListWithDetails = function (dom, el, detail) { updateListStyle(dom, el, detail); updateListAttrs(dom, el, detail); }; var removeStyles = function (dom, element, styles) { global$5.each(styles, function (style) { var _a; return dom.setStyle(element, (_a = {}, _a[style] = '', _a)); }); }; var getEndPointNode = function (editor, rng, start, root) { var container, offset; container = rng[start ? 'startContainer' : 'endContainer']; offset = rng[start ? 'startOffset' : 'endOffset']; if (container.nodeType === 1) { container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container; } if (!start && NodeType.isBr(container.nextSibling)) { container = container.nextSibling; } while (container.parentNode !== root) { if (NodeType.isTextBlock(editor, container)) { return container; } if (/^(TD|TH)$/.test(container.parentNode.nodeName)) { return container; } container = container.parentNode; } return container; }; var getSelectedTextBlocks = function (editor, rng, root) { var textBlocks = [], dom = editor.dom; var startNode = getEndPointNode(editor, rng, true, root); var endNode = getEndPointNode(editor, rng, false, root); var block; var siblings = []; for (var node = startNode; node; node = node.nextSibling) { siblings.push(node); if (node === endNode) { break; } } global$5.each(siblings, function (node) { if (NodeType.isTextBlock(editor, node)) { textBlocks.push(node); block = null; return; } if (dom.isBlock(node) || NodeType.isBr(node)) { if (NodeType.isBr(node)) { dom.remove(node); } block = null; return; } var nextSibling = node.nextSibling; if (global$4.isBookmarkNode(node)) { if (NodeType.isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) { block = null; return; } } if (!block) { block = dom.create('p'); node.parentNode.insertBefore(block, node); textBlocks.push(block); } block.appendChild(node); }); return textBlocks; }; var hasCompatibleStyle = function (dom, sib, detail) { var sibStyle = dom.getStyle(sib, 'list-style-type'); var detailStyle = detail ? detail['list-style-type'] : ''; detailStyle = detailStyle === null ? '' : detailStyle; return sibStyle === detailStyle; }; var applyList = function (editor, listName, detail) { if (detail === void 0) { detail = {}; } var rng = editor.selection.getRng(true); var bookmark; var listItemName = 'LI'; var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true)); var dom = editor.dom; if (dom.getContentEditable(editor.selection.getNode()) === 'false') { return; } listName = listName.toUpperCase(); if (listName === 'DL') { listItemName = 'DT'; } bookmark = Bookmark.createBookmark(rng); global$5.each(getSelectedTextBlocks(editor, rng, root), function (block) { var listBlock, sibling; sibling = block.previousSibling; if (sibling && NodeType.isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) { listBlock = sibling; block = dom.rename(block, listItemName); sibling.appendChild(block); } else { listBlock = dom.create(listName); block.parentNode.insertBefore(listBlock, block); listBlock.appendChild(block); block = dom.rename(block, listItemName); } removeStyles(dom, block, [ 'margin', 'margin-right', 'margin-bottom', 'margin-left', 'margin-top', 'padding', 'padding-right', 'padding-bottom', 'padding-left', 'padding-top' ]); updateListWithDetails(dom, listBlock, detail); mergeWithAdjacentLists(editor.dom, listBlock); }); editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); }; var isValidLists = function (list1, list2) { return list1 && list2 && NodeType.isListNode(list1) && list1.nodeName === list2.nodeName; }; var hasSameListStyle = function (dom, list1, list2) { var targetStyle = dom.getStyle(list1, 'list-style-type', true); var style = dom.getStyle(list2, 'list-style-type', true); return targetStyle === style; }; var hasSameClasses = function (elm1, elm2) { return elm1.className === elm2.className; }; var shouldMerge = function (dom, list1, list2) { return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2); }; var mergeWithAdjacentLists = function (dom, listBlock) { var sibling, node; sibling = listBlock.nextSibling; if (shouldMerge(dom, listBlock, sibling)) { while (node = sibling.firstChild) { listBlock.appendChild(node); } dom.remove(sibling); } sibling = listBlock.previousSibling; if (shouldMerge(dom, listBlock, sibling)) { while (node = sibling.lastChild) { listBlock.insertBefore(node, listBlock.firstChild); } dom.remove(sibling); } }; var updateList = function (dom, list, listName, detail) { if (list.nodeName !== listName) { var newList = dom.rename(list, listName); updateListWithDetails(dom, newList, detail); } else { updateListWithDetails(dom, list, detail); } }; var toggleMultipleLists = function (editor, parentList, lists, listName, detail) { if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { flattenListSelection(editor); } else { var bookmark = Bookmark.createBookmark(editor.selection.getRng(true)); global$5.each([parentList].concat(lists), function (elm) { updateList(editor.dom, elm, listName, detail); }); editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); } }; var hasListStyleDetail = function (detail) { return 'list-style-type' in detail; }; var toggleSingleList = function (editor, parentList, listName, detail) { if (parentList === editor.getBody()) { return; } if (parentList) { if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { flattenListSelection(editor); } else { var bookmark = Bookmark.createBookmark(editor.selection.getRng(true)); updateListWithDetails(editor.dom, parentList, detail); mergeWithAdjacentLists(editor.dom, editor.dom.rename(parentList, listName)); editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); } } else { applyList(editor, listName, detail); } }; var toggleList = function (editor, listName, detail) { var parentList = Selection.getParentList(editor); var selectedSubLists = Selection.getSelectedSubLists(editor); detail = detail ? detail : {}; if (parentList && selectedSubLists.length > 0) { toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail); } else { toggleSingleList(editor, parentList, listName, detail); } }; var ToggleList = { toggleList: toggleList, mergeWithAdjacentLists: mergeWithAdjacentLists }; var DOM$2 = global$6.DOM; var normalizeList = function (dom, ul) { var sibling; var parentNode = ul.parentNode; if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) { sibling = parentNode.previousSibling; if (sibling && sibling.nodeName === 'LI') { sibling.appendChild(ul); if (NodeType.isEmpty(dom, parentNode)) { DOM$2.remove(parentNode); } } else { DOM$2.setStyle(parentNode, 'listStyleType', 'none'); } } if (NodeType.isListNode(parentNode)) { sibling = parentNode.previousSibling; if (sibling && sibling.nodeName === 'LI') { sibling.appendChild(ul); } } }; var normalizeLists = function (dom, element) { global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) { normalizeList(dom, ul); }); }; var NormalizeLists = { normalizeList: normalizeList, normalizeLists: normalizeLists }; var findNextCaretContainer = function (editor, rng, isForward, root) { var node = rng.startContainer; var offset = rng.startOffset; var nonEmptyBlocks, walker; if (node.nodeType === 3 && (isForward ? offset < node.data.length : offset > 0)) { return node; } nonEmptyBlocks = editor.schema.getNonEmptyElements(); if (node.nodeType === 1) { node = global$1.getNode(node, offset); } walker = new global$2(node, root); if (isForward) { if (NodeType.isBogusBr(editor.dom, node)) { walker.next(); } } while (node = walker[isForward ? 'next' : 'prev2']()) { if (node.nodeName === 'LI' && !node.hasChildNodes()) { return node; } if (nonEmptyBlocks[node.nodeName]) { return node; } if (node.nodeType === 3 && node.data.length > 0) { return node; } } }; var hasOnlyOneBlockChild = function (dom, elm) { var childNodes = elm.childNodes; return childNodes.length === 1 && !NodeType.isListNode(childNodes[0]) && dom.isBlock(childNodes[0]); }; var unwrapSingleBlockChild = function (dom, elm) { if (hasOnlyOneBlockChild(dom, elm)) { dom.remove(elm.firstChild, true); } }; var moveChildren = function (dom, fromElm, toElm) { var node, targetElm; targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm; unwrapSingleBlockChild(dom, fromElm); if (!NodeType.isEmpty(dom, fromElm, true)) { while (node = fromElm.firstChild) { targetElm.appendChild(node); } } }; var mergeLiElements = function (dom, fromElm, toElm) { var node, listNode; var ul = fromElm.parentNode; if (!NodeType.isChildOfBody(dom, fromElm) || !NodeType.isChildOfBody(dom, toElm)) { return; } if (NodeType.isListNode(toElm.lastChild)) { listNode = toElm.lastChild; } if (ul === toElm.lastChild) { if (NodeType.isBr(ul.previousSibling)) { dom.remove(ul.previousSibling); } } node = toElm.lastChild; if (node && NodeType.isBr(node) && fromElm.hasChildNodes()) { dom.remove(node); } if (NodeType.isEmpty(dom, toElm, true)) { dom.$(toElm).empty(); } moveChildren(dom, fromElm, toElm); if (listNode) { toElm.appendChild(listNode); } var contains = contains$1(Element.fromDom(toElm), Element.fromDom(fromElm)); var nestedLists = contains ? dom.getParents(fromElm, NodeType.isListNode, toElm) : []; dom.remove(fromElm); each(nestedLists, function (list) { if (NodeType.isEmpty(dom, list) && list !== dom.getRoot()) { dom.remove(list); } }); }; var mergeIntoEmptyLi = function (editor, fromLi, toLi) { editor.dom.$(toLi).empty(); mergeLiElements(editor.dom, fromLi, toLi); editor.selection.setCursorLocation(toLi); }; var mergeForward = function (editor, rng, fromLi, toLi) { var dom = editor.dom; if (dom.isEmpty(toLi)) { mergeIntoEmptyLi(editor, fromLi, toLi); } else { var bookmark = Bookmark.createBookmark(rng); mergeLiElements(dom, fromLi, toLi); editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); } }; var mergeBackward = function (editor, rng, fromLi, toLi) { var bookmark = Bookmark.createBookmark(rng); mergeLiElements(editor.dom, fromLi, toLi); var resolvedBookmark = Bookmark.resolveBookmark(bookmark); editor.selection.setRng(resolvedBookmark); }; var backspaceDeleteFromListToListCaret = function (editor, isForward) { var dom = editor.dom, selection = editor.selection; var selectionStartElm = selection.getStart(); var root = Selection.getClosestListRootElm(editor, selectionStartElm); var li = dom.getParent(selection.getStart(), 'LI', root); var ul, rng, otherLi; if (li) { ul = li.parentNode; if (ul === editor.getBody() && NodeType.isEmpty(dom, ul)) { return true; } rng = Range.normalizeRange(selection.getRng(true)); otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); if (otherLi && otherLi !== li) { if (isForward) { mergeForward(editor, rng, otherLi, li); } else { mergeBackward(editor, rng, li, otherLi); } return true; } else if (!otherLi) { if (!isForward) { flattenListSelection(editor); return true; } } } return false; }; var removeBlock = function (dom, block, root) { var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root); dom.remove(block); if (parentBlock && dom.isEmpty(parentBlock)) { dom.remove(parentBlock); } }; var backspaceDeleteIntoListCaret = function (editor, isForward) { var dom = editor.dom; var selectionStartElm = editor.selection.getStart(); var root = Selection.getClosestListRootElm(editor, selectionStartElm); var block = dom.getParent(selectionStartElm, dom.isBlock, root); if (block && dom.isEmpty(block)) { var rng = Range.normalizeRange(editor.selection.getRng(true)); var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); if (otherLi_1) { editor.undoManager.transact(function () { removeBlock(dom, block, root); ToggleList.mergeWithAdjacentLists(dom, otherLi_1.parentNode); editor.selection.select(otherLi_1, true); editor.selection.collapse(isForward); }); return true; } } return false; }; var backspaceDeleteCaret = function (editor, isForward) { return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward); }; var backspaceDeleteRange = function (editor) { var selectionStartElm = editor.selection.getStart(); var root = Selection.getClosestListRootElm(editor, selectionStartElm); var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root); if (startListParent || Selection.getSelectedListItems(editor).length > 0) { editor.undoManager.transact(function () { editor.execCommand('Delete'); NormalizeLists.normalizeLists(editor.dom, editor.getBody()); }); return true; } return false; }; var backspaceDelete = function (editor, isForward) { return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor); }; var setup = function (editor) { editor.on('keydown', function (e) { if (e.keyCode === global$3.BACKSPACE) { if (backspaceDelete(editor, false)) { e.preventDefault(); } } else if (e.keyCode === global$3.DELETE) { if (backspaceDelete(editor, true)) { e.preventDefault(); } } }); }; var Delete = { setup: setup, backspaceDelete: backspaceDelete }; var get = function (editor) { return { backspaceDelete: function (isForward) { Delete.backspaceDelete(editor, isForward); } }; }; var Api = { get: get }; var queryListCommandState = function (editor, listName) { return function () { var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL'); return parentList && parentList.nodeName === listName; }; }; var register = function (editor) { editor.on('BeforeExecCommand', function (e) { var cmd = e.command.toLowerCase(); if (cmd === 'indent') { indentListSelection(editor); } else if (cmd === 'outdent') { outdentListSelection(editor); } }); editor.addCommand('InsertUnorderedList', function (ui, detail) { ToggleList.toggleList(editor, 'UL', detail); }); editor.addCommand('InsertOrderedList', function (ui, detail) { ToggleList.toggleList(editor, 'OL', detail); }); editor.addCommand('InsertDefinitionList', function (ui, detail) { ToggleList.toggleList(editor, 'DL', detail); }); editor.addCommand('RemoveList', function () { flattenListSelection(editor); }); editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL')); editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL')); editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL')); }; var Commands = { register: register }; var shouldIndentOnTab = function (editor) { return editor.getParam('lists_indent_on_tab', true); }; var Settings = { shouldIndentOnTab: shouldIndentOnTab }; var setupTabKey = function (editor) { editor.on('keydown', function (e) { if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) { return; } editor.undoManager.transact(function () { if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) { e.preventDefault(); } }); }); }; var setup$1 = function (editor) { if (Settings.shouldIndentOnTab(editor)) { setupTabKey(editor); } Delete.setup(editor); }; var Keyboard = { setup: setup$1 }; var findIndex = function (list, predicate) { for (var index = 0; index < list.length; index++) { var element = list[index]; if (predicate(element)) { return index; } } return -1; }; var listState = function (editor, listName) { return function (e) { var ctrl = e.control; editor.on('NodeChange', function (e) { var tableCellIndex = findIndex(e.parents, NodeType.isTableCellNode); var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents; var lists = global$5.grep(parents, NodeType.isListNode); ctrl.active(lists.length > 0 && lists[0].nodeName === listName); }); }; }; var register$1 = function (editor) { var hasPlugin = function (editor, plugin) { var plugins = editor.settings.plugins ? editor.settings.plugins : ''; return global$5.inArray(plugins.split(/[ ,]/), plugin) !== -1; }; if (!hasPlugin(editor, 'advlist')) { editor.addButton('numlist', { active: false, title: 'Numbered list', cmd: 'InsertOrderedList', onPostRender: listState(editor, 'OL') }); editor.addButton('bullist', { active: false, title: 'Bullet list', cmd: 'InsertUnorderedList', onPostRender: listState(editor, 'UL') }); } editor.addButton('indent', { icon: 'indent', title: 'Increase indent', cmd: 'Indent' }); }; var Buttons = { register: register$1 }; global.add('lists', function (editor) { Keyboard.setup(editor); Buttons.register(editor); Commands.register(editor); return Api.get(editor); }); function Plugin () { } return Plugin; }(window)); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/fullscreen/plugin.js 0000644 00000012733 15006100513 0021745 0 ustar 00 (function () { var fullscreen = (function (domGlobals) { 'use strict'; var Cell = function (initial) { var value = initial; var get = function () { return value; }; var set = function (v) { value = v; }; var clone = function () { return Cell(get()); }; return { get: get, set: set, clone: clone }; }; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var get = function (fullscreenState) { return { isFullscreen: function () { return fullscreenState.get() !== null; } }; }; var Api = { get: get }; var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var fireFullscreenStateChanged = function (editor, state) { editor.fire('FullscreenStateChanged', { state: state }); }; var Events = { fireFullscreenStateChanged: fireFullscreenStateChanged }; var DOM = global$1.DOM; var getWindowSize = function () { var w; var h; var win = domGlobals.window; var doc = domGlobals.document; var body = doc.body; if (body.offsetWidth) { w = body.offsetWidth; h = body.offsetHeight; } if (win.innerWidth && win.innerHeight) { w = win.innerWidth; h = win.innerHeight; } return { w: w, h: h }; }; var getScrollPos = function () { var vp = DOM.getViewPort(); return { x: vp.x, y: vp.y }; }; var setScrollPos = function (pos) { domGlobals.window.scrollTo(pos.x, pos.y); }; var toggleFullscreen = function (editor, fullscreenState) { var body = domGlobals.document.body; var documentElement = domGlobals.document.documentElement; var editorContainerStyle; var editorContainer, iframe, iframeStyle; var fullscreenInfo = fullscreenState.get(); var resize = function () { DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); }; var removeResize = function () { DOM.unbind(domGlobals.window, 'resize', resize); }; editorContainer = editor.getContainer(); editorContainerStyle = editorContainer.style; iframe = editor.getContentAreaContainer().firstChild; iframeStyle = iframe.style; if (!fullscreenInfo) { var newFullScreenInfo = { scrollPos: getScrollPos(), containerWidth: editorContainerStyle.width, containerHeight: editorContainerStyle.height, iframeWidth: iframeStyle.width, iframeHeight: iframeStyle.height, resizeHandler: resize, removeHandler: removeResize }; iframeStyle.width = iframeStyle.height = '100%'; editorContainerStyle.width = editorContainerStyle.height = ''; DOM.addClass(body, 'mce-fullscreen'); DOM.addClass(documentElement, 'mce-fullscreen'); DOM.addClass(editorContainer, 'mce-fullscreen'); DOM.bind(domGlobals.window, 'resize', resize); editor.on('remove', removeResize); resize(); fullscreenState.set(newFullScreenInfo); Events.fireFullscreenStateChanged(editor, true); } else { iframeStyle.width = fullscreenInfo.iframeWidth; iframeStyle.height = fullscreenInfo.iframeHeight; if (fullscreenInfo.containerWidth) { editorContainerStyle.width = fullscreenInfo.containerWidth; } if (fullscreenInfo.containerHeight) { editorContainerStyle.height = fullscreenInfo.containerHeight; } DOM.removeClass(body, 'mce-fullscreen'); DOM.removeClass(documentElement, 'mce-fullscreen'); DOM.removeClass(editorContainer, 'mce-fullscreen'); setScrollPos(fullscreenInfo.scrollPos); DOM.unbind(domGlobals.window, 'resize', fullscreenInfo.resizeHandler); editor.off('remove', fullscreenInfo.removeHandler); fullscreenState.set(null); Events.fireFullscreenStateChanged(editor, false); } }; var Actions = { toggleFullscreen: toggleFullscreen }; var register = function (editor, fullscreenState) { editor.addCommand('mceFullScreen', function () { Actions.toggleFullscreen(editor, fullscreenState); }); }; var Commands = { register: register }; var postRender = function (editor) { return function (e) { var ctrl = e.control; editor.on('FullscreenStateChanged', function (e) { ctrl.active(e.state); }); }; }; var register$1 = function (editor) { editor.addMenuItem('fullscreen', { text: 'Fullscreen', shortcut: 'Ctrl+Shift+F', selectable: true, cmd: 'mceFullScreen', onPostRender: postRender(editor), context: 'view' }); editor.addButton('fullscreen', { active: false, tooltip: 'Fullscreen', cmd: 'mceFullScreen', onPostRender: postRender(editor) }); }; var Buttons = { register: register$1 }; global.add('fullscreen', function (editor) { var fullscreenState = Cell(null); if (editor.settings.inline) { return Api.get(fullscreenState); } Commands.register(editor, fullscreenState); Buttons.register(editor); editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen'); return Api.get(fullscreenState); }); function Plugin () { } return Plugin; }(window)); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js 0000644 00000004607 15006100634 0021601 0 ustar 00 /* global tinymce */ /** * Included for back-compat. * The default WindowManager in TinyMCE 4.0 supports three types of dialogs: * - With HTML created from JS. * - With inline HTML (like WPWindowManager). * - Old type iframe based dialogs. * For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins */ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { if ( this.wp ) { return this; } this.wp = {}; this.parent = editor.windowManager; this.editor = editor; tinymce.extend( this, this.parent ); this.open = function( args, params ) { var $element, self = this, wp = this.wp; if ( ! args.wpDialog ) { return this.parent.open.apply( this, arguments ); } else if ( ! args.id ) { return; } if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) { // wpdialog.js is not loaded. if ( window.console && window.console.error ) { window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.'); } return; } wp.$element = $element = jQuery( '#' + args.id ); if ( ! $element.length ) { return; } if ( window.console && window.console.log ) { window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.'); } wp.features = args; wp.params = params; // Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog. editor.nodeChanged(); // Create the dialog if necessary. if ( ! $element.data('wpdialog') ) { $element.wpdialog({ title: args.title, width: args.width, height: args.height, modal: true, dialogClass: 'wp-dialog', zIndex: 300000 }); } $element.wpdialog('open'); $element.on( 'wpdialogclose', function() { if ( self.wp.$element ) { self.wp = {}; } }); }; this.close = function() { if ( ! this.wp.features || ! this.wp.features.wpDialog ) { return this.parent.close.apply( this, arguments ); } this.wp.$element.wpdialog('close'); }; }; tinymce.PluginManager.add( 'wpdialogs', function( editor ) { // Replace window manager. editor.on( 'init', function() { editor.windowManager = new tinymce.WPWindowManager( editor ); }); }); home/ephorei/www/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js 0000644 00000013544 15006100755 0022355 0 ustar 00 /** * plugin.js * * Copyright, Moxiecode Systems AB * Released under LGPL License. * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ // Forked for WordPress so it can be turned on/off after loading. /*global tinymce:true */ /*eslint no-nested-ternary:0 */ /** * Auto Resize * * This plugin automatically resizes the content area to fit its content height. * It will retain a minimum height, which is the height of the content area when * it's initialized. */ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { var settings = editor.settings, oldSize = 300, isActive = false; if ( editor.settings.inline || tinymce.Env.iOS ) { return; } function isFullscreen() { return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen(); } function getInt( n ) { return parseInt( n, 10 ) || 0; } /** * This method gets executed each time the editor needs to resize. */ function resize( e ) { var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom; if ( ! isActive ) { return; } doc = editor.getDoc(); if ( ! doc ) { return; } e = e || {}; body = doc.body; docElm = doc.documentElement; resizeHeight = settings.autoresize_min_height; if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) { if ( body && docElm ) { body.style.overflowY = 'auto'; docElm.style.overflowY = 'auto'; // Old IE. } return; } // Calculate outer height of the body element using CSS styles. marginTop = editor.dom.getStyle( body, 'margin-top', true ); marginBottom = editor.dom.getStyle( body, 'margin-bottom', true ); paddingTop = editor.dom.getStyle( body, 'padding-top', true ); paddingBottom = editor.dom.getStyle( body, 'padding-bottom', true ); borderTop = editor.dom.getStyle( body, 'border-top-width', true ); borderBottom = editor.dom.getStyle( body, 'border-bottom-width', true ); myHeight = body.offsetHeight + getInt( marginTop ) + getInt( marginBottom ) + getInt( paddingTop ) + getInt( paddingBottom ) + getInt( borderTop ) + getInt( borderBottom ); // IE < 11, other? if ( myHeight && myHeight < docElm.offsetHeight ) { myHeight = docElm.offsetHeight; } // Make sure we have a valid height. if ( isNaN( myHeight ) || myHeight <= 0 ) { // Get height differently depending on the browser used. myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight ); } // Don't make it smaller than the minimum height. if ( myHeight > settings.autoresize_min_height ) { resizeHeight = myHeight; } // If a maximum height has been defined don't exceed this height. if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) { resizeHeight = settings.autoresize_max_height; body.style.overflowY = 'auto'; docElm.style.overflowY = 'auto'; // Old IE. } else { body.style.overflowY = 'hidden'; docElm.style.overflowY = 'hidden'; // Old IE. body.scrollTop = 0; } // Resize content element. if (resizeHeight !== oldSize) { deltaSize = resizeHeight - oldSize; DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' ); oldSize = resizeHeight; // WebKit doesn't decrease the size of the body element until the iframe gets resized. // So we need to continue to resize the iframe down until the size gets fixed. if ( tinymce.isWebKit && deltaSize < 0 ) { resize( e ); } editor.fire( 'wp-autoresize', { height: resizeHeight, deltaHeight: e.type === 'nodechange' ? deltaSize : null } ); } } /** * Calls the resize x times in 100ms intervals. We can't wait for load events since * the CSS files might load async. */ function wait( times, interval, callback ) { setTimeout( function() { resize(); if ( times-- ) { wait( times, interval, callback ); } else if ( callback ) { callback(); } }, interval ); } // Define minimum height. settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 ); // Define maximum height. settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 ); function on() { if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) { isActive = true; editor.dom.addClass( editor.getBody(), 'wp-autoresize' ); // Add appropriate listeners for resizing the content area. editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize ); resize(); } } function off() { var doc; // Don't turn off if the setting is 'on'. if ( ! settings.wp_autoresize_on ) { isActive = false; doc = editor.getDoc(); editor.dom.removeClass( editor.getBody(), 'wp-autoresize' ); editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize ); doc.body.style.overflowY = 'auto'; doc.documentElement.style.overflowY = 'auto'; // Old IE. oldSize = 0; } } if ( settings.wp_autoresize_on ) { // Turn resizing on when the editor loads. isActive = true; editor.on( 'init', function() { editor.dom.addClass( editor.getBody(), 'wp-autoresize' ); }); editor.on( 'nodechange keyup FullscreenStateChanged', resize ); editor.on( 'setcontent', function() { wait( 3, 100 ); }); if ( editor.getParam( 'autoresize_on_init', true ) ) { editor.on( 'init', function() { // Hit it 10 times in 200 ms intervals. wait( 10, 200, function() { // Hit it 5 times in 1 sec intervals. wait( 5, 1000 ); }); }); } } // Reset the stored size. editor.on( 'show', function() { oldSize = 0; }); // Register the command. editor.addCommand( 'wpAutoResize', resize ); // On/off. editor.addCommand( 'wpAutoResizeOn', on ); editor.addCommand( 'wpAutoResizeOff', off ); }); home/ephorei/www/wp-includes/js/tinymce/plugins/wpview/plugin.js 0000644 00000013703 15006100755 0021132 0 ustar 00 /** * WordPress View plugin. */ ( function( tinymce ) { tinymce.PluginManager.add( 'wpview', function( editor ) { function noop () {} // Set this here as wp-tinymce.js may be loaded too early. var wp = window.wp; if ( ! wp || ! wp.mce || ! wp.mce.views ) { return { getView: noop }; } // Check if a node is a view or not. function isView( node ) { return editor.dom.hasClass( node, 'wpview' ); } // Replace view tags with their text. function resetViews( content ) { function callback( match, $1 ) { return '<p>' + window.decodeURIComponent( $1 ) + '</p>'; } if ( ! content || content.indexOf( ' data-wpview-' ) === -1 ) { return content; } return content .replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g, callback ) .replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, callback ); } editor.on( 'init', function() { var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; if ( MutationObserver ) { new MutationObserver( function() { editor.fire( 'wp-body-class-change' ); } ) .observe( editor.getBody(), { attributes: true, attributeFilter: ['class'] } ); } // Pass on body class name changes from the editor to the wpView iframes. editor.on( 'wp-body-class-change', function() { var className = editor.getBody().className; editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) { // Make sure it is a local iframe. // jshint scripturl: true if ( ! iframe.src || iframe.src === 'javascript:""' ) { try { iframe.contentWindow.document.body.className = className; } catch( er ) {} } }); } ); }); // Scan new content for matching view patterns and replace them with markers. editor.on( 'beforesetcontent', function( event ) { var node; if ( ! event.selection ) { wp.mce.views.unbind(); } if ( ! event.content ) { return; } if ( ! event.load ) { node = editor.selection.getNode(); if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) { // When a url is pasted or inserted, only try to embed it when it is in an empty paragraph. node = editor.dom.getParent( node, 'p' ); if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) { // Make sure there are no empty inline elements in the <p>. node.innerHTML = ''; } else { return; } } } event.content = wp.mce.views.setMarkers( event.content, editor ); } ); // Replace any new markers nodes with views. editor.on( 'setcontent', function() { wp.mce.views.render(); } ); // Empty view nodes for easier processing. editor.on( 'preprocess hide', function( event ) { editor.$( 'div[data-wpview-text], p[data-wpview-marker]', event.node ).each( function( i, node ) { node.innerHTML = '.'; } ); }, true ); // Replace views with their text. editor.on( 'postprocess', function( event ) { event.content = resetViews( event.content ); } ); // Prevent adding of undo levels when replacing wpview markers // or when there are changes only in the (non-editable) previews. editor.on( 'beforeaddundo', function( event ) { var lastContent; var newContent = event.level.content || ( event.level.fragments && event.level.fragments.join( '' ) ); if ( ! event.lastLevel ) { lastContent = editor.startContent; } else { lastContent = event.lastLevel.content || ( event.lastLevel.fragments && event.lastLevel.fragments.join( '' ) ); } if ( ! newContent || ! lastContent || newContent.indexOf( ' data-wpview-' ) === -1 || lastContent.indexOf( ' data-wpview-' ) === -1 ) { return; } if ( resetViews( lastContent ) === resetViews( newContent ) ) { event.preventDefault(); } } ); // Make sure views are copied as their text. editor.on( 'drop objectselected', function( event ) { if ( isView( event.targetClone ) ) { event.targetClone = editor.getDoc().createTextNode( window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) ) ); } } ); // Clean up URLs for easier processing. editor.on( 'pastepreprocess', function( event ) { var content = event.content; if ( content ) { content = tinymce.trim( content.replace( /<[^>]+>/g, '' ) ); if ( /^https?:\/\/\S+$/i.test( content ) ) { event.content = content; } } } ); // Show the view type in the element path. editor.on( 'resolvename', function( event ) { if ( isView( event.target ) ) { event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'object'; } } ); // See `media` plugin. editor.on( 'click keyup', function() { var node = editor.selection.getNode(); if ( isView( node ) ) { if ( editor.dom.getAttrib( node, 'data-mce-selected' ) ) { node.setAttribute( 'data-mce-selected', '2' ); } } } ); editor.addButton( 'wp_view_edit', { tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { var node = editor.selection.getNode(); if ( isView( node ) ) { wp.mce.views.edit( editor, node ); } } } ); editor.addButton( 'wp_view_remove', { tooltip: 'Remove', icon: 'dashicon dashicons-no', onclick: function() { editor.fire( 'cut' ); } } ); editor.once( 'preinit', function() { var toolbar; if ( editor.wp && editor.wp._createToolbar ) { toolbar = editor.wp._createToolbar( [ 'wp_view_edit', 'wp_view_remove' ] ); editor.on( 'wptoolbar', function( event ) { if ( ! event.collapsed && isView( event.element ) ) { event.toolbar = toolbar; } } ); } } ); editor.wp = editor.wp || {}; editor.wp.getView = noop; editor.wp.setViewCursor = noop; return { getView: noop }; } ); } )( window.tinymce ); home/ephorei/www/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js 0000644 00000021142 15006100756 0022537 0 ustar 00 /** * Text pattern plugin for TinyMCE * * @since 4.3.0 * * This plugin can automatically format text patterns as you type. It includes several groups of patterns. * * Start of line patterns: * As-you-type: * - Unordered list (`* ` and `- `). * - Ordered list (`1. ` and `1) `). * * On enter: * - h2 (## ). * - h3 (### ). * - h4 (#### ). * - h5 (##### ). * - h6 (###### ). * - blockquote (> ). * - hr (---). * * Inline patterns: * - <code> (`) (backtick). * * If the transformation in unwanted, the user can undo the change by pressing backspace, * using the undo shortcut, or the undo button in the toolbar. * * Setting for the patterns can be overridden by plugins by using the `tiny_mce_before_init` PHP filter. * The setting name is `wptextpattern` and the value is an object containing override arrays for each * patterns group. There are three groups: "space", "enter", and "inline". Example (PHP): * * add_filter( 'tiny_mce_before_init', 'my_mce_init_wptextpattern' ); * function my_mce_init_wptextpattern( $init ) { * $init['wptextpattern'] = wp_json_encode( array( * 'inline' => array( * array( 'delimiter' => '**', 'format' => 'bold' ), * array( 'delimiter' => '__', 'format' => 'italic' ), * ), * ) ); * * return $init; * } * * Note that setting this will override the default text patterns. You will need to include them * in your settings array if you want to keep them working. */ ( function( tinymce, setTimeout ) { if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) { return; } /** * Escapes characters for use in a Regular Expression. * * @param {String} string Characters to escape * * @return {String} Escaped characters */ function escapeRegExp( string ) { return string.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&' ); } tinymce.PluginManager.add( 'wptextpattern', function( editor ) { var VK = tinymce.util.VK; var settings = editor.settings.wptextpattern || {}; var spacePatterns = settings.space || [ { regExp: /^[*-]\s/, cmd: 'InsertUnorderedList' }, { regExp: /^1[.)]\s/, cmd: 'InsertOrderedList' } ]; var enterPatterns = settings.enter || [ { start: '##', format: 'h2' }, { start: '###', format: 'h3' }, { start: '####', format: 'h4' }, { start: '#####', format: 'h5' }, { start: '######', format: 'h6' }, { start: '>', format: 'blockquote' }, { regExp: /^(-){3,}$/, element: 'hr' } ]; var inlinePatterns = settings.inline || [ { delimiter: '`', format: 'code' } ]; var canUndo; editor.on( 'selectionchange', function() { canUndo = null; } ); editor.on( 'keydown', function( event ) { if ( ( canUndo && event.keyCode === 27 /* ESCAPE */ ) || ( canUndo === 'space' && event.keyCode === VK.BACKSPACE ) ) { editor.undoManager.undo(); event.preventDefault(); event.stopImmediatePropagation(); } if ( VK.metaKeyPressed( event ) ) { return; } if ( event.keyCode === VK.ENTER ) { enter(); // Wait for the browser to insert the character. } else if ( event.keyCode === VK.SPACEBAR ) { setTimeout( space ); } else if ( event.keyCode > 47 && ! ( event.keyCode >= 91 && event.keyCode <= 93 ) ) { setTimeout( inline ); } }, true ); function inline() { var rng = editor.selection.getRng(); var node = rng.startContainer; var offset = rng.startOffset; var startOffset; var endOffset; var pattern; var format; var zero; // We need a non-empty text node with an offset greater than zero. if ( ! node || node.nodeType !== 3 || ! node.data.length || ! offset ) { return; } var string = node.data.slice( 0, offset ); var lastChar = node.data.charAt( offset - 1 ); tinymce.each( inlinePatterns, function( p ) { // Character before selection should be delimiter. if ( lastChar !== p.delimiter.slice( -1 ) ) { return; } var escDelimiter = escapeRegExp( p.delimiter ); var delimiterFirstChar = p.delimiter.charAt( 0 ); var regExp = new RegExp( '(.*)' + escDelimiter + '.+' + escDelimiter + '$' ); var match = string.match( regExp ); if ( ! match ) { return; } startOffset = match[1].length; endOffset = offset - p.delimiter.length; var before = string.charAt( startOffset - 1 ); var after = string.charAt( startOffset + p.delimiter.length ); // test*test* => format applied. // test *test* => applied. // test* test* => not applied. if ( startOffset && /\S/.test( before ) ) { if ( /\s/.test( after ) || before === delimiterFirstChar ) { return; } } // Do not replace when only whitespace and delimiter characters. if ( ( new RegExp( '^[\\s' + escapeRegExp( delimiterFirstChar ) + ']+$' ) ).test( string.slice( startOffset, endOffset ) ) ) { return; } pattern = p; return false; } ); if ( ! pattern ) { return; } format = editor.formatter.get( pattern.format ); if ( format && format[0].inline ) { editor.undoManager.add(); editor.undoManager.transact( function() { node.insertData( offset, '\uFEFF' ); node = node.splitText( startOffset ); zero = node.splitText( offset - startOffset ); node.deleteData( 0, pattern.delimiter.length ); node.deleteData( node.data.length - pattern.delimiter.length, pattern.delimiter.length ); editor.formatter.apply( pattern.format, {}, node ); editor.selection.setCursorLocation( zero, 1 ); } ); // We need to wait for native events to be triggered. setTimeout( function() { canUndo = 'space'; editor.once( 'selectionchange', function() { var offset; if ( zero ) { offset = zero.data.indexOf( '\uFEFF' ); if ( offset !== -1 ) { zero.deleteData( offset, offset + 1 ); } } } ); } ); } } function firstTextNode( node ) { var parent = editor.dom.getParent( node, 'p' ), child; if ( ! parent ) { return; } while ( child = parent.firstChild ) { if ( child.nodeType !== 3 ) { parent = child; } else { break; } } if ( ! child ) { return; } if ( ! child.data ) { if ( child.nextSibling && child.nextSibling.nodeType === 3 ) { child = child.nextSibling; } else { child = null; } } return child; } function space() { var rng = editor.selection.getRng(), node = rng.startContainer, parent, text; if ( ! node || firstTextNode( node ) !== node ) { return; } parent = node.parentNode; text = node.data; tinymce.each( spacePatterns, function( pattern ) { var match = text.match( pattern.regExp ); if ( ! match || rng.startOffset !== match[0].length ) { return; } editor.undoManager.add(); editor.undoManager.transact( function() { node.deleteData( 0, match[0].length ); if ( ! parent.innerHTML ) { parent.appendChild( document.createElement( 'br' ) ); } editor.selection.setCursorLocation( parent ); editor.execCommand( pattern.cmd ); } ); // We need to wait for native events to be triggered. setTimeout( function() { canUndo = 'space'; } ); return false; } ); } function enter() { var rng = editor.selection.getRng(), start = rng.startContainer, node = firstTextNode( start ), i = enterPatterns.length, text, pattern, parent; if ( ! node ) { return; } text = node.data; while ( i-- ) { if ( enterPatterns[ i ].start ) { if ( text.indexOf( enterPatterns[ i ].start ) === 0 ) { pattern = enterPatterns[ i ]; break; } } else if ( enterPatterns[ i ].regExp ) { if ( enterPatterns[ i ].regExp.test( text ) ) { pattern = enterPatterns[ i ]; break; } } } if ( ! pattern ) { return; } if ( node === start && tinymce.trim( text ) === pattern.start ) { return; } editor.once( 'keyup', function() { editor.undoManager.add(); editor.undoManager.transact( function() { if ( pattern.format ) { editor.formatter.apply( pattern.format, {}, node ); node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) ); } else if ( pattern.element ) { parent = node.parentNode && node.parentNode.parentNode; if ( parent ) { parent.replaceChild( document.createElement( pattern.element ), node.parentNode ); } } } ); // We need to wait for native events to be triggered. setTimeout( function() { canUndo = 'enter'; } ); } ); } function ltrim( text ) { return text ? text.replace( /^\s+/, '' ) : ''; } } ); } )( window.tinymce, window.setTimeout ); home/ephorei/www/wp-includes/js/tinymce/plugins/colorpicker/plugin.js 0000644 00000006751 15006117127 0022133 0 ustar 00 (function () { var colorpicker = (function () { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var global$1 = tinymce.util.Tools.resolve('tinymce.util.Color'); var showPreview = function (win, hexColor) { win.find('#preview')[0].getEl().style.background = hexColor; }; var setColor = function (win, value) { var color = global$1(value), rgb = color.toRgb(); win.fromJSON({ r: rgb.r, g: rgb.g, b: rgb.b, hex: color.toHex().substr(1) }); showPreview(win, color.toHex()); }; var open = function (editor, callback, value) { var win = editor.windowManager.open({ title: 'Color', items: { type: 'container', layout: 'flex', direction: 'row', align: 'stretch', padding: 5, spacing: 10, items: [ { type: 'colorpicker', value: value, onchange: function () { var rgb = this.rgb(); if (win) { win.find('#r').value(rgb.r); win.find('#g').value(rgb.g); win.find('#b').value(rgb.b); win.find('#hex').value(this.value().substr(1)); showPreview(win, this.value()); } } }, { type: 'form', padding: 0, labelGap: 5, defaults: { type: 'textbox', size: 7, value: '0', flex: 1, spellcheck: false, onchange: function () { var colorPickerCtrl = win.find('colorpicker')[0]; var name, value; name = this.name(); value = this.value(); if (name === 'hex') { value = '#' + value; setColor(win, value); colorPickerCtrl.value(value); return; } value = { r: win.find('#r').value(), g: win.find('#g').value(), b: win.find('#b').value() }; colorPickerCtrl.value(value); setColor(win, value); } }, items: [ { name: 'r', label: 'R', autofocus: 1 }, { name: 'g', label: 'G' }, { name: 'b', label: 'B' }, { name: 'hex', label: '#', value: '000000' }, { name: 'preview', type: 'container', border: 1 } ] } ] }, onSubmit: function () { callback('#' + win.toJSON().hex); } }); setColor(win, value); }; var Dialog = { open: open }; global.add('colorpicker', function (editor) { if (!editor.settings.color_picker_callback) { editor.settings.color_picker_callback = function (callback, value) { Dialog.open(editor, callback, value); }; } }); function Plugin () { } return Plugin; }()); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/tabfocus/plugin.js 0000644 00000007212 15006121642 0021413 0 ustar 00 (function () { var tabfocus = (function (domGlobals) { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var global$2 = tinymce.util.Tools.resolve('tinymce.EditorManager'); var global$3 = tinymce.util.Tools.resolve('tinymce.Env'); var global$4 = tinymce.util.Tools.resolve('tinymce.util.Delay'); var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var global$6 = tinymce.util.Tools.resolve('tinymce.util.VK'); var getTabFocusElements = function (editor) { return editor.getParam('tabfocus_elements', ':prev,:next'); }; var getTabFocus = function (editor) { return editor.getParam('tab_focus', getTabFocusElements(editor)); }; var Settings = { getTabFocus: getTabFocus }; var DOM = global$1.DOM; var tabCancel = function (e) { if (e.keyCode === global$6.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) { e.preventDefault(); } }; var setup = function (editor) { function tabHandler(e) { var x, el, v, i; if (e.keyCode !== global$6.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) { return; } function find(direction) { el = DOM.select(':input:enabled,*[tabindex]:not(iframe)'); function canSelectRecursive(e) { return e.nodeName === 'BODY' || e.type !== 'hidden' && e.style.display !== 'none' && e.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode); } function canSelect(el) { return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$2.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el); } global$5.each(el, function (e, i) { if (e.id === editor.id) { x = i; return false; } }); if (direction > 0) { for (i = x + 1; i < el.length; i++) { if (canSelect(el[i])) { return el[i]; } } } else { for (i = x - 1; i >= 0; i--) { if (canSelect(el[i])) { return el[i]; } } } return null; } v = global$5.explode(Settings.getTabFocus(editor)); if (v.length === 1) { v[1] = v[0]; v[0] = ':prev'; } if (e.shiftKey) { if (v[0] === ':prev') { el = find(-1); } else { el = DOM.get(v[0]); } } else { if (v[1] === ':next') { el = find(1); } else { el = DOM.get(v[1]); } } if (el) { var focusEditor = global$2.get(el.id || el.name); if (el.id && focusEditor) { focusEditor.focus(); } else { global$4.setTimeout(function () { if (!global$3.webkit) { domGlobals.window.focus(); } el.focus(); }, 10); } e.preventDefault(); } } editor.on('init', function () { if (editor.inline) { DOM.setAttrib(editor.getBody(), 'tabIndex', null); } editor.on('keyup', tabCancel); if (global$3.gecko) { editor.on('keypress keydown', tabHandler); } else { editor.on('keydown', tabHandler); } }); }; var Keyboard = { setup: setup }; global.add('tabfocus', function (editor) { Keyboard.setup(editor); }); function Plugin () { } return Plugin; }(window)); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/compat3x/plugin.js 0000644 00000022352 15006122327 0021346 0 ustar 00 /** * plugin.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ /*global tinymce:true, console:true */ /*eslint no-console:0, new-cap:0 */ /** * This plugin adds missing events form the 4.x API back. Not every event is * properly supported but most things should work. * * Unsupported things: * - No editor.onEvent * - Can't cancel execCommands with beforeExecCommand */ (function (tinymce) { var reported; function noop() { } function log(apiCall) { if (!reported && window && window.console) { reported = true; console.log("Deprecated TinyMCE API call: " + apiCall); } } function Dispatcher(target, newEventName, argsMap, defaultScope) { target = target || this; var cbs = []; if (!newEventName) { this.add = this.addToTop = this.remove = this.dispatch = noop; return; } this.add = function (callback, scope, prepend) { log('<target>.on' + newEventName + ".add(..)"); // Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2) function patchedEventCallback(e) { var callbackArgs = []; if (typeof argsMap == "string") { argsMap = argsMap.split(" "); } if (argsMap && typeof argsMap !== "function") { for (var i = 0; i < argsMap.length; i++) { callbackArgs.push(e[argsMap[i]]); } } if (typeof argsMap == "function") { callbackArgs = argsMap(newEventName, e, target); if (!callbackArgs) { return; } } if (!argsMap) { callbackArgs = [e]; } callbackArgs.unshift(defaultScope || target); if (callback.apply(scope || defaultScope || target, callbackArgs) === false) { e.stopImmediatePropagation(); } } target.on(newEventName, patchedEventCallback, prepend); var handlers = { original: callback, patched: patchedEventCallback }; cbs.push(handlers); return patchedEventCallback; }; this.addToTop = function (callback, scope) { this.add(callback, scope, true); }; this.remove = function (callback) { cbs.forEach(function (item, i) { if (item.original === callback) { cbs.splice(i, 1); return target.off(newEventName, item.patched); } }); return target.off(newEventName, callback); }; this.dispatch = function () { target.fire(newEventName); return true; }; } tinymce.util.Dispatcher = Dispatcher; tinymce.onBeforeUnload = new Dispatcher(tinymce, "BeforeUnload"); tinymce.onAddEditor = new Dispatcher(tinymce, "AddEditor", "editor"); tinymce.onRemoveEditor = new Dispatcher(tinymce, "RemoveEditor", "editor"); tinymce.util.Cookie = { get: noop, getHash: noop, remove: noop, set: noop, setHash: noop }; function patchEditor(editor) { function translate(str) { var prefix = editor.settings.language || "en"; var prefixedStr = [prefix, str].join('.'); var translatedStr = tinymce.i18n.translate(prefixedStr); return prefixedStr !== translatedStr ? translatedStr : tinymce.i18n.translate(str); } function patchEditorEvents(oldEventNames, argsMap) { tinymce.each(oldEventNames.split(" "), function (oldName) { editor["on" + oldName] = new Dispatcher(editor, oldName, argsMap); }); } function convertUndoEventArgs(type, event, target) { return [ event.level, target ]; } function filterSelectionEvents(needsSelection) { return function (type, e) { if ((!e.selection && !needsSelection) || e.selection == needsSelection) { return [e]; } }; } if (editor.controlManager) { return; } function cmNoop() { var obj = {}, methods = 'add addMenu addSeparator collapse createMenu destroy displayColor expand focus ' + 'getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark ' + 'postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex ' + 'setActive setAriaProperty setColor setDisabled setSelected setState showMenu update'; log('editor.controlManager.*'); function _noop() { return cmNoop(); } tinymce.each(methods.split(' '), function (method) { obj[method] = _noop; }); return obj; } editor.controlManager = { buttons: {}, setDisabled: function (name, state) { log("controlManager.setDisabled(..)"); if (this.buttons[name]) { this.buttons[name].disabled(state); } }, setActive: function (name, state) { log("controlManager.setActive(..)"); if (this.buttons[name]) { this.buttons[name].active(state); } }, onAdd: new Dispatcher(), onPostRender: new Dispatcher(), add: function (obj) { return obj; }, createButton: cmNoop, createColorSplitButton: cmNoop, createControl: cmNoop, createDropMenu: cmNoop, createListBox: cmNoop, createMenuButton: cmNoop, createSeparator: cmNoop, createSplitButton: cmNoop, createToolbar: cmNoop, createToolbarGroup: cmNoop, destroy: noop, get: noop, setControlType: cmNoop }; patchEditorEvents("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate", "editor"); patchEditorEvents("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"); patchEditorEvents("BeforeExecCommand ExecCommand", "command ui value args"); // args.terminate not supported patchEditorEvents("PreProcess PostProcess LoadContent SaveContent Change"); patchEditorEvents("BeforeSetContent BeforeGetContent SetContent GetContent", filterSelectionEvents(false)); patchEditorEvents("SetProgressState", "state time"); patchEditorEvents("VisualAid", "element hasVisual"); patchEditorEvents("Undo Redo", convertUndoEventArgs); patchEditorEvents("NodeChange", function (type, e) { return [ editor.controlManager, e.element, editor.selection.isCollapsed(), e ]; }); var originalAddButton = editor.addButton; editor.addButton = function (name, settings) { var originalOnPostRender; function patchedPostRender() { editor.controlManager.buttons[name] = this; if (originalOnPostRender) { return originalOnPostRender.apply(this, arguments); } } for (var key in settings) { if (key.toLowerCase() === "onpostrender") { originalOnPostRender = settings[key]; settings.onPostRender = patchedPostRender; } } if (!originalOnPostRender) { settings.onPostRender = patchedPostRender; } if (settings.title) { settings.title = translate(settings.title); } return originalAddButton.call(this, name, settings); }; editor.on('init', function () { var undoManager = editor.undoManager, selection = editor.selection; undoManager.onUndo = new Dispatcher(editor, "Undo", convertUndoEventArgs, null, undoManager); undoManager.onRedo = new Dispatcher(editor, "Redo", convertUndoEventArgs, null, undoManager); undoManager.onBeforeAdd = new Dispatcher(editor, "BeforeAddUndo", null, undoManager); undoManager.onAdd = new Dispatcher(editor, "AddUndo", null, undoManager); selection.onBeforeGetContent = new Dispatcher(editor, "BeforeGetContent", filterSelectionEvents(true), selection); selection.onGetContent = new Dispatcher(editor, "GetContent", filterSelectionEvents(true), selection); selection.onBeforeSetContent = new Dispatcher(editor, "BeforeSetContent", filterSelectionEvents(true), selection); selection.onSetContent = new Dispatcher(editor, "SetContent", filterSelectionEvents(true), selection); }); editor.on('BeforeRenderUI', function () { var windowManager = editor.windowManager; windowManager.onOpen = new Dispatcher(); windowManager.onClose = new Dispatcher(); windowManager.createInstance = function (className, a, b, c, d, e) { log("windowManager.createInstance(..)"); var constr = tinymce.resolve(className); return new constr(a, b, c, d, e); }; }); } tinymce.on('SetupEditor', function (e) { patchEditor(e.editor); }); tinymce.PluginManager.add("compat3x", patchEditor); tinymce.addI18n = function (prefix, o) { var I18n = tinymce.util.I18n, each = tinymce.each; if (typeof prefix == "string" && prefix.indexOf('.') === -1) { I18n.add(prefix, o); return; } if (!tinymce.is(prefix, 'string')) { each(prefix, function (o, lc) { each(o, function (o, g) { each(o, function (o, k) { if (g === 'common') { I18n.data[lc + '.' + k] = o; } else { I18n.data[lc + '.' + g + '.' + k] = o; } }); }); }); } else { each(o, function (o, k) { I18n.data[prefix + '.' + k] = o; }); } }; })(tinymce); home/ephorei/www/wp-includes/js/tinymce/plugins/wpgallery/plugin.js 0000644 00000006157 15006122526 0021624 0 ustar 00 /* global tinymce */ tinymce.PluginManager.add('wpgallery', function( editor ) { function replaceGalleryShortcodes( content ) { return content.replace( /\[gallery([^\]]*)\]/g, function( match ) { return html( 'wp-gallery', match ); }); } function html( cls, data ) { data = window.encodeURIComponent( data ); return '<img src="' + tinymce.Env.transparentSrc + '" class="wp-media mceItem ' + cls + '" ' + 'data-wp-media="' + data + '" data-mce-resize="false" data-mce-placeholder="1" alt="" />'; } function restoreMediaShortcodes( content ) { function getAttr( str, name ) { name = new RegExp( name + '=\"([^\"]+)\"' ).exec( str ); return name ? window.decodeURIComponent( name[1] ) : ''; } return content.replace( /(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g, function( match, image ) { var data = getAttr( image, 'data-wp-media' ); if ( data ) { return '<p>' + data + '</p>'; } return match; }); } function editMedia( node ) { var gallery, frame, data; if ( node.nodeName !== 'IMG' ) { return; } // Check if the `wp.media` API exists. if ( typeof wp === 'undefined' || ! wp.media ) { return; } data = window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) ); // Make sure we've selected a gallery node. if ( editor.dom.hasClass( node, 'wp-gallery' ) && wp.media.gallery ) { gallery = wp.media.gallery; frame = gallery.edit( data ); frame.state('gallery-edit').on( 'update', function( selection ) { var shortcode = gallery.shortcode( selection ).string(); editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) ); frame.detach(); }); } } // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'). editor.addCommand( 'WP_Gallery', function() { editMedia( editor.selection.getNode() ); }); editor.on( 'mouseup', function( event ) { var dom = editor.dom, node = event.target; function unselect() { dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' ); } if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) { // Don't trigger on right-click. if ( event.button !== 2 ) { if ( dom.hasClass( node, 'wp-media-selected' ) ) { editMedia( node ); } else { unselect(); dom.addClass( node, 'wp-media-selected' ); } } } else { unselect(); } }); // Display gallery, audio or video instead of img in the element path. editor.on( 'ResolveName', function( event ) { var dom = editor.dom, node = event.target; if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) { if ( dom.hasClass( node, 'wp-gallery' ) ) { event.name = 'gallery'; } } }); editor.on( 'BeforeSetContent', function( event ) { // 'wpview' handles the gallery shortcode when present. if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) { event.content = replaceGalleryShortcodes( event.content ); } }); editor.on( 'PostProcess', function( event ) { if ( event.get ) { event.content = restoreMediaShortcodes( event.content ); } }); }); home/ephorei/www/wp-includes/js/tinymce/plugins/textcolor/plugin.js 0000644 00000026056 15006123065 0021640 0 ustar 00 (function () { var textcolor = (function () { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var getCurrentColor = function (editor, format) { var color; editor.dom.getParents(editor.selection.getStart(), function (elm) { var value; if (value = elm.style[format === 'forecolor' ? 'color' : 'background-color']) { color = color ? color : value; } }); return color; }; var mapColors = function (colorMap) { var i; var colors = []; for (i = 0; i < colorMap.length; i += 2) { colors.push({ text: colorMap[i + 1], color: '#' + colorMap[i] }); } return colors; }; var applyFormat = function (editor, format, value) { editor.undoManager.transact(function () { editor.focus(); editor.formatter.apply(format, { value: value }); editor.nodeChanged(); }); }; var removeFormat = function (editor, format) { editor.undoManager.transact(function () { editor.focus(); editor.formatter.remove(format, { value: null }, null, true); editor.nodeChanged(); }); }; var TextColor = { getCurrentColor: getCurrentColor, mapColors: mapColors, applyFormat: applyFormat, removeFormat: removeFormat }; var register = function (editor) { editor.addCommand('mceApplyTextcolor', function (format, value) { TextColor.applyFormat(editor, format, value); }); editor.addCommand('mceRemoveTextcolor', function (format) { TextColor.removeFormat(editor, format); }); }; var Commands = { register: register }; var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var defaultColorMap = [ '000000', 'Black', '993300', 'Burnt orange', '333300', 'Dark olive', '003300', 'Dark green', '003366', 'Dark azure', '000080', 'Navy Blue', '333399', 'Indigo', '333333', 'Very dark gray', '800000', 'Maroon', 'FF6600', 'Orange', '808000', 'Olive', '008000', 'Green', '008080', 'Teal', '0000FF', 'Blue', '666699', 'Grayish blue', '808080', 'Gray', 'FF0000', 'Red', 'FF9900', 'Amber', '99CC00', 'Yellow green', '339966', 'Sea green', '33CCCC', 'Turquoise', '3366FF', 'Royal blue', '800080', 'Purple', '999999', 'Medium gray', 'FF00FF', 'Magenta', 'FFCC00', 'Gold', 'FFFF00', 'Yellow', '00FF00', 'Lime', '00FFFF', 'Aqua', '00CCFF', 'Sky blue', '993366', 'Red violet', 'FFFFFF', 'White', 'FF99CC', 'Pink', 'FFCC99', 'Peach', 'FFFF99', 'Light yellow', 'CCFFCC', 'Pale green', 'CCFFFF', 'Pale cyan', '99CCFF', 'Light sky blue', 'CC99FF', 'Plum' ]; var getTextColorMap = function (editor) { return editor.getParam('textcolor_map', defaultColorMap); }; var getForeColorMap = function (editor) { return editor.getParam('forecolor_map', getTextColorMap(editor)); }; var getBackColorMap = function (editor) { return editor.getParam('backcolor_map', getTextColorMap(editor)); }; var getTextColorRows = function (editor) { return editor.getParam('textcolor_rows', 5); }; var getTextColorCols = function (editor) { return editor.getParam('textcolor_cols', 8); }; var getForeColorRows = function (editor) { return editor.getParam('forecolor_rows', getTextColorRows(editor)); }; var getBackColorRows = function (editor) { return editor.getParam('backcolor_rows', getTextColorRows(editor)); }; var getForeColorCols = function (editor) { return editor.getParam('forecolor_cols', getTextColorCols(editor)); }; var getBackColorCols = function (editor) { return editor.getParam('backcolor_cols', getTextColorCols(editor)); }; var getColorPickerCallback = function (editor) { return editor.getParam('color_picker_callback', null); }; var hasColorPicker = function (editor) { return typeof getColorPickerCallback(editor) === 'function'; }; var Settings = { getForeColorMap: getForeColorMap, getBackColorMap: getBackColorMap, getForeColorRows: getForeColorRows, getBackColorRows: getBackColorRows, getForeColorCols: getForeColorCols, getBackColorCols: getBackColorCols, getColorPickerCallback: getColorPickerCallback, hasColorPicker: hasColorPicker }; var global$3 = tinymce.util.Tools.resolve('tinymce.util.I18n'); var getHtml = function (cols, rows, colorMap, hasColorPicker) { var colors, color, html, last, x, y, i, count = 0; var id = global$1.DOM.uniqueId('mcearia'); var getColorCellHtml = function (color, title) { var isNoColor = color === 'transparent'; return '<td class="mce-grid-cell' + (isNoColor ? ' mce-colorbtn-trans' : '') + '">' + '<div id="' + id + '-' + count++ + '"' + ' data-mce-color="' + (color ? color : '') + '"' + ' role="option"' + ' tabIndex="-1"' + ' style="' + (color ? 'background-color: ' + color : '') + '"' + ' title="' + global$3.translate(title) + '">' + (isNoColor ? '×' : '') + '</div>' + '</td>'; }; colors = TextColor.mapColors(colorMap); colors.push({ text: global$3.translate('No color'), color: 'transparent' }); html = '<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>'; last = colors.length - 1; for (y = 0; y < rows; y++) { html += '<tr>'; for (x = 0; x < cols; x++) { i = y * cols + x; if (i > last) { html += '<td></td>'; } else { color = colors[i]; html += getColorCellHtml(color.color, color.text); } } html += '</tr>'; } if (hasColorPicker) { html += '<tr>' + '<td colspan="' + cols + '" class="mce-custom-color-btn">' + '<div id="' + id + '-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" ' + 'role="button" tabindex="-1" aria-labelledby="' + id + '-c" style="width: 100%">' + '<button type="button" role="presentation" tabindex="-1">' + global$3.translate('Custom...') + '</button>' + '</div>' + '</td>' + '</tr>'; html += '<tr>'; for (x = 0; x < cols; x++) { html += getColorCellHtml('', 'Custom color'); } html += '</tr>'; } html += '</tbody></table>'; return html; }; var ColorPickerHtml = { getHtml: getHtml }; var setDivColor = function setDivColor(div, value) { div.style.background = value; div.setAttribute('data-mce-color', value); }; var onButtonClick = function (editor) { return function (e) { var ctrl = e.control; if (ctrl._color) { editor.execCommand('mceApplyTextcolor', ctrl.settings.format, ctrl._color); } else { editor.execCommand('mceRemoveTextcolor', ctrl.settings.format); } }; }; var onPanelClick = function (editor, cols) { return function (e) { var buttonCtrl = this.parent(); var value; var currentColor = TextColor.getCurrentColor(editor, buttonCtrl.settings.format); var selectColor = function (value) { editor.execCommand('mceApplyTextcolor', buttonCtrl.settings.format, value); buttonCtrl.hidePanel(); buttonCtrl.color(value); }; var resetColor = function () { editor.execCommand('mceRemoveTextcolor', buttonCtrl.settings.format); buttonCtrl.hidePanel(); buttonCtrl.resetColor(); }; if (global$1.DOM.getParent(e.target, '.mce-custom-color-btn')) { buttonCtrl.hidePanel(); var colorPickerCallback = Settings.getColorPickerCallback(editor); colorPickerCallback.call(editor, function (value) { var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0]; var customColorCells, div, i; customColorCells = global$2.map(tableElm.rows[tableElm.rows.length - 1].childNodes, function (elm) { return elm.firstChild; }); for (i = 0; i < customColorCells.length; i++) { div = customColorCells[i]; if (!div.getAttribute('data-mce-color')) { break; } } if (i === cols) { for (i = 0; i < cols - 1; i++) { setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color')); } } setDivColor(div, value); selectColor(value); }, currentColor); } value = e.target.getAttribute('data-mce-color'); if (value) { if (this.lastId) { global$1.DOM.get(this.lastId).setAttribute('aria-selected', 'false'); } e.target.setAttribute('aria-selected', true); this.lastId = e.target.id; if (value === 'transparent') { resetColor(); } else { selectColor(value); } } else if (value !== null) { buttonCtrl.hidePanel(); } }; }; var renderColorPicker = function (editor, foreColor) { return function () { var cols = foreColor ? Settings.getForeColorCols(editor) : Settings.getBackColorCols(editor); var rows = foreColor ? Settings.getForeColorRows(editor) : Settings.getBackColorRows(editor); var colorMap = foreColor ? Settings.getForeColorMap(editor) : Settings.getBackColorMap(editor); var hasColorPicker = Settings.hasColorPicker(editor); return ColorPickerHtml.getHtml(cols, rows, colorMap, hasColorPicker); }; }; var register$1 = function (editor) { editor.addButton('forecolor', { type: 'colorbutton', tooltip: 'Text color', format: 'forecolor', panel: { role: 'application', ariaRemember: true, html: renderColorPicker(editor, true), onclick: onPanelClick(editor, Settings.getForeColorCols(editor)) }, onclick: onButtonClick(editor) }); editor.addButton('backcolor', { type: 'colorbutton', tooltip: 'Background color', format: 'hilitecolor', panel: { role: 'application', ariaRemember: true, html: renderColorPicker(editor, false), onclick: onPanelClick(editor, Settings.getBackColorCols(editor)) }, onclick: onButtonClick(editor) }); }; var Buttons = { register: register$1 }; global.add('textcolor', function (editor) { Commands.register(editor); Buttons.register(editor); }); function Plugin () { } return Plugin; }()); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/image/plugin.js 0000644 00000116126 15006123067 0020677 0 ustar 00 (function () { var image = (function (domGlobals) { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var hasDimensions = function (editor) { return editor.settings.image_dimensions === false ? false : true; }; var hasAdvTab = function (editor) { return editor.settings.image_advtab === true ? true : false; }; var getPrependUrl = function (editor) { return editor.getParam('image_prepend_url', ''); }; var getClassList = function (editor) { return editor.getParam('image_class_list'); }; var hasDescription = function (editor) { return editor.settings.image_description === false ? false : true; }; var hasImageTitle = function (editor) { return editor.settings.image_title === true ? true : false; }; var hasImageCaption = function (editor) { return editor.settings.image_caption === true ? true : false; }; var getImageList = function (editor) { return editor.getParam('image_list', false); }; var hasUploadUrl = function (editor) { return editor.getParam('images_upload_url', false); }; var hasUploadHandler = function (editor) { return editor.getParam('images_upload_handler', false); }; var getUploadUrl = function (editor) { return editor.getParam('images_upload_url'); }; var getUploadHandler = function (editor) { return editor.getParam('images_upload_handler'); }; var getUploadBasePath = function (editor) { return editor.getParam('images_upload_base_path'); }; var getUploadCredentials = function (editor) { return editor.getParam('images_upload_credentials'); }; var Settings = { hasDimensions: hasDimensions, hasAdvTab: hasAdvTab, getPrependUrl: getPrependUrl, getClassList: getClassList, hasDescription: hasDescription, hasImageTitle: hasImageTitle, hasImageCaption: hasImageCaption, getImageList: getImageList, hasUploadUrl: hasUploadUrl, hasUploadHandler: hasUploadHandler, getUploadUrl: getUploadUrl, getUploadHandler: getUploadHandler, getUploadBasePath: getUploadBasePath, getUploadCredentials: getUploadCredentials }; 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) { o = o[parts[i]]; } return o; }; 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'); } return actual; }; var Global$1 = { getOrDie: getOrDie }; function FileReader () { var f = Global$1.getOrDie('FileReader'); return new f(); } var global$1 = tinymce.util.Tools.resolve('tinymce.util.Promise'); var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var global$3 = tinymce.util.Tools.resolve('tinymce.util.XHR'); var parseIntAndGetMax = function (val1, val2) { return Math.max(parseInt(val1, 10), parseInt(val2, 10)); }; var getImageSize = function (url, callback) { var img = domGlobals.document.createElement('img'); function done(width, height) { if (img.parentNode) { img.parentNode.removeChild(img); } callback({ width: width, height: height }); } img.onload = function () { var width = parseIntAndGetMax(img.width, img.clientWidth); var height = parseIntAndGetMax(img.height, img.clientHeight); done(width, height); }; img.onerror = function () { done(0, 0); }; var style = img.style; style.visibility = 'hidden'; style.position = 'fixed'; style.bottom = style.left = '0px'; style.width = style.height = 'auto'; domGlobals.document.body.appendChild(img); img.src = url; }; var buildListItems = function (inputList, itemCallback, startItems) { function appendItems(values, output) { output = output || []; global$2.each(values, function (item) { var menuItem = { text: item.text || item.title }; if (item.menu) { menuItem.menu = appendItems(item.menu); } else { menuItem.value = item.value; itemCallback(menuItem); } output.push(menuItem); }); return output; } return appendItems(inputList, startItems || []); }; var removePixelSuffix = function (value) { if (value) { value = value.replace(/px$/, ''); } return value; }; var addPixelSuffix = function (value) { if (value.length > 0 && /^[0-9]+$/.test(value)) { value += 'px'; } return value; }; var mergeMargins = function (css) { if (css.margin) { var splitMargin = css.margin.split(' '); switch (splitMargin.length) { case 1: css['margin-top'] = css['margin-top'] || splitMargin[0]; css['margin-right'] = css['margin-right'] || splitMargin[0]; css['margin-bottom'] = css['margin-bottom'] || splitMargin[0]; css['margin-left'] = css['margin-left'] || splitMargin[0]; break; case 2: css['margin-top'] = css['margin-top'] || splitMargin[0]; css['margin-right'] = css['margin-right'] || splitMargin[1]; css['margin-bottom'] = css['margin-bottom'] || splitMargin[0]; css['margin-left'] = css['margin-left'] || splitMargin[1]; break; case 3: css['margin-top'] = css['margin-top'] || splitMargin[0]; css['margin-right'] = css['margin-right'] || splitMargin[1]; css['margin-bottom'] = css['margin-bottom'] || splitMargin[2]; css['margin-left'] = css['margin-left'] || splitMargin[1]; break; case 4: css['margin-top'] = css['margin-top'] || splitMargin[0]; css['margin-right'] = css['margin-right'] || splitMargin[1]; css['margin-bottom'] = css['margin-bottom'] || splitMargin[2]; css['margin-left'] = css['margin-left'] || splitMargin[3]; } delete css.margin; } return css; }; var createImageList = function (editor, callback) { var imageList = Settings.getImageList(editor); if (typeof imageList === 'string') { global$3.send({ url: imageList, success: function (text) { callback(JSON.parse(text)); } }); } else if (typeof imageList === 'function') { imageList(callback); } else { callback(imageList); } }; var waitLoadImage = function (editor, data, imgElm) { function selectImage() { imgElm.onload = imgElm.onerror = null; if (editor.selection) { editor.selection.select(imgElm); editor.nodeChanged(); } } imgElm.onload = function () { if (!data.width && !data.height && Settings.hasDimensions(editor)) { editor.dom.setAttribs(imgElm, { width: imgElm.clientWidth, height: imgElm.clientHeight }); } selectImage(); }; imgElm.onerror = selectImage; }; var blobToDataUri = function (blob) { return new global$1(function (resolve, reject) { var reader = FileReader(); reader.onload = function () { resolve(reader.result); }; reader.onerror = function () { reject(reader.error.message); }; reader.readAsDataURL(blob); }); }; var Utils = { getImageSize: getImageSize, buildListItems: buildListItems, removePixelSuffix: removePixelSuffix, addPixelSuffix: addPixelSuffix, mergeMargins: mergeMargins, createImageList: createImageList, waitLoadImage: waitLoadImage, blobToDataUri: blobToDataUri }; var global$4 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var hasOwnProperty = Object.prototype.hasOwnProperty; var shallow = function (old, nu) { return nu; }; var baseMerge = function (merger) { return function () { var objects = new Array(arguments.length); for (var i = 0; i < objects.length; i++) { objects[i] = arguments[i]; } if (objects.length === 0) { throw new Error('Can\'t merge zero objects'); } var ret = {}; for (var j = 0; j < objects.length; j++) { var curObject = objects[j]; for (var key in curObject) { if (hasOwnProperty.call(curObject, key)) { ret[key] = merger(ret[key], curObject[key]); } } } return ret; }; }; var merge = baseMerge(shallow); var DOM = global$4.DOM; var getHspace = function (image) { if (image.style.marginLeft && image.style.marginRight && image.style.marginLeft === image.style.marginRight) { return Utils.removePixelSuffix(image.style.marginLeft); } else { return ''; } }; var getVspace = function (image) { if (image.style.marginTop && image.style.marginBottom && image.style.marginTop === image.style.marginBottom) { return Utils.removePixelSuffix(image.style.marginTop); } else { return ''; } }; var getBorder = function (image) { if (image.style.borderWidth) { return Utils.removePixelSuffix(image.style.borderWidth); } else { return ''; } }; var getAttrib = function (image, name) { if (image.hasAttribute(name)) { return image.getAttribute(name); } else { return ''; } }; var getStyle = function (image, name) { return image.style[name] ? image.style[name] : ''; }; var hasCaption = function (image) { return image.parentNode !== null && image.parentNode.nodeName === 'FIGURE'; }; var setAttrib = function (image, name, value) { image.setAttribute(name, value); }; var wrapInFigure = function (image) { var figureElm = DOM.create('figure', { class: 'image' }); DOM.insertAfter(figureElm, image); figureElm.appendChild(image); figureElm.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); figureElm.contentEditable = 'false'; }; var removeFigure = function (image) { var figureElm = image.parentNode; DOM.insertAfter(image, figureElm); DOM.remove(figureElm); }; var toggleCaption = function (image) { if (hasCaption(image)) { removeFigure(image); } else { wrapInFigure(image); } }; var normalizeStyle = function (image, normalizeCss) { var attrValue = image.getAttribute('style'); var value = normalizeCss(attrValue !== null ? attrValue : ''); if (value.length > 0) { image.setAttribute('style', value); image.setAttribute('data-mce-style', value); } else { image.removeAttribute('style'); } }; var setSize = function (name, normalizeCss) { return function (image, name, value) { if (image.style[name]) { image.style[name] = Utils.addPixelSuffix(value); normalizeStyle(image, normalizeCss); } else { setAttrib(image, name, value); } }; }; var getSize = function (image, name) { if (image.style[name]) { return Utils.removePixelSuffix(image.style[name]); } else { return getAttrib(image, name); } }; var setHspace = function (image, value) { var pxValue = Utils.addPixelSuffix(value); image.style.marginLeft = pxValue; image.style.marginRight = pxValue; }; var setVspace = function (image, value) { var pxValue = Utils.addPixelSuffix(value); image.style.marginTop = pxValue; image.style.marginBottom = pxValue; }; var setBorder = function (image, value) { var pxValue = Utils.addPixelSuffix(value); image.style.borderWidth = pxValue; }; var setBorderStyle = function (image, value) { image.style.borderStyle = value; }; var getBorderStyle = function (image) { return getStyle(image, 'borderStyle'); }; var isFigure = function (elm) { return elm.nodeName === 'FIGURE'; }; var defaultData = function () { return { src: '', alt: '', title: '', width: '', height: '', class: '', style: '', caption: false, hspace: '', vspace: '', border: '', borderStyle: '' }; }; var getStyleValue = function (normalizeCss, data) { var image = domGlobals.document.createElement('img'); setAttrib(image, 'style', data.style); if (getHspace(image) || data.hspace !== '') { setHspace(image, data.hspace); } if (getVspace(image) || data.vspace !== '') { setVspace(image, data.vspace); } if (getBorder(image) || data.border !== '') { setBorder(image, data.border); } if (getBorderStyle(image) || data.borderStyle !== '') { setBorderStyle(image, data.borderStyle); } return normalizeCss(image.getAttribute('style')); }; var create = function (normalizeCss, data) { var image = domGlobals.document.createElement('img'); write(normalizeCss, merge(data, { caption: false }), image); setAttrib(image, 'alt', data.alt); if (data.caption) { var figure = DOM.create('figure', { class: 'image' }); figure.appendChild(image); figure.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); figure.contentEditable = 'false'; return figure; } else { return image; } }; var read = function (normalizeCss, image) { return { src: getAttrib(image, 'src'), alt: getAttrib(image, 'alt'), title: getAttrib(image, 'title'), width: getSize(image, 'width'), height: getSize(image, 'height'), class: getAttrib(image, 'class'), style: normalizeCss(getAttrib(image, 'style')), caption: hasCaption(image), hspace: getHspace(image), vspace: getVspace(image), border: getBorder(image), borderStyle: getStyle(image, 'borderStyle') }; }; var updateProp = function (image, oldData, newData, name, set) { if (newData[name] !== oldData[name]) { set(image, name, newData[name]); } }; var normalized = function (set, normalizeCss) { return function (image, name, value) { set(image, value); normalizeStyle(image, normalizeCss); }; }; var write = function (normalizeCss, newData, image) { var oldData = read(normalizeCss, image); updateProp(image, oldData, newData, 'caption', function (image, _name, _value) { return toggleCaption(image); }); updateProp(image, oldData, newData, 'src', setAttrib); updateProp(image, oldData, newData, 'alt', setAttrib); updateProp(image, oldData, newData, 'title', setAttrib); updateProp(image, oldData, newData, 'width', setSize('width', normalizeCss)); updateProp(image, oldData, newData, 'height', setSize('height', normalizeCss)); updateProp(image, oldData, newData, 'class', setAttrib); updateProp(image, oldData, newData, 'style', normalized(function (image, value) { return setAttrib(image, 'style', value); }, normalizeCss)); updateProp(image, oldData, newData, 'hspace', normalized(setHspace, normalizeCss)); updateProp(image, oldData, newData, 'vspace', normalized(setVspace, normalizeCss)); updateProp(image, oldData, newData, 'border', normalized(setBorder, normalizeCss)); updateProp(image, oldData, newData, 'borderStyle', normalized(setBorderStyle, normalizeCss)); }; var normalizeCss = function (editor, cssText) { var css = editor.dom.styles.parse(cssText); var mergedCss = Utils.mergeMargins(css); var compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss)); return editor.dom.styles.serialize(compressed); }; var getSelectedImage = function (editor) { var imgElm = editor.selection.getNode(); var figureElm = editor.dom.getParent(imgElm, 'figure.image'); if (figureElm) { return editor.dom.select('img', figureElm)[0]; } if (imgElm && (imgElm.nodeName !== 'IMG' || imgElm.getAttribute('data-mce-object') || imgElm.getAttribute('data-mce-placeholder'))) { return null; } return imgElm; }; var splitTextBlock = function (editor, figure) { var dom = editor.dom; var textBlock = dom.getParent(figure.parentNode, function (node) { return editor.schema.getTextBlockElements()[node.nodeName]; }, editor.getBody()); if (textBlock) { return dom.split(textBlock, figure); } else { return figure; } }; var readImageDataFromSelection = function (editor) { var image = getSelectedImage(editor); return image ? read(function (css) { return normalizeCss(editor, css); }, image) : defaultData(); }; var insertImageAtCaret = function (editor, data) { var elm = create(function (css) { return normalizeCss(editor, css); }, data); editor.dom.setAttrib(elm, 'data-mce-id', '__mcenew'); editor.focus(); editor.selection.setContent(elm.outerHTML); var insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0]; editor.dom.setAttrib(insertedElm, 'data-mce-id', null); if (isFigure(insertedElm)) { var figure = splitTextBlock(editor, insertedElm); editor.selection.select(figure); } else { editor.selection.select(insertedElm); } }; var syncSrcAttr = function (editor, image) { editor.dom.setAttrib(image, 'src', image.getAttribute('src')); }; var deleteImage = function (editor, image) { if (image) { var elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image; editor.dom.remove(elm); editor.focus(); editor.nodeChanged(); if (editor.dom.isEmpty(editor.getBody())) { editor.setContent(''); editor.selection.setCursorLocation(); } } }; var writeImageDataToSelection = function (editor, data) { var image = getSelectedImage(editor); write(function (css) { return normalizeCss(editor, css); }, data, image); syncSrcAttr(editor, image); if (isFigure(image.parentNode)) { var figure = image.parentNode; splitTextBlock(editor, figure); editor.selection.select(image.parentNode); } else { editor.selection.select(image); Utils.waitLoadImage(editor, data, image); } }; var insertOrUpdateImage = function (editor, data) { var image = getSelectedImage(editor); if (image) { if (data.src) { writeImageDataToSelection(editor, data); } else { deleteImage(editor, image); } } else if (data.src) { insertImageAtCaret(editor, data); } }; var updateVSpaceHSpaceBorder = function (editor) { return function (evt) { var dom = editor.dom; var rootControl = evt.control.rootControl; if (!Settings.hasAdvTab(editor)) { return; } var data = rootControl.toJSON(); var css = dom.parseStyle(data.style); rootControl.find('#vspace').value(''); rootControl.find('#hspace').value(''); css = Utils.mergeMargins(css); if (css['margin-top'] && css['margin-bottom'] || css['margin-right'] && css['margin-left']) { if (css['margin-top'] === css['margin-bottom']) { rootControl.find('#vspace').value(Utils.removePixelSuffix(css['margin-top'])); } else { rootControl.find('#vspace').value(''); } if (css['margin-right'] === css['margin-left']) { rootControl.find('#hspace').value(Utils.removePixelSuffix(css['margin-right'])); } else { rootControl.find('#hspace').value(''); } } if (css['border-width']) { rootControl.find('#border').value(Utils.removePixelSuffix(css['border-width'])); } else { rootControl.find('#border').value(''); } if (css['border-style']) { rootControl.find('#borderStyle').value(css['border-style']); } else { rootControl.find('#borderStyle').value(''); } rootControl.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css)))); }; }; var updateStyle = function (editor, win) { win.find('#style').each(function (ctrl) { var value = getStyleValue(function (css) { return normalizeCss(editor, css); }, merge(defaultData(), win.toJSON())); ctrl.value(value); }); }; var makeTab = function (editor) { return { title: 'Advanced', type: 'form', pack: 'start', items: [ { label: 'Style', name: 'style', type: 'textbox', onchange: updateVSpaceHSpaceBorder(editor) }, { type: 'form', layout: 'grid', packV: 'start', columns: 2, padding: 0, defaults: { type: 'textbox', maxWidth: 50, onchange: function (evt) { updateStyle(editor, evt.control.rootControl); } }, items: [ { label: 'Vertical space', name: 'vspace' }, { label: 'Border width', name: 'border' }, { label: 'Horizontal space', name: 'hspace' }, { label: 'Border style', type: 'listbox', name: 'borderStyle', width: 90, maxWidth: 90, onselect: function (evt) { updateStyle(editor, evt.control.rootControl); }, values: [ { text: 'Select...', value: '' }, { text: 'Solid', value: 'solid' }, { text: 'Dotted', value: 'dotted' }, { text: 'Dashed', value: 'dashed' }, { text: 'Double', value: 'double' }, { text: 'Groove', value: 'groove' }, { text: 'Ridge', value: 'ridge' }, { text: 'Inset', value: 'inset' }, { text: 'Outset', value: 'outset' }, { text: 'None', value: 'none' }, { text: 'Hidden', value: 'hidden' } ] } ] } ] }; }; var AdvTab = { makeTab: makeTab }; var doSyncSize = function (widthCtrl, heightCtrl) { widthCtrl.state.set('oldVal', widthCtrl.value()); heightCtrl.state.set('oldVal', heightCtrl.value()); }; var doSizeControls = function (win, f) { var widthCtrl = win.find('#width')[0]; var heightCtrl = win.find('#height')[0]; var constrained = win.find('#constrain')[0]; if (widthCtrl && heightCtrl && constrained) { f(widthCtrl, heightCtrl, constrained.checked()); } }; var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { var oldWidth = widthCtrl.state.get('oldVal'); var oldHeight = heightCtrl.state.get('oldVal'); var newWidth = widthCtrl.value(); var newHeight = heightCtrl.value(); if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { if (newWidth !== oldWidth) { newHeight = Math.round(newWidth / oldWidth * newHeight); if (!isNaN(newHeight)) { heightCtrl.value(newHeight); } } else { newWidth = Math.round(newHeight / oldHeight * newWidth); if (!isNaN(newWidth)) { widthCtrl.value(newWidth); } } } doSyncSize(widthCtrl, heightCtrl); }; var syncSize = function (win) { doSizeControls(win, doSyncSize); }; var updateSize = function (win) { doSizeControls(win, doUpdateSize); }; var createUi = function () { var recalcSize = function (evt) { updateSize(evt.control.rootControl); }; return { type: 'container', label: 'Dimensions', layout: 'flex', align: 'center', spacing: 5, items: [ { name: 'width', type: 'textbox', maxLength: 5, size: 5, onchange: recalcSize, ariaLabel: 'Width' }, { type: 'label', text: 'x' }, { name: 'height', type: 'textbox', maxLength: 5, size: 5, onchange: recalcSize, ariaLabel: 'Height' }, { name: 'constrain', type: 'checkbox', checked: true, text: 'Constrain proportions' } ] }; }; var SizeManager = { createUi: createUi, syncSize: syncSize, updateSize: updateSize }; var onSrcChange = function (evt, editor) { var srcURL, prependURL, absoluteURLPattern; var meta = evt.meta || {}; var control = evt.control; var rootControl = control.rootControl; var imageListCtrl = rootControl.find('#image-list')[0]; if (imageListCtrl) { imageListCtrl.value(editor.convertURL(control.value(), 'src')); } global$2.each(meta, function (value, key) { rootControl.find('#' + key).value(value); }); if (!meta.width && !meta.height) { srcURL = editor.convertURL(control.value(), 'src'); prependURL = Settings.getPrependUrl(editor); absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i'); if (prependURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, prependURL.length) !== prependURL) { srcURL = prependURL + srcURL; } control.value(srcURL); Utils.getImageSize(editor.documentBaseURI.toAbsolute(control.value()), function (data) { if (data.width && data.height && Settings.hasDimensions(editor)) { rootControl.find('#width').value(data.width); rootControl.find('#height').value(data.height); SizeManager.syncSize(rootControl); } }); } }; var onBeforeCall = function (evt) { evt.meta = evt.control.rootControl.toJSON(); }; var getGeneralItems = function (editor, imageListCtrl) { var generalFormItems = [ { name: 'src', type: 'filepicker', filetype: 'image', label: 'Source', autofocus: true, onchange: function (evt) { onSrcChange(evt, editor); }, onbeforecall: onBeforeCall }, imageListCtrl ]; if (Settings.hasDescription(editor)) { generalFormItems.push({ name: 'alt', type: 'textbox', label: 'Image description' }); } if (Settings.hasImageTitle(editor)) { generalFormItems.push({ name: 'title', type: 'textbox', label: 'Image Title' }); } if (Settings.hasDimensions(editor)) { generalFormItems.push(SizeManager.createUi()); } if (Settings.getClassList(editor)) { generalFormItems.push({ name: 'class', type: 'listbox', label: 'Class', values: Utils.buildListItems(Settings.getClassList(editor), function (item) { if (item.value) { item.textStyle = function () { return editor.formatter.getCssText({ inline: 'img', classes: [item.value] }); }; } }) }); } if (Settings.hasImageCaption(editor)) { generalFormItems.push({ name: 'caption', type: 'checkbox', label: 'Caption' }); } return generalFormItems; }; var makeTab$1 = function (editor, imageListCtrl) { return { title: 'General', type: 'form', items: getGeneralItems(editor, imageListCtrl) }; }; var MainTab = { makeTab: makeTab$1, getGeneralItems: getGeneralItems }; var url = function () { return Global$1.getOrDie('URL'); }; var createObjectURL = function (blob) { return url().createObjectURL(blob); }; var revokeObjectURL = function (u) { url().revokeObjectURL(u); }; var URL = { createObjectURL: createObjectURL, revokeObjectURL: revokeObjectURL }; var global$5 = tinymce.util.Tools.resolve('tinymce.ui.Factory'); function XMLHttpRequest () { var f = Global$1.getOrDie('XMLHttpRequest'); return new f(); } var noop = function () { }; var pathJoin = function (path1, path2) { if (path1) { return path1.replace(/\/$/, '') + '/' + path2.replace(/^\//, ''); } return path2; }; function Uploader (settings) { var defaultHandler = function (blobInfo, success, failure, progress) { var xhr, formData; xhr = XMLHttpRequest(); xhr.open('POST', settings.url); xhr.withCredentials = settings.credentials; xhr.upload.onprogress = function (e) { progress(e.loaded / e.total * 100); }; xhr.onerror = function () { failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status); }; xhr.onload = function () { var json; if (xhr.status < 200 || xhr.status >= 300) { failure('HTTP Error: ' + xhr.status); return; } json = JSON.parse(xhr.responseText); if (!json || typeof json.location !== 'string') { failure('Invalid JSON: ' + xhr.responseText); return; } success(pathJoin(settings.basePath, json.location)); }; formData = new domGlobals.FormData(); formData.append('file', blobInfo.blob(), blobInfo.filename()); xhr.send(formData); }; var uploadBlob = function (blobInfo, handler) { return new global$1(function (resolve, reject) { try { handler(blobInfo, resolve, reject, noop); } catch (ex) { reject(ex.message); } }); }; var isDefaultHandler = function (handler) { return handler === defaultHandler; }; var upload = function (blobInfo) { return !settings.url && isDefaultHandler(settings.handler) ? global$1.reject('Upload url missing from the settings.') : uploadBlob(blobInfo, settings.handler); }; settings = global$2.extend({ credentials: false, handler: defaultHandler }, settings); return { upload: upload }; } var onFileInput = function (editor) { return function (evt) { var Throbber = global$5.get('Throbber'); var rootControl = evt.control.rootControl; var throbber = new Throbber(rootControl.getEl()); var file = evt.control.value(); var blobUri = URL.createObjectURL(file); var uploader = Uploader({ url: Settings.getUploadUrl(editor), basePath: Settings.getUploadBasePath(editor), credentials: Settings.getUploadCredentials(editor), handler: Settings.getUploadHandler(editor) }); var finalize = function () { throbber.hide(); URL.revokeObjectURL(blobUri); }; throbber.show(); return Utils.blobToDataUri(file).then(function (dataUrl) { var blobInfo = editor.editorUpload.blobCache.create({ blob: file, blobUri: blobUri, name: file.name ? file.name.replace(/\.[^\.]+$/, '') : null, base64: dataUrl.split(',')[1] }); return uploader.upload(blobInfo).then(function (url) { var src = rootControl.find('#src'); src.value(url); rootControl.find('tabpanel')[0].activateTab(0); src.fire('change'); finalize(); return url; }); }).catch(function (err) { editor.windowManager.alert(err); finalize(); }); }; }; var acceptExts = '.jpg,.jpeg,.png,.gif'; var makeTab$2 = function (editor) { return { title: 'Upload', type: 'form', layout: 'flex', direction: 'column', align: 'stretch', padding: '20 20 20 20', items: [ { type: 'container', layout: 'flex', direction: 'column', align: 'center', spacing: 10, items: [ { text: 'Browse for an image', type: 'browsebutton', accept: acceptExts, onchange: onFileInput(editor) }, { text: 'OR', type: 'label' } ] }, { text: 'Drop an image here', type: 'dropzone', accept: acceptExts, height: 100, onchange: onFileInput(editor) } ] }; }; var UploadTab = { makeTab: makeTab$2 }; function curry(fn) { var initialArgs = []; for (var _i = 1; _i < arguments.length; _i++) { initialArgs[_i - 1] = arguments[_i]; } return function () { var restArgs = []; for (var _i = 0; _i < arguments.length; _i++) { restArgs[_i] = arguments[_i]; } var all = initialArgs.concat(restArgs); return fn.apply(null, all); }; } var submitForm = function (editor, evt) { var win = evt.control.getRoot(); SizeManager.updateSize(win); editor.undoManager.transact(function () { var data = merge(readImageDataFromSelection(editor), win.toJSON()); insertOrUpdateImage(editor, data); }); editor.editorUpload.uploadImagesAuto(); }; function Dialog (editor) { function showDialog(imageList) { var data = readImageDataFromSelection(editor); var win, imageListCtrl; if (imageList) { imageListCtrl = { type: 'listbox', label: 'Image list', name: 'image-list', values: Utils.buildListItems(imageList, function (item) { item.value = editor.convertURL(item.value || item.url, 'src'); }, [{ text: 'None', value: '' }]), value: data.src && editor.convertURL(data.src, 'src'), onselect: function (e) { var altCtrl = win.find('#alt'); if (!altCtrl.value() || e.lastControl && altCtrl.value() === e.lastControl.text()) { altCtrl.value(e.control.text()); } win.find('#src').value(e.control.value()).fire('change'); }, onPostRender: function () { imageListCtrl = this; } }; } if (Settings.hasAdvTab(editor) || Settings.hasUploadUrl(editor) || Settings.hasUploadHandler(editor)) { var body = [MainTab.makeTab(editor, imageListCtrl)]; if (Settings.hasAdvTab(editor)) { body.push(AdvTab.makeTab(editor)); } if (Settings.hasUploadUrl(editor) || Settings.hasUploadHandler(editor)) { body.push(UploadTab.makeTab(editor)); } win = editor.windowManager.open({ title: 'Insert/edit image', data: data, bodyType: 'tabpanel', body: body, onSubmit: curry(submitForm, editor) }); } else { win = editor.windowManager.open({ title: 'Insert/edit image', data: data, body: MainTab.getGeneralItems(editor, imageListCtrl), onSubmit: curry(submitForm, editor) }); } SizeManager.syncSize(win); } function open() { Utils.createImageList(editor, showDialog); } return { open: open }; } var register = function (editor) { editor.addCommand('mceImage', Dialog(editor).open); }; var Commands = { register: register }; var hasImageClass = function (node) { var className = node.attr('class'); return className && /\bimage\b/.test(className); }; var toggleContentEditableState = function (state) { return function (nodes) { var i = nodes.length, node; var toggleContentEditable = function (node) { node.attr('contenteditable', state ? 'true' : null); }; while (i--) { node = nodes[i]; if (hasImageClass(node)) { node.attr('contenteditable', state ? 'false' : null); global$2.each(node.getAll('figcaption'), toggleContentEditable); } } }; }; var setup = function (editor) { editor.on('preInit', function () { editor.parser.addNodeFilter('figure', toggleContentEditableState(true)); editor.serializer.addNodeFilter('figure', toggleContentEditableState(false)); }); }; var FilterContent = { setup: setup }; var register$1 = function (editor) { editor.addButton('image', { icon: 'image', tooltip: 'Insert/edit image', onclick: Dialog(editor).open, stateSelector: 'img:not([data-mce-object],[data-mce-placeholder]),figure.image' }); editor.addMenuItem('image', { icon: 'image', text: 'Image', onclick: Dialog(editor).open, context: 'insert', prependToContext: true }); }; var Buttons = { register: register$1 }; global.add('image', function (editor) { FilterContent.setup(editor); Buttons.register(editor); Commands.register(editor); }); function Plugin () { } return Plugin; }(window)); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/link/plugin.js 0000644 00000056711 15006123067 0020555 0 ustar 00 (function () { var link = (function (domGlobals) { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK'); var assumeExternalTargets = function (editorSettings) { return typeof editorSettings.link_assume_external_targets === 'boolean' ? editorSettings.link_assume_external_targets : false; }; var hasContextToolbar = function (editorSettings) { return typeof editorSettings.link_context_toolbar === 'boolean' ? editorSettings.link_context_toolbar : false; }; var getLinkList = function (editorSettings) { return editorSettings.link_list; }; var hasDefaultLinkTarget = function (editorSettings) { return typeof editorSettings.default_link_target === 'string'; }; var getDefaultLinkTarget = function (editorSettings) { return editorSettings.default_link_target; }; var getTargetList = function (editorSettings) { return editorSettings.target_list; }; var setTargetList = function (editor, list) { editor.settings.target_list = list; }; var shouldShowTargetList = function (editorSettings) { return getTargetList(editorSettings) !== false; }; var getRelList = function (editorSettings) { return editorSettings.rel_list; }; var hasRelList = function (editorSettings) { return getRelList(editorSettings) !== undefined; }; var getLinkClassList = function (editorSettings) { return editorSettings.link_class_list; }; var hasLinkClassList = function (editorSettings) { return getLinkClassList(editorSettings) !== undefined; }; var shouldShowLinkTitle = function (editorSettings) { return editorSettings.link_title !== false; }; var allowUnsafeLinkTarget = function (editorSettings) { return typeof editorSettings.allow_unsafe_link_target === 'boolean' ? editorSettings.allow_unsafe_link_target : false; }; var Settings = { assumeExternalTargets: assumeExternalTargets, hasContextToolbar: hasContextToolbar, getLinkList: getLinkList, hasDefaultLinkTarget: hasDefaultLinkTarget, getDefaultLinkTarget: getDefaultLinkTarget, getTargetList: getTargetList, setTargetList: setTargetList, shouldShowTargetList: shouldShowTargetList, getRelList: getRelList, hasRelList: hasRelList, getLinkClassList: getLinkClassList, hasLinkClassList: hasLinkClassList, shouldShowLinkTitle: shouldShowLinkTitle, allowUnsafeLinkTarget: allowUnsafeLinkTarget }; var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var global$3 = tinymce.util.Tools.resolve('tinymce.Env'); var appendClickRemove = function (link, evt) { domGlobals.document.body.appendChild(link); link.dispatchEvent(evt); domGlobals.document.body.removeChild(link); }; var open = function (url) { if (!global$3.ie || global$3.ie > 10) { var link = domGlobals.document.createElement('a'); link.target = '_blank'; link.href = url; link.rel = 'noreferrer noopener'; var evt = domGlobals.document.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, domGlobals.window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); appendClickRemove(link, evt); } else { var win = domGlobals.window.open('', '_blank'); if (win) { win.opener = null; var doc = win.document; doc.open(); doc.write('<meta http-equiv="refresh" content="0; url=' + global$2.DOM.encode(url) + '">'); doc.close(); } } }; var OpenUrl = { open: open }; var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var toggleTargetRules = function (rel, isUnsafe) { var rules = ['noopener']; var newRel = rel ? rel.split(/\s+/) : []; var toString = function (rel) { return global$4.trim(rel.sort().join(' ')); }; var addTargetRules = function (rel) { rel = removeTargetRules(rel); return rel.length ? rel.concat(rules) : rules; }; var removeTargetRules = function (rel) { return rel.filter(function (val) { return global$4.inArray(rules, val) === -1; }); }; newRel = isUnsafe ? addTargetRules(newRel) : removeTargetRules(newRel); return newRel.length ? toString(newRel) : null; }; var trimCaretContainers = function (text) { return text.replace(/\uFEFF/g, ''); }; var getAnchorElement = function (editor, selectedElm) { selectedElm = selectedElm || editor.selection.getNode(); if (isImageFigure(selectedElm)) { return editor.dom.select('a[href]', selectedElm)[0]; } else { return editor.dom.getParent(selectedElm, 'a[href]'); } }; var getAnchorText = function (selection, anchorElm) { var text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' }); return trimCaretContainers(text); }; var isLink = function (elm) { return elm && elm.nodeName === 'A' && elm.href; }; var hasLinks = function (elements) { return global$4.grep(elements, isLink).length > 0; }; var isOnlyTextSelected = function (html) { if (/</.test(html) && (!/^<a [^>]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') === -1)) { return false; } return true; }; var isImageFigure = function (node) { return node && node.nodeName === 'FIGURE' && /\bimage\b/i.test(node.className); }; var link = function (editor, attachState) { return function (data) { editor.undoManager.transact(function () { var selectedElm = editor.selection.getNode(); var anchorElm = getAnchorElement(editor, selectedElm); var linkAttrs = { href: data.href, target: data.target ? data.target : null, rel: data.rel ? data.rel : null, class: data.class ? data.class : null, title: data.title ? data.title : null }; if (!Settings.hasRelList(editor.settings) && Settings.allowUnsafeLinkTarget(editor.settings) === false) { linkAttrs.rel = toggleTargetRules(linkAttrs.rel, linkAttrs.target === '_blank'); } if (data.href === attachState.href) { attachState.attach(); attachState = {}; } if (anchorElm) { editor.focus(); if (data.hasOwnProperty('text')) { if ('innerText' in anchorElm) { anchorElm.innerText = data.text; } else { anchorElm.textContent = data.text; } } editor.dom.setAttribs(anchorElm, linkAttrs); editor.selection.select(anchorElm); editor.undoManager.add(); } else { if (isImageFigure(selectedElm)) { linkImageFigure(editor, selectedElm, linkAttrs); } else if (data.hasOwnProperty('text')) { editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(data.text))); } else { editor.execCommand('mceInsertLink', false, linkAttrs); } } }); }; }; var unlink = function (editor) { return function () { editor.undoManager.transact(function () { var node = editor.selection.getNode(); if (isImageFigure(node)) { unlinkImageFigure(editor, node); } else { editor.execCommand('unlink'); } }); }; }; var unlinkImageFigure = function (editor, fig) { var a, img; img = editor.dom.select('img', fig)[0]; if (img) { a = editor.dom.getParents(img, 'a[href]', fig)[0]; if (a) { a.parentNode.insertBefore(img, a); editor.dom.remove(a); } } }; var linkImageFigure = function (editor, fig, attrs) { var a, img; img = editor.dom.select('img', fig)[0]; if (img) { a = editor.dom.create('a', attrs); img.parentNode.insertBefore(a, img); a.appendChild(img); } }; var Utils = { link: link, unlink: unlink, isLink: isLink, hasLinks: hasLinks, isOnlyTextSelected: isOnlyTextSelected, getAnchorElement: getAnchorElement, getAnchorText: getAnchorText, toggleTargetRules: toggleTargetRules }; var global$5 = tinymce.util.Tools.resolve('tinymce.util.Delay'); var global$6 = tinymce.util.Tools.resolve('tinymce.util.XHR'); var attachState = {}; var createLinkList = function (editor, callback) { var linkList = Settings.getLinkList(editor.settings); if (typeof linkList === 'string') { global$6.send({ url: linkList, success: function (text) { callback(editor, JSON.parse(text)); } }); } else if (typeof linkList === 'function') { linkList(function (list) { callback(editor, list); }); } else { callback(editor, linkList); } }; var buildListItems = function (inputList, itemCallback, startItems) { var appendItems = function (values, output) { output = output || []; global$4.each(values, function (item) { var menuItem = { text: item.text || item.title }; if (item.menu) { menuItem.menu = appendItems(item.menu); } else { menuItem.value = item.value; if (itemCallback) { itemCallback(menuItem); } } output.push(menuItem); }); return output; }; return appendItems(inputList, startItems || []); }; var delayedConfirm = function (editor, message, callback) { var rng = editor.selection.getRng(); global$5.setEditorTimeout(editor, function () { editor.windowManager.confirm(message, function (state) { editor.selection.setRng(rng); callback(state); }); }); }; var showDialog = function (editor, linkList) { var data = {}; var selection = editor.selection; var dom = editor.dom; var anchorElm, initialText; var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value; var linkListChangeHandler = function (e) { var textCtrl = win.find('#text'); if (!textCtrl.value() || e.lastControl && textCtrl.value() === e.lastControl.text()) { textCtrl.value(e.control.text()); } win.find('#href').value(e.control.value()); }; var buildAnchorListControl = function (url) { var anchorList = []; global$4.each(editor.dom.select('a:not([href])'), function (anchor) { var id = anchor.name || anchor.id; if (id) { anchorList.push({ text: id, value: '#' + id, selected: url.indexOf('#' + id) !== -1 }); } }); if (anchorList.length) { anchorList.unshift({ text: 'None', value: '' }); return { name: 'anchor', type: 'listbox', label: 'Anchors', values: anchorList, onselect: linkListChangeHandler }; } }; var updateText = function () { if (!initialText && onlyText && !data.text) { this.parent().parent().find('#text')[0].value(this.value()); } }; var urlChange = function (e) { var meta = e.meta || {}; if (linkListCtrl) { linkListCtrl.value(editor.convertURL(this.value(), 'href')); } global$4.each(e.meta, function (value, key) { var inp = win.find('#' + key); if (key === 'text') { if (initialText.length === 0) { inp.value(value); data.text = value; } } else { inp.value(value); } }); if (meta.attach) { attachState = { href: this.value(), attach: meta.attach }; } if (!meta.text) { updateText.call(this); } }; var onBeforeCall = function (e) { e.meta = win.toJSON(); }; onlyText = Utils.isOnlyTextSelected(selection.getContent()); anchorElm = Utils.getAnchorElement(editor); data.text = initialText = Utils.getAnchorText(editor.selection, anchorElm); data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : ''; if (anchorElm) { data.target = dom.getAttrib(anchorElm, 'target'); } else if (Settings.hasDefaultLinkTarget(editor.settings)) { data.target = Settings.getDefaultLinkTarget(editor.settings); } if (value = dom.getAttrib(anchorElm, 'rel')) { data.rel = value; } if (value = dom.getAttrib(anchorElm, 'class')) { data.class = value; } if (value = dom.getAttrib(anchorElm, 'title')) { data.title = value; } if (onlyText) { textListCtrl = { name: 'text', type: 'textbox', size: 40, label: 'Text to display', onchange: function () { data.text = this.value(); } }; } if (linkList) { linkListCtrl = { type: 'listbox', label: 'Link list', values: buildListItems(linkList, function (item) { item.value = editor.convertURL(item.value || item.url, 'href'); }, [{ text: 'None', value: '' }]), onselect: linkListChangeHandler, value: editor.convertURL(data.href, 'href'), onPostRender: function () { linkListCtrl = this; } }; } if (Settings.shouldShowTargetList(editor.settings)) { if (Settings.getTargetList(editor.settings) === undefined) { Settings.setTargetList(editor, [ { text: 'None', value: '' }, { text: 'New window', value: '_blank' } ]); } targetListCtrl = { name: 'target', type: 'listbox', label: 'Target', values: buildListItems(Settings.getTargetList(editor.settings)) }; } if (Settings.hasRelList(editor.settings)) { relListCtrl = { name: 'rel', type: 'listbox', label: 'Rel', values: buildListItems(Settings.getRelList(editor.settings), function (item) { if (Settings.allowUnsafeLinkTarget(editor.settings) === false) { item.value = Utils.toggleTargetRules(item.value, data.target === '_blank'); } }) }; } if (Settings.hasLinkClassList(editor.settings)) { classListCtrl = { name: 'class', type: 'listbox', label: 'Class', values: buildListItems(Settings.getLinkClassList(editor.settings), function (item) { if (item.value) { item.textStyle = function () { return editor.formatter.getCssText({ inline: 'a', classes: [item.value] }); }; } }) }; } if (Settings.shouldShowLinkTitle(editor.settings)) { linkTitleCtrl = { name: 'title', type: 'textbox', label: 'Title', value: data.title }; } win = editor.windowManager.open({ title: 'Insert link', data: data, body: [ { name: 'href', type: 'filepicker', filetype: 'file', size: 40, autofocus: true, label: 'Url', onchange: urlChange, onkeyup: updateText, onpaste: updateText, onbeforecall: onBeforeCall }, textListCtrl, linkTitleCtrl, buildAnchorListControl(data.href), linkListCtrl, relListCtrl, targetListCtrl, classListCtrl ], onSubmit: function (e) { var assumeExternalTargets = Settings.assumeExternalTargets(editor.settings); var insertLink = Utils.link(editor, attachState); var removeLink = Utils.unlink(editor); var resultData = global$4.extend({}, data, e.data); var href = resultData.href; if (!href) { removeLink(); return; } if (!onlyText || resultData.text === initialText) { delete resultData.text; } if (href.indexOf('@') > 0 && href.indexOf('//') === -1 && href.indexOf('mailto:') === -1) { delayedConfirm(editor, 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?', function (state) { if (state) { resultData.href = 'mailto:' + href; } insertLink(resultData); }); return; } if (assumeExternalTargets === true && !/^\w+:/i.test(href) || assumeExternalTargets === false && /^\s*www[\.|\d\.]/i.test(href)) { delayedConfirm(editor, 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?', function (state) { if (state) { resultData.href = 'http://' + href; } insertLink(resultData); }); return; } insertLink(resultData); } }); }; var open$1 = function (editor) { createLinkList(editor, showDialog); }; var Dialog = { open: open$1 }; var getLink = function (editor, elm) { return editor.dom.getParent(elm, 'a[href]'); }; var getSelectedLink = function (editor) { return getLink(editor, editor.selection.getStart()); }; var getHref = function (elm) { var href = elm.getAttribute('data-mce-href'); return href ? href : elm.getAttribute('href'); }; var isContextMenuVisible = function (editor) { var contextmenu = editor.plugins.contextmenu; return contextmenu ? contextmenu.isContextMenuVisible() : false; }; var hasOnlyAltModifier = function (e) { return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false; }; var gotoLink = function (editor, a) { if (a) { var href = getHref(a); if (/^#/.test(href)) { var targetEl = editor.$(href); if (targetEl.length) { editor.selection.scrollIntoView(targetEl[0], true); } } else { OpenUrl.open(a.href); } } }; var openDialog = function (editor) { return function () { Dialog.open(editor); }; }; var gotoSelectedLink = function (editor) { return function () { gotoLink(editor, getSelectedLink(editor)); }; }; var leftClickedOnAHref = function (editor) { return function (elm) { var sel, rng, node; if (Settings.hasContextToolbar(editor.settings) && !isContextMenuVisible(editor) && Utils.isLink(elm)) { sel = editor.selection; rng = sel.getRng(); node = rng.startContainer; if (node.nodeType === 3 && sel.isCollapsed() && rng.startOffset > 0 && rng.startOffset < node.data.length) { return true; } } return false; }; }; var setupGotoLinks = function (editor) { editor.on('click', function (e) { var link = getLink(editor, e.target); if (link && global$1.metaKeyPressed(e)) { e.preventDefault(); gotoLink(editor, link); } }); editor.on('keydown', function (e) { var link = getSelectedLink(editor); if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) { e.preventDefault(); gotoLink(editor, link); } }); }; var toggleActiveState = function (editor) { return function () { var self = this; editor.on('nodechange', function (e) { self.active(!editor.readonly && !!Utils.getAnchorElement(editor, e.element)); }); }; }; var toggleViewLinkState = function (editor) { return function () { var self = this; var toggleVisibility = function (e) { if (Utils.hasLinks(e.parents)) { self.show(); } else { self.hide(); } }; if (!Utils.hasLinks(editor.dom.getParents(editor.selection.getStart()))) { self.hide(); } editor.on('nodechange', toggleVisibility); self.on('remove', function () { editor.off('nodechange', toggleVisibility); }); }; }; var Actions = { openDialog: openDialog, gotoSelectedLink: gotoSelectedLink, leftClickedOnAHref: leftClickedOnAHref, setupGotoLinks: setupGotoLinks, toggleActiveState: toggleActiveState, toggleViewLinkState: toggleViewLinkState }; var register = function (editor) { editor.addCommand('mceLink', Actions.openDialog(editor)); }; var Commands = { register: register }; var setup = function (editor) { editor.addShortcut('Meta+K', '', Actions.openDialog(editor)); }; var Keyboard = { setup: setup }; var setupButtons = function (editor) { editor.addButton('link', { active: false, icon: 'link', tooltip: 'Insert/edit link', onclick: Actions.openDialog(editor), onpostrender: Actions.toggleActiveState(editor) }); editor.addButton('unlink', { active: false, icon: 'unlink', tooltip: 'Remove link', onclick: Utils.unlink(editor), onpostrender: Actions.toggleActiveState(editor) }); if (editor.addContextToolbar) { editor.addButton('openlink', { icon: 'newtab', tooltip: 'Open link', onclick: Actions.gotoSelectedLink(editor) }); } }; var setupMenuItems = function (editor) { editor.addMenuItem('openlink', { text: 'Open link', icon: 'newtab', onclick: Actions.gotoSelectedLink(editor), onPostRender: Actions.toggleViewLinkState(editor), prependToContext: true }); editor.addMenuItem('link', { icon: 'link', text: 'Link', shortcut: 'Meta+K', onclick: Actions.openDialog(editor), stateSelector: 'a[href]', context: 'insert', prependToContext: true }); editor.addMenuItem('unlink', { icon: 'unlink', text: 'Remove link', onclick: Utils.unlink(editor), stateSelector: 'a[href]' }); }; var setupContextToolbars = function (editor) { if (editor.addContextToolbar) { editor.addContextToolbar(Actions.leftClickedOnAHref(editor), 'openlink | link unlink'); } }; var Controls = { setupButtons: setupButtons, setupMenuItems: setupMenuItems, setupContextToolbars: setupContextToolbars }; global.add('link', function (editor) { Controls.setupButtons(editor); Controls.setupMenuItems(editor); Controls.setupContextToolbars(editor); Actions.setupGotoLinks(editor); Commands.register(editor); Keyboard.setup(editor); }); function Plugin () { } return Plugin; }(window)); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/charmap/plugin.js 0000644 00000055252 15006123070 0021224 0 ustar 00 (function () { var charmap = (function () { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var fireInsertCustomChar = function (editor, chr) { return editor.fire('insertCustomChar', { chr: chr }); }; var Events = { fireInsertCustomChar: fireInsertCustomChar }; var insertChar = function (editor, chr) { var evtChr = Events.fireInsertCustomChar(editor, chr).chr; editor.execCommand('mceInsertContent', false, evtChr); }; var Actions = { insertChar: insertChar }; var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var getCharMap = function (editor) { return editor.settings.charmap; }; var getCharMapAppend = function (editor) { return editor.settings.charmap_append; }; var Settings = { getCharMap: getCharMap, getCharMapAppend: getCharMapAppend }; var isArray = global$1.isArray; var getDefaultCharMap = function () { return [ [ '160', 'no-break space' ], [ '173', 'soft hyphen' ], [ '34', 'quotation mark' ], [ '162', 'cent sign' ], [ '8364', 'euro sign' ], [ '163', 'pound sign' ], [ '165', 'yen sign' ], [ '169', 'copyright sign' ], [ '174', 'registered sign' ], [ '8482', 'trade mark sign' ], [ '8240', 'per mille sign' ], [ '181', 'micro sign' ], [ '183', 'middle dot' ], [ '8226', 'bullet' ], [ '8230', 'three dot leader' ], [ '8242', 'minutes / feet' ], [ '8243', 'seconds / inches' ], [ '167', 'section sign' ], [ '182', 'paragraph sign' ], [ '223', 'sharp s / ess-zed' ], [ '8249', 'single left-pointing angle quotation mark' ], [ '8250', 'single right-pointing angle quotation mark' ], [ '171', 'left pointing guillemet' ], [ '187', 'right pointing guillemet' ], [ '8216', 'left single quotation mark' ], [ '8217', 'right single quotation mark' ], [ '8220', 'left double quotation mark' ], [ '8221', 'right double quotation mark' ], [ '8218', 'single low-9 quotation mark' ], [ '8222', 'double low-9 quotation mark' ], [ '60', 'less-than sign' ], [ '62', 'greater-than sign' ], [ '8804', 'less-than or equal to' ], [ '8805', 'greater-than or equal to' ], [ '8211', 'en dash' ], [ '8212', 'em dash' ], [ '175', 'macron' ], [ '8254', 'overline' ], [ '164', 'currency sign' ], [ '166', 'broken bar' ], [ '168', 'diaeresis' ], [ '161', 'inverted exclamation mark' ], [ '191', 'turned question mark' ], [ '710', 'circumflex accent' ], [ '732', 'small tilde' ], [ '176', 'degree sign' ], [ '8722', 'minus sign' ], [ '177', 'plus-minus sign' ], [ '247', 'division sign' ], [ '8260', 'fraction slash' ], [ '215', 'multiplication sign' ], [ '185', 'superscript one' ], [ '178', 'superscript two' ], [ '179', 'superscript three' ], [ '188', 'fraction one quarter' ], [ '189', 'fraction one half' ], [ '190', 'fraction three quarters' ], [ '402', 'function / florin' ], [ '8747', 'integral' ], [ '8721', 'n-ary sumation' ], [ '8734', 'infinity' ], [ '8730', 'square root' ], [ '8764', 'similar to' ], [ '8773', 'approximately equal to' ], [ '8776', 'almost equal to' ], [ '8800', 'not equal to' ], [ '8801', 'identical to' ], [ '8712', 'element of' ], [ '8713', 'not an element of' ], [ '8715', 'contains as member' ], [ '8719', 'n-ary product' ], [ '8743', 'logical and' ], [ '8744', 'logical or' ], [ '172', 'not sign' ], [ '8745', 'intersection' ], [ '8746', 'union' ], [ '8706', 'partial differential' ], [ '8704', 'for all' ], [ '8707', 'there exists' ], [ '8709', 'diameter' ], [ '8711', 'backward difference' ], [ '8727', 'asterisk operator' ], [ '8733', 'proportional to' ], [ '8736', 'angle' ], [ '180', 'acute accent' ], [ '184', 'cedilla' ], [ '170', 'feminine ordinal indicator' ], [ '186', 'masculine ordinal indicator' ], [ '8224', 'dagger' ], [ '8225', 'double dagger' ], [ '192', 'A - grave' ], [ '193', 'A - acute' ], [ '194', 'A - circumflex' ], [ '195', 'A - tilde' ], [ '196', 'A - diaeresis' ], [ '197', 'A - ring above' ], [ '256', 'A - macron' ], [ '198', 'ligature AE' ], [ '199', 'C - cedilla' ], [ '200', 'E - grave' ], [ '201', 'E - acute' ], [ '202', 'E - circumflex' ], [ '203', 'E - diaeresis' ], [ '274', 'E - macron' ], [ '204', 'I - grave' ], [ '205', 'I - acute' ], [ '206', 'I - circumflex' ], [ '207', 'I - diaeresis' ], [ '298', 'I - macron' ], [ '208', 'ETH' ], [ '209', 'N - tilde' ], [ '210', 'O - grave' ], [ '211', 'O - acute' ], [ '212', 'O - circumflex' ], [ '213', 'O - tilde' ], [ '214', 'O - diaeresis' ], [ '216', 'O - slash' ], [ '332', 'O - macron' ], [ '338', 'ligature OE' ], [ '352', 'S - caron' ], [ '217', 'U - grave' ], [ '218', 'U - acute' ], [ '219', 'U - circumflex' ], [ '220', 'U - diaeresis' ], [ '362', 'U - macron' ], [ '221', 'Y - acute' ], [ '376', 'Y - diaeresis' ], [ '562', 'Y - macron' ], [ '222', 'THORN' ], [ '224', 'a - grave' ], [ '225', 'a - acute' ], [ '226', 'a - circumflex' ], [ '227', 'a - tilde' ], [ '228', 'a - diaeresis' ], [ '229', 'a - ring above' ], [ '257', 'a - macron' ], [ '230', 'ligature ae' ], [ '231', 'c - cedilla' ], [ '232', 'e - grave' ], [ '233', 'e - acute' ], [ '234', 'e - circumflex' ], [ '235', 'e - diaeresis' ], [ '275', 'e - macron' ], [ '236', 'i - grave' ], [ '237', 'i - acute' ], [ '238', 'i - circumflex' ], [ '239', 'i - diaeresis' ], [ '299', 'i - macron' ], [ '240', 'eth' ], [ '241', 'n - tilde' ], [ '242', 'o - grave' ], [ '243', 'o - acute' ], [ '244', 'o - circumflex' ], [ '245', 'o - tilde' ], [ '246', 'o - diaeresis' ], [ '248', 'o slash' ], [ '333', 'o macron' ], [ '339', 'ligature oe' ], [ '353', 's - caron' ], [ '249', 'u - grave' ], [ '250', 'u - acute' ], [ '251', 'u - circumflex' ], [ '252', 'u - diaeresis' ], [ '363', 'u - macron' ], [ '253', 'y - acute' ], [ '254', 'thorn' ], [ '255', 'y - diaeresis' ], [ '563', 'y - macron' ], [ '913', 'Alpha' ], [ '914', 'Beta' ], [ '915', 'Gamma' ], [ '916', 'Delta' ], [ '917', 'Epsilon' ], [ '918', 'Zeta' ], [ '919', 'Eta' ], [ '920', 'Theta' ], [ '921', 'Iota' ], [ '922', 'Kappa' ], [ '923', 'Lambda' ], [ '924', 'Mu' ], [ '925', 'Nu' ], [ '926', 'Xi' ], [ '927', 'Omicron' ], [ '928', 'Pi' ], [ '929', 'Rho' ], [ '931', 'Sigma' ], [ '932', 'Tau' ], [ '933', 'Upsilon' ], [ '934', 'Phi' ], [ '935', 'Chi' ], [ '936', 'Psi' ], [ '937', 'Omega' ], [ '945', 'alpha' ], [ '946', 'beta' ], [ '947', 'gamma' ], [ '948', 'delta' ], [ '949', 'epsilon' ], [ '950', 'zeta' ], [ '951', 'eta' ], [ '952', 'theta' ], [ '953', 'iota' ], [ '954', 'kappa' ], [ '955', 'lambda' ], [ '956', 'mu' ], [ '957', 'nu' ], [ '958', 'xi' ], [ '959', 'omicron' ], [ '960', 'pi' ], [ '961', 'rho' ], [ '962', 'final sigma' ], [ '963', 'sigma' ], [ '964', 'tau' ], [ '965', 'upsilon' ], [ '966', 'phi' ], [ '967', 'chi' ], [ '968', 'psi' ], [ '969', 'omega' ], [ '8501', 'alef symbol' ], [ '982', 'pi symbol' ], [ '8476', 'real part symbol' ], [ '978', 'upsilon - hook symbol' ], [ '8472', 'Weierstrass p' ], [ '8465', 'imaginary part' ], [ '8592', 'leftwards arrow' ], [ '8593', 'upwards arrow' ], [ '8594', 'rightwards arrow' ], [ '8595', 'downwards arrow' ], [ '8596', 'left right arrow' ], [ '8629', 'carriage return' ], [ '8656', 'leftwards double arrow' ], [ '8657', 'upwards double arrow' ], [ '8658', 'rightwards double arrow' ], [ '8659', 'downwards double arrow' ], [ '8660', 'left right double arrow' ], [ '8756', 'therefore' ], [ '8834', 'subset of' ], [ '8835', 'superset of' ], [ '8836', 'not a subset of' ], [ '8838', 'subset of or equal to' ], [ '8839', 'superset of or equal to' ], [ '8853', 'circled plus' ], [ '8855', 'circled times' ], [ '8869', 'perpendicular' ], [ '8901', 'dot operator' ], [ '8968', 'left ceiling' ], [ '8969', 'right ceiling' ], [ '8970', 'left floor' ], [ '8971', 'right floor' ], [ '9001', 'left-pointing angle bracket' ], [ '9002', 'right-pointing angle bracket' ], [ '9674', 'lozenge' ], [ '9824', 'black spade suit' ], [ '9827', 'black club suit' ], [ '9829', 'black heart suit' ], [ '9830', 'black diamond suit' ], [ '8194', 'en space' ], [ '8195', 'em space' ], [ '8201', 'thin space' ], [ '8204', 'zero width non-joiner' ], [ '8205', 'zero width joiner' ], [ '8206', 'left-to-right mark' ], [ '8207', 'right-to-left mark' ] ]; }; var charmapFilter = function (charmap) { return global$1.grep(charmap, function (item) { return isArray(item) && item.length === 2; }); }; var getCharsFromSetting = function (settingValue) { if (isArray(settingValue)) { return [].concat(charmapFilter(settingValue)); } if (typeof settingValue === 'function') { return settingValue(); } return []; }; var extendCharMap = function (editor, charmap) { var userCharMap = Settings.getCharMap(editor); if (userCharMap) { charmap = getCharsFromSetting(userCharMap); } var userCharMapAppend = Settings.getCharMapAppend(editor); if (userCharMapAppend) { return [].concat(charmap).concat(getCharsFromSetting(userCharMapAppend)); } return charmap; }; var getCharMap$1 = function (editor) { return extendCharMap(editor, getDefaultCharMap()); }; var CharMap = { getCharMap: getCharMap$1 }; var get = function (editor) { var getCharMap = function () { return CharMap.getCharMap(editor); }; var insertChar = function (chr) { Actions.insertChar(editor, chr); }; return { getCharMap: getCharMap, insertChar: insertChar }; }; var Api = { get: get }; var getHtml = function (charmap) { var gridHtml, x, y; var width = Math.min(charmap.length, 25); var height = Math.ceil(charmap.length / width); gridHtml = '<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>'; for (y = 0; y < height; y++) { gridHtml += '<tr>'; for (x = 0; x < width; x++) { var index = y * width + x; if (index < charmap.length) { var chr = charmap[index]; var charCode = parseInt(chr[0], 10); var chrText = chr ? String.fromCharCode(charCode) : ' '; gridHtml += '<td title="' + chr[1] + '">' + '<div tabindex="-1" title="' + chr[1] + '" role="button" data-chr="' + charCode + '">' + chrText + '</div>' + '</td>'; } else { gridHtml += '<td />'; } } gridHtml += '</tr>'; } gridHtml += '</tbody></table>'; return gridHtml; }; var GridHtml = { getHtml: getHtml }; var getParentTd = function (elm) { while (elm) { if (elm.nodeName === 'TD') { return elm; } elm = elm.parentNode; } }; var open = function (editor) { var win; var charMapPanel = { type: 'container', html: GridHtml.getHtml(CharMap.getCharMap(editor)), onclick: function (e) { var target = e.target; if (/^(TD|DIV)$/.test(target.nodeName)) { var charDiv = getParentTd(target).firstChild; if (charDiv && charDiv.hasAttribute('data-chr')) { var charCodeString = charDiv.getAttribute('data-chr'); var charCode = parseInt(charCodeString, 10); if (!isNaN(charCode)) { Actions.insertChar(editor, String.fromCharCode(charCode)); } if (!e.ctrlKey) { win.close(); } } } }, onmouseover: function (e) { var td = getParentTd(e.target); if (td && td.firstChild) { win.find('#preview').text(td.firstChild.firstChild.data); win.find('#previewTitle').text(td.title); } else { win.find('#preview').text(' '); win.find('#previewTitle').text(' '); } } }; win = editor.windowManager.open({ title: 'Special character', spacing: 10, padding: 10, items: [ charMapPanel, { type: 'container', layout: 'flex', direction: 'column', align: 'center', spacing: 5, minWidth: 160, minHeight: 160, items: [ { type: 'label', name: 'preview', text: ' ', style: 'font-size: 40px; text-align: center', border: 1, minWidth: 140, minHeight: 80 }, { type: 'spacer', minHeight: 20 }, { type: 'label', name: 'previewTitle', text: ' ', style: 'white-space: pre-wrap;', border: 1, minWidth: 140 } ] } ], buttons: [{ text: 'Close', onclick: function () { win.close(); } }] }); }; var Dialog = { open: open }; var register = function (editor) { editor.addCommand('mceShowCharmap', function () { Dialog.open(editor); }); }; var Commands = { register: register }; var register$1 = function (editor) { editor.addButton('charmap', { icon: 'charmap', tooltip: 'Special character', cmd: 'mceShowCharmap' }); editor.addMenuItem('charmap', { icon: 'charmap', text: 'Special character', cmd: 'mceShowCharmap', context: 'insert' }); }; var Buttons = { register: register$1 }; global.add('charmap', function (editor) { Commands.register(editor); Buttons.register(editor); return Api.get(editor); }); function Plugin () { } return Plugin; }()); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js 0000644 00000062052 15006123320 0022102 0 ustar 00 /* global tinymce */ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { var toolbar, serializer, touchOnImage, pasteInCaption, each = tinymce.each, trim = tinymce.trim, iOS = tinymce.Env.iOS; function isPlaceholder( node ) { return !! ( editor.dom.getAttrib( node, 'data-mce-placeholder' ) || editor.dom.getAttrib( node, 'data-mce-object' ) ); } editor.addButton( 'wp_img_remove', { tooltip: 'Remove', icon: 'dashicon dashicons-no', onclick: function() { removeImage( editor.selection.getNode() ); } } ); editor.addButton( 'wp_img_edit', { tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { editImage( editor.selection.getNode() ); } } ); each( { alignleft: 'Align left', aligncenter: 'Align center', alignright: 'Align right', alignnone: 'No alignment' }, function( tooltip, name ) { var direction = name.slice( 5 ); editor.addButton( 'wp_img_' + name, { tooltip: tooltip, icon: 'dashicon dashicons-align-' + direction, cmd: 'alignnone' === name ? 'wpAlignNone' : 'Justify' + direction.slice( 0, 1 ).toUpperCase() + direction.slice( 1 ), onPostRender: function() { var self = this; editor.on( 'NodeChange', function( event ) { var node; // Don't bother. if ( event.element.nodeName !== 'IMG' ) { return; } node = editor.dom.getParent( event.element, '.wp-caption' ) || event.element; if ( 'alignnone' === name ) { self.active( ! /\balign(left|center|right)\b/.test( node.className ) ); } else { self.active( editor.dom.hasClass( node, name ) ); } } ); } } ); } ); editor.once( 'preinit', function() { if ( editor.wp && editor.wp._createToolbar ) { toolbar = editor.wp._createToolbar( [ 'wp_img_alignleft', 'wp_img_aligncenter', 'wp_img_alignright', 'wp_img_alignnone', 'wp_img_edit', 'wp_img_remove' ] ); } } ); editor.on( 'wptoolbar', function( event ) { if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) { event.toolbar = toolbar; } } ); function isNonEditable( node ) { var parent = editor.$( node ).parents( '[contenteditable]' ); return parent && parent.attr( 'contenteditable' ) === 'false'; } // Safari on iOS fails to select images in contentEditoble mode on touch. // Select them again. if ( iOS ) { editor.on( 'init', function() { editor.on( 'touchstart', function( event ) { if ( event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) { touchOnImage = true; } }); editor.dom.bind( editor.getDoc(), 'touchmove', function() { touchOnImage = false; }); editor.on( 'touchend', function( event ) { if ( touchOnImage && event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) { var node = event.target; touchOnImage = false; window.setTimeout( function() { editor.selection.select( node ); editor.nodeChanged(); }, 100 ); } else if ( toolbar ) { toolbar.hide(); } }); }); } function parseShortcode( content ) { return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) { var id, align, classes, caption, img, width; id = b.match( /id=['"]([^'"]*)['"] ?/ ); if ( id ) { b = b.replace( id[0], '' ); } align = b.match( /align=['"]([^'"]*)['"] ?/ ); if ( align ) { b = b.replace( align[0], '' ); } classes = b.match( /class=['"]([^'"]*)['"] ?/ ); if ( classes ) { b = b.replace( classes[0], '' ); } width = b.match( /width=['"]([0-9]*)['"] ?/ ); if ( width ) { b = b.replace( width[0], '' ); } c = trim( c ); img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i ); if ( img && img[2] ) { caption = trim( img[2] ); img = trim( img[1] ); } else { // Old captions shortcode style. caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' ); img = c; } id = ( id && id[1] ) ? id[1].replace( /[<>&]+/g, '' ) : ''; align = ( align && align[1] ) ? align[1] : 'alignnone'; classes = ( classes && classes[1] ) ? ' ' + classes[1].replace( /[<>&]+/g, '' ) : ''; if ( ! width && img ) { width = img.match( /width=['"]([0-9]*)['"]/ ); } if ( width && width[1] ) { width = width[1]; } if ( ! width || ! caption ) { return c; } width = parseInt( width, 10 ); if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) { width += 10; } return '<div class="mceTemp"><dl id="' + id + '" class="wp-caption ' + align + classes + '" style="width: ' + width + 'px">' + '<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ caption +'</dd></dl></div>'; }); } function getShortcode( content ) { return content.replace( /(?:<div [^>]+mceTemp[^>]+>)?\s*(<dl [^>]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g, function( all, dl ) { var out = ''; if ( dl.indexOf('<img ') === -1 || dl.indexOf('</p>') !== -1 ) { // Broken caption. The user managed to drag the image out or type in the wrapper div? // Remove the <dl>, <dd> and <dt> and return the remaining text. return dl.replace( /<d[ldt]( [^>]+)?>/g, '' ).replace( /<\/d[ldt]>/g, '' ); } out = dl.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) { var id, classes, align, width; width = c.match( /width="([0-9]*)"/ ); width = ( width && width[1] ) ? width[1] : ''; classes = b.match( /class="([^"]*)"/ ); classes = ( classes && classes[1] ) ? classes[1] : ''; align = classes.match( /align[a-z]+/i ) || 'alignnone'; if ( ! width || ! caption ) { if ( 'alignnone' !== align[0] ) { c = c.replace( /><img/, ' class="' + align[0] + '"><img' ); } return c; } id = b.match( /id="([^"]*)"/ ); id = ( id && id[1] ) ? id[1] : ''; classes = classes.replace( /wp-caption ?|align[a-z]+ ?/gi, '' ); if ( classes ) { classes = ' class="' + classes + '"'; } caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) { // No line breaks inside HTML tags. return a.replace( /[\r\n\t]+/, ' ' ); }); // Convert remaining line breaks to <br>. caption = caption.replace( /\s*\n\s*/g, '<br />' ); return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]'; }); if ( out.indexOf('[caption') === -1 ) { // The caption html seems broken, try to find the image that may be wrapped in a link // and may be followed by <p> with the caption text. out = dl.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' ); } return out; }); } function extractImageData( imageNode ) { var classes, extraClasses, metadata, captionBlock, caption, link, width, height, captionClassName = [], dom = editor.dom, isIntRegExp = /^\d+$/; // Default attributes. metadata = { attachment_id: false, size: 'custom', caption: '', align: 'none', extraClasses: '', link: false, linkUrl: '', linkClassName: '', linkTargetBlank: false, linkRel: '', title: '' }; metadata.url = dom.getAttrib( imageNode, 'src' ); metadata.alt = dom.getAttrib( imageNode, 'alt' ); metadata.title = dom.getAttrib( imageNode, 'title' ); width = dom.getAttrib( imageNode, 'width' ); height = dom.getAttrib( imageNode, 'height' ); if ( ! isIntRegExp.test( width ) || parseInt( width, 10 ) < 1 ) { width = imageNode.naturalWidth || imageNode.width; } if ( ! isIntRegExp.test( height ) || parseInt( height, 10 ) < 1 ) { height = imageNode.naturalHeight || imageNode.height; } metadata.customWidth = metadata.width = width; metadata.customHeight = metadata.height = height; classes = tinymce.explode( imageNode.className, ' ' ); extraClasses = []; tinymce.each( classes, function( name ) { if ( /^wp-image/.test( name ) ) { metadata.attachment_id = parseInt( name.replace( 'wp-image-', '' ), 10 ); } else if ( /^align/.test( name ) ) { metadata.align = name.replace( 'align', '' ); } else if ( /^size/.test( name ) ) { metadata.size = name.replace( 'size-', '' ); } else { extraClasses.push( name ); } } ); metadata.extraClasses = extraClasses.join( ' ' ); // Extract caption. captionBlock = dom.getParents( imageNode, '.wp-caption' ); if ( captionBlock.length ) { captionBlock = captionBlock[0]; classes = captionBlock.className.split( ' ' ); tinymce.each( classes, function( name ) { if ( /^align/.test( name ) ) { metadata.align = name.replace( 'align', '' ); } else if ( name && name !== 'wp-caption' ) { captionClassName.push( name ); } } ); metadata.captionClassName = captionClassName.join( ' ' ); caption = dom.select( 'dd.wp-caption-dd', captionBlock ); if ( caption.length ) { caption = caption[0]; metadata.caption = editor.serializer.serialize( caption ) .replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' ); } } // Extract linkTo. if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { link = imageNode.parentNode; metadata.linkUrl = dom.getAttrib( link, 'href' ); metadata.linkTargetBlank = dom.getAttrib( link, 'target' ) === '_blank' ? true : false; metadata.linkRel = dom.getAttrib( link, 'rel' ); metadata.linkClassName = link.className; } return metadata; } function hasTextContent( node ) { return node && !! ( node.textContent || node.innerText ).replace( /\ufeff/g, '' ); } // Verify HTML in captions. function verifyHTML( caption ) { if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) { return caption; } if ( ! serializer ) { serializer = new tinymce.html.Serializer( {}, editor.schema ); } return serializer.serialize( editor.parser.parse( caption, { forced_root_block: false } ) ); } function updateImage( $imageNode, imageData ) { var classes, className, node, html, parent, wrap, linkNode, imageNode, captionNode, dd, dl, id, attrs, linkAttrs, width, height, align, $imageNode, srcset, src, dom = editor.dom; if ( ! $imageNode || ! $imageNode.length ) { return; } imageNode = $imageNode[0]; classes = tinymce.explode( imageData.extraClasses, ' ' ); if ( ! classes ) { classes = []; } if ( ! imageData.caption ) { classes.push( 'align' + imageData.align ); } if ( imageData.attachment_id ) { classes.push( 'wp-image-' + imageData.attachment_id ); if ( imageData.size && imageData.size !== 'custom' ) { classes.push( 'size-' + imageData.size ); } } width = imageData.width; height = imageData.height; if ( imageData.size === 'custom' ) { width = imageData.customWidth; height = imageData.customHeight; } attrs = { src: imageData.url, width: width || null, height: height || null, title: imageData.title || null, 'class': classes.join( ' ' ) || null }; dom.setAttribs( imageNode, attrs ); // Preserve empty alt attributes. $imageNode.attr( 'alt', imageData.alt || '' ); linkAttrs = { href: imageData.linkUrl, rel: imageData.linkRel || null, target: imageData.linkTargetBlank ? '_blank': null, 'class': imageData.linkClassName || null }; if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { // Update or remove an existing link wrapped around the image. if ( imageData.linkUrl ) { dom.setAttribs( imageNode.parentNode, linkAttrs ); } else { dom.remove( imageNode.parentNode, true ); } } else if ( imageData.linkUrl ) { if ( linkNode = dom.getParent( imageNode, 'a' ) ) { // The image is inside a link together with other nodes, // or is nested in another node, move it out. dom.insertAfter( imageNode, linkNode ); } // Add link wrapped around the image. linkNode = dom.create( 'a', linkAttrs ); imageNode.parentNode.insertBefore( linkNode, imageNode ); linkNode.appendChild( imageNode ); } captionNode = editor.dom.getParent( imageNode, '.mceTemp' ); if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { node = imageNode.parentNode; } else { node = imageNode; } if ( imageData.caption ) { imageData.caption = verifyHTML( imageData.caption ); id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null; align = 'align' + ( imageData.align || 'none' ); className = 'wp-caption ' + align; if ( imageData.captionClassName ) { className += ' ' + imageData.captionClassName.replace( /[<>&]+/g, '' ); } if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) { width = parseInt( width, 10 ); width += 10; } if ( captionNode ) { dl = dom.select( 'dl.wp-caption', captionNode ); if ( dl.length ) { dom.setAttribs( dl, { id: id, 'class': className, style: 'width: ' + width + 'px' } ); } dd = dom.select( '.wp-caption-dd', captionNode ); if ( dd.length ) { dom.setHTML( dd[0], imageData.caption ); } } else { id = id ? 'id="'+ id +'" ' : ''; // Should create a new function for generating the caption markup. html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' + '<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>'; wrap = dom.create( 'div', { 'class': 'mceTemp' }, html ); if ( parent = dom.getParent( node, 'p' ) ) { parent.parentNode.insertBefore( wrap, parent ); } else { node.parentNode.insertBefore( wrap, node ); } editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node ); if ( parent && dom.isEmpty( parent ) ) { dom.remove( parent ); } } } else if ( captionNode ) { // Remove the caption wrapper and place the image in new paragraph. parent = dom.create( 'p' ); captionNode.parentNode.insertBefore( parent, captionNode ); parent.appendChild( node ); dom.remove( captionNode ); } $imageNode = editor.$( imageNode ); srcset = $imageNode.attr( 'srcset' ); src = $imageNode.attr( 'src' ); // Remove srcset and sizes if the image file was edited or the image was replaced. if ( srcset && src ) { src = src.replace( /[?#].*/, '' ); if ( srcset.indexOf( src ) === -1 ) { $imageNode.attr( 'srcset', null ).attr( 'sizes', null ); } } if ( wp.media.events ) { wp.media.events.trigger( 'editor:image-update', { editor: editor, metadata: imageData, image: imageNode } ); } editor.nodeChanged(); } function editImage( img ) { var frame, callback, metadata, imageNode; if ( typeof wp === 'undefined' || ! wp.media ) { editor.execCommand( 'mceImage' ); return; } metadata = extractImageData( img ); // Mark the image node so we can select it later. editor.$( img ).attr( 'data-wp-editing', 1 ); // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal. wp.media.events.trigger( 'editor:image-edit', { editor: editor, metadata: metadata, image: img } ); frame = wp.media({ frame: 'image', state: 'image-details', metadata: metadata } ); wp.media.events.trigger( 'editor:frame-create', { frame: frame } ); callback = function( imageData ) { editor.undoManager.transact( function() { updateImage( imageNode, imageData ); } ); frame.detach(); }; frame.state('image-details').on( 'update', callback ); frame.state('replace-image').on( 'replace', callback ); frame.on( 'close', function() { editor.focus(); frame.detach(); /* * `close` fires first... * To be able to update the image node, we need to find it here, * and use it in the callback. */ imageNode = editor.$( 'img[data-wp-editing]' ) imageNode.removeAttr( 'data-wp-editing' ); }); frame.open(); } function removeImage( node ) { var wrap = editor.dom.getParent( node, 'div.mceTemp' ); if ( ! wrap && node.nodeName === 'IMG' ) { wrap = editor.dom.getParent( node, 'a' ); } if ( wrap ) { if ( wrap.nextSibling ) { editor.selection.select( wrap.nextSibling ); } else if ( wrap.previousSibling ) { editor.selection.select( wrap.previousSibling ); } else { editor.selection.select( wrap.parentNode ); } editor.selection.collapse( true ); editor.dom.remove( wrap ); } else { editor.dom.remove( node ); } editor.nodeChanged(); editor.undoManager.add(); } editor.on( 'init', function() { var dom = editor.dom, captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions'; dom.addClass( editor.getBody(), captionClass ); // Prevent IE11 from making dl.wp-caption resizable. if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) { // The 'mscontrolselect' event is supported only in IE11+. dom.bind( editor.getBody(), 'mscontrolselect', function( event ) { if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) { // Hide the thick border with resize handles around dl.wp-caption. editor.getBody().focus(); // :( } else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) { // Trigger the thick border with resize handles... // This will make the caption text editable. event.target.focus(); } }); } }); editor.on( 'ObjectResized', function( event ) { var node = event.target; if ( node.nodeName === 'IMG' ) { editor.undoManager.transact( function() { var parent, width, dom = editor.dom; node.className = node.className.replace( /\bsize-[^ ]+/, '' ); if ( parent = dom.getParent( node, '.wp-caption' ) ) { width = event.width || dom.getAttrib( node, 'width' ); if ( width ) { width = parseInt( width, 10 ); if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) { width += 10; } dom.setStyle( parent, 'width', width + 'px' ); } } }); } }); editor.on( 'pastePostProcess', function( event ) { // Pasting in a caption node. if ( editor.dom.getParent( editor.selection.getNode(), 'dd.wp-caption-dd' ) ) { // Remove "non-block" elements that should not be in captions. editor.$( 'img, audio, video, object, embed, iframe, script, style', event.node ).remove(); editor.$( '*', event.node ).each( function( i, node ) { if ( editor.dom.isBlock( node ) ) { // Insert <br> where the blocks used to be. Makes it look better after pasting in the caption. if ( tinymce.trim( node.textContent || node.innerText ) ) { editor.dom.insertAfter( editor.dom.create( 'br' ), node ); editor.dom.remove( node, true ); } else { editor.dom.remove( node ); } } }); // Trim <br> tags. editor.$( 'br', event.node ).each( function( i, node ) { if ( ! node.nextSibling || node.nextSibling.nodeName === 'BR' || ! node.previousSibling || node.previousSibling.nodeName === 'BR' ) { editor.dom.remove( node ); } } ); // Pasted HTML is cleaned up for inserting in the caption. pasteInCaption = true; } }); editor.on( 'BeforeExecCommand', function( event ) { var node, p, DL, align, replacement, captionParent, cmd = event.command, dom = editor.dom; if ( cmd === 'mceInsertContent' || cmd === 'Indent' || cmd === 'Outdent' ) { node = editor.selection.getNode(); captionParent = dom.getParent( node, 'div.mceTemp' ); if ( captionParent ) { if ( cmd === 'mceInsertContent' ) { if ( pasteInCaption ) { pasteInCaption = false; /* * We are in the caption element, and in 'paste' context, * and the pasted HTML was cleaned up on 'pastePostProcess' above. * Let it be pasted in the caption. */ return; } /* * The paste is somewhere else in the caption DL element. * Prevent pasting in there as it will break the caption. * Make new paragraph under the caption DL and move the caret there. */ p = dom.create( 'p' ); dom.insertAfter( p, captionParent ); editor.selection.setCursorLocation( p, 0 ); /* * If the image is selected and the user pastes "over" it, * replace both the image and the caption elements with the pasted content. * This matches the behavior when pasting over non-caption images. */ if ( node.nodeName === 'IMG' ) { editor.$( captionParent ).remove(); } editor.nodeChanged(); } else { // Clicking Indent or Outdent while an image with a caption is selected breaks the caption. // See #38313. event.preventDefault(); event.stopImmediatePropagation(); return false; } } } else if ( cmd === 'JustifyLeft' || cmd === 'JustifyRight' || cmd === 'JustifyCenter' || cmd === 'wpAlignNone' ) { node = editor.selection.getNode(); align = 'align' + cmd.slice( 7 ).toLowerCase(); DL = editor.dom.getParent( node, '.wp-caption' ); if ( node.nodeName !== 'IMG' && ! DL ) { return; } node = DL || node; if ( editor.dom.hasClass( node, align ) ) { replacement = ' alignnone'; } else { replacement = ' ' + align; } node.className = trim( node.className.replace( / ?align(left|center|right|none)/g, '' ) + replacement ); editor.nodeChanged(); event.preventDefault(); if ( toolbar ) { toolbar.reposition(); } editor.fire( 'ExecCommand', { command: cmd, ui: event.ui, value: event.value } ); } }); editor.on( 'keydown', function( event ) { var node, wrap, P, spacer, selection = editor.selection, keyCode = event.keyCode, dom = editor.dom, VK = tinymce.util.VK; if ( keyCode === VK.ENTER ) { // When pressing Enter inside a caption move the caret to a new parapraph under it. node = selection.getNode(); wrap = dom.getParent( node, 'div.mceTemp' ); if ( wrap ) { dom.events.cancel( event ); // Doesn't cancel all :( // Remove any extra dt and dd cleated on pressing Enter... tinymce.each( dom.select( 'dt, dd', wrap ), function( element ) { if ( dom.isEmpty( element ) ) { dom.remove( element ); } }); spacer = tinymce.Env.ie && tinymce.Env.ie < 11 ? '' : '<br data-mce-bogus="1" />'; P = dom.create( 'p', null, spacer ); if ( node.nodeName === 'DD' ) { dom.insertAfter( P, wrap ); } else { wrap.parentNode.insertBefore( P, wrap ); } editor.nodeChanged(); selection.setCursorLocation( P, 0 ); } } else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) { node = selection.getNode(); if ( node.nodeName === 'DIV' && dom.hasClass( node, 'mceTemp' ) ) { wrap = node; } else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) { wrap = dom.getParent( node, 'div.mceTemp' ); } if ( wrap ) { dom.events.cancel( event ); removeImage( node ); return false; } } }); /* * After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. * This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. * Collapse the selection to remove the resize handles. */ if ( tinymce.Env.gecko ) { editor.on( 'undo redo', function() { if ( editor.selection.getNode().nodeName === 'IMG' ) { editor.selection.collapse(); } }); } editor.wpSetImgCaption = function( content ) { return parseShortcode( content ); }; editor.wpGetImgCaption = function( content ) { return getShortcode( content ); }; editor.on( 'beforeGetContent', function( event ) { if ( event.format !== 'raw' ) { editor.$( 'img[id="__wp-temp-img-id"]' ).removeAttr( 'id' ); } }); editor.on( 'BeforeSetContent', function( event ) { if ( event.format !== 'raw' ) { event.content = editor.wpSetImgCaption( event.content ); } }); editor.on( 'PostProcess', function( event ) { if ( event.get ) { event.content = editor.wpGetImgCaption( event.content ); } }); ( function() { var wrap; editor.on( 'dragstart', function() { var node = editor.selection.getNode(); if ( node.nodeName === 'IMG' ) { wrap = editor.dom.getParent( node, '.mceTemp' ); if ( ! wrap && node.parentNode.nodeName === 'A' && ! hasTextContent( node.parentNode ) ) { wrap = node.parentNode; } } } ); editor.on( 'drop', function( event ) { var dom = editor.dom, rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() ); // Don't allow anything to be dropped in a captioned image. if ( rng && dom.getParent( rng.startContainer, '.mceTemp' ) ) { event.preventDefault(); } else if ( wrap ) { event.preventDefault(); editor.undoManager.transact( function() { if ( rng ) { editor.selection.setRng( rng ); } editor.selection.setNode( wrap ); dom.remove( wrap ); } ); } wrap = null; } ); } )(); // Add to editor.wp. editor.wp = editor.wp || {}; editor.wp.isPlaceholder = isPlaceholder; // Back-compat. return { _do_shcode: parseShortcode, _get_shcode: getShortcode }; }); home/ephorei/www/wp-includes/js/tinymce/plugins/wpemoji/plugin.js 0000644 00000006774 15006123321 0021267 0 ustar 00 ( function( tinymce ) { tinymce.PluginManager.add( 'wpemoji', function( editor ) { var typing, wp = window.wp, settings = window._wpemojiSettings, env = tinymce.Env, ua = window.navigator.userAgent, isWin = ua.indexOf( 'Windows' ) > -1, isWin8 = ( function() { var match = ua.match( /Windows NT 6\.(\d)/ ); if ( match && match[1] > 1 ) { return true; } return false; }()); if ( ! wp || ! wp.emoji || settings.supports.everything ) { return; } function setImgAttr( image ) { image.className = 'emoji'; image.setAttribute( 'data-mce-resize', 'false' ); image.setAttribute( 'data-mce-placeholder', '1' ); image.setAttribute( 'data-wp-emoji', '1' ); } function replaceEmoji( node ) { var imgAttr = { 'data-mce-resize': 'false', 'data-mce-placeholder': '1', 'data-wp-emoji': '1' }; wp.emoji.parse( node, { imgAttr: imgAttr } ); } // Test if the node text contains emoji char(s) and replace. function parseNode( node ) { var selection, bookmark; if ( node && window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) { if ( env.webkit ) { selection = editor.selection; bookmark = selection.getBookmark(); } replaceEmoji( node ); if ( env.webkit ) { selection.moveToBookmark( bookmark ); } } } if ( isWin8 ) { /* * Windows 8+ emoji can be "typed" with the onscreen keyboard. * That triggers the normal keyboard events, but not the 'input' event. * Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji. */ editor.on( 'keyup', function( event ) { if ( event.keyCode === 231 ) { parseNode( editor.selection.getNode() ); } } ); } else if ( ! isWin ) { /* * In MacOS inserting emoji doesn't trigger the stanradr keyboard events. * Thankfully it triggers the 'input' event. * This works in Android and iOS as well. */ editor.on( 'keydown keyup', function( event ) { typing = ( event.type === 'keydown' ); } ); editor.on( 'input', function() { if ( typing ) { return; } parseNode( editor.selection.getNode() ); }); } editor.on( 'setcontent', function( event ) { var selection = editor.selection, node = selection.getNode(); if ( window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) { replaceEmoji( node ); // In IE all content in the editor is left selected after wp.emoji.parse()... // Collapse the selection to the beginning. if ( env.ie && env.ie < 9 && event.load && node && node.nodeName === 'BODY' ) { selection.collapse( true ); } } } ); // Convert Twemoji compatible pasted emoji replacement images into our format. editor.on( 'PastePostProcess', function( event ) { if ( window.twemoji ) { tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) { if ( image.alt && window.twemoji.test( image.alt ) ) { setImgAttr( image ); } }); } }); editor.on( 'postprocess', function( event ) { if ( event.content ) { event.content = event.content.replace( /<img[^>]+data-wp-emoji="[^>]+>/g, function( img ) { var alt = img.match( /alt="([^"]+)"/ ); if ( alt && alt[1] ) { return alt[1]; } return img; }); } } ); editor.on( 'resolvename', function( event ) { if ( event.target.nodeName === 'IMG' && editor.dom.getAttrib( event.target, 'data-wp-emoji' ) ) { event.preventDefault(); } } ); } ); } )( window.tinymce ); home/ephorei/www/wp-includes/js/tinymce/plugins/hr/plugin.js 0000644 00000001627 15006123321 0020216 0 ustar 00 (function () { var hr = (function () { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var register = function (editor) { editor.addCommand('InsertHorizontalRule', function () { editor.execCommand('mceInsertContent', false, '<hr />'); }); }; var Commands = { register: register }; var register$1 = function (editor) { editor.addButton('hr', { icon: 'hr', tooltip: 'Horizontal line', cmd: 'InsertHorizontalRule' }); editor.addMenuItem('hr', { icon: 'hr', text: 'Horizontal line', cmd: 'InsertHorizontalRule', context: 'insert' }); }; var Buttons = { register: register$1 }; global.add('hr', function (editor) { Commands.register(editor); Buttons.register(editor); }); function Plugin () { } return Plugin; }()); })(); home/ephorei/www/wp-includes/js/tinymce/plugins/media/plugin.js 0000644 00000120572 15006123511 0020666 0 ustar 00 (function () { var media = (function () { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var getScripts = function (editor) { return editor.getParam('media_scripts'); }; var getAudioTemplateCallback = function (editor) { return editor.getParam('audio_template_callback'); }; var getVideoTemplateCallback = function (editor) { return editor.getParam('video_template_callback'); }; var hasLiveEmbeds = function (editor) { return editor.getParam('media_live_embeds', true); }; var shouldFilterHtml = function (editor) { return editor.getParam('media_filter_html', true); }; var getUrlResolver = function (editor) { return editor.getParam('media_url_resolver'); }; var hasAltSource = function (editor) { return editor.getParam('media_alt_source', true); }; var hasPoster = function (editor) { return editor.getParam('media_poster', true); }; var hasDimensions = function (editor) { return editor.getParam('media_dimensions', true); }; var Settings = { getScripts: getScripts, getAudioTemplateCallback: getAudioTemplateCallback, getVideoTemplateCallback: getVideoTemplateCallback, hasLiveEmbeds: hasLiveEmbeds, shouldFilterHtml: shouldFilterHtml, getUrlResolver: getUrlResolver, hasAltSource: hasAltSource, hasPoster: hasPoster, hasDimensions: hasDimensions }; var Cell = function (initial) { var value = initial; var get = function () { return value; }; var set = function (v) { value = v; }; var clone = function () { return Cell(get()); }; return { get: get, set: set, clone: clone }; }; var noop = function () { }; var constant = function (value) { return function () { return value; }; }; var never = constant(false); var always = constant(true); var none = function () { return NONE; }; var NONE = function () { var eq = function (o) { return o.isNone(); }; var call = function (thunk) { return thunk(); }; var id = function (n) { return n; }; var me = { fold: function (n, s) { return n(); }, is: never, isSome: never, isNone: always, getOr: id, getOrThunk: call, getOrDie: function (msg) { throw new Error(msg || 'error: getOrDie called on none.'); }, getOrNull: constant(null), getOrUndefined: constant(undefined), or: id, orThunk: call, map: none, each: noop, bind: none, exists: never, forall: always, filter: none, equals: eq, equals_: eq, toArray: function () { return []; }, toString: constant('none()') }; if (Object.freeze) { Object.freeze(me); } return me; }(); var some = function (a) { var constant_a = constant(a); var self = function () { return me; }; var bind = function (f) { return f(a); }; var me = { fold: function (n, s) { return s(a); }, is: function (v) { return a === v; }, isSome: always, isNone: never, getOr: constant_a, getOrThunk: constant_a, getOrDie: constant_a, getOrNull: constant_a, getOrUndefined: constant_a, or: self, orThunk: self, map: function (f) { return some(f(a)); }, each: function (f) { f(a); }, bind: bind, exists: bind, forall: bind, filter: function (f) { return f(a) ? me : NONE; }, toArray: function () { return [a]; }, toString: function () { return 'some(' + a + ')'; }, equals: function (o) { return o.is(a); }, equals_: function (o, elementEq) { return o.fold(never, function (b) { return elementEq(a, b); }); } }; return me; }; var from = function (value) { return value === null || value === undefined ? NONE : some(value); }; var Option = { some: some, none: none, from: from }; var hasOwnProperty = Object.hasOwnProperty; var get = function (obj, key) { return has(obj, key) ? Option.from(obj[key]) : Option.none(); }; var has = function (obj, key) { return hasOwnProperty.call(obj, key); }; var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); var global$4 = tinymce.util.Tools.resolve('tinymce.html.SaxParser'); var getVideoScriptMatch = function (prefixes, src) { if (prefixes) { for (var i = 0; i < prefixes.length; i++) { if (src.indexOf(prefixes[i].filter) !== -1) { return prefixes[i]; } } } }; var VideoScript = { getVideoScriptMatch: getVideoScriptMatch }; var DOM = global$3.DOM; var trimPx = function (value) { return value.replace(/px$/, ''); }; var getEphoxEmbedData = function (attrs) { var style = attrs.map.style; var styles = style ? DOM.parseStyle(style) : {}; return { type: 'ephox-embed-iri', source1: attrs.map['data-ephox-embed-iri'], source2: '', poster: '', width: get(styles, 'max-width').map(trimPx).getOr(''), height: get(styles, 'max-height').map(trimPx).getOr('') }; }; var htmlToData = function (prefixes, html) { var isEphoxEmbed = Cell(false); var data = {}; global$4({ validate: false, allow_conditional_comments: true, special: 'script,noscript', start: function (name, attrs) { if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) { isEphoxEmbed.set(true); data = getEphoxEmbedData(attrs); } else { if (!data.source1 && name === 'param') { data.source1 = attrs.map.movie; } if (name === 'iframe' || name === 'object' || name === 'embed' || name === 'video' || name === 'audio') { if (!data.type) { data.type = name; } data = global$2.extend(attrs.map, data); } if (name === 'script') { var videoScript = VideoScript.getVideoScriptMatch(prefixes, attrs.map.src); if (!videoScript) { return; } data = { type: 'script', source1: attrs.map.src, width: videoScript.width, height: videoScript.height }; } if (name === 'source') { if (!data.source1) { data.source1 = attrs.map.src; } else if (!data.source2) { data.source2 = attrs.map.src; } } if (name === 'img' && !data.poster) { data.poster = attrs.map.src; } } } }).parse(html); data.source1 = data.source1 || data.src || data.data; data.source2 = data.source2 || ''; data.poster = data.poster || ''; return data; }; var HtmlToData = { htmlToData: htmlToData }; var global$5 = tinymce.util.Tools.resolve('tinymce.util.Promise'); var guess = function (url) { var mimes = { mp3: 'audio/mpeg', wav: 'audio/wav', mp4: 'video/mp4', webm: 'video/webm', ogg: 'video/ogg', swf: 'application/x-shockwave-flash' }; var fileEnd = url.toLowerCase().split('.').pop(); var mime = mimes[fileEnd]; return mime ? mime : ''; }; var Mime = { guess: guess }; var global$6 = tinymce.util.Tools.resolve('tinymce.html.Schema'); var global$7 = tinymce.util.Tools.resolve('tinymce.html.Writer'); var DOM$1 = global$3.DOM; var addPx = function (value) { return /^[0-9.]+$/.test(value) ? value + 'px' : value; }; var setAttributes = function (attrs, updatedAttrs) { for (var name in updatedAttrs) { var value = '' + updatedAttrs[name]; if (attrs.map[name]) { var i = attrs.length; while (i--) { var attr = attrs[i]; if (attr.name === name) { if (value) { attrs.map[name] = value; attr.value = value; } else { delete attrs.map[name]; attrs.splice(i, 1); } } } } else if (value) { attrs.push({ name: name, value: value }); attrs.map[name] = value; } } }; var updateEphoxEmbed = function (data, attrs) { var style = attrs.map.style; var styleMap = style ? DOM$1.parseStyle(style) : {}; styleMap['max-width'] = addPx(data.width); styleMap['max-height'] = addPx(data.height); setAttributes(attrs, { style: DOM$1.serializeStyle(styleMap) }); }; var updateHtml = function (html, data, updateAll) { var writer = global$7(); var isEphoxEmbed = Cell(false); var sourceCount = 0; var hasImage; global$4({ validate: false, allow_conditional_comments: true, special: 'script,noscript', comment: function (text) { writer.comment(text); }, cdata: function (text) { writer.cdata(text); }, text: function (text, raw) { writer.text(text, raw); }, start: function (name, attrs, empty) { if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) { isEphoxEmbed.set(true); updateEphoxEmbed(data, attrs); } else { switch (name) { case 'video': case 'object': case 'embed': case 'img': case 'iframe': if (data.height !== undefined && data.width !== undefined) { setAttributes(attrs, { width: data.width, height: data.height }); } break; } if (updateAll) { switch (name) { case 'video': setAttributes(attrs, { poster: data.poster, src: '' }); if (data.source2) { setAttributes(attrs, { src: '' }); } break; case 'iframe': setAttributes(attrs, { src: data.source1 }); break; case 'source': sourceCount++; if (sourceCount <= 2) { setAttributes(attrs, { src: data['source' + sourceCount], type: data['source' + sourceCount + 'mime'] }); if (!data['source' + sourceCount]) { return; } } break; case 'img': if (!data.poster) { return; } hasImage = true; break; } } } writer.start(name, attrs, empty); }, end: function (name) { if (!isEphoxEmbed.get()) { if (name === 'video' && updateAll) { for (var index = 1; index <= 2; index++) { if (data['source' + index]) { var attrs = []; attrs.map = {}; if (sourceCount < index) { setAttributes(attrs, { src: data['source' + index], type: data['source' + index + 'mime'] }); writer.start('source', attrs, true); } } } } if (data.poster && name === 'object' && updateAll && !hasImage) { var imgAttrs = []; imgAttrs.map = {}; setAttributes(imgAttrs, { src: data.poster, width: data.width, height: data.height }); writer.start('img', imgAttrs, true); } } writer.end(name); } }, global$6({})).parse(html); return writer.getContent(); }; var UpdateHtml = { updateHtml: updateHtml }; var urlPatterns = [ { regex: /youtu\.be\/([\w\-_\?&=.]+)/i, type: 'iframe', w: 560, h: 314, url: '//www.youtube.com/embed/$1', allowFullscreen: true }, { regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i, type: 'iframe', w: 560, h: 314, url: '//www.youtube.com/embed/$2?$4', allowFullscreen: true }, { regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i, type: 'iframe', w: 560, h: 314, url: '//www.youtube.com/embed/$1', allowFullscreen: true }, { regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc', allowFullscreen: true }, { regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$2?title=0&byline=0', allowFullscreen: true }, { regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"', allowFullscreen: false }, { regex: /dailymotion\.com\/video\/([^_]+)/, type: 'iframe', w: 480, h: 270, url: '//www.dailymotion.com/embed/video/$1', allowFullscreen: true }, { regex: /dai\.ly\/([^_]+)/, type: 'iframe', w: 480, h: 270, url: '//www.dailymotion.com/embed/video/$1', allowFullscreen: true } ]; var getUrl = function (pattern, url) { var match = pattern.regex.exec(url); var newUrl = pattern.url; var _loop_1 = function (i) { newUrl = newUrl.replace('$' + i, function () { return match[i] ? match[i] : ''; }); }; for (var i = 0; i < match.length; i++) { _loop_1(i); } return newUrl.replace(/\?$/, ''); }; var matchPattern = function (url) { var pattern = urlPatterns.filter(function (pattern) { return pattern.regex.test(url); }); if (pattern.length > 0) { return global$2.extend({}, pattern[0], { url: getUrl(pattern[0], url) }); } else { return null; } }; var getIframeHtml = function (data) { var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : ''; return '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>'; }; var getFlashHtml = function (data) { var html = '<object data="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">'; if (data.poster) { html += '<img src="' + data.poster + '" width="' + data.width + '" height="' + data.height + '" />'; } html += '</object>'; return html; }; var getAudioHtml = function (data, audioTemplateCallback) { if (audioTemplateCallback) { return audioTemplateCallback(data); } else { return '<audio controls="controls" src="' + data.source1 + '">' + (data.source2 ? '\n<source src="' + data.source2 + '"' + (data.source2mime ? ' type="' + data.source2mime + '"' : '') + ' />\n' : '') + '</audio>'; } }; var getVideoHtml = function (data, videoTemplateCallback) { if (videoTemplateCallback) { return videoTemplateCallback(data); } else { return '<video width="' + data.width + '" height="' + data.height + '"' + (data.poster ? ' poster="' + data.poster + '"' : '') + ' controls="controls">\n' + '<source src="' + data.source1 + '"' + (data.source1mime ? ' type="' + data.source1mime + '"' : '') + ' />\n' + (data.source2 ? '<source src="' + data.source2 + '"' + (data.source2mime ? ' type="' + data.source2mime + '"' : '') + ' />\n' : '') + '</video>'; } }; var getScriptHtml = function (data) { return '<script src="' + data.source1 + '"></script>'; }; var dataToHtml = function (editor, dataIn) { var data = global$2.extend({}, dataIn); if (!data.source1) { global$2.extend(data, HtmlToData.htmlToData(Settings.getScripts(editor), data.embed)); if (!data.source1) { return ''; } } if (!data.source2) { data.source2 = ''; } if (!data.poster) { data.poster = ''; } data.source1 = editor.convertURL(data.source1, 'source'); data.source2 = editor.convertURL(data.source2, 'source'); data.source1mime = Mime.guess(data.source1); data.source2mime = Mime.guess(data.source2); data.poster = editor.convertURL(data.poster, 'poster'); var pattern = matchPattern(data.source1); if (pattern) { data.source1 = pattern.url; data.type = pattern.type; data.allowFullscreen = pattern.allowFullscreen; data.width = data.width || pattern.w; data.height = data.height || pattern.h; } if (data.embed) { return UpdateHtml.updateHtml(data.embed, data, true); } else { var videoScript = VideoScript.getVideoScriptMatch(Settings.getScripts(editor), data.source1); if (videoScript) { data.type = 'script'; data.width = videoScript.width; data.height = videoScript.height; } var audioTemplateCallback = Settings.getAudioTemplateCallback(editor); var videoTemplateCallback = Settings.getVideoTemplateCallback(editor); data.width = data.width || 300; data.height = data.height || 150; global$2.each(data, function (value, key) { data[key] = editor.dom.encode(value); }); if (data.type === 'iframe') { return getIframeHtml(data); } else if (data.source1mime === 'application/x-shockwave-flash') { return getFlashHtml(data); } else if (data.source1mime.indexOf('audio') !== -1) { return getAudioHtml(data, audioTemplateCallback); } else if (data.type === 'script') { return getScriptHtml(data); } else { return getVideoHtml(data, videoTemplateCallback); } } }; var DataToHtml = { dataToHtml: dataToHtml }; var cache = {}; var embedPromise = function (data, dataToHtml, handler) { return new global$5(function (res, rej) { var wrappedResolve = function (response) { if (response.html) { cache[data.source1] = response; } return res({ url: data.source1, html: response.html ? response.html : dataToHtml(data) }); }; if (cache[data.source1]) { wrappedResolve(cache[data.source1]); } else { handler({ url: data.source1 }, wrappedResolve, rej); } }); }; var defaultPromise = function (data, dataToHtml) { return new global$5(function (res) { res({ html: dataToHtml(data), url: data.source1 }); }); }; var loadedData = function (editor) { return function (data) { return DataToHtml.dataToHtml(editor, data); }; }; var getEmbedHtml = function (editor, data) { var embedHandler = Settings.getUrlResolver(editor); return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor)); }; var isCached = function (url) { return cache.hasOwnProperty(url); }; var Service = { getEmbedHtml: getEmbedHtml, isCached: isCached }; var trimPx$1 = function (value) { return value.replace(/px$/, ''); }; var addPx$1 = function (value) { return /^[0-9.]+$/.test(value) ? value + 'px' : value; }; var getSize = function (name) { return function (elm) { return elm ? trimPx$1(elm.style[name]) : ''; }; }; var setSize = function (name) { return function (elm, value) { if (elm) { elm.style[name] = addPx$1(value); } }; }; var Size = { getMaxWidth: getSize('maxWidth'), getMaxHeight: getSize('maxHeight'), setMaxWidth: setSize('maxWidth'), setMaxHeight: setSize('maxHeight') }; var doSyncSize = function (widthCtrl, heightCtrl) { widthCtrl.state.set('oldVal', widthCtrl.value()); heightCtrl.state.set('oldVal', heightCtrl.value()); }; var doSizeControls = function (win, f) { var widthCtrl = win.find('#width')[0]; var heightCtrl = win.find('#height')[0]; var constrained = win.find('#constrain')[0]; if (widthCtrl && heightCtrl && constrained) { f(widthCtrl, heightCtrl, constrained.checked()); } }; var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { var oldWidth = widthCtrl.state.get('oldVal'); var oldHeight = heightCtrl.state.get('oldVal'); var newWidth = widthCtrl.value(); var newHeight = heightCtrl.value(); if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { if (newWidth !== oldWidth) { newHeight = Math.round(newWidth / oldWidth * newHeight); if (!isNaN(newHeight)) { heightCtrl.value(newHeight); } } else { newWidth = Math.round(newHeight / oldHeight * newWidth); if (!isNaN(newWidth)) { widthCtrl.value(newWidth); } } } doSyncSize(widthCtrl, heightCtrl); }; var syncSize = function (win) { doSizeControls(win, doSyncSize); }; var updateSize = function (win) { doSizeControls(win, doUpdateSize); }; var createUi = function (onChange) { var recalcSize = function () { onChange(function (win) { updateSize(win); }); }; return { type: 'container', label: 'Dimensions', layout: 'flex', align: 'center', spacing: 5, items: [ { name: 'width', type: 'textbox', maxLength: 5, size: 5, onchange: recalcSize, ariaLabel: 'Width' }, { type: 'label', text: 'x' }, { name: 'height', type: 'textbox', maxLength: 5, size: 5, onchange: recalcSize, ariaLabel: 'Height' }, { name: 'constrain', type: 'checkbox', checked: true, text: 'Constrain proportions' } ] }; }; var SizeManager = { createUi: createUi, syncSize: syncSize, updateSize: updateSize }; var embedChange = global$1.ie && global$1.ie <= 8 ? 'onChange' : 'onInput'; var handleError = function (editor) { return function (error) { var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.'; editor.notificationManager.open({ type: 'error', text: errorMessage }); }; }; var getData = function (editor) { var element = editor.selection.getNode(); var dataEmbed = element.getAttribute('data-ephox-embed-iri'); if (dataEmbed) { return { 'source1': dataEmbed, 'data-ephox-embed-iri': dataEmbed, 'width': Size.getMaxWidth(element), 'height': Size.getMaxHeight(element) }; } return element.getAttribute('data-mce-object') ? HtmlToData.htmlToData(Settings.getScripts(editor), editor.serializer.serialize(element, { selection: true })) : {}; }; var getSource = function (editor) { var elm = editor.selection.getNode(); if (elm.getAttribute('data-mce-object') || elm.getAttribute('data-ephox-embed-iri')) { return editor.selection.getContent(); } }; var addEmbedHtml = function (win, editor) { return function (response) { var html = response.html; var embed = win.find('#embed')[0]; var data = global$2.extend(HtmlToData.htmlToData(Settings.getScripts(editor), html), { source1: response.url }); win.fromJSON(data); if (embed) { embed.value(html); SizeManager.updateSize(win); } }; }; var selectPlaceholder = function (editor, beforeObjects) { var i; var y; var afterObjects = editor.dom.select('img[data-mce-object]'); for (i = 0; i < beforeObjects.length; i++) { for (y = afterObjects.length - 1; y >= 0; y--) { if (beforeObjects[i] === afterObjects[y]) { afterObjects.splice(y, 1); } } } editor.selection.select(afterObjects[0]); }; var handleInsert = function (editor, html) { var beforeObjects = editor.dom.select('img[data-mce-object]'); editor.insertContent(html); selectPlaceholder(editor, beforeObjects); editor.nodeChanged(); }; var submitForm = function (win, editor) { var data = win.toJSON(); data.embed = UpdateHtml.updateHtml(data.embed, data); if (data.embed && Service.isCached(data.source1)) { handleInsert(editor, data.embed); } else { Service.getEmbedHtml(editor, data).then(function (response) { handleInsert(editor, response.html); }).catch(handleError(editor)); } }; var populateMeta = function (win, meta) { global$2.each(meta, function (value, key) { win.find('#' + key).value(value); }); }; var showDialog = function (editor) { var win; var data; var generalFormItems = [{ name: 'source1', type: 'filepicker', filetype: 'media', size: 40, autofocus: true, label: 'Source', onpaste: function () { setTimeout(function () { Service.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); }, 1); }, onchange: function (e) { Service.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); populateMeta(win, e.meta); }, onbeforecall: function (e) { e.meta = win.toJSON(); } }]; var advancedFormItems = []; var reserialise = function (update) { update(win); data = win.toJSON(); win.find('#embed').value(UpdateHtml.updateHtml(data.embed, data)); }; if (Settings.hasAltSource(editor)) { advancedFormItems.push({ name: 'source2', type: 'filepicker', filetype: 'media', size: 40, label: 'Alternative source' }); } if (Settings.hasPoster(editor)) { advancedFormItems.push({ name: 'poster', type: 'filepicker', filetype: 'image', size: 40, label: 'Poster' }); } if (Settings.hasDimensions(editor)) { var control = SizeManager.createUi(reserialise); generalFormItems.push(control); } data = getData(editor); var embedTextBox = { id: 'mcemediasource', type: 'textbox', flex: 1, name: 'embed', value: getSource(editor), multiline: true, rows: 5, label: 'Source' }; var updateValueOnChange = function () { data = global$2.extend({}, HtmlToData.htmlToData(Settings.getScripts(editor), this.value())); this.parent().parent().fromJSON(data); }; embedTextBox[embedChange] = updateValueOnChange; var body = [ { title: 'General', type: 'form', items: generalFormItems }, { title: 'Embed', type: 'container', layout: 'flex', direction: 'column', align: 'stretch', padding: 10, spacing: 10, items: [ { type: 'label', text: 'Paste your embed code below:', forId: 'mcemediasource' }, embedTextBox ] } ]; if (advancedFormItems.length > 0) { body.push({ title: 'Advanced', type: 'form', items: advancedFormItems }); } win = editor.windowManager.open({ title: 'Insert/edit media', data: data, bodyType: 'tabpanel', body: body, onSubmit: function () { SizeManager.updateSize(win); submitForm(win, editor); } }); SizeManager.syncSize(win); }; var Dialog = { showDialog: showDialog }; var get$1 = function (editor) { var showDialog = function () { Dialog.showDialog(editor); }; return { showDialog: showDialog }; }; var Api = { get: get$1 }; var register = function (editor) { var showDialog = function () { Dialog.showDialog(editor); }; editor.addCommand('mceMedia', showDialog); }; var Commands = { register: register }; var global$8 = tinymce.util.Tools.resolve('tinymce.html.Node'); var sanitize = function (editor, html) { if (Settings.shouldFilterHtml(editor) === false) { return html; } var writer = global$7(); var blocked; global$4({ validate: false, allow_conditional_comments: false, special: 'script,noscript', comment: function (text) { writer.comment(text); }, cdata: function (text) { writer.cdata(text); }, text: function (text, raw) { writer.text(text, raw); }, start: function (name, attrs, empty) { blocked = true; if (name === 'script' || name === 'noscript' || name === 'svg') { return; } for (var i = attrs.length - 1; i >= 0; i--) { var attrName = attrs[i].name; if (attrName.indexOf('on') === 0) { delete attrs.map[attrName]; attrs.splice(i, 1); } if (attrName === 'style') { attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name); } } writer.start(name, attrs, empty); blocked = false; }, end: function (name) { if (blocked) { return; } writer.end(name); } }, global$6({})).parse(html); return writer.getContent(); }; var Sanitize = { sanitize: sanitize }; var createPlaceholderNode = function (editor, node) { var placeHolder; var name = node.name; placeHolder = new global$8('img', 1); placeHolder.shortEnded = true; retainAttributesAndInnerHtml(editor, node, placeHolder); placeHolder.attr({ 'width': node.attr('width') || '300', 'height': node.attr('height') || (name === 'audio' ? '30' : '150'), 'style': node.attr('style'), 'src': global$1.transparentSrc, 'data-mce-object': name, 'class': 'mce-object mce-object-' + name }); return placeHolder; }; var createPreviewIframeNode = function (editor, node) { var previewWrapper; var previewNode; var shimNode; var name = node.name; previewWrapper = new global$8('span', 1); previewWrapper.attr({ 'contentEditable': 'false', 'style': node.attr('style'), 'data-mce-object': name, 'class': 'mce-preview-object mce-object-' + name }); retainAttributesAndInnerHtml(editor, node, previewWrapper); previewNode = new global$8(name, 1); previewNode.attr({ src: node.attr('src'), allowfullscreen: node.attr('allowfullscreen'), style: node.attr('style'), class: node.attr('class'), width: node.attr('width'), height: node.attr('height'), frameborder: '0' }); shimNode = new global$8('span', 1); shimNode.attr('class', 'mce-shim'); previewWrapper.append(previewNode); previewWrapper.append(shimNode); return previewWrapper; }; var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) { var attrName; var attrValue; var attribs; var ai; var innerHtml; attribs = sourceNode.attributes; ai = attribs.length; while (ai--) { attrName = attribs[ai].name; attrValue = attribs[ai].value; if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') { if (attrName === 'data' || attrName === 'src') { attrValue = editor.convertURL(attrValue, attrName); } targetNode.attr('data-mce-p-' + attrName, attrValue); } } innerHtml = sourceNode.firstChild && sourceNode.firstChild.value; if (innerHtml) { targetNode.attr('data-mce-html', escape(Sanitize.sanitize(editor, innerHtml))); targetNode.firstChild = null; } }; var isWithinEphoxEmbed = function (node) { while (node = node.parent) { if (node.attr('data-ephox-embed-iri')) { return true; } } return false; }; var placeHolderConverter = function (editor) { return function (nodes) { var i = nodes.length; var node; var videoScript; while (i--) { node = nodes[i]; if (!node.parent) { continue; } if (node.parent.attr('data-mce-object')) { continue; } if (node.name === 'script') { videoScript = VideoScript.getVideoScriptMatch(Settings.getScripts(editor), node.attr('src')); if (!videoScript) { continue; } } if (videoScript) { if (videoScript.width) { node.attr('width', videoScript.width.toString()); } if (videoScript.height) { node.attr('height', videoScript.height.toString()); } } if (node.name === 'iframe' && Settings.hasLiveEmbeds(editor) && global$1.ceFalse) { if (!isWithinEphoxEmbed(node)) { node.replace(createPreviewIframeNode(editor, node)); } } else { if (!isWithinEphoxEmbed(node)) { node.replace(createPlaceholderNode(editor, node)); } } } }; }; var Nodes = { createPreviewIframeNode: createPreviewIframeNode, createPlaceholderNode: createPlaceholderNode, placeHolderConverter: placeHolderConverter }; var setup = function (editor) { editor.on('preInit', function () { var specialElements = editor.schema.getSpecialElements(); global$2.each('video audio iframe object'.split(' '), function (name) { specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi'); }); var boolAttrs = editor.schema.getBoolAttrs(); global$2.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) { boolAttrs[name] = {}; }); editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', Nodes.placeHolderConverter(editor)); editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) { var i = nodes.length; var node; var realElm; var ai; var attribs; var innerHtml; var innerNode; var realElmName; var className; while (i--) { node = nodes[i]; if (!node.parent) { continue; } realElmName = node.attr(name); realElm = new global$8(realElmName, 1); if (realElmName !== 'audio' && realElmName !== 'script') { className = node.attr('class'); if (className && className.indexOf('mce-preview-object') !== -1) { realElm.attr({ width: node.firstChild.attr('width'), height: node.firstChild.attr('height') }); } else { realElm.attr({ width: node.attr('width'), height: node.attr('height') }); } } realElm.attr({ style: node.attr('style') }); attribs = node.attributes; ai = attribs.length; while (ai--) { var attrName = attribs[ai].name; if (attrName.indexOf('data-mce-p-') === 0) { realElm.attr(attrName.substr(11), attribs[ai].value); } } if (realElmName === 'script') { realElm.attr('type', 'text/javascript'); } innerHtml = node.attr('data-mce-html'); if (innerHtml) { innerNode = new global$8('#text', 3); innerNode.raw = true; innerNode.value = Sanitize.sanitize(editor, unescape(innerHtml)); realElm.append(innerNode); } node.replace(realElm); } }); }); editor.on('setContent', function () { editor.$('span.mce-preview-object').each(function (index, elm) { var $elm = editor.$(elm); if ($elm.find('span.mce-shim', elm).length === 0) { $elm.append('<span class="mce-shim"></span>'); } }); }); }; var FilterContent = { setup: setup }; var setup$1 = function (editor) { editor.on('ResolveName', function (e) { var name; if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { e.name = name; } }); }; var ResolveName = { setup: setup$1 }; var setup$2 = function (editor) { editor.on('click keyup', function () { var selectedNode = editor.selection.getNode(); if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { selectedNode.setAttribute('data-mce-selected', '2'); } } }); editor.on('ObjectSelected', function (e) { var objectType = e.target.getAttribute('data-mce-object'); if (objectType === 'audio' || objectType === 'script') { e.preventDefault(); } }); editor.on('objectResized', function (e) { var target = e.target; var html; if (target.getAttribute('data-mce-object')) { html = target.getAttribute('data-mce-html'); if (html) { html = unescape(html); target.setAttribute('data-mce-html', escape(UpdateHtml.updateHtml(html, { width: e.width, height: e.height }))); } } }); }; var Selection = { setup: setup$2 }; var register$1 = function (editor) { editor.addButton('media', { tooltip: 'Insert/edit media', cmd: 'mceMedia', stateSelector: [ 'img[data-mce-object]', 'span[data-mce-object]', 'div[data-ephox-embed-iri]' ] }); editor.addMenuItem('media', { icon: 'media', text: 'Media', cmd: 'mceMedia', context: 'insert', prependToContext: true }); }; var Buttons = { register: register$1 }; global.add('media', function (editor) { Commands.register(editor); Buttons.register(editor); ResolveName.setup(editor); FilterContent.setup(editor); Selection.setup(editor); return Api.get(editor); }); function Plugin () { } return Plugin; }()); })();