如何在 contenteditable div 中过滤用户粘贴的内容?
How to filter user pasted content in contenteditable div?
我有一个 div 允许 contenteditable。
<div contenteditable="true">
</div>
我想过滤所有从用户复制和粘贴的 html 标签(除了 ),这在 Dart 代码中如何实现?
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();
});
另请参阅:
-
- Detect a paste event in a contenteditable
我有一个 div 允许 contenteditable。
<div contenteditable="true">
</div>
我想过滤所有从用户复制和粘贴的 html 标签(除了 ),这在 Dart 代码中如何实现?
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();
});
另请参阅:
-
- Detect a paste event in a contenteditable