feat(editor): add copy text action for toggle and list blocks#8819
Open
HarishKolla1 wants to merge 1 commit into
Open
feat(editor): add copy text action for toggle and list blocks#8819HarishKolla1 wants to merge 1 commit into
HarishKolla1 wants to merge 1 commit into
Conversation
Contributor
Reviewer's GuideAdds 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 actionsequenceDiagram
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())
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
OptionAction.copyTextlabel is currently hard-coded as'Copy text'; consider adding a localized key (similar tocopyLinkToBlock) so it respects the existing i18n setup. copyTextis added tostandardActionsfor 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 whendeltais null; consider filtering out nodes withoutdeltaand 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Summary by Sourcery
Add a block menu action to copy the plain text content of selected blocks in the editor.
New Features:
Enhancements: