Edit File by line
/home/barbar84/www/wp-inclu.../js/tinymce/plugins/paste
File: plugin.js
},
[2000] Fix | Delete
getLastRng: function () {
[2001] Fix | Delete
return getLastRng(lastRng);
[2002] Fix | Delete
},
[2003] Fix | Delete
isDefault: function () {
[2004] Fix | Delete
return isDefault(editor, pasteBinDefaultContent);
[2005] Fix | Delete
},
[2006] Fix | Delete
isDefaultContent: function (content) {
[2007] Fix | Delete
return isDefaultContent(pasteBinDefaultContent, content);
[2008] Fix | Delete
}
[2009] Fix | Delete
};
[2010] Fix | Delete
};
[2011] Fix | Delete
[2012] Fix | Delete
var Clipboard = function (editor, pasteFormat) {
[2013] Fix | Delete
var pasteBin = PasteBin(editor);
[2014] Fix | Delete
editor.on('preInit', function () {
[2015] Fix | Delete
return registerEventsAndFilters(editor, pasteBin, pasteFormat);
[2016] Fix | Delete
});
[2017] Fix | Delete
return {
[2018] Fix | Delete
pasteFormat: pasteFormat,
[2019] Fix | Delete
pasteHtml: function (html, internalFlag) {
[2020] Fix | Delete
return pasteHtml$1(editor, html, internalFlag);
[2021] Fix | Delete
},
[2022] Fix | Delete
pasteText: function (text) {
[2023] Fix | Delete
return pasteText(editor, text);
[2024] Fix | Delete
},
[2025] Fix | Delete
pasteImageData: function (e, rng) {
[2026] Fix | Delete
return pasteImageData(editor, e, rng);
[2027] Fix | Delete
},
[2028] Fix | Delete
getDataTransferItems: getDataTransferItems,
[2029] Fix | Delete
hasHtmlOrText: hasHtmlOrText,
[2030] Fix | Delete
hasContentType: hasContentType
[2031] Fix | Delete
};
[2032] Fix | Delete
};
[2033] Fix | Delete
[2034] Fix | Delete
var noop$1 = function () {
[2035] Fix | Delete
};
[2036] Fix | Delete
var hasWorkingClipboardApi = function (clipboardData) {
[2037] Fix | Delete
return global$2.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true;
[2038] Fix | Delete
};
[2039] Fix | Delete
var setHtml5Clipboard = function (clipboardData, html, text) {
[2040] Fix | Delete
if (hasWorkingClipboardApi(clipboardData)) {
[2041] Fix | Delete
try {
[2042] Fix | Delete
clipboardData.clearData();
[2043] Fix | Delete
clipboardData.setData('text/html', html);
[2044] Fix | Delete
clipboardData.setData('text/plain', text);
[2045] Fix | Delete
clipboardData.setData(InternalHtml.internalHtmlMime(), html);
[2046] Fix | Delete
return true;
[2047] Fix | Delete
} catch (e) {
[2048] Fix | Delete
return false;
[2049] Fix | Delete
}
[2050] Fix | Delete
} else {
[2051] Fix | Delete
return false;
[2052] Fix | Delete
}
[2053] Fix | Delete
};
[2054] Fix | Delete
var setClipboardData = function (evt, data, fallback, done) {
[2055] Fix | Delete
if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {
[2056] Fix | Delete
evt.preventDefault();
[2057] Fix | Delete
done();
[2058] Fix | Delete
} else {
[2059] Fix | Delete
fallback(data.html, done);
[2060] Fix | Delete
}
[2061] Fix | Delete
};
[2062] Fix | Delete
var fallback = function (editor) {
[2063] Fix | Delete
return function (html, done) {
[2064] Fix | Delete
var markedHtml = InternalHtml.mark(html);
[2065] Fix | Delete
var outer = editor.dom.create('div', {
[2066] Fix | Delete
'contenteditable': 'false',
[2067] Fix | Delete
'data-mce-bogus': 'all'
[2068] Fix | Delete
});
[2069] Fix | Delete
var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml);
[2070] Fix | Delete
editor.dom.setStyles(outer, {
[2071] Fix | Delete
position: 'fixed',
[2072] Fix | Delete
top: '0',
[2073] Fix | Delete
left: '-3000px',
[2074] Fix | Delete
width: '1000px',
[2075] Fix | Delete
overflow: 'hidden'
[2076] Fix | Delete
});
[2077] Fix | Delete
outer.appendChild(inner);
[2078] Fix | Delete
editor.dom.add(editor.getBody(), outer);
[2079] Fix | Delete
var range = editor.selection.getRng();
[2080] Fix | Delete
inner.focus();
[2081] Fix | Delete
var offscreenRange = editor.dom.createRng();
[2082] Fix | Delete
offscreenRange.selectNodeContents(inner);
[2083] Fix | Delete
editor.selection.setRng(offscreenRange);
[2084] Fix | Delete
setTimeout(function () {
[2085] Fix | Delete
editor.selection.setRng(range);
[2086] Fix | Delete
outer.parentNode.removeChild(outer);
[2087] Fix | Delete
done();
[2088] Fix | Delete
}, 0);
[2089] Fix | Delete
};
[2090] Fix | Delete
};
[2091] Fix | Delete
var getData = function (editor) {
[2092] Fix | Delete
return {
[2093] Fix | Delete
html: editor.selection.getContent({ contextual: true }),
[2094] Fix | Delete
text: editor.selection.getContent({ format: 'text' })
[2095] Fix | Delete
};
[2096] Fix | Delete
};
[2097] Fix | Delete
var isTableSelection = function (editor) {
[2098] Fix | Delete
return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
[2099] Fix | Delete
};
[2100] Fix | Delete
var hasSelectedContent = function (editor) {
[2101] Fix | Delete
return !editor.selection.isCollapsed() || isTableSelection(editor);
[2102] Fix | Delete
};
[2103] Fix | Delete
var cut = function (editor) {
[2104] Fix | Delete
return function (evt) {
[2105] Fix | Delete
if (hasSelectedContent(editor)) {
[2106] Fix | Delete
setClipboardData(evt, getData(editor), fallback(editor), function () {
[2107] Fix | Delete
setTimeout(function () {
[2108] Fix | Delete
editor.execCommand('Delete');
[2109] Fix | Delete
}, 0);
[2110] Fix | Delete
});
[2111] Fix | Delete
}
[2112] Fix | Delete
};
[2113] Fix | Delete
};
[2114] Fix | Delete
var copy = function (editor) {
[2115] Fix | Delete
return function (evt) {
[2116] Fix | Delete
if (hasSelectedContent(editor)) {
[2117] Fix | Delete
setClipboardData(evt, getData(editor), fallback(editor), noop$1);
[2118] Fix | Delete
}
[2119] Fix | Delete
};
[2120] Fix | Delete
};
[2121] Fix | Delete
var register$1 = function (editor) {
[2122] Fix | Delete
editor.on('cut', cut(editor));
[2123] Fix | Delete
editor.on('copy', copy(editor));
[2124] Fix | Delete
};
[2125] Fix | Delete
var CutCopy = { register: register$1 };
[2126] Fix | Delete
[2127] Fix | Delete
var global$b = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
[2128] Fix | Delete
[2129] Fix | Delete
var getCaretRangeFromEvent = function (editor, e) {
[2130] Fix | Delete
return global$b.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
[2131] Fix | Delete
};
[2132] Fix | Delete
var isPlainTextFileUrl = function (content) {
[2133] Fix | Delete
var plainTextContent = content['text/plain'];
[2134] Fix | Delete
return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;
[2135] Fix | Delete
};
[2136] Fix | Delete
var setFocusedRange = function (editor, rng) {
[2137] Fix | Delete
editor.focus();
[2138] Fix | Delete
editor.selection.setRng(rng);
[2139] Fix | Delete
};
[2140] Fix | Delete
var setup = function (editor, clipboard, draggingInternallyState) {
[2141] Fix | Delete
if (Settings.shouldBlockDrop(editor)) {
[2142] Fix | Delete
editor.on('dragend dragover draggesture dragdrop drop drag', function (e) {
[2143] Fix | Delete
e.preventDefault();
[2144] Fix | Delete
e.stopPropagation();
[2145] Fix | Delete
});
[2146] Fix | Delete
}
[2147] Fix | Delete
if (!Settings.shouldPasteDataImages(editor)) {
[2148] Fix | Delete
editor.on('drop', function (e) {
[2149] Fix | Delete
var dataTransfer = e.dataTransfer;
[2150] Fix | Delete
if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
[2151] Fix | Delete
e.preventDefault();
[2152] Fix | Delete
}
[2153] Fix | Delete
});
[2154] Fix | Delete
}
[2155] Fix | Delete
editor.on('drop', function (e) {
[2156] Fix | Delete
var dropContent, rng;
[2157] Fix | Delete
rng = getCaretRangeFromEvent(editor, e);
[2158] Fix | Delete
if (e.isDefaultPrevented() || draggingInternallyState.get()) {
[2159] Fix | Delete
return;
[2160] Fix | Delete
}
[2161] Fix | Delete
dropContent = clipboard.getDataTransferItems(e.dataTransfer);
[2162] Fix | Delete
var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime());
[2163] Fix | Delete
if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) {
[2164] Fix | Delete
return;
[2165] Fix | Delete
}
[2166] Fix | Delete
if (rng && Settings.shouldFilterDrop(editor)) {
[2167] Fix | Delete
var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
[2168] Fix | Delete
if (content_1) {
[2169] Fix | Delete
e.preventDefault();
[2170] Fix | Delete
global$3.setEditorTimeout(editor, function () {
[2171] Fix | Delete
editor.undoManager.transact(function () {
[2172] Fix | Delete
if (dropContent['mce-internal']) {
[2173] Fix | Delete
editor.execCommand('Delete');
[2174] Fix | Delete
}
[2175] Fix | Delete
setFocusedRange(editor, rng);
[2176] Fix | Delete
content_1 = Utils.trimHtml(content_1);
[2177] Fix | Delete
if (!dropContent['text/html']) {
[2178] Fix | Delete
clipboard.pasteText(content_1);
[2179] Fix | Delete
} else {
[2180] Fix | Delete
clipboard.pasteHtml(content_1, internal);
[2181] Fix | Delete
}
[2182] Fix | Delete
});
[2183] Fix | Delete
});
[2184] Fix | Delete
}
[2185] Fix | Delete
}
[2186] Fix | Delete
});
[2187] Fix | Delete
editor.on('dragstart', function (e) {
[2188] Fix | Delete
draggingInternallyState.set(true);
[2189] Fix | Delete
});
[2190] Fix | Delete
editor.on('dragover dragend', function (e) {
[2191] Fix | Delete
if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) {
[2192] Fix | Delete
e.preventDefault();
[2193] Fix | Delete
setFocusedRange(editor, getCaretRangeFromEvent(editor, e));
[2194] Fix | Delete
}
[2195] Fix | Delete
if (e.type === 'dragend') {
[2196] Fix | Delete
draggingInternallyState.set(false);
[2197] Fix | Delete
}
[2198] Fix | Delete
});
[2199] Fix | Delete
};
[2200] Fix | Delete
var DragDrop = { setup: setup };
[2201] Fix | Delete
[2202] Fix | Delete
var setup$1 = function (editor) {
[2203] Fix | Delete
var plugin = editor.plugins.paste;
[2204] Fix | Delete
var preProcess = Settings.getPreProcess(editor);
[2205] Fix | Delete
if (preProcess) {
[2206] Fix | Delete
editor.on('PastePreProcess', function (e) {
[2207] Fix | Delete
preProcess.call(plugin, plugin, e);
[2208] Fix | Delete
});
[2209] Fix | Delete
}
[2210] Fix | Delete
var postProcess = Settings.getPostProcess(editor);
[2211] Fix | Delete
if (postProcess) {
[2212] Fix | Delete
editor.on('PastePostProcess', function (e) {
[2213] Fix | Delete
postProcess.call(plugin, plugin, e);
[2214] Fix | Delete
});
[2215] Fix | Delete
}
[2216] Fix | Delete
};
[2217] Fix | Delete
var PrePostProcess = { setup: setup$1 };
[2218] Fix | Delete
[2219] Fix | Delete
function addPreProcessFilter(editor, filterFunc) {
[2220] Fix | Delete
editor.on('PastePreProcess', function (e) {
[2221] Fix | Delete
e.content = filterFunc(editor, e.content, e.internal, e.wordContent);
[2222] Fix | Delete
});
[2223] Fix | Delete
}
[2224] Fix | Delete
function addPostProcessFilter(editor, filterFunc) {
[2225] Fix | Delete
editor.on('PastePostProcess', function (e) {
[2226] Fix | Delete
filterFunc(editor, e.node);
[2227] Fix | Delete
});
[2228] Fix | Delete
}
[2229] Fix | Delete
function removeExplorerBrElementsAfterBlocks(editor, html) {
[2230] Fix | Delete
if (!WordFilter.isWordContent(html)) {
[2231] Fix | Delete
return html;
[2232] Fix | Delete
}
[2233] Fix | Delete
var blockElements = [];
[2234] Fix | Delete
global$4.each(editor.schema.getBlockElements(), function (block, blockName) {
[2235] Fix | Delete
blockElements.push(blockName);
[2236] Fix | Delete
});
[2237] Fix | Delete
var explorerBlocksRegExp = new RegExp('(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*', 'g');
[2238] Fix | Delete
html = Utils.filter(html, [[
[2239] Fix | Delete
explorerBlocksRegExp,
[2240] Fix | Delete
'$1'
[2241] Fix | Delete
]]);
[2242] Fix | Delete
html = Utils.filter(html, [
[2243] Fix | Delete
[
[2244] Fix | Delete
/<br><br>/g,
[2245] Fix | Delete
'<BR><BR>'
[2246] Fix | Delete
],
[2247] Fix | Delete
[
[2248] Fix | Delete
/<br>/g,
[2249] Fix | Delete
' '
[2250] Fix | Delete
],
[2251] Fix | Delete
[
[2252] Fix | Delete
/<BR><BR>/g,
[2253] Fix | Delete
'<br>'
[2254] Fix | Delete
]
[2255] Fix | Delete
]);
[2256] Fix | Delete
return html;
[2257] Fix | Delete
}
[2258] Fix | Delete
function removeWebKitStyles(editor, content, internal, isWordHtml) {
[2259] Fix | Delete
if (isWordHtml || internal) {
[2260] Fix | Delete
return content;
[2261] Fix | Delete
}
[2262] Fix | Delete
var webKitStylesSetting = Settings.getWebkitStyles(editor);
[2263] Fix | Delete
var webKitStyles;
[2264] Fix | Delete
if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') {
[2265] Fix | Delete
return content;
[2266] Fix | Delete
}
[2267] Fix | Delete
if (webKitStylesSetting) {
[2268] Fix | Delete
webKitStyles = webKitStylesSetting.split(/[, ]/);
[2269] Fix | Delete
}
[2270] Fix | Delete
if (webKitStyles) {
[2271] Fix | Delete
var dom_1 = editor.dom, node_1 = editor.selection.getNode();
[2272] Fix | Delete
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) {
[2273] Fix | Delete
var inputStyles = dom_1.parseStyle(dom_1.decode(value));
[2274] Fix | Delete
var outputStyles = {};
[2275] Fix | Delete
if (webKitStyles === 'none') {
[2276] Fix | Delete
return before + after;
[2277] Fix | Delete
}
[2278] Fix | Delete
for (var i = 0; i < webKitStyles.length; i++) {
[2279] Fix | Delete
var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true);
[2280] Fix | Delete
if (/color/.test(webKitStyles[i])) {
[2281] Fix | Delete
inputValue = dom_1.toHex(inputValue);
[2282] Fix | Delete
currentValue = dom_1.toHex(currentValue);
[2283] Fix | Delete
}
[2284] Fix | Delete
if (currentValue !== inputValue) {
[2285] Fix | Delete
outputStyles[webKitStyles[i]] = inputValue;
[2286] Fix | Delete
}
[2287] Fix | Delete
}
[2288] Fix | Delete
outputStyles = dom_1.serializeStyle(outputStyles, 'span');
[2289] Fix | Delete
if (outputStyles) {
[2290] Fix | Delete
return before + ' style="' + outputStyles + '"' + after;
[2291] Fix | Delete
}
[2292] Fix | Delete
return before + after;
[2293] Fix | Delete
});
[2294] Fix | Delete
} else {
[2295] Fix | Delete
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
[2296] Fix | Delete
}
[2297] Fix | Delete
content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) {
[2298] Fix | Delete
return before + ' style="' + value + '"' + after;
[2299] Fix | Delete
});
[2300] Fix | Delete
return content;
[2301] Fix | Delete
}
[2302] Fix | Delete
function removeUnderlineAndFontInAnchor(editor, root) {
[2303] Fix | Delete
editor.$('a', root).find('font,u').each(function (i, node) {
[2304] Fix | Delete
editor.dom.remove(node, true);
[2305] Fix | Delete
});
[2306] Fix | Delete
}
[2307] Fix | Delete
var setup$2 = function (editor) {
[2308] Fix | Delete
if (global$2.webkit) {
[2309] Fix | Delete
addPreProcessFilter(editor, removeWebKitStyles);
[2310] Fix | Delete
}
[2311] Fix | Delete
if (global$2.ie) {
[2312] Fix | Delete
addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks);
[2313] Fix | Delete
addPostProcessFilter(editor, removeUnderlineAndFontInAnchor);
[2314] Fix | Delete
}
[2315] Fix | Delete
};
[2316] Fix | Delete
var Quirks = { setup: setup$2 };
[2317] Fix | Delete
[2318] Fix | Delete
var stateChange = function (editor, clipboard, e) {
[2319] Fix | Delete
var ctrl = e.control;
[2320] Fix | Delete
ctrl.active(clipboard.pasteFormat.get() === 'text');
[2321] Fix | Delete
editor.on('PastePlainTextToggle', function (e) {
[2322] Fix | Delete
ctrl.active(e.state);
[2323] Fix | Delete
});
[2324] Fix | Delete
};
[2325] Fix | Delete
var register$2 = function (editor, clipboard) {
[2326] Fix | Delete
var postRender = curry(stateChange, editor, clipboard);
[2327] Fix | Delete
editor.addButton('pastetext', {
[2328] Fix | Delete
active: false,
[2329] Fix | Delete
icon: 'pastetext',
[2330] Fix | Delete
tooltip: 'Paste as text',
[2331] Fix | Delete
cmd: 'mceTogglePlainTextPaste',
[2332] Fix | Delete
onPostRender: postRender
[2333] Fix | Delete
});
[2334] Fix | Delete
editor.addMenuItem('pastetext', {
[2335] Fix | Delete
text: 'Paste as text',
[2336] Fix | Delete
selectable: true,
[2337] Fix | Delete
active: clipboard.pasteFormat,
[2338] Fix | Delete
cmd: 'mceTogglePlainTextPaste',
[2339] Fix | Delete
onPostRender: postRender
[2340] Fix | Delete
});
[2341] Fix | Delete
};
[2342] Fix | Delete
var Buttons = { register: register$2 };
[2343] Fix | Delete
[2344] Fix | Delete
global$1.add('paste', function (editor) {
[2345] Fix | Delete
if (DetectProPlugin.hasProPlugin(editor) === false) {
[2346] Fix | Delete
var userIsInformedState = Cell(false);
[2347] Fix | Delete
var draggingInternallyState = Cell(false);
[2348] Fix | Delete
var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html');
[2349] Fix | Delete
var clipboard = Clipboard(editor, pasteFormat);
[2350] Fix | Delete
var quirks = Quirks.setup(editor);
[2351] Fix | Delete
Buttons.register(editor, clipboard);
[2352] Fix | Delete
Commands.register(editor, clipboard, userIsInformedState);
[2353] Fix | Delete
PrePostProcess.setup(editor);
[2354] Fix | Delete
CutCopy.register(editor);
[2355] Fix | Delete
DragDrop.setup(editor, clipboard, draggingInternallyState);
[2356] Fix | Delete
return Api.get(clipboard, quirks);
[2357] Fix | Delete
}
[2358] Fix | Delete
});
[2359] Fix | Delete
function Plugin () {
[2360] Fix | Delete
}
[2361] Fix | Delete
[2362] Fix | Delete
return Plugin;
[2363] Fix | Delete
[2364] Fix | Delete
}(window));
[2365] Fix | Delete
})();
[2366] Fix | Delete
[2367] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function