diff --git a/customize.dist/ckeditor-config.js b/customize.dist/ckeditor-config.js index 36cac87f0..882c5e0fc 100644 --- a/customize.dist/ckeditor-config.js +++ b/customize.dist/ckeditor-config.js @@ -5,7 +5,7 @@ CKEDITOR.editorConfig = function( config ) { config.needsBrFiller= fixThings; config.needsNbspFiller= fixThings; - config.removeButtons= 'Source,Maximize,Anchor'; + config.removeButtons= 'Source,Maximize'; // magicline plugin inserts html crap into the document which is not part of the // document itself and causes problems when it's sent across the wire and reflected back config.removePlugins= 'resize,elementspath'; diff --git a/www/pad/inner.js b/www/pad/inner.js index 865be9ef8..317b53778 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -32,6 +32,7 @@ define([ '/common/common-util.js', '/bower_components/chainpad/chainpad.dist.js', '/customize/application_config.js', + '/common/test.js', '/bower_components/diff-dom/diffDOM.js', @@ -52,7 +53,9 @@ define([ Hash, Util, ChainPad, - AppConfig) + AppConfig, + Test +) { var DiffDom = window.diffDOM; @@ -160,7 +163,14 @@ define([ ]; var getHTML = function (inner) { - return ('\n' + '\n' + inner.innerHTML); + return ('\n' + '\n' + + '
\n ' + + inner.innerHTML.replace(/]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/g, + function(match,realElt){ + //console.log("returning realElt \"" + unescape(realElt)+ "\"."); + return decodeURIComponent(realElt); }) + + ' \n' + ); }; var CKEDITOR_CHECK_INTERVAL = 100; @@ -753,6 +763,79 @@ define([ }).nThen(waitFor()); }).nThen(function (/*waitFor*/) { + function launchAnchorTest(test) { + // -------- anchor test: make sure the exported anchor contains ------- + console.log('---- anchor test: make sure the exported anchor contains -----.'); + + function tryAndTestExport() { + console.log("Starting tryAndTestExport."); + editor.on( 'dialogShow', function( evt ) { + console.log("Anchor dialog detected."); + var dialog = evt.data; + $(dialog.parts.contents.$).find("input").val('xx-' + Math.round(Math.random()*1000)); + dialog.click(window.CKEDITOR.dialog.okButton(editor).id); + } ); + var existingText = editor.getData(); + editor.insertText("A bit of text"); + console.log("Launching anchor command."); + editor.execCommand(editor.ui.get('Anchor').command); + console.log("Anchor command launched."); + + var waitH = window.setInterval(function() { + console.log("Waited 2s for the dialog to appear"); + var anchors = window.CKEDITOR.plugins["link"].getEditorAnchors(editor); + if(!anchors || anchors.length===0) { + test.fail("No anchors found. Please adjust document"); + } else { + console.log(anchors.length + " anchors found."); + var exported = getHTML(window.inner); + console.log("Obtained exported: " + exported); + var allFound = true; + for(var i=0; i