-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Fixed Koenig editor failing to load in React admin shell #25675
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
base: main
Are you sure you want to change the base?
Conversation
The Koenig editor was not loading when using `yarn dev:forward` because
`Settings.tsx` was passing an empty no-op function for `fetchKoenigLexical`.
After implementing a proper `fetchKoenigLexical` function that loaded the
UMD bundle from `/ghost/assets/koenig-lexical/`, a second issue emerged:
React hooks errors ("Invalid hook call", "Cannot read properties of null
reading 'useMemo'"). This happened because the UMD bundle includes its own
bundled React, which conflicted with Vite's React instance in dev mode.
The fix imports `@tryghost/koenig-lexical` as an ESM module directly,
allowing Vite to handle React deduplication. This required adding the
package as a dependency to the admin app.
Changes:
- Added `@tryghost/koenig-lexical` dependency to apps/admin
- Created `fetchKoenigLexical.ts` utility that imports the ESM module
- Updated `Settings.tsx` to use the new utility function
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #25675 +/- ##
==========================================
+ Coverage 72.02% 72.11% +0.09%
==========================================
Files 1533 1535 +2
Lines 117438 117582 +144
Branches 14040 14111 +71
==========================================
+ Hits 84580 84800 +220
+ Misses 31850 31774 -76
Partials 1008 1008
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Tested this out and it's working locally, but I'm still getting the red "An error occurred loading editor. Please refresh and try again." error when I tried deploying this to staging. Not sure if it's an issue with the code in this PR, or if we're maybe not versioning the assets properly, so deploying a PR to a staging site isn't using the correct files. |
ref https://linear.app/ghost/issue/BER-3111/
The Koenig editor was not loading when using
yarn dev:forwardbecauseSettings.tsxwas passing an empty no-op function forfetchKoenigLexical.After implementing a proper
fetchKoenigLexicalfunction that loaded the UMD bundle from/ghost/assets/koenig-lexical/, a second issue emerged: React hooks errors ("Invalid hook call", "Cannot read properties of null reading 'useMemo'"). This happened because the UMD bundle includes its own bundled React, which conflicted with Vite's React instance in dev mode.The fix imports
@tryghost/koenig-lexicalas an ESM module directly, allowing Vite to handle React deduplication. This required adding the package as a dependency to the admin app.Changes:
@tryghost/koenig-lexicaldependency to apps/adminfetchKoenigLexical.tsutility that imports the ESM moduleSettings.tsxto use the new utility function