1 | <html lang='en' xml:lang='en'> |
---|
2 | <head> |
---|
3 | <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> |
---|
4 | <script src="https://cdn.ckeditor.com/4.4.2/standard/ckeditor.js"></script> |
---|
5 | <script src="https://raw.githubusercontent.com/eligrey/FileSaver.js/master/FileSaver.js"></script> |
---|
6 | <script type='application/javascript'> |
---|
7 | CKEDITOR.disableAutoInline = true; |
---|
8 | function downloadFile() { |
---|
9 | var blob = new Blob(["some string"], { |
---|
10 | type: "text/plain;charset=utf-8" |
---|
11 | }); |
---|
12 | saveAs(blob, "file.txt"); |
---|
13 | } |
---|
14 | window.onload = function () { |
---|
15 | var editor = CKEDITOR.inline("editor1", { |
---|
16 | floatSpaceDockedOffsetY: 999999, |
---|
17 | startupFocus: true, |
---|
18 | title: false, |
---|
19 | toolbarGroups: [ |
---|
20 | { name: 'document', groups: [ 'mode', 'document' ] }, // Displays document group with its two subgroups. |
---|
21 | { name: 'clipboard', groups: [ 'clipboard', 'undo' ] }, // Group's name will be used to create voice label. |
---|
22 | '/', // Line break - next group will be placed in new line. |
---|
23 | { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] }, |
---|
24 | { name: 'links' } |
---|
25 | ] |
---|
26 | |
---|
27 | }); |
---|
28 | editor.addCommand('downloadDraft', { |
---|
29 | exec: downloadFile |
---|
30 | }); |
---|
31 | editor.ui.addButton('DownloadDraft', { |
---|
32 | label: 'Download Draft', |
---|
33 | command: 'downloadDraft', |
---|
34 | toolbar: 'document,20' |
---|
35 | }); |
---|
36 | }; |
---|
37 | </script> |
---|
38 | </head> |
---|
39 | <body> |
---|
40 | <div id='maincontainer'> |
---|
41 | <div id='contentwrapper' style="margin-top: 100px;"> |
---|
42 | <!-- Container of editors. --> |
---|
43 | <div id='editor1' contenteditable="true"> |
---|
44 | <p>Some content blah blah</p> |
---|
45 | </div> |
---|
46 | <button onclick="downloadFile()">download file</button> |
---|
47 | </div> |
---|
48 | </div> |
---|
49 | </body> |
---|
50 | </html> |
---|