Koenig Editor Engine

repository·main·Indexed 43 days ago

https://github.com/tryghost/koenig

The editor engine for Ghost, built upon the Lexical framework. Koenig handles content creation, node management, and transformations within the Ghost ecosystem, providing packages for HTML rendering, Lexical state conversion, and default node/card definitions.

Tokens
29.6K
Snippets
118
Records
134
Agent score
54%

What's inside Koenig

  1. Styling and Assets in Koenig Lexical

    main

    CSS

    • Framework: Use Tailwind classes where possible.
    • Scoping: All styles are scoped under the .koenig-lexical class to prevent collisions. PostCSS nesting is supported.
    • Inclusion: Styles in src/styles/ are included in the final built module. Styles in demo/*.css are only for the demo and are excluded from the build.
    • Packaging: Styles are bundled inside the JS file to allow for a single module import.

    SVGs

    • SVGs can be imported as React components (similar to create-react-app).
    • Files are typically stored in src/assets/.
    • All SVGs are optimized via SVGO during the build process.
  2. How @tryghost/kg-lexical-html-renderer differs from Lexical's native renderer

    main

    Unlike the standard lexical-html package from Facebook, this renderer is designed for different constraints:

    1. Output Target: It targets rendered web pages or emails rather than an interactive editor. This means node handling (especially DecoratorNodes) is optimized for static output.
    2. Target-specific Output: The HTML structure varies based on the target option (e.g., using <table> for 'email').
    3. Environment: It is primarily intended for server-side usage.
  3. How SimpleMDE works

    main
    SimpleMDE is a Markdown editor built on top of CodeMirror, which handles the parsing of Markdown syntax to provide real-time styling. It uses Font Awesome for its iconography and Marked (using GFM) to render Markdown previews. The editor includes a toolbar at the top and a status bar at the bottom to enhance the writing experience.
  4. Run Koenig in Standalone Mode

    main

    Use standalone mode to run a demo version of the editor that does not depend on Ghost. This is useful for isolated development of editor features.

    1. Run the development command.
    2. Access the editor at http://localhost:5173.

    The command renders the demo app located in demo/demo.jsx using the index.html file.

    yarn dev
  5. Develop and test @tryghost/kg-default-cards

    main

    This package is part of a monorepo managed with Lerna. To develop locally, you must first clone the top-level repository and run yarn to install all dependencies.

    Once the environment is set up, you can use the following commands:

    • yarn dev: Starts the development environment.
    • yarn lint: Runs ESLint to check for code style and errors.
    • yarn test: Runs both linting and the test suite.
    yarn dev
    yarn lint
    yarn test