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 88d9f5011..21919c1a2 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,12 @@ define([ ]; var getHTML = function (inner) { - return ('\n' + '\n' + inner.innerHTML); + return ('\n' + '\n' + + ' \n ' + + inner.innerHTML.replace(/]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/, + function(match,realElt){ return unescape(realElt); }) + + ' \n' + ); }; var CKEDITOR_CHECK_INTERVAL = 100; @@ -752,6 +760,51 @@ 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 -----.'); + + // TODO: cleanup fixme, too much ---, and removed tests + // TODO: any other unwanted changes (sframe-app?)? + // TODO: upgrade to latest of master, create branch + // TODO: any way to make sure that content contains anchors? Seems to need selenium-driven clicks and inputs + function tryAndTestExport() { + // window.setContent("This goes before the anchor"); + var anchors = 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(inner); + console.log("Obtained exported: " + exported); + var allFound = true; + for(var i=0; i=0; + console.log("Found " + expected + " " + found + "."); + allFound = allFound && found; + } + console.log("Finished anchor test."); + if(allFound) {test.pass();} + else + {test.fail("Not all expected a elements found.");} + } + } + var intervalHandle = window.setInterval(function() { + if(editor.status==="ready") { + window.clearInterval(intervalHandle); + tryAndTestExport(); + } else { + console.log("Waiting for editor to be ready."); + } + }, 100); + } + Test(function(test) { + + launchAnchorTest(test); + }); andThen2(editor, Ckeditor, framework); }); };