X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/81dcf42eb0bd11110ec30ce3840718b259ec5082..e533b4e9662636f565f6e487b0ab99e768858370:/edit/page.js diff --git a/edit/page.js b/edit/page.js index c9a6f1e..4e389db 100644 --- a/edit/page.js +++ b/edit/page.js @@ -2,8 +2,10 @@ 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(); + // trim trailing whitespace in non-empty paragraphs + body = body.replace(/((?!

).{3})(?:\s|\u200B)+(?=<\/p>)/g, '$1'); // empty line is equivalent to a paragraph break body = body.replace(/
\s*
/g, '

'); // wrap long line after each sentence @@ -39,6 +41,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, @@ -58,6 +61,17 @@ CKEDITOR.on('dialogDefinition', function (event) { infotab.remove('txtCellSpace'); infotab.remove('txtCellPad'); infotab.remove('cmbAlign'); + + // horizontal repositioning of existing elements + var hbox = { + id: 'hboxDimensions', + type: 'hbox', + children: [ infotab.get('txtCols'), infotab.get('txtRows') ], + }; + infotab.add(hbox, 'selHeaders'); + infotab.remove('txtCols'); + infotab.remove('txtRows'); + break; case 'link': // hide unneeded widgets from the Link Info tab @@ -149,8 +163,14 @@ if (pagebody) { editlink.href = ''; editlink.onclick = undefined; pagebody.setAttribute('contenteditable', true); - pagebody.innerHTML = pagebody.innerHTML - .replace(/[^]*?/g, '$1'); + pagebody.querySelectorAll('[data-dyn]').forEach(function (el) { + let blockname = el.getAttribute('data-dyn'); + if (!blockname) { + el.remove(); + return; + } + el.outerHTML = '[[' + blockname + ']]'; + }); CKEDITOR.inline(pagebody, { customConfig: '' }); document.body.className = 'edit'; return false;