Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical] Chore: make unable to find active editor state error more descriptive about potential dependency issue #5996

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/lexical-devtools/src/lexicalForExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function getActiveEditorState(): lexical.EditorState {
'Unable to find an active editor state. ' +
'State helpers or node methods can only be used ' +
'synchronously during the callback of ' +
'editor.update() or editorState.read().',
'editor.update() or editorState.read(). ' +
'This issue can also occur if you have a mismatching ' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this is more technically correct:

Suggested change
'This issue can also occur if you have a mismatching ' +
'This issue can also occur if you have more than one copy of lexical in the same JS bundle ' +
'or you're trying to update/read state of lexical that belongs to another JS bundle.'

'or more than one copy of lexical in the same app.',
);
}

Expand All @@ -41,7 +43,9 @@ function getActiveEditor(): lexical.LexicalEditor {
'Unable to find an active editor state. ' +
'State helpers or node methods can only be used ' +
'synchronously during the callback of ' +
'editor.update() or editorState.read().',
'editor.update() or editorState.read(). ' +
'This issue can also occur if you have a mismatching ' +
'or more than one copy of lexical in the same app.',
);
}

Expand Down
8 changes: 6 additions & 2 deletions packages/lexical/src/LexicalUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export function getActiveEditorState(): EditorState {
'Unable to find an active editor state. ' +
'State helpers or node methods can only be used ' +
'synchronously during the callback of ' +
'editor.update() or editorState.read().',
'editor.update() or editorState.read(). ' +
'This issue can also occur if you have a mismatching ' +
'or more than one copy of lexical in the same app.',
);
}

Expand All @@ -110,7 +112,9 @@ export function getActiveEditor(): LexicalEditor {
'Unable to find an active editor. ' +
'This method can only be used ' +
'synchronously during the callback of ' +
'editor.update().',
'editor.update(). ' +
'This issue can also occur if you have a mismatching ' +
'or more than one copy of lexical in the same app.',
);
}

Expand Down
7 changes: 4 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ async function build(name, inputFile, outputPath, outputFile, isProd, format) {
}),
// Extract error codes from invariant() messages into a file.
{
transform(source) {
// eslint-disable-next-line no-unused-expressions
extractCodes && findAndRecordErrorCodes(source);
transform(source, id) {
if (extractCodes && id.match(/\.(js|jsx|ts|tsx|mts|mjs|cjs|cts)$/)) {
findAndRecordErrorCodes(source);
}
return source;
},
},
Expand Down
Loading
Loading