This forces the editor to re-use the editor instance that existed prior to an unmount and remount of the same component.
This fixes a bug in `React.StrictMode` introduced with the latest performance updates by PR #5161
* fix: default to rendering the editor immediately, while staying backward compatible
* feat: add `useEditorWithState` hook for extracting state and editor instance simultaneously
* feat(react): add `useEditorState` hook for subscribing to selected editor state
* docs: add an example to show the concept
* chore: add changeset
* fix: make blockquote shortcut work in starter-kit
Because blockquote uses Mod-Shift-b, and bold uses Mod-b,
the bold shortcut will override the blockquote shortcut if added
to the extensions later.
Fixes#4994
* chore: add changeset
---------
Co-authored-by: Nick Perez <nicholas.perez@tiptap.dev>
* chore: get rid of lerna and install changesets
* chore: dont ignore demos in changesets
* chore: add deprecation notice for global CHANGELOG.md
* chore: remove commitlint from husky
* update package-lock
* join pre track for develop
* add new publish workflow with changesets
* update CONTRIBUTING guidelines
* fix typo in CONTRIBUTING
* update PR template
* rename release script to publish
* added pre actions
* use singular workflow for publishing
* chore: get rid of lerna and install changesets
* chore: dont ignore demos in changesets
* chore: add deprecation notice for global CHANGELOG.md
* chore: remove commitlint from husky
* update package-lock
* join pre track for develop
* add new publish workflow with changesets
* update CONTRIBUTING guidelines
* fix typo in CONTRIBUTING
* update PR template
* rename release script to publish
* added pre actions
* use singular workflow for publishing
Typically when inserting a new table we want to select within the first cell of the newly inserted
table. This change should ensure that occurs even if original selection's head precedes the anchor.
fix#5143
Using `CSS.escape` is the wrong tool for the job here:
- it is meant for CSS selectors and does not handle CSS variables properly.
- you can't use `var(--title)` as a font-family because it was getting escaped to `var\(--title\)`
This change introduces two new top-level options to the editor: `enableContentCheck` & `onContentError` for dealing with content supplied that does not match the prose-mirror schema generated by the set of tiptap extensions.
`enableContentCheck` allows the app developer to opt into the behavior to check for invalid schemas (this change is otherwise backwards compatible).
When true, this will try to parse the document, and any content that does not match the schema will emit a `contentError` which can be listened to via the `onContentError` callback.
* fix(extension-code-block): paste code from vscode
* fix: remove unused import
* fix: put cursor inside the created code block
---------
Co-authored-by: Nick the Sick <nicholas.perez@tiptap.dev>
* Fix typing for Suggestion `command` with new MentionAttrs generic
As of
7cae9673f0,
new generics were added for Suggestion options and props. However,
there is a subtle bug in the current typing: the object selected with
the suggestion `command` need not have the same types as the `items` in
the suggestion options. For instance, in Tiptap's official demo
https://tiptap.dev/api/nodes/mention, the suggestion `items` are all
`string`s, but the selected Mention is of type `{id: string}` (which are
the attributes of the Mention node, as the Mention extension requires):
```ts
const selectItem = index => {
const item = props.items[index]
if (item) {
props.command({ id: item })
}
}
```
i.e., there should be no restriction that when you select something with
the suggestion `command`, it must use the identical structure as the
suggested items. When using the suggestion plugin with the Mention
extension, for instance, the value passed to the SuggestionProps
`props.command()` function must be a `Record<string, any>`, as it's
directly/exclusively used to set the `attrs` of a `Node` via
`insertContentAt` (and you need not use that shape for suggestion
options, as in the Tiptap example above):
44996d60be/packages/extension-mention/src/mention.ts (L42)f869507396/packages/core/src/types.ts (L79)
This fixes the typing so that suggestions can correctly refer separately
to their own items (of any type), while ensuring the `command`ed item be
of whatever type is necessary (and so in the Mention context, could be
restricted further).
* Add generics to override selected suggestion type
---------
Co-authored-by: Steven DeMartini <sjdemartini@users.noreply.github.com>
* added JSDocs for almost all extensions
* start adding commands jsdocs
* add jsdocs for rest of extensions
* add jsdocs for Extensions
* add js docs for all extensions
* add more jsdocs
* add js docs for node spec definitions