加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > CMS系统 > Dedecms > 正文

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

发布时间:2020-12-14 04:50:21 所属栏目:Dedecms 来源:网络整理
导读:织梦kindeditor文本编辑器增加“查找替换”功能效果演示 ? 1、items 里面增加 search 按钮 ['source','|','undo','redo','preview','print','template','code','cut','copy','paste','plainpaste','wordpaste','justifyleft','justifycenter','justifyright'

织梦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
????//?自定义插件?查找与替换
????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织梦模板
????function?FindReplace()?{
????????var?findVal?=?document.getElementById("txtFind").value;
????????var?replaceVal?=?document.getElementById("txtReplace").value;
????????if?(findVal.length?==?0)?{
????????????alert("查找内容不能够为空!");
????????????return?false;
????????}
????????var?editorHtml?=?editor1.html();
????????//利用正则表达式,实现对编辑器内文本进行全文扫描并替换
????????editorHtml?=?editorHtml.replace(new?RegExp(findVal,?"gi"),?replaceVal);
????????//重新加载编辑器内值
????????editor1.html(editorHtml);
????}



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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//?自定义插件?查找与替换
KindEditor.plugin('search',?function?(K)?{
????var?self?=?this,?name?=?'search';
????self.clickToolbar(name,?function?()?{
????????menu?=?self.createMenu({
????????????name:?name
????????});
????????var?wrapperDiv?=?"
????????????????????????????"
????????????????????????????"
????????????????????????????"
????????????????????????????"
??????????????????????????"
????????menu.div.append(wrapperDiv);
????});
});

完成?


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读