git-svn-id: https://develop.svn.wordpress.org/trunk@29458 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-08-09 20:55:34 +00:00
parent e23c1ae3ff
commit f8fed596ec
20 changed files with 459 additions and 240 deletions

View File

@ -22,7 +22,8 @@
(function(tinymce) {
var reported;
function noop() {}
function noop() {
}
function log(apiCall) {
if (!reported && window && window.console) {
@ -170,7 +171,9 @@
onAdd: new Dispatcher(),
onPostRender: new Dispatcher(),
add: function(obj) { return obj; },
add: function(obj) {
return obj;
},
createButton: cmNoop,
createColorSplitButton: cmNoop,
createControl: cmNoop,

View File

@ -17,6 +17,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
{regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1'},
{regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2'},
{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'},
{regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0"},
{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"'}
];

File diff suppressed because one or more lines are too long

View File

@ -250,7 +250,7 @@ define("tinymce/pasteplugin/Clipboard", [
"tinymce/pasteplugin/Utils"
], function(Env, VK, Utils) {
return function(editor) {
var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0;
var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0, draggingInternally = false;
var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
/**
@ -455,16 +455,20 @@ define("tinymce/pasteplugin/Clipboard", [
function getDataTransferItems(dataTransfer) {
var data = {};
if (dataTransfer && dataTransfer.types) {
// Use old WebKit API
var legacyText = dataTransfer.getData('Text');
if (legacyText && legacyText.length > 0) {
data['text/plain'] = legacyText;
if (dataTransfer) {
// Use old WebKit/IE API
if (dataTransfer.getData) {
var legacyText = dataTransfer.getData('Text');
if (legacyText && legacyText.length > 0) {
data['text/plain'] = legacyText;
}
}
for (var i = 0; i < dataTransfer.types.length; i++) {
var contentType = dataTransfer.types[i];
data[contentType] = dataTransfer.getData(contentType);
if (dataTransfer.types) {
for (var i = 0; i < dataTransfer.types.length; i++) {
var contentType = dataTransfer.types[i];
data[contentType] = dataTransfer.getData(contentType);
}
}
}
@ -675,6 +679,11 @@ define("tinymce/pasteplugin/Clipboard", [
removePasteBin();
// If we got nothing from clipboard API and pastebin then we could try the last resort: plain/text
if (!content.length) {
plainTextMode = true;
}
// Grab plain text from Clipboard API or convert existing HTML to plain text
if (plainTextMode) {
// Use plain text contents from Clipboard API unless the HTML contains paragraphs then
@ -704,20 +713,14 @@ define("tinymce/pasteplugin/Clipboard", [
}, 0);
});
editor.on('dragstart', function(e) {
if (e.dataTransfer.types) {
try {
e.dataTransfer.setData('mce-internal', editor.selection.getContent());
} catch (ex) {
// IE 10 throws an error since it doesn't support custom data items
}
}
editor.on('dragstart dragend', function(e) {
draggingInternally = e.type == 'dragstart';
});
editor.on('drop', function(e) {
var rng = getCaretRangeFromEvent(e);
if (e.isDefaultPrevented()) {
if (e.isDefaultPrevented() || draggingInternally) {
return;
}
@ -725,7 +728,7 @@ define("tinymce/pasteplugin/Clipboard", [
return;
}
if (rng) {
if (rng && editor.settings.paste_filter_drop !== false) {
var dropContent = getDataTransferItems(e.dataTransfer);
var content = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
@ -739,6 +742,8 @@ define("tinymce/pasteplugin/Clipboard", [
editor.selection.setRng(rng);
content = Utils.trimHtml(content);
if (!dropContent['text/html']) {
pasteText(content);
} else {
@ -830,6 +835,38 @@ define("tinymce/pasteplugin/WordFilter", [
);
}
/**
* Checks if the specified text starts with "1. " or "a. " etc.
*/
function isNumericList(text) {
var found, patterns;
patterns = [
/^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
/^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
/^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
/^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
/^[0-9]+\.[ \u00a0]/, // Numeric lists
/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/, // Japanese
/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/ // Chinese
];
text = text.replace(/^[\u00a0 ]+/, '');
Tools.each(patterns, function(pattern) {
if (pattern.test(text)) {
found = true;
return false;
}
});
return found;
}
function isBulletList(text) {
return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*/.test(text);
}
function WordFilter(editor) {
var settings = editor.settings;
@ -951,16 +988,15 @@ define("tinymce/pasteplugin/WordFilter", [
if (node.name == 'p' && node.firstChild) {
// Find first text node in paragraph
var nodeText = getText(node);
var listStartTextNode = node.firstChild;
// Detect unordered lists look for bullets
if (/^[\s\u00a0]*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*/.test(nodeText)) {
if (isBulletList(nodeText)) {
convertParagraphToLi(node, 'ul');
continue;
}
// Detect ordered lists 1., a. or ixv.
if (/^[\s\u00a0]*\w+\./.test(nodeText) && !/^[\s\u00a0]*\w+\.\s*[^\s]+/.test(listStartTextNode.value)) {
if (isNumericList(nodeText)) {
// Parse OL start number
var matches = /([0-9])\./.exec(nodeText);
var start = 1;

File diff suppressed because one or more lines are too long

View File

@ -33,11 +33,16 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
return;
}
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;
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight,
marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
if ( ! isActive ) {
return;
@ -65,7 +70,13 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
// 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 );
myHeight = body.offsetHeight + parseInt( marginTop, 10 ) + parseInt( marginBottom, 10 );
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 ) {
@ -97,7 +108,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
// Resize content element
if (resizeHeight !== oldSize) {
deltaSize = resizeHeight - oldSize;
DOM.setStyle( DOM.get( editor.id + '_ifr'), 'height', resizeHeight + 'px' );
DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' );
oldSize = resizeHeight;
// WebKit doesn't decrease the size of the body element until the iframe gets resized

View File

@ -1,4 +1,4 @@
// 4.1.2 (2014-07-15)
// 4.1.3 (2014-07-29)
/**
* Compiled inline version. (Library mode)
@ -428,6 +428,7 @@ define("tinymce/dom/EventUtils", [], function() {
events[id][name] = callbackList = [{func: callback, scope: scope}];
callbackList.fakeName = fakeName;
callbackList.capture = capture;
//callbackList.callback = callback;
// Add the nativeHandler to the callback list so that we can later unbind it
callbackList.nativeHandler = nativeHandler;
@ -4793,7 +4794,7 @@ define("tinymce/dom/DomQuery", [
DomQuery.overrideDefaults = function(callback) {
var defaults;
function jQuerySub(selector, context) {
function sub(selector, context) {
defaults = defaults || callback();
if (arguments.length === 0) {
@ -4804,12 +4805,12 @@ define("tinymce/dom/DomQuery", [
context = defaults.context;
}
return new jQuerySub.fn.init(selector, context);
return new sub.fn.init(selector, context);
}
DomQuery.extend(jQuerySub, this);
DomQuery.extend(sub, this);
return jQuerySub;
return sub;
};
function appendHooks(targetHooks, prop, hooks) {
@ -4868,6 +4869,8 @@ define("tinymce/dom/DomQuery", [
}
if (Env.ie && Env.ie < 9) {
/*jshint sub:true */
/*eslint dot-notation: 0*/
cssFix['float'] = 'styleFloat';
appendHooks(cssHooks, 'set', {
@ -7319,6 +7322,10 @@ define("tinymce/dom/DOMUtils", [
elm = self.$$(elm);
originalValue = elm.attr(name);
if (!elm.length) {
return;
}
hook = self.attrHooks[name];
if (hook && hook.set) {
hook.set(elm, value, name);
@ -7372,11 +7379,14 @@ define("tinymce/dom/DOMUtils", [
elm = self.$$(elm);
hook = self.attrHooks[name];
if (hook && hook.get) {
value = hook.get(elm, name);
} else {
value = elm.attr(name);
if (elm.length) {
hook = self.attrHooks[name];
if (hook && hook.get) {
value = hook.get(elm, name);
} else {
value = elm.attr(name);
}
}
if (typeof value == 'undefined') {
@ -7395,21 +7405,22 @@ define("tinymce/dom/DOMUtils", [
* @return {object} Absolute position of the specified element object with x, y fields.
*/
getPos: function(elm, rootElm) {
var self = this, x = 0, y = 0, offsetParent, doc = self.doc, pos;
var self = this, x = 0, y = 0, offsetParent, doc = self.doc, body = doc.body, pos;
elm = self.get(elm);
rootElm = rootElm || doc.body;
rootElm = rootElm || body;
if (elm) {
// Use getBoundingClientRect if it exists since it's faster than looping offset nodes
if (rootElm === doc.body && elm.getBoundingClientRect) {
// Fallback to offsetParent calculations if the body isn't static better since it stops at the body root
if (rootElm === body && elm.getBoundingClientRect && $(body).css('position') === 'static') {
pos = elm.getBoundingClientRect();
rootElm = self.boxModel ? doc.documentElement : doc.body;
rootElm = self.boxModel ? doc.documentElement : body;
// Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit
// Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position
x = pos.left + (doc.documentElement.scrollLeft || doc.body.scrollLeft) - rootElm.clientLeft;
y = pos.top + (doc.documentElement.scrollTop || doc.body.scrollTop) - rootElm.clientTop;
x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - rootElm.clientLeft;
y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - rootElm.clientTop;
return {x: x, y: y};
}
@ -9480,7 +9491,7 @@ define("tinymce/NodeChange", [
// Gecko doesn't support the "selectionchange" event
if (!('onselectionchange' in editor.getDoc())) {
editor.on('NodeChange Click MouseUp KeyUp', function(e) {
editor.on('NodeChange Click MouseUp KeyUp Focus', function(e) {
var nativeRng, fakeRng;
// Since DOM Ranges mutate on modification
@ -9510,7 +9521,7 @@ define("tinymce/NodeChange", [
});
editor.on('SelectionChange', function() {
var startElm = editor.selection.getStart();
var startElm = editor.selection.getStart(true);
// Selection change might fire when focus is lost so check if the start is still within the body
if (!isSameElementPath(startElm) && editor.dom.isChildOf(startElm, editor.getBody())) {
@ -10095,7 +10106,7 @@ define("tinymce/html/Node", [], function() {
define("tinymce/html/Schema", [
"tinymce/util/Tools"
], function(Tools) {
var mapCache = {};
var mapCache = {}, dummyObj = {};
var makeMap = Tools.makeMap, each = Tools.each, extend = Tools.extend, explode = Tools.explode, inArray = Tools.inArray;
function split(items, delim) {
@ -10116,11 +10127,11 @@ define("tinymce/html/Schema", [
function add(name, attributes, children) {
var ni, i, attributesOrder, args = arguments;
function arrayToMap(array) {
function arrayToMap(array, obj) {
var map = {}, i, l;
for (i = 0, l = array.length; i < l; i++) {
map[array[i]] = {};
map[array[i]] = obj || {};
}
return map;
@ -10149,7 +10160,7 @@ define("tinymce/html/Schema", [
schema[name[ni]] = {
attributes: arrayToMap(attributesOrder),
attributesOrder: attributesOrder,
children: arrayToMap(children)
children: arrayToMap(children, dummyObj)
};
}
}
@ -13872,6 +13883,7 @@ define("tinymce/dom/ControlSelection", [
}
editor.fire('ObjectResized', {target: selectedElm, width: width, height: height});
dom.setAttrib(selectedElm, 'style', dom.getAttrib(selectedElm, 'style'));
editor.nodeChanged();
}
@ -14019,7 +14031,7 @@ define("tinymce/dom/ControlSelection", [
}
function updateResizeRect(e) {
var controlElm;
var startElm, controlElm;
function isChildOrEqual(node, parent) {
if (node) {
@ -14041,9 +14053,10 @@ define("tinymce/dom/ControlSelection", [
if (isChildOrEqual(controlElm, rootElement)) {
disableGeckoResize();
startElm = selection.getStart(true);
if (isChildOrEqual(selection.getStart(), controlElm) && isChildOrEqual(selection.getEnd(), controlElm)) {
if (!isIE || (controlElm != selection.getStart() && selection.getStart().nodeName !== 'IMG')) {
if (isChildOrEqual(startElm, controlElm) && isChildOrEqual(selection.getEnd(true), controlElm)) {
if (!isIE || (controlElm != startElm && startElm.nodeName !== 'IMG')) {
showResizeRect(controlElm);
return;
}
@ -14203,7 +14216,7 @@ define("tinymce/dom/ControlSelection", [
}
}
editor.on('nodechange mousedown mouseup ResizeEditor', updateResizeRect);
editor.on('nodechange ResizeEditor', updateResizeRect);
// Update resize rect while typing in a table
editor.on('keydown keyup', function(e) {
@ -14875,9 +14888,10 @@ define("tinymce/dom/Selection", [
* node the parent element will be returned.
*
* @method getStart
* @param {Boolean} real Optional state to get the real parent when the selection is collapsed not the closest element.
* @return {Element} Start element of selection range.
*/
getStart: function() {
getStart: function(real) {
var self = this, rng = self.getRng(), startElement, parentElement, checkRng, node;
if (rng.duplicate || rng.item) {
@ -14909,7 +14923,9 @@ define("tinymce/dom/Selection", [
startElement = rng.startContainer;
if (startElement.nodeType == 1 && startElement.hasChildNodes()) {
startElement = startElement.childNodes[Math.min(startElement.childNodes.length - 1, rng.startOffset)];
if (!real || !rng.collapsed) {
startElement = startElement.childNodes[Math.min(startElement.childNodes.length - 1, rng.startOffset)];
}
}
if (startElement && startElement.nodeType == 3) {
@ -14925,9 +14941,10 @@ define("tinymce/dom/Selection", [
* node the parent element will be returned.
*
* @method getEnd
* @param {Boolean} real Optional state to get the real parent when the selection is collapsed not the closest element.
* @return {Element} End element of selection range.
*/
getEnd: function() {
getEnd: function(real) {
var self = this, rng = self.getRng(), endElement, endOffset;
if (rng.duplicate || rng.item) {
@ -14952,7 +14969,9 @@ define("tinymce/dom/Selection", [
endOffset = rng.endOffset;
if (endElement.nodeType == 1 && endElement.hasChildNodes()) {
endElement = endElement.childNodes[endOffset > 0 ? endOffset - 1 : endOffset];
if (!real || !rng.collapsed) {
endElement = endElement.childNodes[endOffset > 0 ? endOffset - 1 : endOffset];
}
}
if (endElement && endElement.nodeType == 3) {
@ -15544,8 +15563,8 @@ define("tinymce/dom/Selection", [
return;
}
// BR/IMG/INPUT elements
if (nonEmptyElementsMap[node.nodeName]) {
// BR/IMG/INPUT elements but not table cells
if (nonEmptyElementsMap[node.nodeName] && !/^(TD|TH)$/.test(node.nodeName)) {
if (start) {
rng.setStartBefore(node);
} else {
@ -16001,8 +16020,8 @@ define("tinymce/Formatter", [
{inline: 'strike', remove: 'all'}
],
forecolor: {inline: 'span', styles: {color: '%value'}, wrap_links: false, remove_similar: true},
hilitecolor: {inline: 'span', styles: {backgroundColor: '%value'}, wrap_links: false, remove_similar: true},
forecolor: {inline: 'span', styles: {color: '%value'}, links: true, remove_similar: true},
hilitecolor: {inline: 'span', styles: {backgroundColor: '%value'}, links: true, remove_similar: true},
fontname: {inline: 'span', styles: {fontFamily: '%value'}},
fontsize: {inline: 'span', styles: {fontSize: '%value'}},
fontsize_class: {inline: 'span', attributes: {'class': '%value'}},
@ -16338,22 +16357,12 @@ define("tinymce/Formatter", [
each(nodes, process);
});
// Wrap links inside as well, for example color inside a link when the wrapper is around the link
if (format.wrap_links === false) {
// Apply formats to links as well to get the color of the underline to change as well
if (format.links === true) {
each(newWrappers, function(node) {
function process(node) {
var i, currentWrapElm, children;
if (node.nodeName === 'A') {
currentWrapElm = dom.clone(wrapElm, FALSE);
newWrappers.push(currentWrapElm);
children = grep(node.childNodes);
for (i = 0; i < children.length; i++) {
currentWrapElm.appendChild(children[i]);
}
node.appendChild(currentWrapElm);
setElementFormat(node, format);
}
each(grep(node.childNodes), process);
@ -16423,24 +16432,10 @@ define("tinymce/Formatter", [
// this: <span style="color:red"><b><span style="color:red; font-size:10px">text</span></b></span>
// will become: <span style="color:red"><b><span style="font-size:10px">text</span></b></span>
each(dom.select(format.inline, node), function(child) {
var parent;
if (isBookmarkNode(child)) {
return;
}
// When wrap_links is set to false we don't want
// to remove the format on children within links
if (format.wrap_links === false) {
parent = child.parentNode;
do {
if (parent.nodeName === 'A') {
return;
}
} while ((parent = parent.parentNode));
}
removeFormat(format, vars, child, format.exact ? child : null);
});
});
@ -16982,7 +16977,7 @@ define("tinymce/Formatter", [
// Ignore bogus nodes like the <a> tag created by moveStart()
parents = Tools.grep(parents, function(node) {
return !node.getAttribute('data-mce-bogus');
return node.nodeType == 1 && !node.getAttribute('data-mce-bogus');
});
// Check for new formats
@ -17062,8 +17057,8 @@ define("tinymce/Formatter", [
// Initialize
defaultFormats();
addKeyboardShortcuts();
ed.on('BeforeGetContent', function() {
if (markCaretContainersBogus) {
ed.on('BeforeGetContent', function(e) {
if (markCaretContainersBogus && e.format != 'raw') {
markCaretContainersBogus();
}
});
@ -17553,6 +17548,10 @@ define("tinymce/Formatter", [
};
}
function isColorFormatAndAnchor(node, format) {
return format.links && node.tagName == 'A';
}
/**
* Removes the specified format for the specified node. It will also remove the node if it doesn't have
* any attributes if the format specifies it to do so.
@ -17568,7 +17567,7 @@ define("tinymce/Formatter", [
var i, attrs, stylesModified;
// Check if node matches format
if (!matchName(node, format)) {
if (!matchName(node, format) && !isColorFormatAndAnchor(node, format)) {
return FALSE;
}
@ -20781,7 +20780,7 @@ define("tinymce/util/EventDispatcher", [
"focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange " +
"mouseout mouseenter mouseleave wheel keydown keypress keyup input contextmenu dragstart dragend dragover " +
"draggesture dragdrop drop drag submit " +
"compositionstart compositionend compositionupdate",
"compositionstart compositionend compositionupdate touchstart touchend",
' '
);
@ -21975,7 +21974,6 @@ define("tinymce/ui/Control", [
], function(Class, Tools, EventDispatcher, Collection, DomUtils) {
"use strict";
var elementIdCache = {};
var hasMouseWheelEventSupport = "onmousewheel" in document;
var hasWheelEventSupport = false;
var classPrefix = "mce-";
@ -22005,7 +22003,6 @@ define("tinymce/ui/Control", [
var Control = Class.extend({
Statics: {
elementIdCache: elementIdCache,
classPrefix: classPrefix
},
@ -22048,6 +22045,7 @@ define("tinymce/ui/Control", [
self._text = self._name = '';
self._width = self._height = 0;
self._aria = {role: settings.role};
this._elmCache = {};
// Setup classes
classes = settings.classes;
@ -22789,15 +22787,16 @@ define("tinymce/ui/Control", [
*
* @method getEl
* @param {String} [suffix] Suffix to get element by.
* @param {Boolean} [dropCache] True if the cache for the element should be dropped.
* @return {Element} HTML DOM element for the current control or it's children.
*/
getEl: function(suffix, dropCache) {
var elm, id = suffix ? this._id + '-' + suffix : this._id;
getEl: function(suffix) {
var id = suffix ? this._id + '-' + suffix : this._id;
elm = elementIdCache[id] = (dropCache === true ? null : elementIdCache[id]) || DomUtils.get(id);
if (!this._elmCache[id]) {
this._elmCache[id] = DomUtils.get(id);
}
return elm;
return this._elmCache[id];
},
/**
@ -23008,16 +23007,7 @@ define("tinymce/ui/Control", [
delete lookup[self._id];
}
delete elementIdCache[self._id];
if (elm && elm.parentNode) {
var nodes = elm.getElementsByTagName('*');
i = nodes.length;
while (i--) {
delete elementIdCache[nodes[i].id];
}
elm.parentNode.removeChild(elm);
}
@ -25170,8 +25160,15 @@ define("tinymce/ui/FloatPanel", [
function bindWindowResizeHandler() {
if (!windowResizeHandler) {
var docElm = document.documentElement, clientWidth = docElm.clientWidth, clientHeight = docElm.clientHeight;
windowResizeHandler = function() {
FloatPanel.hideAll();
// Workaround for #7065 IE 7 fires resize events event though the window wasn't resized
if (!document.all || clientWidth != docElm.clientWidth || clientHeight != docElm.clientHeight) {
clientWidth = docElm.clientWidth;
clientHeight = docElm.clientHeight;
FloatPanel.hideAll();
}
};
DomUtils.on(window, 'resize', windowResizeHandler);
@ -26117,6 +26114,14 @@ define("tinymce/WindowManager", [
self.windows = windows;
editor.on('remove', function() {
var i = windows.length;
while (i--) {
windows[i].close();
}
});
/**
* Opens a new window.
*
@ -26443,7 +26448,7 @@ define("tinymce/util/Quirks", [
// Make sure all elements has a data-mce-style attribute
if (!elm.hasAttribute('data-mce-style') && elm.hasAttribute('style')) {
editor.dom.setAttrib(elm, 'style', elm.getAttribute('style'));
editor.dom.setAttrib(elm, 'style', editor.dom.getAttrib(elm, 'style'));
}
});
@ -26865,35 +26870,6 @@ define("tinymce/util/Quirks", [
});
}
/**
* Fire a nodeChanged when the selection is changed on WebKit this fixes selection issues on iOS5. It only fires the nodeChange
* event every 50ms since it would other wise update the UI when you type and it hogs the CPU.
*/
function selectionChangeNodeChanged() {
var lastRng, selectionTimer;
editor.on('selectionchange', function() {
if (selectionTimer) {
clearTimeout(selectionTimer);
selectionTimer = 0;
}
selectionTimer = window.setTimeout(function() {
if (editor.removed) {
return;
}
var rng = selection.getRng();
// Compare the ranges to see if it was a real change or not
if (!lastRng || !RangeUtils.compareRanges(rng, lastRng)) {
editor.nodeChanged();
lastRng = rng;
}
}, 50);
});
}
/**
* Screen readers on IE needs to have the role application set on the body.
*/
@ -27420,6 +27396,53 @@ define("tinymce/util/Quirks", [
editor.contentStyles.push('.mce-content-body {-webkit-touch-callout: none}');
}
/**
* iOS Safari and possible other browsers have a bug where it won't fire
* a click event when a contentEditable is focused. This function fakes click events
* by using touchstart/touchend and measuring the time and distance travelled.
*/
function touchClickEvent() {
editor.on('touchstart', function(e) {
var elm, time, startTouch, changedTouches;
elm = e.target;
time = new Date().getTime();
changedTouches = e.changedTouches;
if (!changedTouches || changedTouches.length > 1) {
return;
}
startTouch = changedTouches[0];
editor.once('touchend', function(e) {
var endTouch = e.changedTouches[0], args;
if (new Date().getTime() - time > 500) {
return;
}
if (Math.abs(startTouch.clientX - endTouch.clientX) > 5) {
return;
}
if (Math.abs(startTouch.clientY - endTouch.clientY) > 5) {
return;
}
args = {
target: elm
};
each('pageX pageY clientX clientY screenX screenY'.split(' '), function(key) {
args[key] = endTouch[key];
});
args = editor.fire('click', args);
});
});
}
/**
* WebKit has a bug where it will allow forms to be submitted if they are inside a contentEditable element.
* For example this: <form><button></form>
@ -27466,10 +27489,10 @@ define("tinymce/util/Quirks", [
blockFormSubmitInsideEditor();
disableBackspaceIntoATable();
removeAppleInterchangeBrs();
touchClickEvent();
// iOS
if (Env.iOS) {
selectionChangeNodeChanged();
restoreFocusOnKeyDown();
bodyHeight();
tapLinksAndImages();
@ -27671,8 +27694,18 @@ define("tinymce/EditorObservable", [
"tinymce/dom/DOMUtils",
"tinymce/util/Tools"
], function(Observable, DOMUtils, Tools) {
var DOM = DOMUtils.DOM;
var DOM = DOMUtils.DOM, customEventRootDelegates;
/**
* Returns the event target so for the specified event. Some events fire
* only on document, some fire on documentElement etc. This also handles the
* custom event root setting where it returns that element instead of the body.
*
* @private
* @param {tinymce.Editor} editor Editor instance to get event target from.
* @param {String} eventName Name of the event for example "click".
* @return {Element/Document} HTML Element or document target to bind on.
*/
function getEventTarget(editor, eventName) {
if (eventName == 'selectionchange') {
return editor.getDoc();
@ -27681,62 +27714,96 @@ define("tinymce/EditorObservable", [
// Need to bind mousedown/mouseup etc to document not body in iframe mode
// Since the user might click on the HTML element not the BODY
if (!editor.inline && /^mouse|click|contextmenu|drop|dragover|dragend/.test(eventName)) {
return editor.getDoc();
return editor.getDoc().documentElement;
}
// Bind to event root instead of body if it's defined
if (editor.settings.event_root) {
if (!editor.eventRoot) {
editor.eventRoot = DOM.select(editor.settings.event_root)[0];
}
return editor.eventRoot;
}
return editor.getBody();
}
function bindEventDelegate(editor, name) {
var eventRootSelector = editor.settings.event_root, editorManager = editor.editorManager;
var eventRootElm = editorManager.eventRootElm || getEventTarget(editor, name);
/**
* Binds a event delegate for the specified name this delegate will fire
* the event to the editor dispatcher.
*
* @private
* @param {tinymce.Editor} editor Editor instance to get event target from.
* @param {String} eventName Name of the event for example "click".
*/
function bindEventDelegate(editor, eventName) {
var eventRootElm = getEventTarget(editor, eventName), delegate;
if (eventRootSelector) {
if (!editorManager.rootEvents) {
editorManager.rootEvents = {};
if (!editor.delegates) {
editor.delegates = {};
}
editorManager.on('RemoveEditor', function() {
if (!editorManager.activeEditor) {
DOM.unbind(eventRootElm);
delete editorManager.rootEvents;
if (editor.delegates[eventName]) {
return;
}
if (editor.settings.event_root) {
if (!customEventRootDelegates) {
customEventRootDelegates = {};
editor.editorManager.on('removeEditor', function() {
var name;
if (!editor.editorManager.activeEditor) {
if (customEventRootDelegates) {
for (name in customEventRootDelegates) {
editor.dom.unbind(getEventTarget(editor, name));
}
customEventRootDelegates = null;
}
}
});
}
if (editorManager.rootEvents[name]) {
if (customEventRootDelegates[eventName]) {
return;
}
if (eventRootElm == editor.getBody()) {
eventRootElm = DOM.select(eventRootSelector)[0];
editorManager.eventRootElm = eventRootElm;
}
editorManager.rootEvents[name] = true;
DOM.bind(eventRootElm, name, function(e) {
var target = e.target, editors = editorManager.editors, i = editors.length;
delegate = function(e) {
var target = e.target, editors = editor.editorManager.editors, i = editors.length;
while (i--) {
var body = editors[i].getBody();
if (body === target || DOM.isChildOf(target, body)) {
if (!editors[i].hidden) {
editors[i].fire(name, e);
editors[i].fire(eventName, e);
}
}
}
});
};
customEventRootDelegates[eventName] = delegate;
DOM.bind(eventRootElm, eventName, delegate);
} else {
editor.dom.bind(eventRootElm, name, function(e) {
delegate = function(e) {
if (!editor.hidden) {
editor.fire(name, e);
editor.fire(eventName, e);
}
});
};
DOM.bind(eventRootElm, eventName, delegate);
editor.delegates[eventName] = delegate;
}
}
var EditorObservable = {
/**
* Bind any pending event delegates. This gets executed after the target body/document is created.
*
* @private
*/
bindPendingEventDelegates: function() {
var self = this;
@ -27745,6 +27812,12 @@ define("tinymce/EditorObservable", [
});
},
/**
* Toggles a native event on/off this is called by the EventDispatcher when
* the first native event handler is added and when the last native event handler is removed.
*
* @private
*/
toggleNativeEvent: function(name, state) {
var self = this;
@ -27768,8 +27841,35 @@ define("tinymce/EditorObservable", [
}
}
} else if (self.initialized) {
self.dom.unbind(getEventTarget(self, name), name);
self.dom.unbind(getEventTarget(self, name), name, self.delegates[name]);
delete self.delegates[name];
}
},
/**
* Unbinds all native event handlers that means delegates, custom events bound using the Events API etc.
*
* @private
*/
unbindAllNativeEvents: function() {
var self = this, name;
if (self.delegates) {
for (name in self.delegates) {
self.dom.unbind(getEventTarget(self, name), name, self.delegates[name]);
}
delete self.delegates;
}
if (!self.inline) {
self.getBody().onload = null;
self.dom.unbind(self.getWin());
self.dom.unbind(self.getDoc());
}
self.dom.unbind(self.getBody());
self.dom.unbind(self.getContainer());
}
};
@ -28576,6 +28676,9 @@ define("tinymce/Editor", [
DOM.setAttrib("src", url || 'javascript:""');
self.contentAreaContainer = o.iframeContainer;
self.iframeElement = ifr;
n = DOM.add(o.iframeContainer, ifr);
// Try accessing the document this will fail on IE when document.domain is set to the same as location.hostname
@ -28588,9 +28691,6 @@ define("tinymce/Editor", [
}
}
self.contentAreaContainer = o.iframeContainer;
self.iframeElement = ifr;
if (o.editorContainer) {
DOM.get(o.editorContainer).style.display = self.orgDisplay;
self.hidden = DOM.isHidden(o.editorContainer);
@ -28901,12 +29001,15 @@ define("tinymce/Editor", [
// Handle auto focus
if (settings.auto_focus) {
setTimeout(function() {
var ed = self.editorManager.get(settings.auto_focus);
var editor;
ed.selection.select(ed.getBody(), 1);
ed.selection.collapse(1);
ed.getBody().focus();
ed.getWin().focus();
if (settings.auto_focus === true) {
editor = self;
} else {
editor = self.editorManager.get(settings.auto_focus);
}
editor.focus();
}, 100);
}
@ -29949,6 +30052,7 @@ define("tinymce/Editor", [
if (!self.removed) {
self.save();
self.removed = 1;
self.unbindAllNativeEvents();
// Remove any hidden input
if (self.hasHiddenInput) {
@ -29964,21 +30068,12 @@ define("tinymce/Editor", [
DOM.setStyle(self.id, 'display', self.orgDisplay);
self.getBody().onload = null; // Prevent #6816
// Don't clear the window or document if content editable
// is enabled since other instances might still be present
Event.unbind(self.getWin());
Event.unbind(self.getDoc());
}
var elm = self.getContainer();
Event.unbind(self.getBody());
Event.unbind(elm);
self.fire('remove');
self.editorManager.remove(self);
DOM.remove(elm);
DOM.remove(self.getContainer());
self.destroy();
}
},
@ -30006,14 +30101,6 @@ define("tinymce/Editor", [
return;
}
// We must unbind on Gecko since it would otherwise produce the pesky "attempt
// to run compile-and-go script on a cleared scope" message
if (automatic && isGecko) {
Event.unbind(self.getDoc());
Event.unbind(self.getWin());
Event.unbind(self.getBody());
}
if (!automatic) {
self.editorManager.off('beforeunload', self._beforeUnload);
@ -30496,6 +30583,7 @@ define("tinymce/EditorManager", [
// User has manually destroyed the editor lets clean up the mess
if (editor && !(editor.getContainer() || editor.getBody()).parentNode) {
removeEditorFromList(editor);
editor.unbindAllNativeEvents();
editor.destroy(true);
editor = null;
}
@ -30526,7 +30614,7 @@ define("tinymce/EditorManager", [
* @property minorVersion
* @type String
*/
minorVersion: '1.2',
minorVersion: '1.3',
/**
* Release date of TinyMCE build.
@ -30534,7 +30622,7 @@ define("tinymce/EditorManager", [
* @property releaseDate
* @type String
*/
releaseDate: '2014-07-15',
releaseDate: '2014-07-29',
/**
* Collection of editor instances.
@ -31153,6 +31241,7 @@ define("tinymce/LegacyInput", [
/**
* This class enables you to send XMLHTTPRequests cross browser.
* @class tinymce.util.XHR
* @mixes tinymce.util.Observable
* @static
* @example
* // Sends a low level Ajax request
@ -31162,9 +31251,17 @@ define("tinymce/LegacyInput", [
* console.debug(text);
* }
* });
*
* // Add custom header to XHR request
* tinymce.util.XHR.on('beforeSend', function(e) {
* e.xhr.setRequestHeader('X-Requested-With', 'Something');
* });
*/
define("tinymce/util/XHR", [], function() {
return {
define("tinymce/util/XHR", [
"tinymce/util/Observable",
"tinymce/util/Tools"
], function(Observable, Tools) {
var XHR = {
/**
* Sends a XMLHTTPRequest.
* Consult the Wiki for details on what settings this method takes.
@ -31208,12 +31305,14 @@ define("tinymce/util/XHR", [], function() {
if (settings.crossDomain) {
xhr.withCredentials = true;
}
if (settings.content_type) {
xhr.setRequestHeader('Content-Type', settings.content_type);
}
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr = XHR.fire('beforeSend', {xhr: xhr, settings: settings}).xhr;
xhr.send(settings.data);
// Syncronous request
@ -31226,6 +31325,10 @@ define("tinymce/util/XHR", [], function() {
}
}
};
Tools.extend(XHR, Observable);
return XHR;
});
// Included from: js/tinymce/classes/util/JSON.js
@ -33092,6 +33195,15 @@ define("tinymce/ui/PanelButton", [
});
return self._super();
},
remove: function() {
if (this.panel) {
this.panel.remove();
this.panel = null;
}
return this._super();
}
});
});
@ -34878,7 +34990,6 @@ define("tinymce/ui/FormatControls", [
paste: ['Paste', 'Paste'],
help: ['Help', 'mceHelp'],
selectall: ['Select all', 'SelectAll'],
hr: ['Insert horizontal rule', 'InsertHorizontalRule'],
removeformat: ['Clear formatting', 'RemoveFormat'],
visualaid: ['Visual aids', 'mceToggleVisualAid'],
newdocument: ['New document', 'mceNewDocument']
@ -37321,5 +37432,5 @@ define("tinymce/ui/Throbber", [
};
});
expose(["tinymce/dom/EventUtils","tinymce/dom/Sizzle","tinymce/util/Tools","tinymce/Env","tinymce/dom/DomQuery","tinymce/html/Styles","tinymce/dom/TreeWalker","tinymce/dom/Range","tinymce/html/Entities","tinymce/dom/StyleSheetLoader","tinymce/dom/DOMUtils","tinymce/dom/ScriptLoader","tinymce/AddOnManager","tinymce/dom/RangeUtils","tinymce/NodeChange","tinymce/html/Node","tinymce/html/Schema","tinymce/html/SaxParser","tinymce/html/DomParser","tinymce/html/Writer","tinymce/html/Serializer","tinymce/dom/Serializer","tinymce/dom/TridentSelection","tinymce/util/VK","tinymce/dom/ControlSelection","tinymce/dom/BookmarkManager","tinymce/dom/Selection","tinymce/dom/ElementUtils","tinymce/fmt/Preview","tinymce/Formatter","tinymce/UndoManager","tinymce/EnterKey","tinymce/ForceBlocks","tinymce/EditorCommands","tinymce/util/URI","tinymce/util/Class","tinymce/util/EventDispatcher","tinymce/ui/Selector","tinymce/ui/Collection","tinymce/ui/DomUtils","tinymce/ui/Control","tinymce/ui/Factory","tinymce/ui/KeyboardNavigation","tinymce/ui/Container","tinymce/ui/DragHelper","tinymce/ui/Scrollable","tinymce/ui/Panel","tinymce/ui/Movable","tinymce/ui/Resizable","tinymce/ui/FloatPanel","tinymce/ui/Window","tinymce/ui/MessageBox","tinymce/WindowManager","tinymce/util/Quirks","tinymce/util/Observable","tinymce/EditorObservable","tinymce/Shortcuts","tinymce/Editor","tinymce/util/I18n","tinymce/FocusManager","tinymce/EditorManager","tinymce/LegacyInput","tinymce/util/XHR","tinymce/util/JSON","tinymce/util/JSONRequest","tinymce/util/JSONP","tinymce/util/LocalStorage","tinymce/Compat","tinymce/ui/Layout","tinymce/ui/AbsoluteLayout","tinymce/ui/Tooltip","tinymce/ui/Widget","tinymce/ui/Button","tinymce/ui/ButtonGroup","tinymce/ui/Checkbox","tinymce/ui/ComboBox","tinymce/ui/ColorBox","tinymce/ui/PanelButton","tinymce/ui/ColorButton","tinymce/util/Color","tinymce/ui/ColorPicker","tinymce/ui/Path","tinymce/ui/ElementPath","tinymce/ui/FormItem","tinymce/ui/Form","tinymce/ui/FieldSet","tinymce/ui/FilePicker","tinymce/ui/FitLayout","tinymce/ui/FlexLayout","tinymce/ui/FlowLayout","tinymce/ui/FormatControls","tinymce/ui/GridLayout","tinymce/ui/Iframe","tinymce/ui/Label","tinymce/ui/Toolbar","tinymce/ui/MenuBar","tinymce/ui/MenuButton","tinymce/ui/ListBox","tinymce/ui/MenuItem","tinymce/ui/Menu","tinymce/ui/Radio","tinymce/ui/ResizeHandle","tinymce/ui/Spacer","tinymce/ui/SplitButton","tinymce/ui/StackLayout","tinymce/ui/TabPanel","tinymce/ui/TextBox","tinymce/ui/Throbber"]);
expose(["tinymce/dom/EventUtils","tinymce/dom/Sizzle","tinymce/util/Tools","tinymce/Env","tinymce/dom/DomQuery","tinymce/html/Styles","tinymce/dom/TreeWalker","tinymce/dom/Range","tinymce/html/Entities","tinymce/dom/DOMUtils","tinymce/dom/ScriptLoader","tinymce/AddOnManager","tinymce/html/Node","tinymce/html/Schema","tinymce/html/SaxParser","tinymce/html/DomParser","tinymce/html/Writer","tinymce/html/Serializer","tinymce/dom/Serializer","tinymce/dom/TridentSelection","tinymce/util/VK","tinymce/dom/ControlSelection","tinymce/dom/BookmarkManager","tinymce/dom/Selection","tinymce/dom/ElementUtils","tinymce/Formatter","tinymce/UndoManager","tinymce/EnterKey","tinymce/ForceBlocks","tinymce/EditorCommands","tinymce/util/URI","tinymce/util/Class","tinymce/util/EventDispatcher","tinymce/ui/Selector","tinymce/ui/Collection","tinymce/ui/DomUtils","tinymce/ui/Control","tinymce/ui/Factory","tinymce/ui/KeyboardNavigation","tinymce/ui/Container","tinymce/ui/DragHelper","tinymce/ui/Scrollable","tinymce/ui/Panel","tinymce/ui/Movable","tinymce/ui/Resizable","tinymce/ui/FloatPanel","tinymce/ui/Window","tinymce/ui/MessageBox","tinymce/WindowManager","tinymce/util/Quirks","tinymce/util/Observable","tinymce/EditorObservable","tinymce/Shortcuts","tinymce/Editor","tinymce/util/I18n","tinymce/FocusManager","tinymce/EditorManager","tinymce/LegacyInput","tinymce/util/XHR","tinymce/util/JSON","tinymce/util/JSONRequest","tinymce/util/JSONP","tinymce/util/LocalStorage","tinymce/Compat","tinymce/ui/Layout","tinymce/ui/AbsoluteLayout","tinymce/ui/Tooltip","tinymce/ui/Widget","tinymce/ui/Button","tinymce/ui/ButtonGroup","tinymce/ui/Checkbox","tinymce/ui/ComboBox","tinymce/ui/ColorBox","tinymce/ui/PanelButton","tinymce/ui/ColorButton","tinymce/util/Color","tinymce/ui/ColorPicker","tinymce/ui/Path","tinymce/ui/ElementPath","tinymce/ui/FormItem","tinymce/ui/Form","tinymce/ui/FieldSet","tinymce/ui/FilePicker","tinymce/ui/FitLayout","tinymce/ui/FlexLayout","tinymce/ui/FlowLayout","tinymce/ui/FormatControls","tinymce/ui/GridLayout","tinymce/ui/Iframe","tinymce/ui/Label","tinymce/ui/Toolbar","tinymce/ui/MenuBar","tinymce/ui/MenuButton","tinymce/ui/ListBox","tinymce/ui/MenuItem","tinymce/ui/Menu","tinymce/ui/Radio","tinymce/ui/ResizeHandle","tinymce/ui/Spacer","tinymce/ui/SplitButton","tinymce/ui/StackLayout","tinymce/ui/TabPanel","tinymce/ui/TextBox","tinymce/ui/Throbber"]);
})(this);

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ $wp_db_version = 29188;
*
* @global string $tinymce_version
*/
$tinymce_version = '4102-20140721';
$tinymce_version = '4103-20140809';
/**
* Holds the required PHP version

View File

@ -1,4 +1,6 @@
(function() {
var menuCtrl;
module("tinymce.plugins.ImportCSS", {
setupModule: function() {
QUnit.stop();
@ -16,6 +18,11 @@
},
teardown: function() {
if (menuCtrl) {
menuCtrl.remove();
menuCtrl = null;
}
editor.contentCSS = [];
delete editor.settings.importcss_file_filter;
delete editor.settings.importcss_merge_classes;
@ -26,8 +33,12 @@
});
function fireFormatsMenuEvent(styleSheets, items) {
menuCtrl = tinymce.ui.Factory.create('menu', {
items: items
}).renderTo(document.getElementById('view'));
return editor.fire('renderFormatsMenu', {
control: tinymce.ui.Factory.create('menu', {items: items}).renderTo(document.getElementById('view')),
control: menuCtrl,
doc: {
styleSheets: styleSheets
}

View File

@ -132,10 +132,10 @@ test("Paste list like paragraph and list", function() {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: '<p class=MsoNormal><span style=\'font-size:10.0pt;line-height:115%;font-family:"Trebuchet MS","sans-serif";color:#666666\'>A. X<o:p></o:p></span></p><p class=MsoListParagraph style=\'text-indent:-.25in;mso-list:l0 level1 lfo1\'><![if !supportLists]><span style=\'mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin\'><span style=\'mso-list:Ignore\'>1.<span style=\'font:7.0pt "Times New Roman"\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><![endif]>Y</p>'
content: '<p class=MsoNormal><span style=\'font-size:10.0pt;line-height:115%;font-family:"Trebuchet MS","sans-serif";color:#666666\'>ABC. X<o:p></o:p></span></p><p class=MsoListParagraph style=\'text-indent:-.25in;mso-list:l0 level1 lfo1\'><![if !supportLists]><span style=\'mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin\'><span style=\'mso-list:Ignore\'>1.<span style=\'font:7.0pt "Times New Roman"\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><![endif]>Y</p>'
});
equal(editor.getContent(), '<p>A. X</p><ol><li>Y</li></ol>');
equal(editor.getContent(), '<p>ABC. X</p><ol><li>Y</li></ol>');
});
test("Paste Word table", function() {
@ -729,4 +729,4 @@ if (tinymce.Env.webkit) {
equal(editor.getContent(), '<p style="color: #ff0000;">abc</p>');
});
}
}

View File

@ -440,7 +440,7 @@
Utils.setSelection('tr:nth-child(2) td:nth-child(2)', 0);
editor.fire('keydown', {keyCode: 9});
equal(editor.selection.getStart().nodeName, 'TD');
equal(editor.selection.getStart(true).nodeName, 'TD');
equal(
editor.getContent(),
'<table><tbody><tr><td>A1</td><td>A2</td></tr><tr><td>B1</td><td>B2</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table><p>x</p>'

View File

@ -43,7 +43,7 @@ module("tinymce.Editor", {
},
teardown: function() {
Utils.unpatch(editor.getDoc());
Utils.unpatch(editor.getDoc());
inlineEditor.show();
editor.show();
}
@ -169,7 +169,6 @@ test('WebKit Serialization range bug', function() {
}
});
test('editor_methods - getParam', function() {
expect(5);
@ -214,6 +213,14 @@ test('setContent', function() {
equal(count, 0);
});
test('setContent with comment bug #4409', function() {
editor.setContent('<!-- x --><br>');
editor.settings.disable_nodechange = false;
editor.nodeChanged();
editor.settings.disable_nodechange = true;
equal(editor.getContent(), "<!-- x --><p>\u00a0</p>");
});
test('custom elements', function() {
editor.setContent('<custom1>c1</custom1><custom2>c1</custom2>');
equal(editor.getContent(), '<custom1>c1</custom1><p><custom2>c1</custom2></p>');
@ -221,7 +228,7 @@ test('custom elements', function() {
test('Store/restore tabindex', function() {
editor.setContent('<span tabindex="42">abc</span>');
equal(editor.getContent({format:'raw'}).toLowerCase(), '<p><span data-mce-tabindex="42">abc</span></p>');
equal(editor.getContent({format: 'raw'}).toLowerCase(), '<p><span data-mce-tabindex="42">abc</span></p>');
equal(editor.getContent(), '<p><span tabindex="42">abc</span></p>');
});

View File

@ -1038,7 +1038,7 @@ test('Bold and italics is applied to text that is not highlighted', function() {
equal(editor.getContent(), '<p><span style="font-family: Arial;"><strong>test1 <em>test2</em></strong> test3 test4 test5 test6</span></p>', 'Selected text should be bold.');
});
test('No wrapping of links', function() {
test('Apply color format to links as well', function() {
editor.setContent('<p>123<a href="#">abc</a>456</p>');
var rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 0);
@ -1050,11 +1050,15 @@ test('No wrapping of links', function() {
styles: {
color: '#FF0000'
},
wrap_links: false
links: true
});
editor.formatter.apply('format');
equal(editor.getContent(), '<p><span style="color: #ff0000;">123<a href="#"><span style="color: #ff0000;">abc</span></a>456</span></p>', 'Link should have it\'s own span.');
equal(
editor.getContent(),
'<p><span style="color: #ff0000;">123<a style="color: #ff0000;" href="#">abc</a>456</span></p>',
'Link should have it\'s own color.'
);
});
test('Color on link element', function() {
@ -1069,11 +1073,15 @@ test('Color on link element', function() {
styles: {
color: '#FF0000'
},
wrap_links: false
links: true
});
editor.formatter.apply('format');
equal(editor.getContent(), '<p><span style="color: #ff0000; font-size: 10px;">123<a href="#"><span style="color: #ff0000;">abc</span></a>456</span></p>', 'Link should have it\'s own span.');
equal(
editor.getContent(),
'<p><span style="color: #ff0000; font-size: 10px;">123<a style="color: #ff0000;" href="#">abc</a>456</span></p>',
'Link should have it\'s own color.'
);
});
test("Applying formats in lists", function() {

View File

@ -1,5 +1,9 @@
(function() {
module("tinymce.dom.DOMUtils");
module("tinymce.dom.DOMUtils", {
teardownModule: function() {
DOM = null;
}
});
var DOM = new tinymce.dom.DOMUtils(document, {keep_values : true, schema : new tinymce.html.Schema()});
@ -262,6 +266,11 @@
DOM.remove('test');
});
test('setGetAttrib on null', function() {
strictEqual(DOM.getAttrib(null, 'test'), '');
DOM.setAttrib(null, 'test');
});
test('getAttribs', 2, function() {
function check(obj, val) {
var count = 0;

View File

@ -1,6 +1,13 @@
(function() {
var $elm;
module("tinymce.dom.DomQuery", {
teardown: function() {
if ($elm) {
$elm.off();
$elm = null;
}
document.getElementById('view').innerHTML = '';
}
});
@ -582,7 +589,9 @@
});
test(prefix + 'on()/off()/trigger()', function() {
var $elm = $('<b />'), lastArgs1, lastArgs2;
var lastArgs1, lastArgs2;
$elm = $('<b />')
// Single listener
$elm.on('click', function(e) {
@ -945,7 +954,7 @@
strictEqual($result.length, 1);
strictEqual($result[0].tagName, 'I');
});
test(prefix + 'children()', function() {
var $result, html;
@ -983,7 +992,7 @@
strictEqual(innerMost.closest($(html[0].firstChild.firstChild)[0]).html().toLowerCase(), '<b>x</b>');
});
test(prefix + 'offset()', function() {
test(prefix + 'offset()', function() {
var testElm = $('<b></b>').offset({top: 10, left: 20});
strictEqual(testElm[0].style.top, '10px');
strictEqual(testElm[0].style.left, '20px');

View File

@ -467,6 +467,12 @@ test('getBookmark/setBookmark (nonintrusive) - Get bookmark inside complex html'
equal(rng.endOffset, 2);
});
test('select empty TD', function() {
editor.getBody().innerHTML = '<table><tr><td><br></td></tr></table>';
editor.selection.select(editor.dom.select('td')[0], true);
equal(editor.selection.getRng(true).startContainer.nodeName, 'TD');
});
test('select first p', 2, function() {
editor.setContent('<p>text1</p><p>text2</p>');
editor.selection.select(editor.dom.select('p')[0]);

View File

@ -175,7 +175,7 @@ test("off (all specific observer)", function() {
test("scope setting", function() {
var lastScope, lastEvent, dispatcher;
dispatcher = new tinymce.util.EventDispatcher();
dispatcher.on('click', function() {
lastScope = this;
@ -194,7 +194,7 @@ test("scope setting", function() {
test("beforeFire setting", function() {
var lastArgs, dispatcher, args;
dispatcher = new tinymce.util.EventDispatcher({
beforeFire: function(args) {
lastArgs = args;

View File

@ -43,7 +43,7 @@ if (tinymce.isWebKit) {
editor.getBody().innerHTML ='<h1>a</h1><p>b<span style="color:red">c</span></p>';
Utils.setSelection('p', 0);
editor.execCommand('Delete');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<h1>ab<span data-mce-style="color:red" style="color: red;">c</span></h1>');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<h1>ab<span data-mce-style="color: red;" style="color: red;">c</span></h1>');
equal(editor.selection.getStart().nodeName, 'H1');
});
@ -69,10 +69,10 @@ if (tinymce.isWebKit) {
});
test('ForwardDelete from end of H1 into P with style span inside', function() {
editor.getBody().innerHTML ='<h1>a</h1><p>b<span style="color:red">c</span></p>';
editor.getBody().innerHTML ='<h1>a</h1><p>b<span style="color: #010203">c</span></p>';
Utils.setSelection('h1', 1);
editor.execCommand('ForwardDelete');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<h1>ab<span data-mce-style="color:red" style="color: red;">c</span></h1>');
equal(editor.getContent(), '<h1>ab<span style="color: #010203;">c</span></h1>');
equal(editor.selection.getStart().nodeName, 'H1');
});

View File

@ -2,14 +2,21 @@ if (location.protocol != "file:") {
module("tinymce.util.XHR");
asyncTest("Successful request", function() {
expect(3);
expect(5);
tinymce.util.XHR.on('beforeSend', function(e) {
e.xhr.test = 123;
e.settings.test = 456;
});
tinymce.util.XHR.send({
url : 'tinymce/util/json_rpc_ok.js',
url: 'tinymce/util/json_rpc_ok.js',
success: function(data, xhr, input) {
equal(tinymce.trim(data), '{"result": "Hello JSON-RPC", "error": null, "id": 1}');
ok(!!xhr.status);
equal(input.url, 'tinymce/util/json_rpc_ok.js');
equal(xhr.test, 123);
equal(input.test, 456);
start();
}
});
@ -19,7 +26,7 @@ if (location.protocol != "file:") {
expect(3);
tinymce.util.XHR.send({
url : 'tinymce/util/404.js',
url: 'tinymce/util/404.js',
error: function(type, xhr, input) {
equal(type, 'GENERAL');
ok(!!xhr.status);