* Rephrased to removed idiom and better describe Slate.
* Added links to educate folks about the core DOM concepts
* Renamed headline to `Slate Mirrors the Dom`
* Rephrased immutable js introduction
* Corrected spelling error
* Simplified language introducing how one can change values.
* Simplified statement about collection methods
* Added encouraging language for Immutable JS learning suggestion
* Quoted mozilla links
* Suggestions to improve readability of data-model documentation
* Added serialized example value
* Resolved one prettier complaints
* `yarn run prettier`
* anchor/focus point glossary content
* normalized term identifiers
* added mark
* Added plugin
* Added schema
* `yarn run prettier` and enhancements to collapsed, focus, and value
Correct me if I am wrong, but I believe that this `return true` is a no-op. I removed it and everything kept working as usual. And, when I was following the tutorial, that particular line created an interrogation mark in my brain. So, my suggestion is to remove that line to avoid creating entropy for no reason.
* Clarify children access in renderEditor in docs
* Applied review changes of renderEditor doc update
* Updated renderEditor docs to match Slate 0.43
* Prettified plugins.md
The Custom Formatting Walkthrough does not work as expected. When
Ctrl + B is pressed it applies both Bold and Code styles to the
content. This is because of the case statement running beyond
the Bold case due to the absence of a break keyword.
* 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
#### Is this adding or improving a _feature_ or fixing a _bug_?
Adding and improving
#### What's the new behavior?
Renames the following node methods (deprecating the old ones):
- `getBlocksAtRangeAsArray` -> `getLeafBlocksAtRangeAsArray`
- `getBlocksAtRange` -> `getLeafBlocksAtRange`
- `getInlinesAtRangeAsArray` -> `getLeafInlinesAtRangeAsArray`
- `getInlinesAtRange` -> `getLeafInlinesAtRange`
Adds the following nodes methods:
- `getRootBlocksAtRange`
- `getRootInlinesAtRange`
#### How does this change work?
Have not changed the implementation of the renamed methods. Added tests for both renamed methods and added methods.
#### Have you checked that...?
* [x] The new code matches the existing patterns and styles.
* [x] The tests pass with `yarn test`.
* [x] The linter passes with `yarn lint`. (Fix errors with `yarn prettier`.)
* [x] The relevant examples still work. (Run examples with `yarn watch`.)
#### Does this fix any issues or need any specific reviewers?
Discussed in #2351
* add placeholder plugin in slate-react
* remove renderPlaceholder logic
* extract placeholder into a plugin
* remove other old placeholder-based logic
* update changelogs
#### 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
* Rename compare function in path-utils to compareOfSameSize
To make way for a new function that makes a full comparison
* Add compare function to path-utils that handles paths of different sizes
* Add function isAfterRange to Point
* Add function isBeforeRange to Point
* Add function isAtStartOfRange to Point
* Add function isAtEndOfRange to Point
* Add function isInRange to Point
* Add range comparison methods to the documentation of the Point model
* Remove `compareOfSameSize` in `path-utils.js`
Using `compare` instead
* Add `Point.isBeforePoint`
* Add `Point.isAfterPoint`
* Use own methods internally for range comparisons in `Point`
* Return null if paths don't finally match in `compare` method of `path-utils`
To convey that it is not a normal scenario
* Add first test for `Point` model (testing `isAfterPoint`)
* Add tests for `Point.isAfterPoint`
* Add tests for `Point.isBeforePoint`
* Add tests for `Point.isAfterRange`
* Add tests for `Point.isBeforeRange`
* Add tests for `Point.isAtEndOfRange`
* Add tests for `Point.isAtStartOfRange`
* Add tests for `Point.isInRange`
* fold Stack into Editor
* switch Change objects to be tied to editors, not values
* introduce controller
* add the "commands" concept
* convert history into commands on `value.data`
* add the ability to not normalize on editor creation/setting
* convert schema to a mutable constructor
* add editor.command method
* convert plugin handlers to receive `next`
* switch commands to use the onCommand middleware
* add queries support, convert schema to queries
* split out browser plugin
* remove noop util
* fixes
* fixes
* start fixing tests, refactor hyperscript to be more literal
* fix slate-html-serializer tests
* fix schema tests with hyperscript
* fix text model tests with hyperscript
* fix more tests
* get all tests passing
* fix lint
* undo decorations example update
* update examples
* small changes to the api to make it nicer
* update docs
* update commands/queries plugin logic
* change normalizeNode and validateNode to be middleware
* fix decoration removal
* rename commands tests
* add useful errors to existing APIs
* update changelogs
* cleanup
* fixes
* update docs
* add editor docs