Expose selected text and blocks from Selection API#3011
Open
RomeoApps wants to merge 1 commit into
Open
Conversation
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.
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 selectedBlockAPI[].Validation
git diff --check origin/next..HEADYARN_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 --quietYARN_IGNORE_ENGINES=1 yarn cypress run --spec test/cypress/tests/selection.cy.ts-> 3 passingPrior broader validation on this branch also passed
yarn lint,yarn build:test,yarn build, fullyarn 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.