Skip to content

fix(paste): pass actual read-only state to tools created for paste config - #3064

Open
Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2878-readonly-tool-init
Open

Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2878-readonly-tool-init

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

Closes #2878.

Paste.processTool creates a Tool instance with a hardcoded false read-only flag to inspect its paste config. Paste is prepared before ReadOnly, so custom Tools always received readOnly: false there, even when the editor started in read-only mode. Plugins that branch on this value in their constructor were set up for edit mode and then never switched, which is the double initialisation with different states described in the report.

Changes

  • Pass the configured read-only state to the Tool instance created for paste config preparation
  • Add a regression test asserting that every Tool constructor call receives true in read-only mode

Testing

  • yarn lint
  • npx cypress run --spec test/cypress/tests/readOnly.cy.ts
  • npx cypress run --spec test/cypress/tests/copy-paste.cy.ts

The new test fails without the change and passes with it.

This branch has not been deployed

No deployments
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.

Why do all Blocks get initialized twice? When you initiate the editor with readOnly true, i've got a problem with custom block tool

1 participant