1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 21:49:20 +01:00

3973 Commits

Author SHA1 Message Date
github-actions[bot]
fece5c1570
Version Packages (#4683)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate@0.71.0 slate-react@0.71.0
2021-11-23 03:17:06 -07:00
unageek
e3afda9466
fix: cursor jumps more than one character unexpectedly (#4671)
* Add test cases suggested in https://github.com/ianstormtaylor/slate/issues/4649#issuecomment-974015248

* fix: cursor jumping more than one character

* Optimization

* Make ZWJs in test strings visible
2021-11-23 01:45:08 -07:00
Matthew Keil
e538065572
fix ssr prop mismatch (#4682)
* fix ssr prop mismatch

* added changeset
2021-11-22 09:29:14 -07:00
Victor Baron
2523dc4f6e
Fix deep-equality for array properties (#4672) 2021-11-22 09:09:51 -07:00
github-actions[bot]
0540fea6a8
Version Packages (#4675)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.70.2
2021-11-20 15:09:22 -07:00
Eric Meier
807716d7df
fix: flush selection change on before input (#4669)
* fix: flush selection change on before input

* chore: remove redundant option from debounce
2021-11-20 11:26:13 -07:00
Leo
0f194a86a0
fix: use ownerDocument to create element (#4661)
* fix: use ownerDocument to create element

* chore: add changeset
2021-11-20 11:24:53 -07:00
github-actions[bot]
3ad3aaccad
Version Packages (#4651)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.70.1
2021-11-16 04:31:36 -07:00
Karthikeyan
95389ed7b0
fix: default scroll selection (#4652)
* fix: default scroll selection

* feat: use Range.isCollapsed to check the selection

* chore: add changeset

* fix: grammer correction

* fix: grammer correction
2021-11-16 02:21:14 -07:00
Doug Reeder
7d9d25e179
Adds clarification & examples to demystify Transforms. (#4653)
* Adds clarification & examples to demystify Transforms.

* Fleshes out documentation of NodeOptions for Transforms

* Update docs/concepts/04-transforms.md

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>

* Uses 'API' in the title of all API documents

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
2021-11-16 02:20:43 -07:00
meri-leeworthy
5dc9dc5227
missing dependency (#4656) 2021-11-15 02:02:51 -07:00
Andreas Hörnicke
2c7750cac5
fix: weak guard on DataTransfer to not rely on current window (#4654) 2021-11-15 01:59:02 -07:00
Ivan Voskoboinyk
b6643132f1
Do not try to disable Grammarly in Slate (#4650)
* Do not try to disable Grammarly in Slate

As the `data-gramm` attribute is no longer working actually. See #4124 

The Grammarly extension is not causing the DOM issues anymore, as they have reworked their highlighting logic: 
https://www.grammarly.com/blog/engineering/making-grammarly-feel-native-on-every-website/

* Add changeset
2021-11-09 16:52:31 -07:00
github-actions[bot]
9874ed704f
Version Packages (#4637)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate@0.70.0 slate-react@0.70.0
2021-11-07 07:09:15 -07:00
Jimmy Oliger
5818aca503
Fix issue with unicode 1.1 smileys (#4565) 2021-11-04 08:06:41 -07:00
Ivan Voskoboinyk
e0f41514a1
Improve props argument type in Transforms.setNodes() (#4638)
* 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
2021-11-04 04:43:18 -07:00
Charlie Martin
9e8d5e2b9b
fix: drag and drop in iframes (#4506) (#4636)
* fix: drag and drop in iframes (#4506)

* Create changeset

* Update iframe-drop-actions.md
2021-10-28 12:36:46 -07:00
github-actions[bot]
35abac13b0
Version Packages (#4632)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.69.0
2021-10-26 21:48:52 -07:00
zhugexinxin
2ee2753d72
fix: image disappears when the drag fails (#4631) 2021-10-26 21:44:09 -07:00
Jim Fisher
0b256b211e
Editable button example: emulate button to work around browser bug (#4630)
It's important to have 100% working examples. Unfortunately this example
I introduced has a bug on Chrome and Safari, where the cursor jumps
around wrongly when using the "up" and "down" keys to navigate. This
is due to a browser bug with display:inline-block elements, and there
is no known workaround except to use display:inline.
2021-10-26 21:12:36 -07:00
Eric Charles
e54f2a0ea0
Fix double insertion due to insertTextData being called when it should not (#4625)
* fix double paste due to insertTextData being called when it should not

* Document return type of insertTextData and insert FragmentData

* Add changeset
2021-10-26 21:09:36 -07:00
github-actions[bot]
02e9245646
Version Packages (#4629)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.68.1
2021-10-25 09:44:43 -07:00
Jim Fisher
d94b229121
Fix examples/images integration test (#4628)
Sorry, I broke this test in https://github.com/ianstormtaylor/slate/pull/4616
by adding a second image to the example!
2021-10-25 08:58:34 -07:00
Jim Fisher
ec01e75fff
Revert "Do NOT use exact match when updating dom selection" (#4627)
* Revert "Do NOT use exact match when updating dom selection"

The change to `exactMatch: false` in https://github.com/ianstormtaylor/slate/pull/4304
was intended to fix https://github.com/ianstormtaylor/slate/issues/4293,
a bug where "backwards typing" happened in nested editors.

But this change has introduced at least two new bugs:

- https://github.com/ianstormtaylor/slate/issues/4601
- https://github.com/ianstormtaylor/slate/issues/4626

These are (IMO) worse than the original "backwards typing" bug.

From discussion in https://github.com/ianstormtaylor/slate/pull/4304,
the true underlying bug is in ReactEditor.toSlateRange. I'll attempt to
fix this underlying bug instead.

* changeset
2021-10-25 08:43:06 -07:00
github-actions[bot]
381f91b1dd
Version Packages (#4624)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.68.0
2021-10-24 22:18:10 -07:00
github-actions[bot]
d467e33c33
Version Packages (#4610)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2021-10-24 08:11:55 -07:00
Nicklas Andersson
0b59ad5414
Feat: Enable selection when editor in readonly=true (#4620)
* make editor.selection avaliable when Editor is contenteditable="false"

* remove dom selection limition of read-only

* Improve grammar of comments regarding selection when read-only is true

* Add Changeset

Co-authored-by: Xheldon <c1006044256@gmail.com>
2021-10-24 07:31:31 -07:00
Jim Fisher
77d9f60ab5
Fix crash when a void node deletes itself on click (#4616)
* Fix crash when a void node deletes itself on click

Fixes https://github.com/ianstormtaylor/slate/issues/4240

* Add 'image delete' feature to example

My immediate motivation is to demonstrate the bug that this fixes. But
this is also a very common editor feature, and I think it's valuable
to show how to achieve it.

* add changeset

* fix:eslint

* revert changes to mentions.tsx
2021-10-24 07:31:00 -07:00
Eric Charles
b50a772136
Add missing insertFragmentData and insertTextData on the ReactEditor class (#4622) 2021-10-23 03:48:05 -07:00
Jim Fisher
f1b7d18f43
Official custom inlines example (#4615)
* Official custom inlines example

This generalizes the "links" example to an "inlines" example, adding
a new example of an inline: an "editable button".

Firstly, this is important to demonstrate that Slate really does allow
_custom_ elements, and not just "standard" ones like links that you'll
find in any editor.

Secondly, it's important to show an example of an inline where "offset"
movement should be used. With links, it's arguable that the cursor
positions <link>foo<cursor/></link> and <link>foo</link><cursor/>
should be considered the same, because they display in the same
position. But with the editable button, the cursor is clearly in a
different position, and so offset movement should be used.

* lint

* fix integration test

* update readme

* try again
2021-10-22 13:19:41 -07:00
Eric Charles
72160fac08
Add insertFragmentData and insertTextData to the ReactEditor API (#4614)
* Add insertFragmentData and insertTextData to the ReactEditor API

* Add patch changeset

* Docs for insertFragment and insertTextData
2021-10-22 06:44:56 -07:00
I Made Budi Surya Darma
b186d3ea12
Fix crash on drag and drop image on readOnly editable (#4617)
* Fix crash on drag and drop image on readOnly editable

* add changeset
2021-10-22 06:39:30 -07:00
Jim Fisher
67badb7dd0
Allow typing at the end of an inline element (#4578)
* 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 f9f36cd43937ed44272294c1c3c19ca2f3302f2d.

* Explain the real reason for this special case - native browser bugs
2021-10-19 10:46:17 -07:00
Jim Fisher
cab8edea7b
Add "selected shadow" to link example (#4609)
Due to standard link CSS, the cursor at the end of the link looks the
same as the cursor immediately after the link, and the cursor at the
start of the link looks the same as the cursor immediately before the
link. However, these are semantically different locations. I've had
several problems with Slate misinterpreting these locations, and had
trouble showing these problems to others using the standard examples,
because the only example of an editable inline element is the link.

To fix this, I've added a box-shadow to the link when it's selected. It
should now be clear to the user whether the cursor is inside or
outside the element.
2021-10-19 06:48:03 -07:00
github-actions[bot]
3678590ccf
Version Packages (#4594)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.67.0 slate-hyperscript@0.67.0
2021-10-18 14:05:11 -07:00
Jake Donham
87ab2efa41
defer native events within Editable to avoid bugs with Editor (#4605)
* defer native events internally to Editable

* add changeset

* suggestions to make DeferredOperation a closure instead of an object type

Co-authored-by: Nemanja Tosic <netosic90@gmail.com>

* fix misapplied suggestion

Co-authored-by: Nemanja Tosic <netosic90@gmail.com>
2021-10-18 13:05:16 -07:00
Dylan Schiemann
f1607da4ad
Revert "in examples, move withReact in front of withHistory (#4604)" (#4607)
This reverts commit 9cf2f4eea2878a7acce84273c3a65c09f0d0ea98.
2021-10-17 06:31:33 -07:00
Jake Donham
9cf2f4eea2
in examples, move withReact in front of withHistory (#4604) 2021-10-15 16:01:22 -07:00
Jim Fisher
08f67d9cbc
Fix typo (#4598) 2021-10-13 15:46:53 -07:00
Jim Fisher
f40e515dc7
Fix bug: setting selection from contentEditable:false element causes crash (#4584)
* Fix bug: setting selection from contentEditable:false element causes crash

Fixes https://github.com/ianstormtaylor/slate/issues/4583

When clicking some text in a `contentEditable:false` element, if the
handler for this sets the selection, Slate crashes. Slate tries to find
a Slate range for the text that was clicked on, but there is no such
range, because the text is inside a `contentEditable:false` element.
Slate seems to be making a bad assumption that the current DOM selection
necessarily corresponds to a Slate range, but this is not the case if
the user just clicked into an element with `contentEditable: false`.
To fix this, I changed `exactMatch: false` to `exactMatch: true`,
which seems to mean "fail gracefully if there is no exact match".

* changeset

* Revert "Fix bug: setting selection from contentEditable:false element causes crash"

This reverts commit 71234284cd454993b139ce065a9ab2db431abce8.

* Unconflate exactMatch flag: add suppressThrow flag for separate behavior

* Fix bug: setting selection from contentEditable:false element causes crash

Fixes #4583

When clicking some text in a `contentEditable:false` element, if the
handler for this sets the selection, Slate crashes. Slate tries to find
a Slate range for the text that was clicked on, but there is no such
range, because the text is inside a `contentEditable:false` element.
Slate seems to be making a bad assumption that the current DOM selection
necessarily corresponds to a Slate range, but this is not the case if
the user just clicked into an element with `contentEditable: false`.
2021-10-13 11:45:00 -07:00
Doug Reeder
43e740c88d
docs: clarifies not setting editor values directly & plugin order (#4571)
* Updates "Saving to a Database" example to distinguish actual content changes.

* Update docs/walkthroughs/06-saving-to-a-database.md

* Update docs/walkthroughs/06-saving-to-a-database.md

* Update docs/walkthroughs/06-saving-to-a-database.md

* Runs prettier

* docs: clarifies not setting editor values directly & plugin order

* Changes reccommended order of withReact & withHistory, to match current knowleged

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
2021-10-11 17:40:38 -07:00
Jim Fisher
4b2e4000d6
Don't remove selection when hovering over a non-selectable DOM element (#4577)
* Don't remove selection when hovering over a non-selectable node

Fixes https://github.com/ianstormtaylor/slate/issues/4545

To reproduce the buggy behavior:

1. Create a page that renders a Slate element with a `contentEditable: false` element in it.
2. Start selecting some text with the mouse.
3. During the drag, mouseover the `contentEditable: false` element.

Expected behavior: After doing a drag-to-select with the mouse, from a valid anchor point on mousedown to a valid focus point on mouseup, the selection is set to those anchor and focus points.

Actual behavior: your selection is removed as soon as your mouse hits the `contentEditable: false` element. This is because the current behavior clears the selection if it is momentarily not a valid Slate location.

* Add changeset
2021-10-11 17:39:53 -07:00
Bryan Haakman
11ef83b47f
Only use Slate Provider's value prop as initial state (#4540)
* Only use value prop as initial state

* Add onChange call back

* add changeset
2021-10-11 17:38:02 -07:00
Bryan Haakman
c29eea022e
Allow passing custom editor creator to slate-hyperscript createEditor (#4555)
* Allow passing custom slate editor creator to slate-hyperscript createEditor()

Makes it easier to create your own testing setup

* run fix:prettier

* remove unused createEditor

* Add changeset

* fix lint and remove accidentally committed file
2021-10-11 17:33:52 -07:00
github-actions[bot]
b18dd40026
Version Packages (#4592)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
slate-react@0.66.7
2021-10-11 17:29:35 -07:00
Jim Fisher
c76f370826
Link to latest changelogs on main branch, not arbitrary snapshot from the past (#4593)
To see the problem, visit https://docs.slatejs.org/general/changelog and follow the links after "...each package will maintain its own individual changelog, which you can find here:"
2021-10-11 06:50:05 -07:00
Jake Donham
ae65ae5f71
revert #4455 / #4512; fix triple-click by unhanging range with void (#4588)
* revert #4455 / #4512; fix triple-click by unhanging range with void

* added changeset
2021-10-11 05:15:04 -07:00
Sunny Hirai
8e02c65184 docs: Fix lint maybe. 2021-10-10 21:22:32 -07:00
Sunny Hirai
8a81b0ea3d docs: updated concepts so Editor Interface matches API reference 2021-10-10 15:27:36 -07:00
Slapbox
528d92553b
Fixes broken changelog link (#4587)
Fixes #4586
2021-10-09 16:50:49 -07:00