Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validHtml 实际没有效果 #52

Open
pool611 opened this issue Jan 2, 2018 · 2 comments
Open

validHtml 实际没有效果 #52

pool611 opened this issue Jan 2, 2018 · 2 comments

Comments

@pool611
Copy link

pool611 commented Jan 2, 2018

粘贴时,去除不合法的html标签
但代码中获取的是粘贴前的html,所以也相当于没有过滤代码就直接粘贴了
建议用var clipboardData = e.clipboardData || e.originalEvent && e.originalEvent.clipboardData;
先获取到剪切板的数据,再getData出来,再把这里面的数据进行过滤吧

@siliushi
Copy link
Owner

siliushi commented Jan 3, 2018

麻烦提供下测试环境

@pool611
Copy link
Author

pool611 commented Jan 3, 2018

跟测试环境无关,我是看的您的代码逻辑
//应该是想打印剪切板的内容
console.log(e.clipboardData.items);
//编辑器里的包含html标签的内容存到content中
var content = $(this).html();
//打印content
console.log(content);
//获得配置的过滤符号
valiHTML = _this._opt.validHtml;
//replace替换,替换的编辑器里的内容,而不是剪切板的内容
content = content.replace(/_moz_dirty=""/gi, "")........
if(...)
{...}
//用这个方法设置编辑器里的内容,最好还是document.execCommand('insertHTML', false, content);比较
//好吧,个人觉得
$(this).html(content);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants