Skip to content

feat: add guillemet auto-formatting (<< and >>) to the document editor#8783

Open
kyo5uke wants to merge 1 commit into
AppFlowy-IO:mainfrom
kyo5uke:format-double-angle-guillemets
Open

feat: add guillemet auto-formatting (<< and >>) to the document editor#8783
kyo5uke wants to merge 1 commit into
AppFlowy-IO:mainfrom
kyo5uke:format-double-angle-guillemets

Conversation

@kyo5uke

@kyo5uke kyo5uke commented Jun 4, 2026

Copy link
Copy Markdown

Feature Preview

This adds two unambiguous auto-typography conversions to the document editor, building on the existing --, -> and => shortcuts:

  • <<«
  • >>»

Both reuse the existing _handleDoubleCharacterReplacement helper (so the conversion is undoable) and are registered in buildCharacterShortcutEvents. The >> handler keys off a preceding >, so it does not conflict with the existing => / -> shortcuts (which look for = / -) or the > + space block-quote toggle.

This is a small first step toward #3322. The other requests in that issue (three-character conversions such as (c)©, the ambiguous quote conversions, and an on/off "Advanced settings" toggle) are intentionally left out of this PR and can be handled separately.

Partially addresses #3322


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Add new auto-typography shortcuts in the document editor to convert double angle brackets into guillemets and wire them into the existing character shortcut system.

New Features:

  • Convert << into the left guillemet character « via a character shortcut event in the document editor.
  • Convert >> into the right guillemet character » via a character shortcut event in the document editor.

Tests:

  • Add unit tests verifying that << and >> are converted to « and » respectively and that the operations are undoable.

@CLAassistant

CLAassistant commented Jun 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sourcery-ai

sourcery-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds new document editor character shortcuts that auto-convert double angle brackets (<<, >>) into guillemets («, »), wired into the existing double-character replacement infrastructure and covered by unit tests including undo behavior.

Sequence diagram for new guillemet auto-formatting shortcuts

sequenceDiagram
  actor User
  participant Editor as DocumentEditor
  participant Shortcuts as CharacterShortcutEvent
  participant Handler as _handleDoubleCharacterReplacement

  User->>Editor: type "<"
  Editor->>Shortcuts: customFormatDoubleAngleLeftGuillemet
  Shortcuts->>Handler: _handleDoubleCharacterReplacement(editorState, character: _leftAngle, replacement: _leftGuillemet)
  Handler-->>Editor: replace "<<" with "«" (undoable)

  User->>Editor: type ">"
  Editor->>Shortcuts: customFormatDoubleAngleRightGuillemet
  Shortcuts->>Handler: _handleDoubleCharacterReplacement(editorState, character: _greater, replacement: _rightGuillemet)
  Handler-->>Editor: replace ">>" with "»" (undoable)
Loading

File-Level Changes

Change Details Files
Introduce guillemet double-angle auto-formatting using the existing double-character replacement helper.
  • Define constants for left/right angle brackets and their corresponding guillemet characters.
  • Create customFormatDoubleAngleLeftGuillemet and customFormatDoubleAngleRightGuillemet CharacterShortcutEvents that call _handleDoubleCharacterReplacement with the appropriate trigger character and replacement.
  • Register the new guillemet shortcuts in the buildCharacterShortcutEvents list so they are active across desktop, mobile, and web.
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/base/format_arrow_character.dart
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/character_shortcuts.dart
Add unit tests to validate guillemet auto-formatting and undo behavior.
  • Initialize a blank document with a single paragraph node containing a single angle bracket and place the cursor after it.
  • Execute the appropriate custom guillemet format command and assert that the document text becomes the guillemet character.
  • Execute undoCommand and assert that the document reverts to the original double angle bracket text, then dispose the editor state.
frontend/appflowy_flutter/test/unit_test/document/shortcuts/format_shortcut_test.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants