Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting from Microsoft Word raises Exceptions #2516

Open
1 task done
lundmark opened this issue Mar 17, 2025 · 6 comments
Open
1 task done

Pasting from Microsoft Word raises Exceptions #2516

lundmark opened this issue Mar 17, 2025 · 6 comments
Labels
awaiting response Pending additional information or feedback from the issue creator bug Something isn't working

Comments

@lundmark
Copy link

Have you checked for an existing issue?

Flutter Quill Version

11.0.0

Steps to Reproduce

  1. Start the flutter quill test
  2. Open a document in Microsoft Word
  3. Copy a formatted section of text from Microsoft Word
  4. Paste into the flutter editor.
  5. Observe exception in default_clipboard_instance.dart line 19.

It seems like it's trying (and failing) to parse the html-version of the paste that's being sent. Microsoft Word also puts things in several different clipboards, among other the rich text which I think should be preferred in this way if the html-parser raises and exception.

Expected results

I'd expect the rich-text formatted text from word to be pasted into the Quill editor, appearing as

Actual results

Multiple exceptions and no text pasted into the Quill editor.

Additional Context

No response

@lundmark lundmark added the bug Something isn't working label Mar 17, 2025
@EchoEllet
Copy link
Collaborator

Are you testing on Windows? Could you please provide the error details including the stack trace?

@EchoEllet EchoEllet added the awaiting response Pending additional information or feedback from the issue creator label Mar 18, 2025
@nano1209
Copy link

same problem, when paste from word in Windows (desktop app)

@lundmark
Copy link
Author

Hi!

Yes this is on windows.

Here is the callstack:

_Utf8Decoder.convertSingle (d:\work\flutter_sdk\flutter\bin\cache\pkg\sky_engine\lib\_internal\vm\lib\convert_patch.dart:1855) Utf8Decoder.convert (d:\work\flutter_sdk\flutter\bin\cache\pkg\sky_engine\lib\convert\utf.dart:351) Utf8Codec.decode (d:\work\flutter_sdk\flutter\bin\cache\pkg\sky_engine\lib\convert\utf.dart:64) Utf8Pointer.toDartString (c:\Users\simon\AppData\Local\Pub\Cache\hosted\pub.dev\ffi-2.1.3\lib\src\utf8.dart:48) QuillNativeBridgeWindows.getClipboardHtml (c:\Users\simon\AppData\Local\Pub\Cache\hosted\pub.dev\quill_native_bridge_windows-0.0.1\lib\quill_native_bridge_windows.dart:87) QuillNativeBridge.getClipboardHtml (c:\Users\simon\AppData\Local\Pub\Cache\hosted\pub.dev\quill_native_bridge-11.0.0\lib\quill_native_bridge.dart:64) DefaultClipboardService.getHtmlText (d:\work\code\flutter_quill\flutter-quill\lib\src\editor_toolbar_controller_shared\clipboard\default_clipboard_service.dart:19) <asynchronous gap> (Unknown Source:0) QuillControllerRichPaste.pasteHTML.getHTML (d:\work\code\flutter_quill\flutter-quill\lib\src\controller\clipboard\quill_controller_rich_paste.dart:25) <asynchronous gap> (Unknown Source:0) QuillControllerRichPaste.pasteHTML (d:\work\code\flutter_quill\flutter-quill\lib\src\controller\clipboard\quill_controller_rich_paste.dart:36) <asynchronous gap> (Unknown Source:0) QuillController.clipboardPaste (d:\work\code\flutter_quill\flutter-quill\lib\src\controller\quill_controller.dart:572) <asynchronous gap> (Unknown Source:0) QuillRawEditorState.pasteText (d:\work\code\flutter_quill\flutter-quill\lib\src\editor\raw_editor\raw_editor_state.dart:145) <asynchronous gap> (Unknown Source:0)

And the exception is:
FormatException (FormatException: Unexpected extension byte (at offset 52848))

It is not a 100% bug and depends on what you paste in. When I try to paste in other stuff, like something easy, then the following can happen:

SourceURL:file:///<REDACTED DOCUMENT NAME>Here is some text I want to copy from word

Where "Here is some text I want to copy from word" was the text in the word document I copied.

@EchoEllet
Copy link
Collaborator

Could you try using the quill_super_clipboard implementation to see if this issue is reproducible?

Instructions

Add the dependency:

flutter pub add quill_super_clipboard

Then call QuillSuperClipboard.use:

import 'package:quill_super_clipboard/quill_super_clipboard.dart';

QuillSuperClipboard.use();

The issue might be with getClipboardHtml or html_formatter.dart or the HTML-to-delta parser.

Last time I tested on Windows 10 VM and didn't found any issues.

@CatHood0 CatHood0 added awaiting response Pending additional information or feedback from the issue creator and removed awaiting response Pending additional information or feedback from the issue creator labels Mar 18, 2025
@EchoEllet
Copy link
Collaborator

This is the related line however we need to conform if this issue is reproducible with super_clipboard.

@lundmark
Copy link
Author

Sorry, I haven't had the time to try it out with super clipboard yet. Will let you know as soon as I get some time to set it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Pending additional information or feedback from the issue creator bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants