2 Star 5 Fork 3

aveyuan / UEditor for Typecho

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Plugin.php 2.74 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
aveyuan 提交于 2017-11-14 16:18 . 启用路径更改及说明
<?php
/**
* UEditor编辑器
* 官方版本 1.4.3.3
* 更新了2017年8月14日的Uploader补丁防止ssrf
* 发布日期2017年11月13日
* @package UEditor
* @author 系统笔记
* @version 3.0
* @link http://www.osblog.cn/ueditor.html
*
* @date 2017-11-13
*/
class UEditor_Plugin implements Typecho_Plugin_Interface
{
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate()
{
Typecho_Plugin::factory('admin/write-post.php')->richEditor = array('UEditor_Plugin', 'render');
Typecho_Plugin::factory('admin/write-page.php')->richEditor = array('UEditor_Plugin', 'render');
Helper::addPanel(0, 'UEditor/ueditor/ueditor.config.js','', '', 'contributor');
}
/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate()
{
Helper::removePanel(0, 'UEditor/ueditor/ueditor.config.js');
}
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form) {}
/**
* 个人用户的配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
/**
* 插件实现方法
*
* @access public
* @return void
*/
public static function render($post)
{
$options = Helper::options();
$js = Typecho_Common::url('UEditor/ueditor/ueditor.all.min.js', $options->pluginUrl);
$configJs = Typecho_Common::url('UEditor/ueditor/ueditor.config.js', $options->pluginUrl);
echo '<style type="text/css">
body{
/** 保留此规则使dialogs的某些组件文字可见 */
color:#000 !important;
}
.typecho-label + p{overflow:hidden;}
</style>';
echo '</script><script type="text/javascript" src="'. $configJs. '"></script><script type="text/javascript" src="'. $js. '"></script>';
echo '<script type="text/javascript">
var ue1 = new baidu.editor.ui.Editor();
window.onload = function() {
// 渲染
ue1.render("text");
}
// 保存草稿时同步
document.getElementById("btn-save").onclick = function() {
ue1.sync("text");
}
// 提交时同步
document.getElementById("btn-submit").onclick = function() {
ue1.sync("text");
}
</script>';
}
}
PHP
1
https://gitee.com/aveyuan/UEditor-for-Typecho.git
git@gitee.com:aveyuan/UEditor-for-Typecho.git
aveyuan
UEditor-for-Typecho
UEditor for Typecho
master

搜索帮助