Skip to content

Conversation

@cmraible
Copy link
Collaborator

@cmraible cmraible commented Dec 9, 2025

ref https://linear.app/ghost/issue/BER-3111/

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

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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-koenig-editor-dev-forward

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.11%. Comparing base (2ace1fa) to head (5a254af).
⚠️ Report is 11 commits behind head on main.

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              
Flag Coverage Δ
admin-tests 51.80% <ø> (+0.01%) ⬆️
e2e-tests 72.11% <ø> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cmraible cmraible added the deploy-to-staging Optionally deploy PR to staging label Dec 10, 2025
@cmraible
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-to-staging Optionally deploy PR to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants