edit/page: indicate edit replacements in data-dyn attributes
[minimedit.git] / edit / page.js
index 5e383835993ebd8f92034e8a1fdf75e275e84217..3071844a96e685c64d8ae6328e81af773e940bc2 100644 (file)
@@ -2,7 +2,7 @@ CKEDITOR.plugins.add('inlinesave', {
        init: function(editor) {
                editor.addCommand( 'inlinesave', {
                        exec: function (editor) {
-                               var pagename = window.location.pathname.replace(/\/$/, '/index');
+                               var pagename = window.location.pathname;
                                var body = editor.getData();
                                // empty line is equivalent to a paragraph break
                                body = body.replace(/<br \/>\s*<br \/>/g, '<p>');
@@ -39,6 +39,7 @@ CKEDITOR.plugins.add('inlinesave', {
                                ajaxpost.send(data);
                        },
                });
+               editor.setKeystroke(CKEDITOR.CTRL + 83 /*S*/, 'inlinesave');
                editor.ui.addButton( 'Inlinesave', {
                        command: 'inlinesave',
                        label: editor.lang.save.toolbar,
@@ -160,8 +161,9 @@ if (pagebody) {
                editlink.href = '';
                editlink.onclick = undefined;
                pagebody.setAttribute('contenteditable', true);
-               pagebody.innerHTML = pagebody.innerHTML
-                       .replace(/<!--BLOCK:(.*?)-->[^]*?<!--\/-->/g, '$1');
+               pagebody.querySelectorAll('[data-dyn]').forEach(function (el) {
+                       el.outerHTML = '[[' + el.getAttribute('data-dyn') + ']]';
+               });
                CKEDITOR.inline(pagebody, { customConfig: '' });
                document.body.className = 'edit';
                return false;