singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.53k stars 810 forks source link

Prevent Pasting BlockEmbed.imageType with Ctrl + V on Desktop from Creating a Block #1905

Open sandapilarius opened 3 months ago

sandapilarius commented 3 months ago

Is there an existing issue for this?

The question

When attempting to paste using Ctrl + V on desktop, I want it to do nothing if it is BlockEmbed.imageType. Therefore, I created an EmbedBuilder as shown below, but it creates a line block. Is there a method that can do absolutely nothing without forcing the return of a Widget?

class ImageEmbedBuilder extends EmbedBuilder {
  @override
  String get key => BlockEmbed.imageType;

  @override
  bool get expanded => false;

  @override
  Widget build(
    BuildContext context,
    QuillController controller,
    Embed node,
    bool readOnly,
    bool inline,
    TextStyle textStyle,
  ) {
    return const SizedBox.shrink();
  }
}
AtlasAutocode commented 1 month ago

I see that no one has responded to this request. So, I guess, we need more information to understand what the question is.

For example, you say you are pasting a BlockEmbed.imageType - but this implies you have copied BlockEmbed.imageType in the first place! I don't understand why you copy and then don't want to paste? Can you explain what you are trying to do?

CatHood0 commented 1 month ago

If he want to avoid pasting for Embed blocks, then he shouldn't use FlutterQuillExtensions.useSuperClipboardPlugin() that makes posible paste Embed blocks from the Clipboard

AtlasAutocode commented 1 month ago

Interesting. I know you can copy-paste embeds within the editor, but I didn't know you could copy-paste embeds between apps using the extensions. We need to know why the OP wants to do this and what they are doing.