-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wasm): avoid using quill_controller_web_stub.dart for web which w…
…ill throw exception
- Loading branch information
Showing
2 changed files
with
34 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
// TODO: This might be removed from here or moved to quill_native_bridge | ||
|
||
// This file should not be exported as the APIs in it are meant for internal usage only | ||
|
||
import 'dart:async' show StreamSubscription; | ||
// import 'dart:async' show StreamSubscription; | ||
|
||
import 'package:web/web.dart'; | ||
// import 'package:web/web.dart'; | ||
|
||
import '../quill_controller.dart'; | ||
// ignore: unused_import | ||
import '../quill_controller_rich_paste.dart'; | ||
// import '../quill_controller.dart'; | ||
// // ignore: unused_import | ||
// import '../quill_controller_rich_paste.dart'; | ||
|
||
/// Paste event for the web. | ||
/// | ||
/// Will be `null` when [QuillControllerWeb.initializeWebPasteEvent] was not called | ||
/// or the subscription was canceled due to calling [QuillControllerWeb.cancelWebPasteEvent] | ||
/// | ||
/// See: https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event | ||
StreamSubscription? _webPasteEventSubscription; | ||
// /// Paste event for the web. | ||
// /// | ||
// /// Will be `null` when [QuillControllerWeb.initializeWebPasteEvent] was not called | ||
// /// or the subscription was canceled due to calling [QuillControllerWeb.cancelWebPasteEvent] | ||
// /// | ||
// /// See: https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event | ||
// StreamSubscription? _webPasteEventSubscription; | ||
|
||
extension QuillControllerWeb on QuillController { | ||
void initializeWebPasteEvent() { | ||
_webPasteEventSubscription = | ||
EventStreamProviders.pasteEvent.forTarget(window.document).listen((e) { | ||
// TODO: See if we can support markdown paste | ||
final html = e.clipboardData?.getData('text/html'); | ||
if (html == null) { | ||
return; | ||
} | ||
// TODO: Temporarily disable the rich text pasting feature as a workaround | ||
// due to issue https://github.com/singerdmx/flutter-quill/issues/2220 | ||
// pasteHTML(html: html); | ||
}); | ||
} | ||
// extension QuillControllerWeb on QuillController { | ||
// void initializeWebPasteEvent() { | ||
// _webPasteEventSubscription = | ||
// EventStreamProviders.pasteEvent.forTarget(window.document).listen((e) { | ||
// // TODO: See if we can support markdown paste | ||
// final html = e.clipboardData?.getData('text/html'); | ||
// if (html == null) { | ||
// return; | ||
// } | ||
// // TODO: Temporarily disable the rich text pasting feature as a workaround | ||
// // due to issue https://github.com/singerdmx/flutter-quill/issues/2220 | ||
// // pasteHTML(html: html); | ||
// }); | ||
// } | ||
|
||
void cancelWebPasteEvent() { | ||
_webPasteEventSubscription?.cancel(); | ||
_webPasteEventSubscription = null; | ||
} | ||
} | ||
// void cancelWebPasteEvent() { | ||
// _webPasteEventSubscription?.cancel(); | ||
// _webPasteEventSubscription = null; | ||
// } | ||
// } |