1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 09:13:24 +01:00

614 Commits

Author SHA1 Message Date
Sunny Hirai
17cdeae858
Android 8.0, 8.1 and 9.0 Support (#2553)
* Allow the dev server to work for non localhost host

* Refactored set-selection-from-dom into utils as prep for Android support

* Show debug onInput at start if triggered

* Added and refactored to use set-text-from-dom-node with improved set selection after input

* Remove unnecessary console.log in set-text-from-dom-node

* Fixes to pass linter

* Adds basic composition to Android API27 including fixing one bug where compositionStart does not fire

* Fix some of the enter handling in API 27 and 28

* Add fixes for API 25

* Add debug for slate:update instead of separate render and updateSelection

* Add API 26 fix for ignoring all but Enter in onKeyDown

* Fix enter on Android 26 and 27

* Revert onSelect bug. Editor API 26 and 27 stable-ish

* Fix enter at beginning and end of word in API 26 and 27

* Fix enter handling at end of line API 26 and 27

* Fix reversion of enter bug when not at end of line

* Rename enter to linefeed which is more accurate

* Fix backspace on Android 27 and 28

* Fix enter at end of line then backspace then enter bug in API 26 and 27

* Refactor to simplify reading code

* Refactor to use executor and fix the suggestion problem

* Fix multi point edit in API 27/28

* Update Android documentation on enter handling

* Fix enter in API 26/27 and document 4 different enter cases

* Refactor partial into SlateSnapshot

* Complete SlateSnapshot refactor

* Remove unnecessary plugin comments

* Add smoke tests

* Rename smoke tests to composition in exmaples

* Fix API28 split join and insertion

* Fix space then backspace in middle of word bug in API 28

* Add text for middle word space and backspace bug

* Add note that the space backspace bug does not exist on API 27

* Fix 'It me. No.' bug in API 26/27

* Fix comments

* Update comments to fit Slate style guide

* Move a debug statement

* Fix zero-width selection placement bug.

* Fix 'it is' then enter in middle of 'it' bug

* Partial fix of enter, backspace, enter in word

* Add and fix comments. Fix selection in zero-width for API26-27

* Fix linting

* Fix documentation

* Remove snapback from packages

* Remove snapback from yarn.lock
2019-01-28 12:30:48 -08:00
Sunny Hirai
92c1ffbcd3
Refactor to utils (#2522)
* Refactored set-selection-from-dom into utils as prep for Android support

* Added and refactored to use set-text-from-dom-node with improved set selection after input
2019-01-04 12:02:33 -08:00
Ian Storm Taylor
d9cc247d45 Publish
- slate-base64-serializer@0.2.94
 - slate-html-serializer@0.7.33
 - slate-hyperscript@0.11.24
 - slate-plain-serializer@0.6.33
 - slate-prop-types@0.5.24
 - slate-react-placeholder@0.1.12
 - slate-react@0.21.15
 - slate@0.44.9
2018-12-11 13:23:21 -08:00
David Gertmenian-Wong
2ad73d73e5 Update Placeholder to be compatible with older versions of React (#2491)
* Make `placeholder` element compatible with older versions of React

`React.Fragment` is only available in react >= 16.2, which does not
meet the dependency requirements specified by the package (react >=
0.14.0). Updates from `React.Fragment` -> `span` to provide coverage
for older versions of react.

* Update `slate-react` placeholder test case
2018-12-11 12:54:26 -08:00
Dundercover
76a88a649a Add editor.HasCommand and editor.HasQuery (#2438)
* Add `editor.hasCommand` method

* Add `editor.hasQuery` method

* Rename directories `hasCommand` and `hasQuery` to kebab case

* Add tests for `editor.hasCommand` of React component

* Add tests for `editor.hasQuery` of React component
2018-12-11 11:25:53 -08:00
Ian Storm Taylor
37fcaf348c Publish
- slate-base64-serializer@0.2.93
 - slate-dev-environment@0.2.1
 - slate-hotkeys@0.2.8
 - slate-html-serializer@0.7.32
 - slate-hyperscript@0.11.23
 - slate-plain-serializer@0.6.32
 - slate-prop-types@0.5.23
 - slate-react-placeholder@0.1.11
 - slate-react@0.21.14
 - slate@0.44.8
2018-12-04 11:14:33 -08:00
Ian Storm Taylor
e909475ccb Publish
- slate-base64-serializer@0.2.92
 - slate-html-serializer@0.7.31
 - slate-hyperscript@0.11.22
 - slate-plain-serializer@0.6.31
 - slate-prop-types@0.5.22
 - slate-react-placeholder@0.1.10
 - slate-react@0.21.13
 - slate@0.44.7
2018-12-02 16:20:57 -08:00
Dundercover
61be5f8881 Add defaultValue prop to Editor component (#2418)
* Add `defaultValue` prop to `Editor` component

* Use `defaultValue` prop in the `Read Only` example

* Use `defaultValue` prop in the `Check Lists` example

* Use `defaultValue` prop in the `Code Highlighting` example

* Use `defaultValue` prop in the `Embeds` example

* Use `defaultValue` prop in the `Emojis` example

* Use `defaultValue` prop in the `Forced Layout` example

* Use `defaultValue` prop in the `Huge Document` example

* Use `defaultValue` prop in the `Images` example

* Use `defaultValue` prop in the `Input Tester` example

* Use `defaultValue` prop in the `Markdown Preview` example

* Use `defaultValue` prop in the `Markdown Shortcuts` example

* Use `defaultValue` prop in the `Paste HTML` example

* Use `defaultValue` prop in the `Plain Text` example

* Use `defaultValue` prop in the `Plugins` example

* Use `defaultValue` prop in the `RTL` example

* Use `defaultValue` prop in the `Search Highlighting` example

* Use `defaultValue` prop in the `Tables` example
2018-11-15 08:21:42 -08:00
Gersom van Ginkel
0c94ccebce Add changes made to shouldNodeComponentUpdate to changelog of slate-react (#2417)
* When the component unmounts, make sure async commands don't trigger react updates.

* Eslint fix

* Add changes made to shouldNodeComponentUpdate to changelog of slate-react
2018-11-13 10:28:10 -08:00
Ian Storm Taylor
1d0a0e6cf6 Publish
- slate-base64-serializer@0.2.91
 - slate-html-serializer@0.7.30
 - slate-hyperscript@0.11.21
 - slate-plain-serializer@0.6.30
 - slate-prop-types@0.5.21
 - slate-react-placeholder@0.1.9
 - slate-react@0.21.12
 - slate@0.44.6
2018-11-12 11:29:46 -08:00
Ian Storm Taylor
b78f6546cd Publish
- slate-base64-serializer@0.2.90
 - slate-html-serializer@0.7.29
 - slate-hyperscript@0.11.20
 - slate-plain-serializer@0.6.29
 - slate-prop-types@0.5.20
 - slate-react-placeholder@0.1.8
 - slate-react@0.21.11
 - slate@0.44.5
2018-11-11 14:42:07 -08:00
Ian Storm Taylor
a75c06b501 Publish
- slate-base64-serializer@0.2.89
 - slate-html-serializer@0.7.28
 - slate-hyperscript@0.11.19
 - slate-plain-serializer@0.6.28
 - slate-prop-types@0.5.19
 - slate-react-placeholder@0.1.7
 - slate-react@0.21.10
 - slate@0.44.4
2018-11-09 17:27:30 -08:00
Ian Storm Taylor
f13571cb65 Publish
- slate-base64-serializer@0.2.88
 - slate-html-serializer@0.7.27
 - slate-hyperscript@0.11.18
 - slate-plain-serializer@0.6.27
 - slate-prop-types@0.5.18
 - slate-react-placeholder@0.1.6
 - slate-react@0.21.9
 - slate@0.44.3
2018-11-09 16:41:50 -08:00
Ian Storm Taylor
f3922ed2f7 Publish
- slate-base64-serializer@0.2.87
 - slate-html-serializer@0.7.26
 - slate-hyperscript@0.11.17
 - slate-plain-serializer@0.6.26
 - slate-prop-types@0.5.17
 - slate-react-placeholder@0.1.5
 - slate-react@0.21.8
 - slate@0.44.2
2018-11-09 08:31:56 -08:00
Dundercover
3f0f55ff38 Do not show placeholder when document contains multiple text nodes (#2403) 2018-11-09 08:29:22 -08:00
Ian Storm Taylor
6ddba0ea35 Publish
- slate-base64-serializer@0.2.86
 - slate-html-serializer@0.7.25
 - slate-hyperscript@0.11.16
 - slate-plain-serializer@0.6.25
 - slate-prop-types@0.5.16
 - slate-react-placeholder@0.1.4
 - slate-react@0.21.7
 - slate@0.44.1
2018-11-08 15:40:26 -08:00
Dundercover
13107b0c43 Add optional id prop to the Editor component (#2402) 2018-11-08 15:36:44 -08:00
Ian Storm Taylor
7a47a52e29 Publish
- slate-base64-serializer@0.2.85
 - slate-html-serializer@0.7.24
 - slate-hyperscript@0.11.15
 - slate-plain-serializer@0.6.24
 - slate-prop-types@0.5.15
 - slate-react-placeholder@0.1.3
 - slate-react@0.21.6
 - slate@0.44.0
2018-11-08 13:17:10 -08:00
Ian Storm Taylor
f2f97e502e Publish
- slate-react@0.21.5
2018-11-07 16:47:24 -08:00
Ian Storm Taylor
e493905f29
fix focusing across multiple editors (#2396) 2018-11-07 16:45:01 -08:00
Gersom van Ginkel
990d37b694 Avoid async commands causing rerenders after unmount. (#2395)
* When the component unmounts, make sure async commands don't trigger react updates.

* Eslint fix
2018-11-07 11:34:15 -08:00
Irwan Fario Subastian
8d616b1f98 fix softbreak at the end of the leaf (#2389) 2018-11-06 18:25:51 -08:00
Ian Storm Taylor
312a4ce1a5 Publish
- slate-react@0.21.4
2018-11-06 14:04:11 -08:00
Ian Storm Taylor
836ab1d494 fix findDOMPoint for non-empty void node offsets 2018-11-06 14:01:55 -08:00
Ian Storm Taylor
9446bcbf6d Publish
- slate-react@0.21.3
2018-11-06 13:53:36 -08:00
Ian Storm Taylor
07ecbc69c9 fix findDOMPoint for void nodes with content length 2018-11-06 13:51:52 -08:00
Ian Storm Taylor
60e897599f Publish
- slate-base64-serializer@0.2.84
 - slate-html-serializer@0.7.23
 - slate-hyperscript@0.11.14
 - slate-plain-serializer@0.6.23
 - slate-prop-types@0.5.14
 - slate-react-placeholder@0.1.2
 - slate-react@0.21.2
 - slate@0.43.7
2018-11-06 12:54:58 -08:00
Ian Storm Taylor
7079433ac1 fix findDOMPoint behavior for void nodes 2018-11-06 12:53:05 -08:00
Ian Storm Taylor
24af6113dc Publish
- slate-react-placeholder@0.1.1
 - slate-react@0.21.1
2018-11-02 17:42:51 -07:00
Ian Storm Taylor
456d8f570f fix slate-react-* peerDependencies 2018-11-02 17:39:29 -07:00
Ian Storm Taylor
bb6d39edb6 Publish
- slate-base64-serializer@0.2.83
 - slate-html-serializer@0.7.22
 - slate-hyperscript@0.11.13
 - slate-plain-serializer@0.6.22
 - slate-prop-types@0.5.13
 - slate-react-placeholder@0.1.0
 - slate-react@0.21.0
 - slate@0.43.6
2018-11-02 17:07:12 -07:00
Ian Storm Taylor
a09c3c2fdf
Remove renderPlaceholder (#2370)
* add placeholder plugin in slate-react

* remove renderPlaceholder logic

* extract placeholder into a plugin

* remove other old placeholder-based logic

* update changelogs
2018-11-02 17:04:20 -07:00
Ian Storm Taylor
0cf94c73c9 Publish
- slate-base64-serializer@0.2.82
 - slate-html-serializer@0.7.21
 - slate-hyperscript@0.11.12
 - slate-plain-serializer@0.6.21
 - slate-prop-types@0.5.12
 - slate-react@0.20.8
 - slate@0.43.5
2018-11-02 16:18:24 -07:00
Ian Storm Taylor
f438f12d5b fix peer dependency ranges 2018-11-02 16:14:14 -07:00
Ian Storm Taylor
562f7be4b6 Publish
- slate-react@0.20.7
2018-11-01 19:29:44 -07:00
Slapbox
0436ad4a64 Skip operations on child nodes if !node.nodes.size (#2365)
* Skip operations on child nodes if !node.nodes.size

Avoid running decoration and text decoration related functions on child nodes that don't exist.

* Uses isLeafBlock

* Restores the original order of statements
2018-11-01 18:26:46 -07:00
Ian Storm Taylor
fac8228f23 Publish
- slate-base64-serializer@0.2.81
 - slate-html-serializer@0.7.20
 - slate-hyperscript@0.11.11
 - slate-plain-serializer@0.6.20
 - slate-prop-types@0.5.11
 - slate-react@0.20.6
 - slate@0.43.4
2018-11-01 17:59:52 -07:00
Ian Storm Taylor
d5bb44383d Publish
- slate-base64-serializer@0.2.80
 - slate-html-serializer@0.7.19
 - slate-hyperscript@0.11.10
 - slate-plain-serializer@0.6.19
 - slate-prop-types@0.5.10
 - slate-react@0.20.5
 - slate@0.43.3
2018-10-31 14:33:50 -07:00
Ian Storm Taylor
317297469e Publish
- slate-base64-serializer@0.2.79
 - slate-html-serializer@0.7.18
 - slate-hyperscript@0.11.9
 - slate-plain-serializer@0.6.18
 - slate-prop-types@0.5.9
 - slate-react@0.20.4
 - slate@0.43.2
2018-10-31 10:26:11 -07:00
Ian Storm Taylor
caedc1f108 Publish
- slate-base64-serializer@0.2.78
 - slate-html-serializer@0.7.17
 - slate-hyperscript@0.11.8
 - slate-plain-serializer@0.6.17
 - slate-prop-types@0.5.8
 - slate-react@0.20.3
 - slate@0.43.1
2018-10-31 10:11:00 -07:00
Ian Storm Taylor
46df9f6c52 Publish
- slate-react@0.20.2
2018-10-29 17:35:31 -07:00
Ian Storm Taylor
4a2d7845ba rollback isInEditor check for void nodes 2018-10-29 17:30:24 -07:00
Ian Storm Taylor
8eb8e26958 Publish
- slate-react@0.20.1
2018-10-28 16:28:45 -07:00
Per-Kristian Nordnes
43812193ea Fix deprecated editor.change in after/onCut (#2343) 2018-10-28 12:18:53 -07:00
Ian Storm Taylor
8271cecc1e Publish
- slate-base64-serializer@0.2.77
 - slate-html-serializer@0.7.16
 - slate-hyperscript@0.11.7
 - slate-plain-serializer@0.6.16
 - slate-prop-types@0.5.7
 - slate-react@0.20.0
 - slate@0.43.0
2018-10-27 12:26:11 -07:00
Ian Storm Taylor
c86dfbd65b update changelogs 2018-10-27 12:24:35 -07:00
Ian Storm Taylor
8dd919dc34
remove change, fold into editor (#2337)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Improvement / debt.

#### What's the new behavior?

This pull request removes the `Change` object as we know it, and folds all of its behaviors into the new `Editor` controller instead, simplifying a lot of the confusion around what is a "change vs. editor" and when to use which. It makes the standard API a **lot** nicer to use I think.

---

###### NEW

**The `editor.command` and `editor.query` methods can take functions.** Previously they only accepted a `type` string and would look up the command or query by type. Now, they also accept a custom function. This is helpful for plugin authors, who want to accept a "command option", since it gives users more flexibility to write one-off commands or queries. For example a plugin could be passed either:

```js
Hotkey({
  hotkey: 'cmd+b',
  command: 'addBoldMark',
})
```

Or a custom command function:

```js
Hotkey({
  hotkey: 'cmd+b',
  command: editor => editor.addBoldMark().moveToEnd()
})
```

###### BREAKING

**The `Change` object has been removed.** The `Change` object as we know it previously has been removed, and all of its behaviors have been folded into the `Editor` controller. This includes the top-level commands and queries methods, as well as methods like `applyOperation` and `normalize`. _All places that used to receive `change` now receive `editor`, which is API equivalent._

**Changes are now flushed to `onChange` asynchronously.** Previously this was done synchronously, which resulted in some strange race conditions in React environments. Now they will always be flushed asynchronously, just like `setState`.

**The `render*` and `decorate*` middleware signatures have changed!** Previously the `render*` and `decorate*` middleware was passed `(props, next)`. However now, for consistency with the other middleware they are all passed `(props, editor, next)`. This way, all middleware always receive `editor` and `next` as their final two arguments.

**The `normalize*` and `validate*` middleware signatures have changed!** Previously the `normalize*` and `validate*` middleware was passed `(node, next)`. However now, for consistency with the other middleware they are all passed `(node, editor, next)`. This way, all middleware always receive `editor` and `next` as their final two arguments.

**The `editor.event` method has been removed.** Previously this is what you'd use when writing tests to simulate events being fired—which were slightly different to other running other middleware. With the simplification to the editor and to the newly-consistent middleware signatures, you can now use `editor.run` directly to simulate events:

```js
editor.run('onKeyDown', { key: 'Tab', ... })
```

###### DEPRECATED

**The `editor.change` method is deprecated.** With the removal of the `Change` object, there's no need anymore to create the small closures with `editor.change()`. Instead you can directly invoke commands on the editor in series, and all of the changes will be emitted asynchronously on the next tick.

```js
editor
  .insertText('word')
  .moveFocusForward(10)
  .addMark('bold')
```

**The `applyOperations` method is deprecated.** Instead you can loop a set of operations and apply each one using `applyOperation`. This is to reduce the number of methods exposed on the `Editor` to keep it simpler.

**The `change.call` method is deprecated.** Previously this was used to call a one-off function as a change method. Now this behavior is equivalent to calling `editor.command(fn)` instead.

---

Fixes: https://github.com/ianstormtaylor/slate/issues/2334
Fixes: https://github.com/ianstormtaylor/slate/issues/2282
2018-10-27 12:18:23 -07:00
Ian Storm Taylor
633fc9eebc Publish
- slate-base64-serializer@0.2.76
 - slate-html-serializer@0.7.15
 - slate-hyperscript@0.11.6
 - slate-plain-serializer@0.6.15
 - slate-prop-types@0.5.6
 - slate-react@0.19.8
 - slate@0.42.6
2018-10-25 18:49:32 -07:00
Ian Storm Taylor
7f65eda65a Publish
- slate-base64-serializer@0.2.75
 - slate-html-serializer@0.7.14
 - slate-hyperscript@0.11.5
 - slate-plain-serializer@0.6.14
 - slate-prop-types@0.5.5
 - slate-react@0.19.7
 - slate@0.42.5
2018-10-25 12:40:50 -07:00
Kaspars Dancis
d5834bb5b0 Prevent crash when handling composition of 2+ keypresses when selection is not collapsed (#2218)
https://github.com/ianstormtaylor/slate/issues/1879
When composition starts and the current selection is not collapsed, the
second composition key-down would drop the text wrapping <spans> which
resulted on crash in content.updateSelection after composition ends
(because it cannot find <span> nodes in DOM). This is a workaround that
erases selection as soon as composition starts and preventing <spans>
to be dropped.
2018-10-25 09:47:29 -07:00