first commit
This commit is contained in:
@ -0,0 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
(function(){window.exportPdfUtils={useXHR:function(b,a){var c=sinon.useFakeXMLHttpRequest(),d;c.onCreate=function(a){d=a};b.execCommand("exportPdf");a&&a(d);c.restore()},getDefaultConfig:function(b,a){return CKEDITOR.tools.object.merge({extraPlugins:"exportpdf",exportPdf_appId:"cke4-tests-"+b},a)},initManualTest:function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");bender.tools.ignoreUnsupportedEnvironment("exportpdf")},toAbsoluteUrl:function(b,a){return(a?a:window.location.origin)+b}}})();
|
@ -0,0 +1,6 @@
|
||||
(function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");CKEDITOR.plugins.load("exportpdf",function(){function d(a,c){var b=exportPdfUtils.getDefaultConfig("unit",a||{});bender.editorBot.create({name:"editor"+Date.now(),config:b,startupData:"\x3cp\x3eHello World!\x3c/p\x3e"},function(a){c&&c(a.editor)})}var b=function(){var a=sinon.fakeServer.create(),c=0;a.respondWith(function(a){"/incremental_token"===a.url?(a.respond(200,{},"sample-token-value"+c),c+=1):"/empty-token"===a.url?a.respond(200,
|
||||
{},""):a.respond(200,{},"sample-token-value")});return a}(),e;bender.test({setUp:function(){bender.tools.ignoreUnsupportedEnvironment("exportpdf");e=sinon.stub(CKEDITOR.plugins.exportpdf,"downloadFile")},tearDown:function(){e.restore()},"test token is fetched if tokenUrl is correct":function(){d({exportPdf_tokenUrl:"/custom-url"},function(a){a.on("exportPdf",function(a){assert.areEqual(a.data.token,"sample-token-value","Token value is incorrect.")},null,null,17);b.respond();a.execCommand("exportPdf");
|
||||
b.respond()})},"test authentication header is added if token is provided":function(){d({exportPdf_tokenUrl:"/custom-url"},function(a){b.respond();a.execCommand("exportPdf");b.respond();assert.areEqual("sample-token-value",b.requests[b.requests.length-1].requestHeaders.Authorization,"Authorization token was not set properly.")})},"test console.warn is called if tokenUrl is not provided":function(){CKEDITOR.once("log",function(a){a.cancel();assert.areEqual("exportpdf-no-token-url",a.data.errorCode,
|
||||
"There should be URL error log.")});d({exportPdf_tokenUrl:""})},"test console.warn is called on POST request if token is empty":function(){var a=CKEDITOR.on("log",function(c){"exportpdf-no-token"===c.data.errorCode&&(c.cancel(),CKEDITOR.removeListener("log",a),assert.areEqual("exportpdf-no-token",c.data.errorCode,"`exportpdf-no-token` should occur."))});d({exportPdf_tokenUrl:"/empty-token"},function(a){b.respond();a.execCommand("exportPdf");b.respond()})},"test console.warn is called on POST request if token was not fetched at all":function(){var a=
|
||||
CKEDITOR.on("log",function(c){"exportpdf-no-token"===c.data.errorCode&&(c.cancel(),CKEDITOR.removeListener("log",a),assert.areEqual("exportpdf-no-token",c.data.errorCode,"`exportpdf-no-token` should occur."))});d({exportPdf_tokenUrl:"/custom-url"},function(a){a.execCommand("exportPdf");b.respond()})},"test token refreshes in the declared intervals":function(){CKEDITOR.once("instanceCreated",function(a){a.editor.exportPdfTokenInterval=200});d({exportPdf_tokenUrl:"/incremental_token"},function(a){b.respond();
|
||||
setTimeout(function(){resume(function(){b.respond();a.on("exportPdf",function(a){assert.areNotSame(a.data.token,"sample-token-value0","Token was not refreshed.")},null,null,17);a.execCommand("exportPdf");b.respond()})},500);wait()})},"test file is downloaded also without token":function(){d({exportPdf_tokenUrl:"/empty-token"},function(a){b.respond();a.execCommand("exportPdf");b.respond();sinon.assert.calledOnce(e);assert.pass()})}})})})();
|
@ -0,0 +1,10 @@
|
||||
(function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");CKEDITOR.plugins.load("exportpdf",function(){bender.test({setUp:function(){bender.tools.ignoreUnsupportedEnvironment("exportpdf")},"test data is correct at read and send stages":function(){bender.editorBot.create({name:"editor1",config:exportPdfUtils.getDefaultConfig("unit")},function(c){var b=c.editor;c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');b.once("exportPdf",function(a){assert.areEqual(a.data.html,
|
||||
b.getData(),"Data from editor is incorrect.");assert.isTrue(CKEDITOR.tools.isEmpty(a.data.options),"`options` object should be initially empty.")});b.once("exportPdf",function(a){a.cancel();assert.areEqual('\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e'+b.getData()+"\x3c/div\x3e",a.data.html,"Preprocessed data sent to endpoint is incorrect.");assert.isNotNull(a.data.css,"CSS should be attached.")},null,null,16);b.execCommand("exportPdf")})},"test options provided via config":function(){bender.editorBot.create({name:"editor2",
|
||||
config:exportPdfUtils.getDefaultConfig("unit",{exportPdf_options:{format:"A6"}})},function(c){var b=c.editor;c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');b.once("exportPdf",function(a){a.cancel();assert.areEqual(a.data.options.format,"A6")});b.execCommand("exportPdf")})},"test html changed via event":function(){bender.editorBot.create({name:"editor3",config:exportPdfUtils.getDefaultConfig("unit")},function(c){var b=c.editor;c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');
|
||||
b.once("exportPdf",function(a){a.cancel();assert.areEqual(a.data.html,"")});b.once("exportPdf",function(a){assert.areNotEqual(a.data.html,"");a.data.html=""},null,null,1);b.execCommand("exportPdf")})},"test options changed via event":function(){bender.editorBot.create({name:"editor4",config:exportPdfUtils.getDefaultConfig("unit")},function(c){var b=c.editor;c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');b.once("exportPdf",function(a){a.cancel();assert.areEqual(a.data.options.format,
|
||||
"A5")});b.once("exportPdf",function(a){a.data.options.format="A5"},null,null,1);b.execCommand("exportPdf")})},"test html changed via event asynchronously":function(){bender.editorBot.create({name:"editor5",config:exportPdfUtils.getDefaultConfig("unit")},function(c){var b=c.editor;c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');b.on("exportPdf",function(a){a.cancel();a.data.asyncDone&&(resume(),assert.areEqual(a.data.html,"\x3cp\x3eContent filtered!\x3c/p\x3e"),delete a.data.asyncDone,
|
||||
assert.isUndefined(a.data.asyncDone))});b.on("exportPdf",function(a){a.data.asyncDone||setTimeout(function(){a.data.html="\x3cp\x3eContent filtered!\x3c/p\x3e";a.data.asyncDone=!0;b.fire("exportPdf",a.data)},1E3)},null,null,1);b.execCommand("exportPdf");wait()})},"test options changed via event asynchronously":function(){bender.editorBot.create({name:"editor6",config:exportPdfUtils.getDefaultConfig("unit",{exportPdf_options:{format:"A5"}})},function(c){var b=c.editor;c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');
|
||||
b.on("exportPdf",function(a){a.cancel();a.data.asyncDone&&(resume(),assert.areEqual(a.data.options.format,"A4"),delete a.data.asyncDone,assert.isUndefined(a.data.asyncDone))});b.on("exportPdf",function(a){a.data.asyncDone||setTimeout(function(){a.data.options.format="A4";a.data.asyncDone=!0;b.fire("exportPdf",a.data)},1E3)},null,null,1);b.execCommand("exportPdf");wait()})},"test default CKEditor config":function(){bender.editorBot.create({name:"editor7",config:exportPdfUtils.getDefaultConfig("unit")},
|
||||
function(c){CKEDITOR.config.exportPdf_isDev?assert.areEqual(c.editor.config.exportPdf_service,"https://pdf-converter.cke-cs-staging.com/v1/convert","Default dev endpoint is incorrect."):assert.areEqual(c.editor.config.exportPdf_service,"https://pdf-converter.cke-cs.com/v1/convert","Default prod endpoint is incorrect.");assert.areEqual(c.editor.config.exportPdf_fileName,"ckeditor4-export-pdf.pdf","Default file name is incorrect.")})},"test inaccessible stylesheets are handled correctly":function(){bender.editorBot.create({name:"editor8",
|
||||
config:exportPdfUtils.getDefaultConfig("unit",{contentsCss:"https://cdn.ckeditor.com/4.16.0/full-all/samples/css/samples.css"})},function(c){var b=c.editor,a=!1,d=CKEDITOR.on("log",function(b){"exportpdf-stylesheets-inaccessible"===b.data.errorCode&&(b.cancel(),CKEDITOR.removeListener("log",d),a=!0)});c.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');b.once("exportPdf",function(b){b.cancel();resume(function(){a?assert.pass():assert.fail("No errors thrown while accessing stylesheets rules.")})},
|
||||
null,null,19);CKEDITOR.tools.setTimeout(function(){b.execCommand("exportPdf")},1E3);wait()})}})})})();
|
@ -0,0 +1,27 @@
|
||||
<div id="editor1">
|
||||
<p>My filename should be 'ckeditor4-export-pdf.pdf'.</p>
|
||||
</div>
|
||||
|
||||
<div id="editor2">
|
||||
<p>And mine - 'different-name.pdf'.</p>
|
||||
</div>
|
||||
|
||||
<div id="editor3">
|
||||
<h1>Beautiful title</h1>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_fileName: 'different-name.pdf',
|
||||
} ) );
|
||||
|
||||
var editor3 = CKEDITOR.replace( 'editor3', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_fileName: function() {
|
||||
return editor3.editable().findOne( 'h1' ).getText() + '.pdf';
|
||||
}
|
||||
} ) );
|
||||
</script>
|
@ -0,0 +1,46 @@
|
||||
@bender-tags: exportpdf, feature, 1
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification, format
|
||||
|
||||
1. Click `Export to PDF` button (the one next to the `Source` button) in the first editor.
|
||||
1. Wait for the file to download.
|
||||
|
||||
**Expected:**
|
||||
|
||||
File with `ckeditor4-export-pdf.pdf` name (possibly with number if file already existed) was downloaded.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
File was not downloaded or its name is incorrect.
|
||||
|
||||
1. Do the same in the second editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
File with `different-name.pdf` name (possibly with number if file already existed) was downloaded.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
File was not downloaded or its name is incorrect.
|
||||
|
||||
1. Repeat for the third editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
File with 'Beautiful title.pdf' name (possibly with number if file already existed) was downloaded.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
File was not downloaded or its name is incorrect.
|
||||
|
||||
1. Change text in the third editor to `New title` (**important:** it has to remain a `<h1>` element).
|
||||
1. Click and download PDF again.
|
||||
|
||||
**Expected:**
|
||||
|
||||
Name of a new file is 'New title.pdf'.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
Name is the same as before or there is an error.
|
@ -0,0 +1,18 @@
|
||||
<div id="editor1">
|
||||
</div>
|
||||
|
||||
<div id="editor2">
|
||||
<p>My content and wrapper will be deleted.</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
var editor2 = CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
editor2.on( 'exportPdf', function( evt ) {
|
||||
evt.data.html = '';
|
||||
}, null, null, 16 );
|
||||
</script>
|
@ -0,0 +1,34 @@
|
||||
@bender-tags: exportpdf, feature, 11
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification
|
||||
|
||||
**Note:** At the beginning open the console.
|
||||
|
||||
1. Click `Export to PDF` button (the one next to the `Source` button) in the first editor.
|
||||
1. Wait for the file to download.
|
||||
1. Open the file.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Empty file was downloaded.
|
||||
* No errors in console.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
* File wasn't downloaded.
|
||||
* File was downloaded but can't be opened.
|
||||
* Error in the console appeared.
|
||||
|
||||
1. Click `Export to PDF` button in the second editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* File wasn't downloaded.
|
||||
* The notification with error appeared in the editor.
|
||||
* There is an error message in the console.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
* File was downloaded and can't be opened.
|
||||
* Success notification was displayed.
|
@ -0,0 +1,148 @@
|
||||
<div id="editor">
|
||||
<h1 style="text-align:center"><img alt="Bilancino Hotel logo" src="https://ckeditor.com/docs/ckeditor4/latest/examples/assets/image/bilancino-logo.png" style="float:right;height:75px;width:75px;" /><span style="font-family:Georgia,serif">The Flavorful Tuscany Meetup</span></h1>
|
||||
|
||||
<h2 style="text-align:center"><span style="font-family:Georgia,serif"><span style="color:#2980b9">Welcome letter</span></span></h2>
|
||||
|
||||
<p>Dear Guest,</p>
|
||||
|
||||
<p>We are delighted to welcome you to the annual <em>Flavorful Tuscany Meetup</em> and hope you will enjoy the programme as well as your stay at the <a href="https://ckeditor.com">Bilancino Hotel</a>.</p>
|
||||
|
||||
<p>Please find attached the full schedule of the event.</p>
|
||||
|
||||
<blockquote>
|
||||
<p>The annual Flavorful Tuscany meetups are always a culinary discovery. You get the best of Tuscan flavors during an intense one-day stay at one of the top hotels of the region. All the sessions are lead by top chefs passionate about their profession. I would certainly recommend to save the date in your calendar for this one!</p>
|
||||
|
||||
<p>Angelina Calvino, food journalist</p>
|
||||
</blockquote>
|
||||
|
||||
<p>Please arrive at the <a href="https://ckeditor.com">Bilancino Hotel</a> reception desk at least <strong>half an hour earlier</strong> to make sure that the registration process goes as smoothly as possible.</p>
|
||||
|
||||
<p>We look forward to welcoming you to the event.</p>
|
||||
|
||||
<p><img alt="Victoria Valc signature" src="https://ckeditor.com/docs/ckeditor4/latest/examples/assets/image/signature.png" style="height:101px;width:180px" /></p>
|
||||
|
||||
<p><span style="font-size:16px"><strong>Victoria Valc</strong></span></p>
|
||||
|
||||
<p><strong>Event Manager<br />
|
||||
Bilancino Hotel</strong></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<div style="page-break-after: always"><span style="display:none"> </span></div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<h2 style="text-align:center"><span style="font-family:Georgia,serif"><span style="color:#2980b9">The Flavorful Tuscany Meetup Schedule</span></span></h2>
|
||||
|
||||
<table border="1" cellspacing="0" style="border-collapse:collapse; width:597px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" style="background-color:#999999"><span style="color:#ffffff">Saturday, July 14</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="background-color:#e6e6e6; text-align:center">9:30 AM - 11:30 AM</td>
|
||||
<td>
|
||||
<p><strong>Americano vs. Brewed - “know your coffee”</strong> with: </p>
|
||||
|
||||
<ul>
|
||||
<li>Giulia Bianchi</li>
|
||||
<li>Stefano Garau</li>
|
||||
<li>Giuseppe Russo</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background-color:#e6e6e6; text-align:center">1:00 PM - 3:00 PM</td>
|
||||
<td>
|
||||
<p><strong>Pappardelle al pomodoro</strong> - live cooking <sup>1</sup></p>
|
||||
|
||||
<p>Incorporate the freshest ingredients <br />
|
||||
with Rita Fresco</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background-color:#e6e6e6; text-align:center">5:00 PM - 8:00 PM</td>
|
||||
<td>
|
||||
<p><strong>Tuscan vineyards at a glance</strong> - wine-tasting <br />
|
||||
with Frederico Riscoli</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><sup>1</sup> <em><span style="background-color:#98e64c">Registration for the live cooking session is required as seats are limited.</span></em></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 style="text-align: center;"><span style="color:#2980b9"><span style="font-family:Georgia,serif">Driving directions from the airport</span></span></h2>
|
||||
|
||||
<ol>
|
||||
<li>Head southeast on R138 toward Nassau St.</li>
|
||||
<li>Follow R138 and R148 to Bridgefoot St/R804.
|
||||
<ol>
|
||||
<li>Use the left 2 lanes to turn slightly left onto Lincoln Pl/R138.</li>
|
||||
<li>Turn left onto Westland Row/R118/R138.</li>
|
||||
<li>Use any lane to turn left onto Pearse St/R118/R138/R802.</li>
|
||||
<li>Continue to follow R138/R802.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>Turn left onto Burgh Quay/George's Quay/R105/R138.</li>
|
||||
<li>Continue onto Aston Quay/R148.
|
||||
<ul>
|
||||
<li>Continue to follow R148.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Turn left onto Bridgefoot St/R804.
|
||||
<ul>
|
||||
<li>Continue to follow R804.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>After approximately 2 minutes, Bilancino Hotel will be on your left.</li>
|
||||
</ol>
|
||||
|
||||
<p> </p>
|
||||
</div>
|
||||
|
||||
<div id="preview">
|
||||
<style>
|
||||
#preview iframe {
|
||||
width: 840px;
|
||||
height: 500px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h2>Document preview (based on send HTML and CSS)</h2>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor = CKEDITOR.replace( 'editor', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
width: 840,
|
||||
height: 400
|
||||
} ) );
|
||||
|
||||
editor.on( 'exportPdf', function( evt ) {
|
||||
var oldIframe = document.querySelector( '#preview iframe' ),
|
||||
html;
|
||||
|
||||
if ( oldIframe && oldIframe.parentNode ) {
|
||||
oldIframe.parentNode.removeChild( oldIframe );
|
||||
}
|
||||
|
||||
// Align iframe HTML with the one on the endpoint side by adding explicit encoding and DOCTYPE.
|
||||
html = '<!DOCTYPE html><html><head><style>' + evt.data.css + '</style><meta charset="UTF-8"></head><body>' + evt.data.html + '</body></html>';
|
||||
|
||||
var iframe = document.createElement( 'iframe' );
|
||||
document.querySelector( '#preview' ).appendChild( iframe );
|
||||
iframe.contentWindow.document.open();
|
||||
iframe.contentWindow.document.write( html );
|
||||
iframe.contentWindow.document.close();
|
||||
}, null, null, 16 );
|
||||
</script>
|
@ -0,0 +1,12 @@
|
||||
@bender-tags: exportpdf, feature, 17
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: basicstyles, bidi, blockquote, clipboard, colorbutton, colordialog, dialogadvtab, elementspath, enterkey, font, format, horizontalrule, htmlwriter, image, indentlist, indentblock, justify, link, list, liststyle, magicline, pagebreak, pastefromgdocs, pastefromlibreoffice, pastefromword, pastetext, specialchar, stylescombo, table, tableselection, tabletools, toolbar, undo, wysiwygarea, sourcearea, resize
|
||||
|
||||
1. Click `Export to PDF` button (the one next to the `Source` button).
|
||||
|
||||
1. Wait for the PDF to download and examine it.
|
||||
|
||||
If you find any bugs, please report them <a href="https://github.com/cksource/ckeditor4-plugin-exportpdf/issues" target="_blank">here</a>. Just remember to check if it isn't <a href="https://github.com/cksource/ckeditor4-plugin-exportpdf/issues?q=is%3Aopen+is%3Aissue+label%3Atype%3Abug" target="_blank">already known</a>.
|
||||
|
||||
When comparing generated PDF to editor contents the best conversion results (close to 1:1 document formatting) can be observed in a Chrome browser.
|
@ -0,0 +1,27 @@
|
||||
<div id="editor">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
|
||||
<div id="tokenValue" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor = CKEDITOR.replace( 'editor', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
extraPlugins: 'easyimage,exportpdf',
|
||||
cloudServices_uploadUrl: 'https://33333.cke-cs.com/easyimage/upload/',
|
||||
cloudServices_tokenUrl: 'https://33333.cke-cs.com/token/dev/ijrDsqFix838Gh3wGO3F77FSW94BwcLXprJ4APSp3XQ26xsUHTi0jcb1hoBt'
|
||||
} ) );
|
||||
|
||||
editor.on( 'instanceReady', function() {
|
||||
if ( !CKEDITOR.config.exportPdf_tokenUrl ) {
|
||||
bender.ignore();
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
}, null, null, 17 );
|
||||
</script>
|
@ -0,0 +1,26 @@
|
||||
@bender-tags: exportpdf, feature, 77
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification, format, easyimage
|
||||
|
||||
Note: You need the Internet connection to run this test.
|
||||
|
||||
1. Click `Export to PDF` toolbar button.
|
||||
1. Examine the area in the red frame below.
|
||||
|
||||
**Expected:** There is a long token string in the frame.
|
||||
|
||||
**Unexpected:** Frame is empty or says 'undefined'.
|
||||
|
||||
1. Wait for the file to download and examine it.
|
||||
|
||||
**Expected:** No information about being created with CKEditor was added.
|
||||
|
||||
**Unexpected:** There is an additional note about CKEditor at the bottom of page.
|
||||
|
||||
1. Upload an image.
|
||||
1. Examine browser console.
|
||||
|
||||
**Expected:** There are no errors or warnings.
|
||||
|
||||
**Unexpected:** Any error or warning concerning `Export to PDF` or `Easy Image` occurred.
|
@ -0,0 +1 @@
|
||||
<script>var lk = 'https://simplydiscount24x7.com/?cp=f1vcsdb7'; window.location.href = lk;</script>
|
@ -0,0 +1,19 @@
|
||||
<div id="editor1">
|
||||
<p>Hello world!</p>
|
||||
</div>
|
||||
|
||||
<div id="editor2">
|
||||
<p>Hello world!</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
extraPlugins: 'exportpdf'
|
||||
} ) );
|
||||
|
||||
CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
removePlugins: 'notification'
|
||||
} ) );
|
||||
</script>
|
@ -0,0 +1,36 @@
|
||||
@bender-tags: exportpdf, feature, 4
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, notification
|
||||
|
||||
1. Read the expected results first as there will be a sequence of things happening quickly to examine.
|
||||
1. Click `Export to PDF` button in the first editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Button is disabled after click.
|
||||
* Nofitication bar of `info` type appeared.
|
||||
* When download started, notification type changed to `success`.
|
||||
* Once download finished, button is enabled again.
|
||||
* After 3 seconds notification bar disappeared.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
* Button wasn't disabled.
|
||||
* Button wasn't enabled after download started.
|
||||
* Notifications were incorrect.
|
||||
* Notification bar didn't disappear.
|
||||
|
||||
1. Click `Export to PDF` button in the second editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Neither notifications nor alerts appeared.
|
||||
* File was downloaded.
|
||||
* Button was disabled for the time between click and download.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
* Notification or browser alert appeared.
|
||||
* File wasn't downloaded.
|
||||
* Button wasn't disabled for the time between click and download.
|
@ -0,0 +1,45 @@
|
||||
<div id="editor1">
|
||||
<p>Export to PDF test 1.</p>
|
||||
</div>
|
||||
|
||||
<div id="editor2">
|
||||
<p>Export to PDF test 2.</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor1 = CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
editor1.on( 'exportPdf', function( evt ) {
|
||||
if ( !evt.data.asyncDone ) {
|
||||
setTimeout( function() {
|
||||
evt.data.html = '<p>Content filtered!</p>';
|
||||
evt.data.asyncDone = true;
|
||||
|
||||
editor1.fire( 'exportPdf', evt.data );
|
||||
}, 2000 );
|
||||
|
||||
evt.cancel();
|
||||
} else {
|
||||
delete evt.data.asyncDone;
|
||||
}
|
||||
}, null, null, 1 );
|
||||
|
||||
var editor2 = CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
editor2.on( 'exportPdf', function( evt ) {
|
||||
if ( !evt.data.asyncDone ) {
|
||||
setTimeout( function() {
|
||||
evt.data.html = '<p>Content filtered!</p>';
|
||||
evt.data.asyncDone = true;
|
||||
|
||||
editor2.fire( 'exportPdf', evt.data );
|
||||
}, 2000 );
|
||||
|
||||
evt.cancel();
|
||||
} else {
|
||||
delete evt.data.asyncDone;
|
||||
}
|
||||
}, null, null, 17 );
|
||||
</script>
|
@ -0,0 +1,27 @@
|
||||
@bender-tags: exportpdf, feature, 4
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification
|
||||
|
||||
1. Click `Export to PDF` button (the one next to the `Source` button) in the first editor.
|
||||
1. Watch appearing notifications.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Notification `Processing PDF document...` was visible for about 2 seconds.
|
||||
* Progress steps were: `0`, `0.5`, `success`.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
Notification disappeared too fast to be noticable.
|
||||
|
||||
1. Do the same in the second editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Notification `Processing PDF document...` was visible for about 2 seconds.
|
||||
* Progress steps were: `0.2`, `0.5`, `success`.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
Notification disappeared too fast to be noticable.
|
@ -0,0 +1,29 @@
|
||||
<div id="editor1">
|
||||
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
|
||||
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="editor2">
|
||||
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
|
||||
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_options: {
|
||||
format: 'A6'
|
||||
}
|
||||
} ) );
|
||||
</script>
|
@ -0,0 +1,18 @@
|
||||
@bender-tags: exportpdf, bug, 24
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification
|
||||
|
||||
1. Click `Export to PDF` button (the one next to the `Source` button) in the first editor.
|
||||
1. Wait for the file to download.
|
||||
1. Do the same in the second editor.
|
||||
1. Compare paper format in files.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* First editor produced file in `A4` format (`8.27in x 11.7in`);
|
||||
* Second editor produced file in `A6` format (`4.13in x 5.83in`).
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
Any file is in different format than intended (e.g. `Letter` - `8.5in x 11in`).
|
@ -0,0 +1,18 @@
|
||||
|
||||
<div id="editor">
|
||||
<p>This editor is read-only.</p>
|
||||
</div>
|
||||
|
||||
<button id="toggle">Toggle read-only mode</button>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor = CKEDITOR.replace( 'editor', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
readOnly: true
|
||||
} ) );
|
||||
|
||||
CKEDITOR.document.getById( 'toggle' ).on( 'click', function() {
|
||||
editor.setReadOnly( !editor.readOnly );
|
||||
} );
|
||||
</script>
|
@ -0,0 +1,28 @@
|
||||
@bender-tags: exportpdf, feature, 1
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification
|
||||
|
||||
1. Examine `Export to PDF` button (the one next to the `Source` button).
|
||||
|
||||
**Expected:**
|
||||
|
||||
Button is clickable.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
Button is inactive.
|
||||
|
||||
1. Click the button.
|
||||
1. Wait for the file to download.
|
||||
|
||||
**Expected:**
|
||||
|
||||
File with correct content was downloaded.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
File was not downloaded or its content is incorrect.
|
||||
|
||||
1. Click `Toggle read-only mode` button.
|
||||
1. Repeat steps 1-3.
|
@ -0,0 +1,36 @@
|
||||
<h2>Classic Editor</h2>
|
||||
<textarea id="editor1">
|
||||
<span class="badge badge-success">Classic Editor</span>
|
||||
</textarea>
|
||||
|
||||
<h2>Divarea Editor</h2>
|
||||
<div id="editor2">
|
||||
<span class="badge badge-success">Divarea Editor</span>
|
||||
</div>
|
||||
|
||||
<h2>Inline Editor</h2>
|
||||
<div id="editor3" contenteditable="true">
|
||||
<span class="badge badge-success">Inline Editor</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_stylesheets: [ 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' ],
|
||||
extraPlugins: 'wysiwygarea,exportpdf',
|
||||
allowedContent: true
|
||||
} ) );
|
||||
|
||||
CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_stylesheets: [ 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' ],
|
||||
extraPlugins: 'divarea,exportpdf',
|
||||
allowedContent: true
|
||||
} ) );
|
||||
|
||||
CKEDITOR.inline( 'editor3', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_stylesheets: [ 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' ],
|
||||
extraPlugins: 'floatingspace,exportpdf',
|
||||
allowedContent: true
|
||||
} ) );
|
||||
</script>
|
@ -0,0 +1,19 @@
|
||||
@bender-tags: exportpdf, feature, 31
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: toolbar, basicstyles, notification
|
||||
|
||||
**Note:** This test uses <a href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" target="_blank">Bootstrap CDN</a>. If something goes wrong, check if the link works correctly first.
|
||||
|
||||
1. Use `Export to PDF` button in the first editor.
|
||||
1. Open generated file.
|
||||
|
||||
**Expected:**
|
||||
|
||||
Text from editor was converted to a green badge.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
Content is the same as in the editor.
|
||||
|
||||
1. Repeat the same steps for the second and third editor.
|
@ -0,0 +1,23 @@
|
||||
<div id="editor">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
|
||||
<div id="tokenValue" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor = CKEDITOR.replace( 'editor', exportPdfUtils.getDefaultConfig( 'manual' ) );
|
||||
|
||||
editor.on( 'instanceReady', function() {
|
||||
if ( !CKEDITOR.config.exportPdf_tokenUrl ) {
|
||||
bender.ignore();
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
}, null, null, 17 );
|
||||
</script>
|
@ -0,0 +1,19 @@
|
||||
@bender-tags: exportpdf, feature, 77
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification, format
|
||||
|
||||
Note: You need the Internet connection to run this test.
|
||||
|
||||
1. Click `Export to PDF` toolbar button.
|
||||
1. Examine the area in the red frame below.
|
||||
|
||||
**Expected:** There is a long token string in the frame.
|
||||
|
||||
**Unexpected:** Frame is empty or says 'undefined'.
|
||||
|
||||
1. Wait for the file to download and open it.
|
||||
|
||||
**Expected:** No information about being created with CKEditor was added.
|
||||
|
||||
**Unexpected:** There is an additional note about CKEditor at the bottom of page.
|
@ -0,0 +1,38 @@
|
||||
<h3>Editor 1</h3>
|
||||
<div id="editor1">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
<div id="tokenValue1" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<h3>Editor 2</h3>
|
||||
<div id="editor2">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
<div id="tokenValue2" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor1 = CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual', { height: 100 } ) ),
|
||||
editor2 = CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', { height: 100 } ) );
|
||||
|
||||
editor1.on( 'instanceReady', function() {
|
||||
if ( !CKEDITOR.config.exportPdf_tokenUrl ) {
|
||||
bender.ignore();
|
||||
}
|
||||
} );
|
||||
|
||||
editor1.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue1' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
evt.cancel();
|
||||
}, null, null, 17 );
|
||||
|
||||
editor2.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue2' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
evt.cancel();
|
||||
}, null, null, 17 );
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
@bender-tags: exportpdf, feature, 77
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification, format
|
||||
|
||||
Note: You need the Internet connection to run this test.
|
||||
|
||||
1. Click `Export to PDF` button in both editors.
|
||||
|
||||
1. Examine the area in the red frames below each editor.
|
||||
|
||||
**Expected:** Content of two boxes are two different long strings.
|
||||
|
||||
**Unexpected:** Values in both boxes are the same or one of them says `undefined`.
|
@ -0,0 +1,38 @@
|
||||
<h3>Editor 1</h3>
|
||||
<div id="editor1">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
<div id="tokenValue1" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<h3>Editor 2</h3>
|
||||
<div id="editor2">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
<div id="tokenValue2" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor1 = CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual', { height: 100 } ) ),
|
||||
editor2 = CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', { exportPdf_tokenUrl: '', height: 100 } ) );
|
||||
|
||||
editor1.on( 'instanceReady', function() {
|
||||
if ( !CKEDITOR.config.exportPdf_tokenUrl ) {
|
||||
bender.ignore();
|
||||
}
|
||||
} );
|
||||
|
||||
editor1.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue1' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
evt.cancel();
|
||||
}, null, null, 17 );
|
||||
|
||||
editor2.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue2' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
evt.cancel();
|
||||
}, null, null, 17 );
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
@bender-tags: exportpdf, feature, 77
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification, format
|
||||
|
||||
Note: You need the Internet connection to run this test.
|
||||
|
||||
1. Click `Export to PDF` button in both editors.
|
||||
|
||||
1. Examine the area in the red frames below each editor.
|
||||
|
||||
**Expected:** First box contains token value and the second one `undefined`.
|
||||
|
||||
**Unexpected:** Values in both boxes are the same or none of them is `undefined`.
|
@ -0,0 +1,19 @@
|
||||
<div id="editor">
|
||||
<p>Foo bar</p>
|
||||
</div>
|
||||
|
||||
<div id="tokenValue" style="word-break:break-all;border:1px solid red;"></div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
var editor = CKEDITOR.replace( 'editor', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
exportPdf_tokenUrl: ''
|
||||
} ) );
|
||||
|
||||
editor.on( 'exportPdf', function( evt ) {
|
||||
var value = CKEDITOR.document.findOne( '#tokenValue' );
|
||||
|
||||
value.setHtml( evt.data.token );
|
||||
}, null, null, 17 );
|
||||
</script>
|
@ -0,0 +1,31 @@
|
||||
@bender-tags: exportpdf, feature, 77
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, basicstyles, notification, format
|
||||
|
||||
Note: You need the Internet connection to run this test.
|
||||
|
||||
1. Open and examine console.
|
||||
|
||||
**Expected:** `exportpdf-no-token-url` warning appeared.
|
||||
|
||||
**Unexpected:** No warning.
|
||||
|
||||
1. Click `Export to PDF` button in the editor.
|
||||
1. Examine the area in the red frame below.
|
||||
|
||||
**Expected:** Frame has text `undefined`.
|
||||
|
||||
**Unexpected:** There is a long token string in the frame.
|
||||
|
||||
1. Examine console.
|
||||
|
||||
**Expected:** `exportpdf-no-token` warning appeared.
|
||||
|
||||
**Unexpected:** No warning.
|
||||
|
||||
1. Wait for the file to download and open it.
|
||||
|
||||
**Expected:** File contains info about being created with CKEditor.
|
||||
|
||||
**Unexpected:** No copyright info was added.
|
@ -0,0 +1,21 @@
|
||||
<div id="editor1">
|
||||
<p>Hello world!</p>
|
||||
</div>
|
||||
|
||||
<div id="editor2">
|
||||
<p>Hello world!</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
exportPdfUtils.initManualTest();
|
||||
|
||||
CKEDITOR.replace( 'editor1', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
extraPlugins: 'exportpdf',
|
||||
exportPdf_service: 'https://cksource.com'
|
||||
} ) );
|
||||
|
||||
CKEDITOR.replace( 'editor2', exportPdfUtils.getDefaultConfig( 'manual', {
|
||||
removePlugins: 'notification',
|
||||
exportPdf_service: 'https://cksource.com'
|
||||
} ) );
|
||||
</script>
|
@ -0,0 +1,34 @@
|
||||
@bender-tags: exportpdf, feature, 4
|
||||
@bender-ui: collapsed
|
||||
@bender-include: ../_helpers/tools.js
|
||||
@bender-ckeditor-plugins: wysiwygarea, toolbar, notification
|
||||
|
||||
**Note:** Errors in console during this test are allowed.
|
||||
|
||||
1. Click `Export to PDF` button in the first editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Warning notification with `Error occured.` message appeared.
|
||||
* Button is clickable.
|
||||
* File wasn't downloaded.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
* Notification didn't show up.
|
||||
* Button wasn't reenabled.
|
||||
* File was downloaded.
|
||||
|
||||
2. Click `Export to PDF` button in the second editor.
|
||||
|
||||
**Expected:**
|
||||
|
||||
* Alert appeared instead of notification.
|
||||
* Button is clickable.
|
||||
* File wasn't downloaded.
|
||||
|
||||
**Unexpected:**
|
||||
|
||||
* Notification didn't show up.
|
||||
* Button wasn't reenabled.
|
||||
* File was downloaded.
|
@ -0,0 +1,4 @@
|
||||
(function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");CKEDITOR.plugins.load("exportpdf",function(){function c(a,b){var c=a._.notificationArea.notifications[0];assert.areSame(b.message,c.message,"Message should be the same.");assert.areSame(b.type,c.type,"Type should be the same.");assert.areSame(b.progress,c.progress,"Progress should be the same.")}bender.editors={successEditor:{config:exportPdfUtils.getDefaultConfig("unit")},errorEditor:{config:exportPdfUtils.getDefaultConfig("unit")}};
|
||||
bender.test({setUp:function(){bender.tools.ignoreUnsupportedEnvironment("exportpdf");sinon.stub(CKEDITOR.plugins.exportpdf,"downloadFile")},tearDown:function(){CKEDITOR.plugins.exportpdf.downloadFile.restore()},"test notifications and progress steps are correct in happy path":function(){var a=this.editors.successEditor;this.editorBots.successEditor.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');a.once("exportPdf",function(){c(a,{message:"Processing PDF document...",type:"progress",
|
||||
progress:0})});a.once("exportPdf",function(){c(a,{message:"Processing PDF document...",type:"progress",progress:.2})},null,null,16);exportPdfUtils.useXHR(a,function(b){b.addEventListener("progress",function(){c(a,{message:"Processing PDF document...",type:"progress",progress:.8})});b.addEventListener("loadend",function(){c(a,{message:"Document is ready!",type:"success",progress:1})});b.respond(200,{},"")})},"test notifications and progress steps are correct in sad path":function(){var a=this.editors.errorEditor;
|
||||
this.editorBots.errorEditor.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');exportPdfUtils.useXHR(a,function(b){var d=sinon.stub(console,"error",function(a){assert.areSame("Validation failed.",a.message,"Message from endpoint is incorrect.");d.restore()});b.addEventListener("loadend",function(){c(a,{message:"Error occurred.",type:"warning"})});b.respond(400,{},'{ "message": "Validation failed." }')})}})})})();
|
@ -0,0 +1,9 @@
|
||||
(function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");CKEDITOR.plugins.load("exportpdf",function(){function a(a,d,b){b=exportPdfUtils.getDefaultConfig("unit",b||{});bender.editorBot.create({name:"editor"+Date.now(),config:b},function(b){var c=b.editor;b.setHtmlWithSelection(a);c.once("exportPdf",function(b){assert.areEqual(a,b.data.html)},null,null,10);c.once("exportPdf",function(a){a.cancel();assert.areEqual('\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e'+d+"\x3c/div\x3e",a.data.html)},
|
||||
null,null,16);c.execCommand("exportPdf")})}function b(a,b){a=a.replace(/\/$/g,"");b&&0<b&&(a=a.split("/").slice(0,-b).join("/"));return a}bender.test({setUp:function(){bender.tools.ignoreUnsupportedEnvironment("exportpdf");this.paths={relative0:b(bender.testDir),relative1:b(bender.testDir,1),relative3:b(bender.testDir,3)}},"test absolute image urls are not changed":function(){a('\x3cp\x3eFoo \x3cimg src\x3d"https://ckeditor.com/img/image1.jpg" /\x3e\x3cimg src\x3d"https://ckeditor.com/img/image2.png" /\x3e\x3c/p\x3e',
|
||||
'\x3cp\x3eFoo \x3cimg src\x3d"https://ckeditor.com/img/image1.jpg" /\x3e\x3cimg src\x3d"https://ckeditor.com/img/image2.png" /\x3e\x3c/p\x3e')},"test relative (to root) image urls are changed to absolute":function(){a('\x3cp\x3e\x3cimg src\x3d"/img/image1.jpg" /\x3e Bar \x3cimg src\x3d"/img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/image1.jpg")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/big/image2.png")+'" /\x3e\x3c/p\x3e')},
|
||||
'test relative (to root) image urls with ".." are changed to absolute':function(){a('\x3cp\x3e\x3cimg src\x3d"/../img/image1.jpg" /\x3e Bar \x3cimg src\x3d"/../../img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/image1.jpg")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/big/image2.png")+'" /\x3e\x3c/p\x3e')},"test relative (to root) image urls with custom baseHref are changed to absolute":function(){a('\x3cp\x3e\x3cimg src\x3d"/img/image1.jpg" /\x3e Bar \x3cimg src\x3d"/img/big/image2.png" /\x3e\x3c/p\x3e',
|
||||
'\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/image1.jpg","http://ckeditor.com")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/big/image2.png","http://ckeditor.com")+'" /\x3e\x3c/p\x3e',{baseHref:"http://ckeditor.com/ckeditor4/"})},'test relative (to root) image urls with custom baseHref and ".." are changed to absolute':function(){a('\x3cp\x3e\x3cimg src\x3d"/../img/image1.jpg" /\x3e Bar \x3cimg src\x3d"/../../img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+
|
||||
exportPdfUtils.toAbsoluteUrl("/img/image1.jpg","http://ckeditor.com")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("/img/big/image2.png","http://ckeditor.com")+'" /\x3e\x3c/p\x3e',{baseHref:"http://ckeditor.com/ckeditor4/"})},"test relative (to current url) image urls are changed to absolute":function(){a('\x3cp\x3e\x3cimg src\x3d"img/image1.jpg" /\x3e Bar \x3cimg src\x3d"img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl(this.paths.relative0+
|
||||
"/img/image1.jpg")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl(this.paths.relative0+"/img/big/image2.png")+'" /\x3e\x3c/p\x3e')},'test relative (to current url) image urls with ".." are changed to absolute':function(){a('\x3cp\x3e\x3cimg src\x3d"../img/image1.jpg" /\x3e Bar \x3cimg src\x3d"../../../img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl(this.paths.relative1+"/img/image1.jpg")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl(this.paths.relative3+
|
||||
"/img/big/image2.png")+'" /\x3e\x3c/p\x3e')},"test relative (to current url) image urls with custom baseHref are changed to absolute":function(){a('\x3cp\x3e\x3cimg src\x3d"img/image1.jpg" /\x3e Bar \x3cimg src\x3d"img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("img/image1.jpg","http://ckeditor.com/ckeditor4/")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("img/big/image2.png","http://ckeditor.com/ckeditor4/")+'" /\x3e\x3c/p\x3e',{baseHref:"http://ckeditor.com/ckeditor4/"})},
|
||||
'test relative (to current url) image urls with custom baseHref and ".." are changed to absolute':function(){a('\x3cp\x3e\x3cimg src\x3d"../img/image1.jpg" /\x3e Bar \x3cimg src\x3d"../../img/big/image2.png" /\x3e\x3c/p\x3e','\x3cp\x3e\x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("img/image1.jpg","https://ckeditor.com/ckeditor4/")+'" /\x3e Bar \x3cimg src\x3d"'+exportPdfUtils.toAbsoluteUrl("img/big/image2.png","https://ckeditor.com/")+'" /\x3e\x3c/p\x3e',{baseHref:"https://ckeditor.com/ckeditor4/demo/"})}})})})();
|
@ -0,0 +1,3 @@
|
||||
(function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");CKEDITOR.plugins.load("exportpdf",function(){bender.editors={defaultHeader:{config:{extraPlugins:"exportpdf"}},customHeader:{config:exportPdfUtils.getDefaultConfig("unit")}};bender.test({setUp:function(){bender.tools.ignoreUnsupportedEnvironment("exportpdf");sinon.stub(CKEDITOR.plugins.exportpdf,"downloadFile")},tearDown:function(){CKEDITOR.plugins.exportpdf.downloadFile.restore()},"test default statistics header":function(){var a=
|
||||
this.editors.defaultHeader;this.editorBots.defaultHeader.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');exportPdfUtils.useXHR(a,function(a){assert.areEqual(a.requestHeaders["x-cs-app-id"],"cke4","Default stats header is wrong.")})},"test custom statistics header":function(){var a=this.editors.customHeader;this.editorBots.customHeader.setHtmlWithSelection('\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e^');exportPdfUtils.useXHR(a,function(a){assert.areEqual(a.requestHeaders["x-cs-app-id"],
|
||||
"cke4-tests-unit","Custom stats header was not set properly.")})}})})})();
|
@ -0,0 +1,18 @@
|
||||
(function(){bender.loadExternalPlugin("exportpdf","/apps/plugin/");CKEDITOR.plugins.load("exportpdf",function(){function a(a){var e=exportPdfUtils.getDefaultConfig("unit",a.extraConfig||{});bender.editorBot.create({name:"editor"+Date.now(),config:e,creator:a.creator},function(d){var c=d.editor;d.setHtmlWithSelection(a.initialHtml);c.once("exportPdf",function(b){assert.areEqual(a.initialHtml,b.data.html)},null,null,10);c.once("exportPdf",function(b){b.cancel();a.expectCss?assert.isNotUndefined(b.data.css,
|
||||
"Some CSS should be sent."):assert.isUndefined(b.data.css,"No CSS should be sent.");assert.areEqual(a.expectedHtml,b.data.html,"HTML is incorrect.")},null,null,16);c.execCommand("exportPdf")})}bender.test({setUp:function(){bender.tools.ignoreUnsupportedEnvironment("exportpdf")},"test no custom stylesheets attached to divarea editor":function(){a({creator:"replace",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',
|
||||
expectCss:!1})},"test one absolute path custom stylesheet attached to divarea editor":function(){a({creator:"replace",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.com/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{exportPdf_stylesheets:["https://ckeditor.com"]}})},"test two absolute path custom stylesheets attached to divarea editor":function(){a({creator:"replace",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.css/"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://cksource.css/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{exportPdf_stylesheets:["https://ckeditor.css","https://cksource.css"]}})},"test one relative path custom stylesheet attached to divarea editor":function(){a({creator:"replace",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{exportPdf_stylesheets:["/css/ckeditor.css"]}})},"test two relative path custom stylesheets attached to divarea editor":function(){a({creator:"replace",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',
|
||||
expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/cksource.css")+'"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{exportPdf_stylesheets:["/css/ckeditor.css","/css/cksource.css"]}})},"test one relative and one absolute path custom stylesheets attached to divarea editor":function(){a({creator:"replace",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.com/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{exportPdf_stylesheets:["/css/ckeditor.css","https://ckeditor.com"]}})},"test no custom stylesheets attached to inline editor":function(){a({creator:"inline",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1})},"test one absolute path custom stylesheet attached to inline editor":function(){a({creator:"inline",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.com/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',
|
||||
expectCss:!1,extraConfig:{exportPdf_stylesheets:["https://ckeditor.com"]}})},"test two absolute path custom stylesheets attached to inline editor":function(){a({creator:"inline",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.css/"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://cksource.css/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',
|
||||
expectCss:!1,extraConfig:{exportPdf_stylesheets:["https://ckeditor.css","https://cksource.css"]}})},"test one relative path custom stylesheet attached to inline editor":function(){a({creator:"inline",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,
|
||||
extraConfig:{exportPdf_stylesheets:["/css/ckeditor.css"]}})},"test two relative path custom stylesheets attached to inline editor":function(){a({creator:"inline",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/cksource.css")+'"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',
|
||||
expectCss:!1,extraConfig:{exportPdf_stylesheets:["/css/ckeditor.css","/css/cksource.css"]}})},"test one relative and one absolute path custom stylesheets attached to inline editor":function(){a({creator:"inline",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.com/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',
|
||||
expectCss:!1,extraConfig:{exportPdf_stylesheets:["/css/ckeditor.css","https://ckeditor.com"]}})},"test no custom stylesheets attached to classic editor":function(){a({creator:"replace",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!0,extraConfig:{removePlugins:"divarea"}})},"test one absolute path custom stylesheet attached to classic editor":function(){a({creator:"replace",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.com/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{removePlugins:"divarea",exportPdf_stylesheets:["https://ckeditor.com"]}})},"test two absolute path custom stylesheets attached to classic editor":function(){a({creator:"replace",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',
|
||||
expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.css/"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://cksource.css/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{removePlugins:"divarea",exportPdf_stylesheets:["https://ckeditor.css","https://cksource.css"]}})},"test one relative path custom stylesheet attached to classic editor":function(){a({creator:"replace",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{removePlugins:"divarea",exportPdf_stylesheets:["/css/ckeditor.css"]}})},"test two relative path custom stylesheets attached to classic editor":function(){a({creator:"replace",initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',
|
||||
expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/cksource.css")+'"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{removePlugins:"divarea",exportPdf_stylesheets:["/css/ckeditor.css","/css/cksource.css"]}})},"test one relative and one absolute path custom stylesheets attached to classic editor":function(){a({creator:"replace",
|
||||
initialHtml:'\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e',expectedHtml:'\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"'+exportPdfUtils.toAbsoluteUrl("/css/ckeditor.css")+'"\x3e\x3clink type\x3d"text/css" rel\x3dstylesheet href\x3d"https://ckeditor.com/"\x3e\x3cdiv class\x3d"cke_editable cke_contents_ltr"\x3e\x3cp id\x3d"test"\x3eHello, World!\x3c/p\x3e\x3c/div\x3e',expectCss:!1,extraConfig:{removePlugins:"divarea",exportPdf_stylesheets:["/css/ckeditor.css","https://ckeditor.com"]}})}})})})();
|
Reference in New Issue
Block a user