* feat: add merge to setNodes
* chore: add merge to setNodes test
* chore: prettier
* chore: change to PropsMerge
* chore: restore the changes for addMark
* update insertText logic when selection is not collapsed
* add changeset
* fix bug when end of range is void
Co-authored-by: zhangpengcheng15 <zhangpengcheng15@jd.com>
* Warn when normalization removes node
Slate requires the invariant that children are all blocks or all inlines.
It enforces this in default normalization by removing children.
When such a node is removed, it's almost certainly due to a programming
error: the developer needs to fix their application to ensure it
maintains this invariant. But currently Slate does not tell the
developer this.
I made such a programming error, and spent a long time debugging nodes
that mysteriously went missing. I would have fixed it within 30 seconds
if Slate had warned me when it detected this error.
(Note I have used console.warn despite the eslint rule. As far as I can
see, Slate has no other facility for runtime warnings.)
* Add changeset
* Version Packages
* Update CHANGELOG.md
Add a missing changeset from one of the PRs.
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
* Fix `setNodes()` props argument type
Because Typescript can know which type of nodes we are modifying thanks to the `T` inferred from `match` function,
it can also properly narrow down the `props` argument type.
* Fix TS errors in examples
* Add a changeset
* Allow typing at the end of an inline
This fixes https://github.com/ianstormtaylor/slate/issues/4524
Steps to reproduce the buggy behavior:
* Create a page with an inline element, or go to
https://codepen.io/jameshfisher/pen/xxrXvVO
* Put the cursor at the end of the inline code element
* Type something
Expected behavior: If the cursor is at the end of an inline, text
should be inserted at the end of the inline.
Actual behavior: Slate moves the cursor outside the inline before
inserting text.
This current behavior is explicitly coded. I nevertheless claim that
this is a bug, or at least a misfeature in core. My expected behavior
comes from:
* The fact that the cursor is inside the inline. For the user, the
blinking cursor is visually inside the inline, not outside it. For the
developer, the cursor (i.e. editor.selection) is inside the inline,
not outside it. The definition of "the cursor" is "this is where your
text will go when you type". To break that behavior is really jarring.
* Slate's principle that "all of its logic is implemented with a series
of plugins". If the current behavior is actually desirable in some
circumstance, it should be in a plugin, not core. It's harder and less
elegant for me to remove the core behavior with my own plugin.
* Comparison with other editors. The following editors all insert text
at the end of the inline, as expected: default contenteditable,
Medium, Coda.io, Google Docs, OneNote, Evernote, QuillJS, TinyMCE,
EditorJS, ProseMirror. Two editors with the current buggy behavior are
Notion and Dropbox Paper, but I find it hard to imagine that their
current behavior on this issue is actually designed, and not just
accidental.
* Usability: how else is the user supposed to enter text at the end of
the inline ..? The only way seems to be to insert text before the end
of the inline, and then delete the rest of the inline. This is
obviously horrible.
* add changeset
* Fix test: insert at the end of an inline should _not_ have special behavior
* The selection is no longer moved in insertText so we don't need this special case
* fix:prettier
* Revert "The selection is no longer moved in insertText so we don't need this special case"
This reverts commit f9f36cd439.
* Explain the real reason for this special case - native browser bugs
* Upgrade `is-plain-object` to v5.0.0
The `is-plain-object` package recently had a major version upgrade that
broke libraries which import its default export, such as this one. This
causes issues when other packages in the same application require a
higher version of `is-plain-object`, resulting in an error originating
in Slate's codebase. To remedy this, Slate is now depending on
`is-plain-object@^5.0.0` and its import references across the codebase
have been updated.
Fixes#4499
* Add changeset
Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
* Migrate to yarn berry v3
* Fix yarn dependencies for linting
* Specifically invoke bash in yarn clean to make brace expansion work
* Upgrade cypress to 8.x to support yarn berry
* Try out yarn berry workaround for netlify
From https://answers.netlify.com/t/using-the-new-yarn-release-2-0-0-berry/8270
* Update .yarnrc.yml for syntax consistency
Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
* use rimraf for clean command with escaped glob pattern
* Use workspace:* resolution for workspace packages and rewrite yarn.lock
* set workspace package versions explicit again
* update peer dependencies
* disable import/named for ts and tsx files
* Replace 'key' with 'key=true' wherever babel complains
* replace all instances of key to someKey in tests to satisfy eslint and babel
* remove unnecessary yarn packageExtension and remove cross-env dependency
* upgrade yarn to latest
* Upgrade next.js to 10.x to support yarn berry
* update .yarnrc to satisfy netlify
Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>