X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fckeditor%2Fplugins%2Fblockprotect%2Fplugin.js;h=e4ef3916783d288389244ec623527193582f1e73;hp=61c993a9f679bc6414b047fe6f79c68ef3d46b31;hb=ac20214d38d9af00430423f147b5a0e50751b050;hpb=35d24c449337f95d0e2174cbed55b53eb6c32ca2 diff --git a/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js b/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js index 61c993a9f..e4ef39167 100644 --- a/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js +++ b/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js @@ -6,7 +6,8 @@ var delim_o = '{'; var delim_c = '}'; - var create_block = function(content) { + var create_block = function(content, inside) { + if (inside) return content; // fix nbsp's content = content.replace(/ /gi, ' '); // escape the content @@ -39,6 +40,7 @@ var depth = 0; var chunk = ''; var out = ''; + var in_tag = false; var p = 0; // position in the string while( 1 ) { // find the next delimiter of either kind @@ -54,7 +56,16 @@ if ( i > p ) chunk += data.substr(p, i - p); p = i + 1; if ( depth == 0 ) { - // start of a protected block + // we're in document text. find whether an HTML tag starts, + // or ends, before the next delimiter, so that we know whether + // to output the next block in a SPAN or just as escaped text + for(var q = 0; q < chunk.length; q++ ) { + if (chunk[q] == '<') in_tag = true; + if (chunk[q] == '>') in_tag = false; + } + + // then output the chunk, and go to the start of the + // protected block out += chunk; chunk = ''; } @@ -65,21 +76,21 @@ if ( j > p ) chunk += data.substr(p, j - p); p = j + 1; depth--; - chunk += delim_c - if ( depth == 0 ) { - // end of a protected block - out += create_block(chunk); - chunk = ''; - } else if ( depth < 0 ) { - depth = 0; - } + chunk += delim_c; + if ( depth == 0 ) { + // end of a protected block + out += create_block(chunk, in_tag); + chunk = ''; + } else if ( depth < 0 ) { + depth = 0; + } } else { // can't happen } } // append any text after the last delimiter if ( depth ) { - out += create_block(data.substr(p)); + out += create_block(data.substr(p), in_tag); } else { out += data.substr(p); }