如何在contenteditable div中过滤用户粘贴的内容? [英] How to filter user pasted content in contenteditable div?

查看:440
本文介绍了如何在contenteditable div中过滤用户粘贴的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个允许contenteditable的div。

I have a div which allow contenteditable.

<div contenteditable="true">
</div>

我想过滤所有html标签复制和

I would like to filter all html tags copy & pasted from user (except ), how this could achieve in Dart code?

推荐答案

myDiv.onPaste.listen((e) {
  // do filtering here and then insert the result imperatively
  // one or both of the following might be necessary to prevent
  // the default paste behavior happening as well.
  e.preventDefault();
  e.stopPropagation();
});

另请参阅:

- https://stackoverflow.com/a/3933677/217408

-检测内容可编辑的粘贴事件

这篇关于如何在contenteditable div中过滤用户粘贴的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆