如何在contenteditable div中过滤用户粘贴的内容?

时间:2015-08-05 02:33:34

标签: dart

我有一个允许contenteditable的div。

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

我想过滤所有html标签copy&amp;从用户粘贴(除外),如何在Dart代码中实现?

1 个答案:

答案 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