import { Pipeline, Step } from '@ephox/agar';
import { UnitTest } from '@ephox/bedrock';
import { Arr } from '@ephox/katamari';
import { LegacyUnit, TinyLoader } from '@ephox/mcagar';
import Env from 'tinymce/core/api/Env';
import Utils from 'tinymce/plugins/paste/core/Utils';
import Plugin from 'tinymce/plugins/paste/Plugin';
import Theme from 'tinymce/themes/modern/Theme';
import Strings from '../module/test/Strings';
UnitTest.asynctest('tinymce.plugins.paste.browser.ImagePasteTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
Plugin();
Theme();
/* eslint-disable max-len */
const sTeardown = function (editor) {
return Step.sync(function () {
delete editor.settings.paste_remove_styles_if_webkit;
delete editor.settings.paste_retain_style_properties;
delete editor.settings.paste_enable_default_filters;
delete editor.settings.paste_data_images;
delete editor.settings.paste_webkit_styles;
});
};
const appendTeardown = function (editor, steps) {
return Arr.bind(steps, function (step) {
return [step, sTeardown(editor)];
});
};
const trimContent = function (content) {
return content.replace(/^
<\/p>\n?/, '').replace(/\n?
<\/p>$/, '');
};
suite.test('Plain text toggle event', function (editor) {
const events = [];
editor.on('PastePlainTextToggle', function (e) {
events.push({ state: e.state });
});
editor.execCommand('mceTogglePlainTextPaste');
LegacyUnit.deepEqual(events, [
{ state: true }
], 'Should be enabled');
editor.execCommand('mceTogglePlainTextPaste');
LegacyUnit.deepEqual(events, [
{ state: true },
{ state: false }
], 'Should be disabled');
editor.execCommand('mceTogglePlainTextPaste');
LegacyUnit.deepEqual(events, [
{ state: true },
{ state: false },
{ state: true }
], 'Should be enabled again');
});
suite.test('Paste simple text content', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('
1234
');
editor.focus();
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: 'TEST' });
LegacyUnit.equal(editor.getContent(), '1TEST4
');
});
suite.test('Paste styled text content', function (editor) {
const rng = editor.dom.createRng();
editor.settings.paste_remove_styles_if_webkit = false;
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: 'TEST' });
LegacyUnit.equal(editor.getContent(), '1TEST4
');
});
suite.test('Paste paragraph in paragraph', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: 'TEST
' });
LegacyUnit.equal(editor.getContent(), '1
TEST
4
');
});
suite.test('Paste paragraphs in complex paragraph', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.dom.select('em,i')[0].firstChild, 1);
rng.setEnd(editor.dom.select('em,i')[0].firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: 'TEST 1
TEST 2
' });
LegacyUnit.equal(editor.getContent(), '1
TEST 1
TEST 2
4
');
});
suite.test('Paste Word fake list', function (editor) {
let rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: Strings.wordList2 });
LegacyUnit.equal(editor.getContent(), '- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
');
editor.settings.paste_retain_style_properties = 'border';
rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: '\u25CF Item Spaces.
' });
LegacyUnit.equal(editor.getContent(), '');
rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: '1. Version 7.0:
' });
LegacyUnit.equal(editor.getContent(), '- Version 7.0:
');
});
suite.test('Paste Word fake list before BR', function (editor) {
let rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertContent', false, '
a');
rng = editor.dom.createRng();
rng.setStart(editor.getBody().firstChild, 0);
rng.setEnd(editor.getBody().firstChild, 0);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: Strings.wordList1 });
LegacyUnit.equal(editor.getContent(), '- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
a
');
});
suite.test('Paste Word fake lists interrupted by header', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: '· List before heading A
· List before heading B
heading
· List after heading A
· List after heading B
' });
LegacyUnit.equal(editor.getContent(), '- List before heading A
- List before heading B
heading
- List after heading A
- List after heading B
');
});
suite.test('Paste list like paragraph and list', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: 'ABC. X
1. Y
'
});
LegacyUnit.equal(editor.getContent(), 'ABC. X
- Y
');
});
suite.test('Paste list like paragraph and list (disabled)', function (editor) {
editor.setContent('');
editor.settings.paste_convert_word_fake_lists = false;
editor.execCommand('mceInsertClipboardContent', false, {
content: 'ABC. X
1. Y
'
});
delete editor.settings.paste_convert_word_fake_lists;
LegacyUnit.equal(editor.getContent(), 'ABC. X
1. Y
');
});
suite.test('Paste Word table', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: Strings.table });
LegacyUnit.equal(editor.getContent(), '
');
});
suite.test('Paste Office 365', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test
' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('Paste Google Docs 1', function (editor) {
const rng = editor.dom.createRng();
editor.setContent('1234
');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: '' +
'' +
'
a
' +
'b
' +
'c
' +
'' +
'
'
)
});
LegacyUnit.equal(editor.getContent(), 'a
b
c
');
});
suite.test('Paste Word without mso markings', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'' +
'' +
'Comic Sans MS' +
'
' +
''
)
});
LegacyUnit.equal(editor.getContent(), (
'Comic Sans MS
'
));
});
suite.test('Paste Word links', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'' +
'1' +
'2' +
'3' +
'4' +
'[5]' +
'[5]' +
'[6]' +
'[7]' +
'8' +
'9' +
'named_link' +
'5' +
'
'
)
});
LegacyUnit.equal(editor.getContent(), (
'' +
'1' +
'2' +
'3' +
'4' +
'[5]' +
'[5]' +
'[6]' +
'[7]' +
'8' +
'9' +
'named_link' +
'5' +
'
'
));
});
suite.test('Paste Word retain styles', function (editor) {
editor.settings.paste_retain_style_properties = 'color,background-color,font-family';
// Test color
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test
' });
LegacyUnit.equal(editor.getContent(), 'Test
');
// Test background-color
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test
' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('Paste Word retain bold/italic styles to elements', function (editor) {
editor.settings.paste_retain_style_properties = 'color';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'' +
'bold' +
'italic' +
'bold + italic' +
'bold + color' +
'
'
)
});
LegacyUnit.equal(editor.getContent(), 'bolditalicbold + italicbold + color
');
});
suite.test('paste track changes comment', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'1
' +
'2
' +
'3' +
'4'
)
});
LegacyUnit.equal(editor.getContent(), '1
');
});
suite.test('paste nested (UL) word list', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'' +
'' +
'· ' +
'a
' +
'' +
'' +
'o b
' +
'' +
'' +
'§ c 1. x
'
)
});
LegacyUnit.equal(
editor.getContent(),
''
);
});
suite.test('paste nested (OL) word list', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'' +
'' +
'1. ' +
'a
' +
'' +
'a.' +
' b
' +
'' +
'' +
' ' +
' ' +
' ' +
' i.' +
' c
'
)
});
LegacyUnit.equal(
editor.getContent(),
'' +
'- a' +
'
' +
'- b' +
'
' +
'- c
' +
'
' +
' ' +
'
' +
' ' +
'
'
);
});
suite.test('Paste list start index', function (editor) {
editor.settings.paste_merge_formats = true;
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'' +
'10.' +
'J');
});
suite.test('Paste paste_merge_formats: true', function (editor) {
editor.settings.paste_merge_formats = true;
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 1);
editor.execCommand('mceInsertClipboardContent', false, { content: 'b' });
LegacyUnit.equal(editor.getContent(), 'ab
');
});
suite.test('Paste paste_merge_formats: false', function (editor) {
editor.settings.paste_merge_formats = false;
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 1);
editor.execCommand('mceInsertClipboardContent', false, { content: 'b' });
LegacyUnit.equal(editor.getContent(), 'ab
');
});
suite.test('Paste word DIV as P', function (editor) {
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, { content: '1
2
' });
LegacyUnit.equal(editor.getContent(), '1
2
');
});
if (Env.ie) {
suite.test('Paste part of list from IE', function (editor) {
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, { content: 'item2item3' });
LegacyUnit.equal(trimContent(editor.getContent()), '', 'List tags are inferred when pasting LI');
});
}
suite.test('Disable default filters', function (editor) {
editor.settings.paste_enable_default_filters = false;
// Test color
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test
' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste invalid content with spans on page', function (editor) {
const startingContent = '123 testing span later in document
',
insertedContent = '';
editor.setContent(startingContent);
const rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 0);
rng.setEnd(editor.dom.select('p')[0].firstChild, 0);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { content: insertedContent });
LegacyUnit.equal(editor.getContent(), insertedContent + startingContent);
});
suite.test('paste plain text with space', function (editor) {
editor.setContent('text
');
const rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { text: ' a ' });
LegacyUnit.equal(editor.getContent(), 't a xt
');
});
suite.test('paste plain text with linefeeds', function (editor) {
editor.setContent('text
');
const rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { text: 'a\nb\nc ' });
LegacyUnit.equal(editor.getContent(), 'ta
b
c xt
');
});
suite.test('paste plain text with double linefeeds', function (editor) {
editor.setContent('text
');
const rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { text: 'a\n\nb\n\nc' });
LegacyUnit.equal(editor.getContent(), 't
a
b
c
xt
');
});
suite.test('paste plain text with entities', function (editor) {
editor.setContent('text
');
const rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { text: '< & >' });
LegacyUnit.equal(editor.getContent(), 't< & >xt
');
});
suite.test('paste plain text with paragraphs', function (editor) {
editor.setContent('text
');
const rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, { text: 'a\nb\n\nc' });
LegacyUnit.equal(editor.getContent(), 't
a
<b>b</b>
c
xt
');
});
suite.test('paste data image with paste_data_images: false', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: '
' });
LegacyUnit.equal(editor.getContent(), '');
editor.execCommand('mceInsertClipboardContent', false, { content: '
' });
LegacyUnit.equal(editor.getContent(), '');
});
suite.test('paste data image with paste_data_images: true', function (editor) {
editor.settings.paste_data_images = true;
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: '
' });
LegacyUnit.equal(editor.getContent(), '
');
});
suite.test('paste pre process text (event)', function (editor) {
function callback(e) {
e.content = 'PRE:' + e.content;
}
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 1);
editor.on('PastePreProcess', callback);
editor.execCommand('mceInsertClipboardContent', false, { text: 'b\n2' });
LegacyUnit.equal(editor.getContent(), 'PRE:b
2
');
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 1);
editor.off('PastePreProcess', callback);
editor.execCommand('mceInsertClipboardContent', false, { text: 'c' });
LegacyUnit.equal(editor.getContent(), 'c
');
});
suite.test('paste pre process html (event)', function (editor) {
function callback(e) {
e.content = 'PRE:' + e.content;
}
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 1);
editor.on('PastePreProcess', callback);
editor.execCommand('mceInsertClipboardContent', false, { content: 'b' });
LegacyUnit.equal(editor.getContent(), 'PRE:b
');
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 1);
editor.off('PastePreProcess', callback);
editor.execCommand('mceInsertClipboardContent', false, { content: 'c' });
LegacyUnit.equal(editor.getContent(), 'c
');
});
suite.test('paste post process (event)', function (editor) {
function callback(e) {
e.node.innerHTML += ':POST';
}
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 1);
editor.on('PastePostProcess', callback);
editor.execCommand('mceInsertClipboardContent', false, { content: 'b' });
LegacyUnit.equal(editor.getContent(), 'b:POST
');
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 1);
editor.off('PastePostProcess', callback);
editor.execCommand('mceInsertClipboardContent', false, { content: 'c' });
LegacyUnit.equal(editor.getContent(), 'c
');
});
suite.test('paste innerText of conditional comments', function () {
LegacyUnit.equal(Utils.innerText('X'), 'X');
});
suite.test('paste innerText of single P', function (editor) {
editor.setContent('a
');
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML), 'a');
});
suite.test('paste innerText of single P with whitespace wrapped content', function (editor) {
editor.setContent(' a
');
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML), 'a');
});
suite.test('paste innerText of two P', function (editor) {
editor.setContent('a
b
');
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML), 'a\n\nb');
});
suite.test('paste innerText of H1 and P', function (editor) {
editor.setContent('a
b
');
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML), 'a\nb');
});
suite.test('paste innerText of P with BR', function (editor) {
editor.setContent('a
b
');
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML), 'a\nb');
});
suite.test('paste innerText of P with VIDEO', function (editor) {
editor.setContent('ad
');
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML), 'a d');
});
suite.test('paste innerText of PRE', function (editor) {
editor.getBody().innerHTML = 'a\nb\n
';
LegacyUnit.equal(Utils.innerText(editor.getBody().innerHTML).replace(/\r\n/g, '\n'), 'a\nb\n');
});
suite.test('paste innerText of textnode with whitespace', function (editor) {
editor.getBody().innerHTML = ' a
';
LegacyUnit.equal(Utils.innerText(editor.getBody().firstChild.innerHTML), ' a ');
});
suite.test('trim html from clipboard fragments', function () {
LegacyUnit.equal(Utils.trimHtml('a'), 'a');
LegacyUnit.equal(Utils.trimHtml('a\n\n\nb\n\n\nc'), '\nb\n');
LegacyUnit.equal(Utils.trimHtml('abc'), 'abc');
LegacyUnit.equal(Utils.trimHtml('abc'), 'b');
LegacyUnit.equal(Utils.trimHtml('ab'), 'b');
LegacyUnit.equal(Utils.trimHtml('a\u00a0<\/span>b'), 'a b');
LegacyUnit.equal(Utils.trimHtml('\u00a0<\/span>b'), ' b');
LegacyUnit.equal(Utils.trimHtml('a\u00a0<\/span>'), 'a ');
LegacyUnit.equal(Utils.trimHtml('\u00a0<\/span>'), ' ');
});
if (Env.ie) {
suite.test('paste font and u in anchor', function (editor) {
editor.setContent('a
');
LegacyUnit.setSelection(editor, 'p', 1);
editor.execCommand('mceInsertClipboardContent', false, {
content: 'b
'
});
LegacyUnit.equal(editor.getContent(), 'a
b
');
});
}
if (Env.webkit) {
suite.test('paste webkit retains text styles runtime styles internal', function (editor) {
editor.settings.paste_webkit_styles = 'color';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: '<span style="color:red"><span data-mce-style="color:red">' });
LegacyUnit.equal(editor.getContent(), '<span style="color:red"><span data-mce-style="color:red">
');
});
suite.test('paste webkit remove runtime styles internal', function (editor) {
editor.settings.paste_webkit_styles = 'color';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (color)', function (editor) {
editor.settings.paste_webkit_styles = 'color';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles keep before attr', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles keep after attr', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles keep before/after attr', function (editor) {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (background-color)', function (editor) {
editor.settings.paste_webkit_styles = 'background-color';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (font-size)', function (editor) {
editor.settings.paste_webkit_styles = 'font-size';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (font-family)', function (editor) {
editor.settings.paste_webkit_styles = 'font-family';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles font-family allowed but not specified', function (editor) {
editor.settings.paste_webkit_styles = 'font-family';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test
' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (custom styles)', function (editor) {
editor.settings.paste_webkit_styles = 'color font-style';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (all)', function (editor) {
editor.settings.paste_webkit_styles = 'all';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (none)', function (editor) {
editor.settings.paste_webkit_styles = 'none';
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, { content: 'Test' });
LegacyUnit.equal(editor.getContent(), 'Test
');
});
suite.test('paste webkit remove runtime styles (color) in the same (color) (named)', function (editor) {
editor.settings.paste_webkit_styles = 'color';
editor.setContent('Test
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 4);
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'a' +
'b'
)
});
LegacyUnit.equal(editor.getContent(), 'ab
');
});
suite.test('paste webkit remove runtime styles (color) in the same (color) (hex)', function (editor) {
editor.setContent('Test
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 4);
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'a' +
'b' +
'c'
)
});
LegacyUnit.equal(editor.getContent(), 'abc
');
});
suite.test('paste webkit remove runtime styles (color) in the same (color) (rgb)', function (editor) {
editor.setContent('Test
');
LegacyUnit.setSelection(editor, 'p', 0, 'p', 4);
editor.execCommand('mceInsertClipboardContent', false, {
content: (
'a' +
'b' +
'c'
)
});
LegacyUnit.equal(editor.getContent(), 'abc
');
});
}
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, appendTeardown(editor, suite.toSteps(editor)), onSuccess, onFailure);
}, {
add_unload_trigger: false,
indent: false,
plugins: 'paste',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});