| 1 | <!DOCTYPE html> |
|---|
| 2 | <html lang='en' xml:lang='en'> |
|---|
| 3 | <head> |
|---|
| 4 | <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> |
|---|
| 5 | <script src="http://cdn.ckeditor.com/4.4.7/standard-all/ckeditor.js"></script> |
|---|
| 6 | <script src="https://raw.githubusercontent.com/eligrey/FileSaver.js/master/FileSaver.js"></script> |
|---|
| 7 | <script type='application/javascript'> |
|---|
| 8 | CKEDITOR.disableAutoInline = true; |
|---|
| 9 | function downloadFile() { |
|---|
| 10 | document.getElementById('editor1').blur(); |
|---|
| 11 | var blob = new Blob(["some string"], { |
|---|
| 12 | type: "text/plain;charset=utf-8" |
|---|
| 13 | }); |
|---|
| 14 | saveAs(blob, "file.txt"); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | window.onload = function () { |
|---|
| 18 | editor = CKEDITOR.inline("editor1", { |
|---|
| 19 | floatSpaceDockedOffsetY: 999999, |
|---|
| 20 | startupFocus: true, |
|---|
| 21 | title: false, |
|---|
| 22 | toolbarGroups: [ |
|---|
| 23 | {name: 'document', groups: ['mode', 'document']}, // Displays document group with its two subgroups. |
|---|
| 24 | {name: 'clipboard', groups: ['clipboard', 'undo']}, // Group's name will be used to create voice label. |
|---|
| 25 | '/', // Line break - next group will be placed in new line. |
|---|
| 26 | {name: 'basicstyles', groups: ['basicstyles', 'cleanup']}, |
|---|
| 27 | {name: 'links'} |
|---|
| 28 | ] |
|---|
| 29 | |
|---|
| 30 | }); |
|---|
| 31 | function replaceContent() { |
|---|
| 32 | editor.setData("<p>New content blah blah</p>"); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | editor.addCommand('downloadDraft', { |
|---|
| 36 | exec: downloadFile |
|---|
| 37 | }); |
|---|
| 38 | editor.ui.addButton('DownloadDraft', { |
|---|
| 39 | label: 'Download Draft', |
|---|
| 40 | command: 'downloadDraft', |
|---|
| 41 | toolbar: 'document,20' |
|---|
| 42 | }); |
|---|
| 43 | |
|---|
| 44 | editor.on("loaded", function () { |
|---|
| 45 | var menuGroup = 'AuthorBridgeDocumentTemplates'; |
|---|
| 46 | editor.addMenuGroup(menuGroup); |
|---|
| 47 | editor.ui.add('DocumentTemplates', CKEDITOR.UI_MENUBUTTON, { |
|---|
| 48 | label: 'Document Templates', |
|---|
| 49 | toolbar: 'document,30', |
|---|
| 50 | |
|---|
| 51 | onMenu: function () { |
|---|
| 52 | return {Content: CKEDITOR.TRISTATE_OFF}; |
|---|
| 53 | } |
|---|
| 54 | }); |
|---|
| 55 | |
|---|
| 56 | editor.addMenuItem("Content", { |
|---|
| 57 | label: "Content", |
|---|
| 58 | group: menuGroup, |
|---|
| 59 | order: 1, |
|---|
| 60 | onClick: replaceContent |
|---|
| 61 | }); |
|---|
| 62 | |
|---|
| 63 | }); |
|---|
| 64 | }; |
|---|
| 65 | </script> |
|---|
| 66 | </head> |
|---|
| 67 | <body> |
|---|
| 68 | <div id='maincontainer'> |
|---|
| 69 | <div id='contentwrapper' style="margin-top: 100px;"> |
|---|
| 70 | <!-- Container of editors. --> |
|---|
| 71 | <div id='editor1' contenteditable="true"> |
|---|
| 72 | <p>Some content blah blah</p> |
|---|
| 73 | </div> |
|---|
| 74 | <button onclick="downloadFile()">download file</button> |
|---|
| 75 | </div> |
|---|
| 76 | </div> |
|---|
| 77 | </body> |
|---|
| 78 | </html> |
|---|