Skip to content

feat(editor): add copy text action for toggle and list blocks#8819

Open
HarishKolla1 wants to merge 1 commit into
AppFlowy-IO:mainfrom
HarishKolla1:issue-8800-copy-text
Open

feat(editor): add copy text action for toggle and list blocks#8819
HarishKolla1 wants to merge 1 commit into
AppFlowy-IO:mainfrom
HarishKolla1:issue-8800-copy-text

Conversation

@HarishKolla1

@HarishKolla1 HarishKolla1 commented Jun 16, 2026

Copy link
Copy Markdown

Feature Preview

Adds a "Copy text" action to the block menu for toggle, bulleted list, and numbered list blocks.

Users can copy the block text directly from the 3-dot menu, similar to Notion.

Fixes #8800


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 a block menu action to copy the plain text content of selected blocks in the editor.

New Features:

  • Introduce a Copy text option in the block action menu for applicable editor blocks to copy their text content to the clipboard.

Enhancements:

  • Ensure Copy text operates on the current block or all blocks in a block selection and normalizes their text content before copying.

@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sourcery-ai

sourcery-ai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a new Copy text block action and wires it through the block actions enum, UI configuration, and cubit to copy the selected block(s) plain text to the clipboard.

Sequence diagram for the new Copy text block action

sequenceDiagram
  actor User
  participant BlockMenu
  participant BlockActionOptionCubit
  participant EditorState
  participant ClipboardService

  User->>BlockMenu: tap OptionAction.copyText
  BlockMenu->>BlockActionOptionCubit: emit OptionAction.copyText with node
  BlockActionOptionCubit->>BlockActionOptionCubit: _copyText(node)
  BlockActionOptionCubit->>EditorState: selectionType
  BlockActionOptionCubit->>EditorState: selection
  alt selectionType == SelectionType.block and selection != null
    BlockActionOptionCubit->>EditorState: getNodesInSelection(selection.normalized)
  else
    BlockActionOptionCubit->>BlockActionOptionCubit: use [node] as nodes
  end
  loop for each n in nodes
    BlockActionOptionCubit->>BlockActionOptionCubit: n.delta
    BlockActionOptionCubit->>BlockActionOptionCubit: delta.toPlainText()
  end
  BlockActionOptionCubit->>ClipboardService: setData(ClipboardServiceData)
  ClipboardService-->>BlockActionOptionCubit: clipboard updated
  BlockActionOptionCubit->>BlockActionOptionCubit: emit(BlockActionOptionState())
Loading

File-Level Changes

Change Details Files
Introduce a Copy text option action that maps to an icon and label and is included in the standard block actions list for supported block types.
  • Extend the OptionAction enum with a copyText value.
  • Associate the new action with the FlowySvgs.text_s icon in the optionIcon getter.
  • Provide a user-facing label for the new action and add it to the standardActions list built in editor configuration.
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option/option_actions.dart
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart
Implement behavior for the Copy text action to copy the plain text of the current or selected blocks to the clipboard and trigger a UI update.
  • Add handling of the copyText case in BlockActionOptionCubit.onAction to call a new _copyText helper.
  • Implement _copyText to resolve either the single node or all nodes in the current block selection, concatenate their delta plain text with newlines, and push it to ClipboardService.
  • Emit a fresh BlockActionOptionState after copying to cause the UI to refresh.
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_cubit.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#8800 Add a 'Copy text' action to the 3-dot block menu for toggle, bulleted list, and numbered list blocks.
#8800 Implement functionality so that the 'Copy text' action copies the text content of the selected toggle or list block(s) to the clipboard.

Possibly linked issues


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 left some high level feedback:

  • The OptionAction.copyText label is currently hard-coded as 'Copy text'; consider adding a localized key (similar to copyLinkToBlock) so it respects the existing i18n setup.
  • copyText is added to standardActions for all block types in _buildOptionActions, but the description suggests it should apply only to toggle and list blocks; consider restricting it to the relevant block types to avoid exposing it where it may not behave as expected.
  • In _copyText, you always join block texts with a newline and include empty strings when delta is null; consider filtering out nodes without delta and trimming leading/trailing newlines so the clipboard content is cleaner.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `OptionAction.copyText` label is currently hard-coded as `'Copy text'`; consider adding a localized key (similar to `copyLinkToBlock`) so it respects the existing i18n setup.
- `copyText` is added to `standardActions` for all block types in `_buildOptionActions`, but the description suggests it should apply only to toggle and list blocks; consider restricting it to the relevant block types to avoid exposing it where it may not behave as expected.
- In `_copyText`, you always join block texts with a newline and include empty strings when `delta` is null; consider filtering out nodes without `delta` and trimming leading/trailing newlines so the clipboard content is cleaner.

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.

[FR] Notion-like copy ability

2 participants