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

Add InitialConfigType as the type for the LexicalComposer props #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cNikolaou
Copy link

Add InitialConfigType type from lexical-react. Set this as the type for the LexicalComposer props.

This allows to type-safely use a function for the initial config without the need to add any and without ESLint flagging that when initializing the LexicalComposer.

See changes to the playground/src/App.vue:

const config: InitialConfigType = {
  namespace: 'Vue.js Demo',
  theme: PlaygroundEditorTheme,
  nodes: [
    ...PlaygroundNodes,
  ],
  editable: true,
  editorState: prepopulatedRichText,      // can be a function or an `EditorState` or a string
  onError(error: Error) {
    throw error
  },
}

This creates an easy-to-fix breaking change as the initialConfig is required to have a namespace and a onError property.

Add the `type InitialConfigType` that follows the type
definition of:

https://github.com/facebook/lexical/blob/0d1bb6670f71a70b2ad18243fee7ff4a0309a20f/packages/lexical-react/src/LexicalComposer.tsx#L41

The type is used as the type of the props passed to the
`LexicalComposer` to allow a typed initial configuration for
the `editorState` and use a function without needing to use `any`.

The commit updates the `playground` example to follow the type:

```
const config: InitialConfigType = {
  namespace: 'Vue.js Demo',
  theme: PlaygroundEditorTheme,
  nodes: [
    ...PlaygroundNodes,
  ],
  editorState: prepopulatedRichText,
  onError(error: Error) {
    throw error
  },
}
```
Copy link

changeset-bot bot commented Nov 28, 2024

⚠️ No Changeset found

Latest commit: a263d45

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 5:25pm
lexical-vue-playground ❌ Failed (Inspect) Nov 28, 2024 5:25pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant