Super Editor

repository·main·Indexed 24 days ago

https://github.com/flutter-bounty-hunters/super_editor

A highly extensible and configurable text editing and document rendering toolkit for Flutter. Designed to be backend-agnostic, it includes packages such as attributed_text, super_text_layout, super_editor_clipboard for rich text copy/paste, and super_editor_spellcheck. The toolkit provides the SuperEditor widget, which utilizes a Document, DocumentComposer, and Editor to manage rich text content and user selection.

Tokens
31.9K
Snippets
93
Records
153
Agent score
81%

What's inside super_editor

  1. Overview of Super Editor

    main
    Super Editor is an open-source, configurable, and extensible text editor and document renderer for Flutter. It is designed to work with any backend, allowing developers to plug in their own data storage and synchronization solutions. The project is part of a larger document editing toolkit that includes super_text_layout and attributed_text.
  2. Building AI/GPT-style experiences with Super Editor

    main

    Super Editor does not provide a built-in Large Language Model (LLM). Instead, it provides UI tools and patterns to help you build chat-style interfaces (like ChatGPT or Gemini) where an LLM generates text based on user queries.

    To create a seamless AI experience, you can use Super Editor to implement features like streaming text effects, such as fading in content as the LLM generates it.

  3. What is the SuperKeyboard Unified API?

    main
    The super_keyboard plugin provides a "unified API" via the SuperKeyboard class. This API acts as a "lowest common denominator" interface that provides consistent functionality across all supported platforms (Android and iOS). Use the unified API when you need keyboard functionality that behaves identically regardless of the underlying platform and you do not require platform-specific customizations.
  4. Use platform-specific APIs for iOS and Android

    main

    If you need more detailed information than the unified API provides, or if you need to handle platform-specific reporting behaviors, you can use the dedicated platform APIs:

    • iOS: Use SuperKeyboardIOS.
    • Android: Use SuperKeyboardAndroid.

    These APIs are provided because platforms report keyboard state and height differently, and the unified API is limited to the features common to both.

  5. How SoftwareKeyboardHeightSimulator works

    main

    The SoftwareKeyboardHeightSimulator works by intercepting messages sent over the TextInput platform channel.

    When a widget (like a TextField) requests focus, Flutter sends messages such as TextInput.show. The simulator intercepts these and:

    1. Notifies listeners that the keyboard state has changed to KeyboardState.opening (or closing).
    2. Triggers an animation that increases the MediaQuery bottom insets, simulating the physical space occupied by a software keyboard.
  6. Choosing between Sliver and RenderBox embedding for SuperEditor

    main

    When embedding SuperEditor within an existing scrolling system, you have two primary architectural choices:

    1. Use SuperEditor as a Sliver: This is the preferred method. It is built specifically for this purpose and integrates better with Flutter's scrolling and layout engine. Use this when working with CustomScrollView or other sliver-based layouts.
    2. Use SuperEditor as a RenderBox: This involves expanding SuperEditor to its maximum height by setting shrinkWrap: true. This is useful for ListView or other box-based scrollables, but it requires that all components within the editor (including custom ones) support intrinsic height to avoid layout issues.
  7. Configure Markdown syntax with MarkdownSyntax

    main

    The serializeDocumentToMarkdown function accepts a syntax parameter of type MarkdownSyntax to control how Markdown is generated.

    There are two primary options:

    • MarkdownSyntax.superEditor: Standard Markdown plus custom syntaxes (e.g., paragraph alignment like :--- for left or :---: for center).
    • MarkdownSyntax.normal: Standard Markdown syntax as defined by the markdown package.

    MarkdownSyntax.superEditor is the default.

    final markdown = serializeDocumentToMarkdown(
      superEditorDocument,
      syntax: MarkdownSyntax.normal,
    );