我有一个允许contenteditable的div。
<div contenteditable="true">
</div>
我想过滤所有html标签copy&amp;从用户粘贴(除外),如何在Dart代码中实现?
答案 0 :(得分:1)
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
- Detect a paste event in a contenteditable