rte_editmode.js
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:2k
-
- // setEditMode(): switch between html and textview
- function setEditMode() {
- switchMode.blur(); // htmlview
- if (switchMode.checked == true) {
- ctlStyle.disabled = ctlFont.disabled = ctlSize.disabled = true;
- // btnPost.className = 'disabled';
- doc.style.fontFamily = "宋体";
- doc.style.fontSize = "12pt";
- RichEditor.txtView = false;
- doc.innerText = codeSweeper();
- doc.innerHTML = ccParser(doc.innerHTML);
- } else {
- ctlStyle.disabled = ctlFont.disabled = ctlSize.disabled = false;
- doc.style.fontFamily = doc.style.fontSize = "";
- // btnPost.className = '';
- RichEditor.txtView = true;
- doc.focus();
- doc.innerHTML = doc.innerText;
- }
- }
- // resetMode();
- function resetMode(){
- if (switchMode.checked == true) {
- switchMode.click();
- }
- }
- // ccParser(): colorcode-parser for html-editing view
- function ccParser(html) {
- html = html.replace(/@/gi,"_AT_");
- html = html.replace(/#/gi,"_HASH_");
- var htmltag = /(<[w/]+[ ]*[w="'./;: )(-]*>)/gi;
- html = html.replace(htmltag,"<span class=ccp_tag>$1</span>");
- var imgtag = /<span class=ccp_tag>(<IMG[ ]*[w="'./;: )(-]*>)</span>/gi;
- html = html.replace(imgtag,"<span class=ccp_img>$1</span>");
- var formtag = /<span class=ccp_tag>(<[/]*(form|input){1}[ ]*[w="'./;: )(-]*>)</span>/gi;
- html = html.replace(formtag,"<br><span class=ccp_form>$1</span>");
- var tabletag = /<span class=ccp_tag>(<[/]*(table|tbody|th|tr|td){1}([ ]*[w="'./;:)(-]*){0,}>)</span>/gi;
- html = html.replace(tabletag,"<span class=ccp_table>$1</span>");
- //var Atag = /<span class=ccp_tag>(<(/a>|[W _w="'./;:)(-]>){1})</span>/gi;
- var Atag = /<span class=ccp_tag>(</a>){1}</span>/gi;
- html = html.replace(Atag,"<span class=ccp_A>$1</span>");
- var Atag = /<span class=ccp_tag>(<a [W _w="'./;:)(-]+>){1,}</span>/gi;
- html = html.replace(Atag,"<span class=ccp_A>$1</span>");
- var parameter = /=("[ w'./;:)(-]+"|'[ w"./;:)(-]+')/gi;
- html = html.replace(parameter,"=<span class=ccp_paramvalue>$1</span>");
- var entity = /&([w]+);/gi;
- html = html.replace(entity,"<span class=ccp_entity>&$1;</span>");
- var comment = /(<!--[W _w="'./;:)(-]*-->)/gi;
- html = html.replace(comment,"<br><span class=ccp_htmlcomment>$1</span>");
- html = html.replace(/_AT_/gi,"@");
- html = html.replace(/_HASH_/gi,"#");
- return html;
- }