当前位置:网站首页>为UEditor for typecho 添加阅读更多按钮
为UEditor for typecho 添加阅读更多按钮
2022-06-09 15:15:00 【djc8小码农】
使用百度UEditor for TypeCho有一段时间了,一直对这个编辑器缺少的一个功能耿耿于怀,就是More按钮
这个按钮就是类似在wordpress中,点击后会自动添加 标签,这样可以省了我去敲这个标签(懒)。
具体做法如下:
新建文件:moreBtn.js文件
文件内容如下:
UE.registerUI('阅读更多',function(editor,uiName){
//注册按钮执行时的command命令,使用命令默认就会带有回退操作
editor.registerCommand(uiName,{
execCommand:function(){
alert('execCommand:' + uiName)
}
});
//创建一个button
var btn = new UE.ui.Button({
//按钮的名字
name:uiName,
//提示
title:uiName,
//需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
cssRules :'background-position: -460px -40px;',
//点击时执行的命令
onclick:function () {
//这里可以不用执行命令,做你自己的操作也可
//editor.execCommand(uiName);
editor.execCommand('inserthtml', '<!--more-->');
}
});
//当点到编辑内容上时,按钮要做的状态反射
editor.addListener('selectionchange', function () {
var state = editor.queryCommandState(uiName);
if (state == -1) {
btn.setDisabled(true);
btn.setChecked(false);
} else {
btn.setDisabled(false);
btn.setChecked(state);
}
});
//因为你是添加button,所以需要返回这个button
return btn;
}/*index 指定添加到工具栏上的那个位置,默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的,默认是页面上所有的编辑器都会添加这个按钮*/);将该文件保存到:你的Typecho目录/usr/plugins/UEditor/ueditor下。
修改/usr/plugins/UEditor下的:Plugin.php文件。
具体为,在函数:render
$js = Typecho_Common::url('UEditor/ueditor/ueditor.all.min.js', $options->pluginUrl);下面添加:
$moreBtn = Typecho_Common::url('UEditor/ueditor/moreBtn.js',$options->pluginUrl);在
echo '<script type="text/javascript" src="'. $configJs. '"></script><script type="text/javascript" src="'. $js. '"></script>';后面添加
echo '<script type="text/javascript" src="'. $moreBtn. '"></script>';刷新页面即可。
按钮会自动添加在最后一个哟。
边栏推荐
- MySQL 8.0.29 安装配置方法图文教程(windows zip版)
- 3 个技巧来破解你可以立即使用的 Flutter 生产力!
- 4年经验来面试20K的测试岗,连基本功都不会,还不如去招应届生
- Halodoc's key experience in building Lakehouse using Apache Hudi
- Performance monster on arm64: installation and performance test of API gateway Apache APIs IX on AWS graviton3
- JS事件流、事件冒泡、阻止冒泡、事件捕获(一看就懂)
- 期货网上开户安全吗?期货妙手机开户吗?
- 被大厂认可的测试报告怎么写?拥有这30套模板的我彻底起飞
- 博文推荐|BookKeeper - Apache Pulsar 高可用 / 强一致 / 低延迟的存储实现
- jupyter lab学习笔记
猜你喜欢

华为哈勃将再添IPO,美芯晟蛰伏十余年后冲刺科创板

【二、虚拟主机和域名解析】

AE script - grid reference line golden section line generation tool guidesup! 2.2 active version

新冠病毒的最终解药

国货彩妆,败走618

Error 1062 in database, error reporting

Brand renewal, product innovation, marketing innovation, Dongfeng Peugeot's upward road

自如涨价,会逼退年轻人吗?

How to write a test report approved by a large manufacturer? With these 30 sets of templates, I take off completely

jupyter lab学习笔记
随机推荐
被大厂认可的测试报告怎么写?拥有这30套模板的我彻底起飞
【三、ServerName 匹配规则】
Due to the suspension of Russian business: IBM Q1 lost 2billion, Cisco 1.3 billion, Adobe 500million, HP 6.7 billion, uipath 100million
JS事件流、事件冒泡、阻止冒泡、事件捕获(一看就懂)
MySQL 8.0.28 安装配置图文教程
Hongmeng porting i.mx6ull (12) root file system
【四、基于域名的几种互联网企业需求分析】
Error 1062 in database, error reporting
PHP cloud purchase source code with tutorial (source code)
MySQL数据库用户权限管理
基于tensorflow的猫狗分类
【实战】Redis Cluster(下)-系统版本支持问题
软件测试职业发展方向,6年老测试带你走出迷茫...
Hongmeng porting i.mx6ull (VIII) adding a board
如何优雅的自定义 ThreadPoolExecutor 线程池
InfoQ geek media's 15th anniversary solicitation of papers | design practice of micro service architecture in the cloud native Era
你好,欢迎访问我的博客
A Baidu programmer was sentenced to: dissatisfied with others taking over the project, showing his own role, deleting and modifying the database for many times, and committing the crime of destroying
各厂商的数据湖解决方案
497. 非重叠矩形中的随机点