yaniswang / xheditor Goto Github PK
View Code? Open in Web Editor NEWxhEditor是一个基于jQuery开发的简单迷你并且高效的在线可视化HTML编辑器。
Home Page: http://xheditor.com/
License: GNU Lesser General Public License v3.0
xhEditor是一个基于jQuery开发的简单迷你并且高效的在线可视化HTML编辑器。
Home Page: http://xheditor.com/
License: GNU Lesser General Public License v3.0
bootstrap中有一个“按钮 button.js”
http://v3.bootcss.com/javascript/#buttons-stateful
在页面加如这种按钮的特效后,会提示错误
<script>
$('#myButton').on('click', function () {
var $btn = $(this).button('loading')
// business logic...
$btn.button('reset')
})
</script>
JS错误:
Uncaught Error: cannot call methods on button prior to initialization; attempted to call method 'loading'
去掉“按钮 button.js”的调用,或者是去掉xhEditor,就正常了。
不知道用contents().find().val()设置了多少次,全都出错,不知道有没有人能指导一下我
希望作者能及时解决
编辑文章开头同时使用字体颜色和背景颜色,ubb标签嵌套关系出错。
其他情况下复杂样式也会出错
readonly和disabled都无效,建议增加api readonly(true|false)
以下是我对源代码的修改,或许可以帮到你。
var agent=navigator.userAgent.toLowerCase(),
browserMath = /(chrome)[ \/]([\w.]+)/.exec( agent ) ||
/(webkit)[ \/]([\w.]+)/.exec( agent ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( agent ) ||
/(msie) ([\w.]+)/.exec( agent ) ||
agent.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( agent ) ||
[],
browser = {};
if ( browserMath ) {
browser[ browserMath.browser ] = true;
browser.version = browserMath.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
var bMobile=/mobile/i.test(agent),
browerVer=parseFloat(browser.version),
isIE=browser.msie,
isMozilla=browser.mozilla,
isWebkit=browser.webkit,
isOpera=browser.opera,
isChrome=browser.chrome,
bAir=agent.indexOf(' adobeair/')>-1;
ie11或edge上传文件几次就会出错 sel.addRange(rng);不支持此接口
The editor's source code view allows attacker to bypass the input validation in default view by injecting javascript using IFRAME element.
Proof of Concept:
Injected the the payload <IFRAME SRC="javascript:alert('XSS');"></IFRAME> into the editor's source code view.
好像是取浏览器版本时出问题,可有替代方案?除了jQuery的那个降级插件外还有没有其它解决办法?
上传图片后文章内容不显示图片而事图片路径乱码
今天在使用xhEditor的时,发现在提交的时候非常的缓慢。通过CPU性能排查,发现了主要是这一行的问题:
a = a.replace(/^\s*(?:<(p|div)(?:\s+[^>]*?)?>)?\s*(<span(?:\s+[^>]*?)?>\s*<\/span>|<br(?:\s+[^>]*?)?>| )*\s*(?:<\/\1>)?\s*$/i, "");
然后我的输入时是这个:
var a = " 故障原因:测绘一下啊<br>故障进展:"
完整的是这个
var a = " 故障原因:测绘一下啊<br>故障进展:"
a = a.replace(/^\s*(?:<(p|div)(?:\s+[^>]*?)?>)?\s*(<span(?:\s+[^>]*?)?>\s*<\/span>|<br(?:\s+[^>]*?)?>| )*\s*(?:<\/\1>)?\s*$/i, "");
这个需要优化一下吗?还是需要我尽量避免这样的输入?谢啦>_<
(PS:不是很理解为何这句正则会运行这么慢,不知道作者能否帮我解惑一下?)
我在xhEditor代码区写入一段完整
there are some empty span tags that are coded by the script.... and are wrongly expanded by jquery/browser as per changes in jquery 3.5.1 documentation.
please see in main.js such span tags like
<span ....... />
I suggest,
please change all such occurrences with
<span........></span>
HTH
Thanks
希望作者可以修改下,很喜欢这个编辑器
或者可以看看我提的 pull request,看是否合适
用这个富文本上传,一顿好搞,服务端之前的上传代码不能用。搞了半天原来是默认html5的上传。太搞了吧。建议默认html4的上传。
链接也会转义
2222
初步检测的时候,发现是粘贴的时候,空白首行变成了
以前有一个项目需要输入英文内容。发现有时候会出现空格丢失的现象。
1.2.1 的版本。
注释的地方是bug.注释下面的一行是修改成功的。
this.showImg = function() {
var a = $(getLang(htmlImg)),
b = _this.getParent("img"),
c = $("#xheImgUrl", a),
d = $("#xheImgAlt", a),
e = $("#xheImgAlign", a),
f = $("#xheImgWidth", a),
g = $("#xheImgHeight", a),
h = $("#xheImgBorder", a),
i = $("#xheImgVspace", a),
j = $("#xheImgHspace", a),
k = $("#xheSave", a);
if (1 === b.length) {
c.val(xheAttr(b, "src")),
d.val(b.attr("alt")),
e.val(b.attr("align")),
f.val(b.attr("width")),
g.val(b.attr("height")),
h.val(b.attr("border"));
var l = b.attr("vspace"),
m = b.attr("hspace");
i.val(0 >= l ? "": l),
j.val(0 >= m ? "": m)
}
settings.upImgUrl && _this.uploadInit(c, settings.upImgUrl, settings.upImgExt),
k.click(function() {
_this.loadBookmark();
var a = c.val();
if ("" !== a && "http://" !== a) {
var k = a.toString().split(" "),
l = d.val(),
m = e.val(),
n = f.val(),
o = g.val(),
p = h.val(),
q = i.val(),
r = j.val();
if (k.length > 1) {
var s, t = '<img src="xhe_tmpurl"',
u = [];
"" !== l && (t += ' alt="' + l + '"'),
"" !== m && (t += ' align="' + m + '"'),
"" !== n && (t += ' width="' + n + '"'),
"" !== o && (t += ' height="' + o + '"'),
"" !== p && (t += ' border="' + p + '"'),
"" !== q && (t += ' vspace="' + q + '"'),
"" !== r && (t += ' hspace="' + r + '"'),
t += " />";
//for (var v in k) a = k[v],
for (var v=0,len=k.length;v<len;v++) a = k[v],
"" !== a &&
(
//a = a.split("||"),
a = a.toString().split("||"),
s = t, s = s.replace("xhe_tmpurl", a[0]),
a[1] && (s = '' + s + ""),
u.push(s)
);
_this.pasteHTML(u.join(" "))
} else if (1 === k.length && (a = k[0], "" !== a && (a = a.split("||"), 0 === b.length && (_this.pasteHTML('<img src="' + a[0] + '#xhe_tmpurl" />'), b = $('img[src$="#xhe_tmpurl"]', _doc)), xheAttr(b, "src", a[0]), "" !== l && b.attr("alt", l), "" !== m ? b.attr("align", m) : b.removeAttr("align"), "" !== n ? b.attr("width", n) : b.removeAttr("width"), "" !== o ? b.attr("height", o) : b.removeAttr("height"), "" !== p ? b.attr("border", p) : b.removeAttr("border"), "" !== q ? b.attr("vspace", q) : b.removeAttr("vspace"), "" !== r ? b.attr("hspace", r) : b.removeAttr("hspace"), a[1]))) {
var w = b.parent("a");
0 === w.length && (b.wrap("<a></a>"), w = b.parent("a")),
xheAttr(w, "href", a[1]),
w.attr("target", "_blank")
}
} else 1 === b.length && b.remove();
return _this.hidePanel(),
!1
}),
_this.saveBookmark(),
_this.showDialog(a)
},
66666666,完美兼容ie678
rt
在你们官网演示这里,我复制本地或网上的图片,粘贴进去,会一直显示加载。。,根本无法实现远程抓图&剪切板图片粘贴上传,我用的是最新的火狐和chrome,都不行,希望能解决,很期待。
The editor's source code view allows attacker to bypass the input validation in default view by injecting javascript using details.
payload:
Injected the the payload <details ontoggle="alert(1)">
into the editor's source code view.
真心不希望默认的jquery是1.4.4了
用xheditor的源代码编辑两条公告放在一个页面上,这两条公告的css会出现相互污染过
添加多级列表时,数字列表序号错误,如:
1.-------------
2.-------------
2.1-----------
2.2-----------
1.-------------
2.-------------
3.-------------
在使用编辑器 加载 一个完整的 html 页面源码时,为何自动过滤的 页面的 head,title,和包含的 script?
不知为什么作者都没有维护了,好几个项目都用。
这里我用的requirejs,虽然支持非AMD格式的JS,但是xhEditor要让他支持还需要一点手术刀。
主要是原来根据是script[src*=xheditor]来判断editor的根目录,因为这里涉及到资源加载。但是如果按AMD的方式来加载肯定无法获取正确值。
以下是我做了修改部分,目前都正常使用功能。
$('script[src*=xheditor]').each(function(){
var s=this.src;
if(s.match(/xheditor[^\/]*\.js/i)){editorRoot=s.replace(/[\?#].*$/, '').replace(/(^|[\/\\])[^\/]*$/, '$1');return false;}
});
// editorRoot 编辑器根目录,为了支持AMD,尝试直接通过HTML中查找
if (!editorRoot) {
editorRoot = $('.xheditor_config').first().attr('data-editorRoot');
}
页面需要加入
<textarea name="intro" id="intro" class="xheditor_config" data-editorroot="/r/libs/xheditor/"></textarea>
见标题
用ie8打开官网的演示地址,然后插入一个表情图片,会发现鼠标焦点无法聚焦到表情图片的后面,导致图片后面无法再输入文字,上传一张图片后,也是一样的效果,后面无法再输入文字,希望能修复一下这个bug,毕竟现在ie8使用的还是挺多的。
用xhEditor初始化一个不为空的textarea,该textarea中存在<>等内容时,xhEditor会将这些内容转换为<>,导致本来希望在页面上显示的<>括号由于是HMTL的关键字原因而被隐藏。
老大你好:
非常喜欢xheditor,有个问题就是,目前上传回调函数的参数只有文件地址信息,扩展性太局限了。我改了个暂时使用一下(https://github.com/chekun/xheditor/blob/master/xheditor-zh-cn.js),
希望老大速度出个正式版,感谢。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.