1.1.11 • Published 4 days ago

@tryghost/koenig-lexical v1.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

Koenig - Lexical edition

Early stage re-write of Ghost's editor, using Lexical as the editor framework in place of mobiledoc-kit.

Development

Running the development version

Run yarn dev to start the development server to test/develop the editor standalone. This will generate a demo site from the index.html file which renders the demo app in demo/demo.jsx and makes it available on http://localhost:5173

Cards additional setup

Gif card

To see this card locally, you need to create .env.local file in koenig-lexical root package with the next data:

VITE_TENOR_API_KEY=xxx

How to get the tenor key is described here https://ghost.org/docs/config/#tenor

Bookmark & Embed cards

These cards make external web requests. Since the demo doesn't have a server to process these requests, we must fetch these resources on the front end. To do this we need to enable CORS, which is most easily done with a browser extension like 'Test CORS' for Chrome. Otherwise you will see blocked requests logging errors in the console. This can also be avoided by using test data directly without fetching via fetchEmbed.js.

Running inside Admin

# Within koenig-lexical, start all the build/preview steps
yarn dev

# Within Ghost, run `yarn dev` with `--lexical`
yarn dev --lexical

Admin should now load your local version of Lexical.

Note: if you need to run your local packages of kg-default-nodes and kg-lexical-html-renderer, you will need to run yarn link in those repositories and run the output in ghost/core. Otherwise ghost/core will be using the latest published version listed in package.json.

Project structure

/src

The main module source. /src/index.js is the entry point for the exposed module and should export everything needed to use the module from an external app.

/demo

Used for developing/demoing the editor. Renders a blank editor with all features enabled.

Set up details

CSS

Styling should be done using Tailwind classes where possible.

All styles are scoped under .koenig-lexical class to avoid clashes and keep styling as isolated as possible. PostCSS nesting support is present to make this easier.

  • Styles located in src/styles/ are included in the final built module.
  • Styles located in demo/*.css are only used in the demo and will not be included in the built module.

When packaging the module, styles are included inside the JS file rather than being separate to allow for a single import of the module in the consuming app.

SVGs

SVGs can be imported as React components in the same way as create-react-app. Typically files are stored in src/assets/.

All imported files are processed/optimised via SVGO (see svgo.config.js for optimisation config) and included in the built JS file.

Testing

We use Vitest for unit tests and Playwright for e2e testing.

  • yarn test runs all tests and exits
  • yarn test:unit runs unit tests
  • yarn test:unit:watch runs unit tests and starts a test watcher that re-runs tests on file changes
  • yarn test:unit:watch --ui runs unit tests and opens a browser UI for exploring and re-running tests
  • yarn test:e2e runs e2e tests
  • yarn test:e2e --headed runs tests in browser so you can watch the tests execute
  • yarn test:slowmo same as yarn test:e2e --headed but adds 100ms delay between instructions to make it easier to see what's happening (note that some tests may fail or timeout due to the added delays)
  • yarn test:e2e --ui opens a browser UI in watch mode for exploring and re-running tests
  • yarn test:e2e --ui --headed same as yarn test:e2e --ui but also runs tests in browser so you can watch the tests execute

Before tests are started we build a version of the demo app that is used for the unit tests.

When developing it can be useful to limit unit tests to specific keywords (taken from describe or it/test names). That's possible using the -t param and works with any of the above test commands, e.g.:

  • yarn test:unit:watch -t "buildCardMenu"

How to debug e2e tests on CI

You can download the report in case of tests were failed. It can be found in the actions Summary in the Artifacts section. To check traces, run command npx playwright show-trace trace.zip. More information about traces can be found here https://playwright.dev/docs/trace-viewer

ESM in e2e tests

Node enables ECMAScript modules if type: 'module' in package.json file. It leads to some restrictions:

We can make file extension optional with --experimental-specifier-resolution flag, which we use. But node is not recognized jsx extension. It can be solved with node loaders, whereas as they're still in experimental mode, there is no appropriate implementation for this use case. The same issue was raised in the babel repo, but the loader won't be added while node loaders are in experimental mode.

We can add our loader implementation to solve the issue. Still, in reality, we shouldn't need real JSX components in e2e tests. It can be a situation when some constants locate in the jsx file. In this case, we can move them to js file. If it is a problem in the future, we can add our implementation of the loader or add an extension to all imports in the project.

Deployment

To deploy the changes made in Koenig Lexical and integrate them into Ghost, follow these steps:

  1. Run yarn ship in the top-level Koenig monorepo. This command will update the editor used on Ghost by fetching the latest version from jsdelivr.

  2. Bump the version of @tryghost/kg-default-nodes in the Ghost repository. This step is necessary for rendering to work correctly with newly added or updated nodes. Failure to perform this step may result in issues when saving posts on Ghost that use the new cards.

  3. Run /main in Slack and wait for the new version to build to test on staging.

Editor integration

There's a vitest vscode extension that lets you run and debug individual unit tests/groups directly inside vscode.

1.1.11

4 days ago

1.1.10

6 days ago

1.1.9

8 days ago

1.1.8

12 days ago

1.1.7

13 days ago

1.1.6

21 days ago

1.1.5

23 days ago

1.1.4

26 days ago

1.1.3

27 days ago

1.1.1

29 days ago

1.1.2

29 days ago

1.1.0

2 months ago

1.0.21

3 months ago

1.0.20

3 months ago

1.0.19

3 months ago

1.0.18

3 months ago

1.0.17

3 months ago

1.0.16

3 months ago

1.0.15

3 months ago

1.0.14

3 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.9

4 months ago

0.5.28

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago

1.0.3

5 months ago

0.5.27

6 months ago

0.5.25

6 months ago

0.5.26

6 months ago

0.5.10

7 months ago

0.5.11

7 months ago

0.5.18

6 months ago

0.5.19

6 months ago

0.5.16

6 months ago

0.5.17

6 months ago

0.5.14

7 months ago

0.5.15

6 months ago

0.5.12

7 months ago

0.5.13

7 months ago

0.4.20

7 months ago

0.4.21

7 months ago

0.4.24

7 months ago

0.4.25

7 months ago

0.4.22

7 months ago

0.4.23

7 months ago

0.4.19

7 months ago

0.4.10

8 months ago

0.4.17

8 months ago

0.4.18

8 months ago

0.4.15

8 months ago

0.4.16

8 months ago

0.4.13

8 months ago

0.4.14

8 months ago

0.4.11

8 months ago

0.4.12

8 months ago

0.5.4

7 months ago

0.5.3

7 months ago

0.5.6

7 months ago

0.5.5

7 months ago

0.5.0

7 months ago

0.5.2

7 months ago

0.5.1

7 months ago

0.5.21

6 months ago

0.5.22

6 months ago

0.5.20

6 months ago

0.5.23

6 months ago

0.5.24

6 months ago

0.4.9

8 months ago

0.4.8

9 months ago

0.3.8

11 months ago

0.5.8

7 months ago

0.5.7

7 months ago

0.5.9

7 months ago

0.4.5

9 months ago

0.4.4

9 months ago

0.4.7

9 months ago

0.4.1

9 months ago

0.4.0

9 months ago

0.4.3

9 months ago

0.4.2

9 months ago

0.3.20

9 months ago

0.3.24

9 months ago

0.3.23

9 months ago

0.3.22

9 months ago

0.3.21

9 months ago

0.3.19

9 months ago

0.3.18

9 months ago

0.3.9

10 months ago

0.3.17

10 months ago

0.3.16

10 months ago

0.3.15

10 months ago

0.3.14

10 months ago

0.3.13

10 months ago

0.3.12

10 months ago

0.3.11

10 months ago

0.3.10

10 months ago

0.3.6

11 months ago

0.3.7

11 months ago

0.3.5

11 months ago

0.3.2

11 months ago

0.3.4

11 months ago

0.3.3

11 months ago

0.2.27

11 months ago

0.2.26

11 months ago

0.2.25

11 months ago

0.3.0

11 months ago

0.3.1

11 months ago

0.2.41

11 months ago

0.2.40

11 months ago

0.2.42

11 months ago

0.2.39

11 months ago

0.2.30

11 months ago

0.2.38

11 months ago

0.2.37

11 months ago

0.2.36

11 months ago

0.2.35

11 months ago

0.2.34

11 months ago

0.2.33

11 months ago

0.2.32

11 months ago

0.2.31

11 months ago

0.2.29

11 months ago

0.2.28

11 months ago

0.2.24

11 months ago

0.2.23

11 months ago

0.2.22

11 months ago

0.2.21

11 months ago

0.2.20

11 months ago

0.2.19

11 months ago

0.2.18

11 months ago

0.2.17

12 months ago

0.2.15

12 months ago

0.2.14

12 months ago

0.2.13

12 months ago

0.2.12

12 months ago

0.2.11

12 months ago

0.2.10

12 months ago

0.2.0

1 year ago

0.2.7

12 months ago

0.2.6

12 months ago

0.2.8

12 months ago

0.2.3

12 months ago

0.2.2

1 year ago

0.2.5

12 months ago

0.2.4

12 months ago

0.0.84

1 year ago

0.0.85

1 year ago

0.0.86

1 year ago

0.0.87

1 year ago

0.0.88

1 year ago

0.0.89

1 year ago

0.0.83

1 year ago

0.1.0

1 year ago

0.0.95

1 year ago

0.0.96

1 year ago

0.0.97

1 year ago

0.0.90

1 year ago

0.0.91

1 year ago

0.0.92

1 year ago

0.0.93

1 year ago

0.0.94

1 year ago

0.0.80

1 year ago

0.0.81

1 year ago

0.0.82

1 year ago

0.0.73

1 year ago

0.0.74

1 year ago

0.0.75

1 year ago

0.0.76

1 year ago

0.0.77

1 year ago

0.0.78

1 year ago

0.0.79

1 year ago

0.0.70

1 year ago

0.0.71

1 year ago

0.0.72

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.67

1 year ago

0.0.68

1 year ago

0.0.69

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.58

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.47

1 year ago

0.0.51

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.46

1 year ago

0.0.40

1 year ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago