Skip to content

Commit bfc652b

Browse files
author
wangfupeng
committed
v2.1.8 修复几个bug
1 parent 975054c commit bfc652b

4 files changed

Lines changed: 61 additions & 13 deletions

File tree

dist/js/wangEditor.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ _e(function (E, $) {
172172
var $valueContainer = editor.$valueContainer;
173173
var currentValue = '';
174174
var nodeName = editor.valueNodeName;
175-
176175
if (nodeName === 'div') {
177176
currentValue = $valueContainer.html();
178177
} else if (nodeName === 'textarea') {
@@ -1781,7 +1780,7 @@ _e(function (E, $) {
17811780
self.hide();
17821781
});
17831782

1784-
E.$window.scroll(function () {
1783+
E.$window.scroll(function (e) {
17851784
self.hide();
17861785
});
17871786

@@ -2608,6 +2607,12 @@ _e(function (E, $) {
26082607
if (html === undefined) {
26092608
// 取值,直接触发jquery原生html方法
26102609
result = $.fn.html.call($txt);
2610+
2611+
// 替换 html 中,src和href属性中的 & 字符。
2612+
// 因为 .html() 或者 .innerHTML 会把所有的 & 字符都改成 & 但是 src 和 href 中的要保持 &
2613+
result = result.replace(/(href|src)\=\"(.*)\"/igm, function (a, b, c) {
2614+
return b + '="' + c.replace('&', '&') + '"';
2615+
});
26112616
} else {
26122617
// 赋值,需要同时给 textarea 赋值
26132618
result = $.fn.html.call($txt, html);
@@ -5969,9 +5974,15 @@ _e(function (E, $) {
59695974
var lang = $langSelect ? $langSelect.val() : ''; // 获取高亮语言
59705975
var langClass = '';
59715976
var doHightlight = function () {
5972-
$('pre code').each(function(i, block) {
5973-
if (window.hljs) {
5977+
$txt.find('pre code').each(function (i, block) {
5978+
var $block = $(block);
5979+
if ($block.attr('codemark')) {
5980+
// 有 codemark 标记的代码块,就不再重新格式化了
5981+
return;
5982+
} else if (window.hljs) {
5983+
// 新代码块,格式化之后,立即标记 codemark
59745984
window.hljs.highlightBlock(block);
5985+
$block.attr('codemark', '1');
59755986
}
59765987
});
59775988
};
@@ -7397,10 +7408,10 @@ _e(function (E, $) {
73977408
e.preventDefault();
73987409
e.stopPropagation();
73997410

7400-
}).on('click keypress scroll', function (e) {
7411+
}).on('click keydown scroll', function (e) {
74017412
setTimeout(hide, 100);
74027413
});
7403-
E.$body.on('click keypress scroll', function (e) {
7414+
E.$body.on('click keydown scroll', function (e) {
74047415
setTimeout(hide, 100);
74057416
});
74067417
});
@@ -7932,7 +7943,7 @@ _e(function (E, $) {
79327943
e.preventDefault();
79337944
e.stopPropagation();
79347945

7935-
}).on('click keypress scroll', function (e) {
7946+
}).on('click keydown scroll', function (e) {
79367947
if (!isOnDrag) {
79377948
setTimeout(hide, 100);
79387949
}
@@ -8048,7 +8059,7 @@ _e(function (E, $) {
80488059
clearTimeout(hideTimeoutId);
80498060
}
80508061
hideTimeoutId = setTimeout(hide, 500);
8051-
}).on('click keypress scroll', function (e) {
8062+
}).on('click keydown scroll', function (e) {
80528063
setTimeout(hide, 100);
80538064
});
80548065
// $toolbar 绑定事件

dist/js/wangEditor.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wangeditor",
33
"filename": "dist/js/wangEditor.min.js",
4-
"version": "2.1.7",
4+
"version": "2.1.8",
55
"description": "wangEditor - 基于javascript和css开发的 Web富文本编辑器, 轻量、简洁、易用、开源免费",
66
"homepage": "http://wangeditor.github.io/",
77
"keywords": ["wangEditor", "富文本编辑器"],

test/test-js-head.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>test</title>
6+
<link rel="stylesheet" type="text/css" href="../dist/css/wangEditor.min.css">
7+
<style type="text/css">
8+
#editor-trigger {
9+
height: 400px;
10+
/*max-height: 500px;*/
11+
}
12+
.container {
13+
width: 100%;
14+
margin: 0 auto;
15+
position: relative;
16+
}
17+
</style>
18+
<script type="text/javascript" src="../dist/js/lib/jquery-1.10.2.min.js"></script>
19+
<script type="text/javascript" src="../dist/js/wangEditor.js"></script>
20+
<script type="text/javascript">
21+
// var editor = new wangEditor('editor-trigger');
22+
// editor.create();
23+
$(function () {
24+
var editor = new wangEditor('editor-trigger');
25+
editor.create();
26+
});
27+
</script>
28+
</head>
29+
<body>
30+
<p>wangEditor2.0 支持 IE8 浏览器</p>
31+
<div id="editor-container" class="container">
32+
<div id="editor-trigger">
33+
<p>请输入内容...</p>
34+
</div>
35+
</div>
36+
</body>
37+
</html>

0 commit comments

Comments
 (0)