edit: preview page css in block options
[minimedit.git] / edit.js
diff --git a/edit.js b/edit.js
index 8359c687ceb8fafd144f82e14726374b2137c675..f7068adde6d830e49b9fd6560326dad2598ad019 100644 (file)
--- a/edit.js
+++ b/edit.js
@@ -2,17 +2,18 @@ CKEDITOR.plugins.add('inlinesave', {
        init: function(editor) {
                editor.addCommand( 'inlinesave', {
                        exec: function (editor) {
-                               var pagename = window.location.pathname.replace(/^\/(?:\.html)?/, '') || 'index';
-                               var data = 'page='+encodeURIComponent(pagename)+'&body='+encodeURIComponent(editor.getData());
+                               var pagename = window.location.pathname.replace(/\.html$/, '').replace(/\/$/, '/index');
+                               var data = 'body='+encodeURIComponent(editor.getData());
                                ajaxpost = new XMLHttpRequest();
-                               ajaxpost.open('POST', '/edit.php', true);
+                               ajaxpost.open('POST', '/edit.php'+pagename, true);
                                ajaxpost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                                ajaxpost.onreadystatechange = function () {
                                        if (ajaxpost.readyState != 4)
                                                return; // not done yet
                                        if (ajaxpost.status != 200)
                                                alert('Foutcode '+ajaxpost.status+' bij opslaan: '+ajaxpost.responseText);
-                                       //else alert('ok: '+ajaxpost.responseText);
+                                       else
+                                               alert('Pagina is goed opgeslagen');
                                };
                                ajaxpost.send(data);
                        },
@@ -20,7 +21,7 @@ CKEDITOR.plugins.add('inlinesave', {
                editor.ui.addButton( 'Inlinesave', {
                        command: 'inlinesave',
                        label: editor.lang.save.toolbar,
-                       icon: this.path + '../save/icons/save.png',
+                       icon: 'save',
                });
        }
 });
@@ -46,11 +47,13 @@ CKEDITOR.on('instanceCreated', function (event) {
                config.allowedContent = true;
                config.entities = false; // keep unicode
                config.filebrowserImageUploadUrl = '/edit.php?type=img';
+               config.forcePasteAsPlainText = true;
+               config.contentsCss = '/excelsior.css';
                config.toolbar = [
                        ['Inlinesave', '-', 'ShowBlocks', 'Sourcedialog', '-', 'Undo', 'Redo'],
                        ['Format'],
                        ['BulletedList', 'NumberedList', '-', 'Blockquote'],
-                       ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', '-', 'Link'],
+                       ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', '-', 'Anchor', 'Link'],
                        ['HorizontalRule', 'Table', 'Image'],
                ];
 
@@ -72,3 +75,5 @@ CKEDITOR.on('instanceCreated', function (event) {
 var pagebody = document.getElementsByClassName('article')[0];
 pagebody.setAttribute('contenteditable', 'true');
 
+document.body.className = 'edit';
+