-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4,146 changed files
with
215,203 additions
and
1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
/** | ||
* WindsCkEditor,集成最新CkEditor4编辑器,支持插入Code,支持图片上传,支持原附件插入 | ||
* | ||
* @package WindsCkEditor | ||
* @author 小A | ||
* @version 1.0.0 | ||
* @link http://lijian.net | ||
*/ | ||
class WindsCkEditor_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('WindsCkEditor_Plugin', 'render'); | ||
Typecho_Plugin::factory('admin/write-page.php')->richEditor = array('WindsCkEditor_Plugin', 'render'); | ||
//数据 | ||
Typecho_Plugin::factory('Widget_Contents_Post_Edit')->write = array('WindsCkEditor_Plugin', 'filter'); | ||
Typecho_Plugin::factory('Widget_Contents_Page_Edit')->write = array('WindsCkEditor_Plugin', 'filter'); | ||
|
||
//重写原插入附件 | ||
Typecho_Plugin::factory('admin/write-post.php')->bottom = array('WindsCkEditor_Plugin', 'reInsert'); | ||
Typecho_Plugin::factory('admin/write-page.php')->bottom = array('WindsCkEditor_Plugin', 'reInsert'); | ||
} | ||
|
||
/** | ||
* 禁用插件方法,如果禁用失败,直接抛出异常 | ||
* | ||
* @static | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function deactivate() | ||
{ | ||
} | ||
|
||
/** | ||
* 获取插件配置面板 | ||
* | ||
* @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 | ||
* @param array $post 数据结构体 | ||
* @return array | ||
*/ | ||
public static function filter($post) | ||
{ | ||
$post['text'] = str_replace("\n", '', $post['text']); | ||
return $post; | ||
} | ||
|
||
/** | ||
* 重写原附件插入 | ||
*/ | ||
public static function reInsert($post) { | ||
echo <<<CODE | ||
<script type="text/javascript"> | ||
$(document).ready(function() { | ||
Typecho.insertFileToEditor = function (file, url, isImage) { | ||
var textHtml = isImage ? "<img src='"+url+"' alt='"+file+"' />" : | ||
"<a href='"+ url +"'>" + file + "</a>"; | ||
if(editor && typeof editor.insertHtml == 'function') { | ||
editor.insertHtml(textHtml); | ||
} | ||
} | ||
}); | ||
</script> | ||
CODE; | ||
} | ||
|
||
/** | ||
* 插件实现方法 | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public static function render($post) | ||
{ | ||
$options = Helper::options(); | ||
$ckEditor = Typecho_Common::url('WindsCkEditor/ckeditor', $options->pluginUrl); | ||
$manage = Typecho_Common::url('WindsCkEditor/manage', $options->pluginUrl); | ||
//调用编辑器 | ||
echo <<<CODE | ||
<script type="text/javascript" src="{$ckEditor}/ckeditor.js"></script> | ||
<script type="text/javascript"> | ||
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ){ | ||
CKEDITOR.tools.enableHtml5Elements( document ); | ||
} | ||
var editor = CKEDITOR.replace('text', { | ||
language : "zh-cn", | ||
filebrowserUploadMethod: "form", | ||
filebrowserUploadUrl : "{$manage}/upload.php?type=Files", | ||
filebrowserImageUploadUrl : "{$manage}/upload.php?type=images", | ||
width: 'auto', | ||
height: 350, | ||
}); | ||
</script> | ||
CODE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
# WindsCkEditor | ||
Typecho的ckEditor编辑器 | ||
|
||
版本号v1.0.0 | ||
Typecho1.2编辑器插件,集成最新CkEditor4.21编辑器。 | ||
支持代码插入,支持图片,附件上传(使用系统集成的附件上传)。 | ||
支持原有附件点击添加到编辑器中 | ||
|
||
github:[https://github.com/awinds/WindsCkEditor](https://github.com/awinds/WindsCkEditor) | ||
|
||
## 使用方法 | ||
|
||
1.下载本插件,放在 `usr/plugins/` 目录中 | ||
|
||
2.文件夹名改为 `WindsCkEditor` | ||
|
||
3.登录管理后台,激活插件 | ||
|
||
## 配置 | ||
|
||
### 说明 | ||
- ckEditor为最新的4.21版本,已包括CodeSnippet插件,可以自定义toobar,在`WindsCkEditor/ckeditor/config.js`配置。 | ||
|
||
- 通过`WindsCkEditor/ckeditor/samples/toolbarconfigurator/index.html`可以自定义config项。 | ||
|
||
- 后续可以自已升级ckEditor,去[https://ckeditor.com/ckeditor-4/download/](https://ckeditor.com/ckeditor-4/download/) 下载后更新到ckeditor目录。 | ||
|
||
- 图片上传使用toolbar上`图像`,附件上传使用toolbar上`插入/编辑超链接`,需要在`设置-允许上传的文件类型`中打开上传的类型。 | ||
|
||
### 默认配置 | ||
``` | ||
{ | ||
language : "zh-cn", | ||
width: 'auto', | ||
height: 350, | ||
} | ||
``` | ||
可以自己在Plugin.php修改 |
Oops, something went wrong.