2

I have a div which allow contenteditable.

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

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

Roger Chan
  • 1,293
  • 2
  • 11
  • 24

1 Answers1

2
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();
});

See also:
- https://stackoverflow.com/a/3933677/217408
- Detect a paste event in a contenteditable

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567