Skip to content

Expose selected text and blocks from Selection API#3011

Open
RomeoApps wants to merge 1 commit into
codex-team:nextfrom
RomeoApps:codex/native-multiblock-text-selection-2410
Open

Expose selected text and blocks from Selection API#3011
RomeoApps wants to merge 1 commit into
codex-team:nextfrom
RomeoApps:codex/native-multiblock-text-selection-2410

Conversation

@RomeoApps

Copy link
Copy Markdown

Summary

Adds a small public selection API for the multiblock selection use case discussed in #2410:

  • api.selection.getSelectedText() returns native editor selection text when a normal text range is active, or selected-block text for Editor.js cross-block selections.
  • api.selection.getSelectedBlocks() returns the selected BlockAPI[].
  • Block-selection copy text and selected-block text now share the same sanitized fragment path.
  • Native editable text drags are preserved instead of being converted into whole-block selection.

Validation

  • git diff --check origin/next..HEAD
  • YARN_IGNORE_ENGINES=1 yarn eslint src/components/modules/crossBlockSelection.ts src/components/modules/blockSelection.ts src/components/modules/api/selection.ts test/cypress/tests/selection.cy.ts --quiet
  • YARN_IGNORE_ENGINES=1 yarn cypress run --spec test/cypress/tests/selection.cy.ts -> 3 passing

Prior broader validation on this branch also passed yarn lint, yarn build:test, yarn build, full yarn test:e2e, and a live browser probe. I did not rerun the full suite in this PR refresh pass.

Notes

This does not claim a complete replacement for browser-native arbitrary cross-block text selection behavior. It adds the requested programmatic access to selected text/blocks and preserves native editable drags where they already exist.

Refs #2410.

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.

1 participant