Skip to content

Commit

Permalink
feat: 增加方法
Browse files Browse the repository at this point in the history
  • Loading branch information
ganzw committed Jan 30, 2016
1 parent a13dcc4 commit 94afd6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ artEditor是一款基于jQuery的移动端富文本编辑器,支持插入图
图片上传失败回调


# Methods

### getValue
获取值,$('#content').getValue()
### setValue
设置值,$('#content').setValue('<div></div>')

# Example
html:
```
Expand Down Expand Up @@ -62,3 +70,9 @@ $('#content').artEditor({

# Issues
[new Issue](https://github.com/baixuexiyang/artEditor/issues/new)


# Release
+增加获取值和设置值的方法
+去掉粘贴时过滤不允许的HTML标签
+插入图片自动换行
5 changes: 3 additions & 2 deletions artEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ $.fn.extend({
hasLastChild = hasLastChild.previousSibling;
hasR.removeChild(e);
}
range.insertNode(range.createContextualFragment("<br/>"));
range.insertNode(hasR);
if (hasLastChild) {
range.setEndAfter(hasLastChild);
Expand All @@ -92,13 +93,13 @@ $.fn.extend({
pasteHandler: function() {
var _this = this;
$(this).on("paste", function() {
var content = $(this).html();
/*var content = $(this).html();
valiHTML = _this._opt.validHtml;
content = content.replace(/_moz_dirty=""/gi, "").replace(/\[/g, "[[-").replace(/\]/g, "-]]").replace(/<\/ ?tr[^>]*>/gi, "[br]").replace(/<\/ ?td[^>]*>/gi, "&nbsp;&nbsp;").replace(/<(ul|dl|ol)[^>]*>/gi, "[br]").replace(/<(li|dd)[^>]*>/gi, "[br]").replace(/<p [^>]*>/gi, "[br]").replace(new RegExp("<(/?(?:" + valiHTML.join("|") + ")[^>]*)>", "gi"), "[$1]").replace(new RegExp('<span([^>]*class="?at"?[^>]*)>', "gi"), "[span$1]").replace(/<[^>]*>/g, "").replace(/\[\[\-/g, "[").replace(/\-\]\]/g, "]").replace(new RegExp("\\[(/?(?:" + valiHTML.join("|") + "|img|span)[^\\]]*)\\]", "gi"), "<$1>");
if (!/firefox/.test(navigator.userAgent.toLowerCase())) {
content = content.replace(/\r?\n/gi, "<br>");
}
$(this).html(content);
$(this).html(content);*/
});
},
placeholderHandler: function() {
Expand Down
7 changes: 1 addition & 6 deletions artEditor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94afd6f

Please sign in to comment.