星联网络专注帝国CMS二次功能插件开发-精品网站模板站长代码素材

  • 最近更新
  • 模板:33
  • 记录:12641|
  • 插件:52|
  • 工具:4|
  • 代码:8|
  • 评论:0

织梦kindeditor文本编辑器增加“查找替换”功能

前言

本文主要讲解《织梦kidedio文本编辑器增加“查找替换”功能》的详细内容

织梦kindeditor文本编辑器增加“查找替换”功能效果演示

织梦kindeditor文本编辑器增加“查找替换”功能

1、items 里面增加 search 按钮

['source','|','undo','redo','|','preview','print','template','code','cut','copy','paste','plainpaste','wordpaste','|','justifyleft','justifycenter','justifyright','justifyfull','insertorderedlist','insertunorderedlist','indent','outdent','subscript','superscript','clearhtml','quickformat','selectall','|','fullscreen','/','formatblock', 'fontname','fontsize','|','forecolor','hilitecolor','bold','italic','underline','strikethrough','lineheight','removeformat','|','image','multiimage','flash','media','insertfile','table','hr','emoticons','baidumap','pagebreak','anchor','link','unlink','|','about','search']

2、增加语言 和 执行函数

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 <scripttype="text/javascript"> //自定义插件查找与替换 KindEditor.lang({ search:'查找与替换' }); KindEditor.ready(function(K){ editor1=K.create('textarea[name="{$fname}"]',{ cssPath:'{$GLOBALS['cfg_cmspath']}/include/kindeditor/plugins/code/prettify.css', uploadJson:'$uploadJson', fileManagerJson:'$fileManagerJson', extraFileUploadParams:{ PHPSESSID:'{$session_id}' }, $extendconfig $itemconfig allowFileManager:{$allowFileManager}, afterBlur:function(){this.sync();} }); prettyPrint(); }); //点击“确定”按钮所执行的事情www.dede58.com织梦模板网 functionFindReplace(){ varfindVal=document.getElementById("txtFind").value; varreplaceVal=document.getElementById("txtReplace").value; if(findVal.length==0){ alert("查找内容不能够为空!"); returnfalse; } vareditorHtml=editor1.html(); //利用正则表达式,实现对编辑器内文本进行全文扫描并替换 editorHtml=editorHtml.replace(newRegExp(findVal,"gi"),replaceVal); //重新加载编辑器内值 editor1.html(editorHtml); } </script>



3、增加按钮点击后出来小窗口
kindeditor\plugins 文件夹下新建 search 文件夹,里面再建立个search.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 //自定义插件查找与替换 KindEditor.plugin('search',function(K){ varself=this,name='search'; self.clickToolbar(name,function(){ menu=self.createMenu({ name:name }); varwrapperDiv="<divstyle='width:250px;height:140px;background:#ffffff;'>"+ "<br><bstyle='padding-left:10px;padding-top:20px;'>查找与替换</b>"+ "<divstyle='padding-left:10px;padding-top:10px;'>查找:<inputtype='text'id='txtFind'/></div>"+ "<divstyle='padding-left:10px;padding-top:10px;'>替换:<inputtype='text'id='txtReplace'/></div>"+ "<divstyle='text-align:right;padding-right:5px;padding-top:10px;'><inputtype='button'value='确定'onclick='FindReplace()'/></div>"+ "</div>"; menu.div.append(wrapperDiv); }); });

完成


本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。

本文地址:http://www.xlkjgs.com/notes/web/10485.html

以上内容由本站整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

星联网络

星联网络是中国最具实战的互联网创业者的知识服务商,这里有互联网行业动态,网络推广,SEO优化,SEM优化,ESC配置,行业经验分型,互联网项目,微信营销、淘宝客赚钱、新媒体营销、京东运营、跨境电商等众多互联网营销知识分享

站长运营站长必备网站运营之道才能长久发展