#### Is this adding or improving a _feature_ or fixing a _bug_?
Improvement.
#### What's the new behavior?
This introduces two new models: `Decoration` and `Selection`, which both implement the simpler `Range` interface. This way we can introduce properties to these concepts without having to have them live on all ranges, and we can start to introduce more helpful methods specific to each one's needs.
It also means we don't need to move `isFocused` to value, which saves some complexity on the operations side, retaining `set_selection` as the only way selections are modified.
In the process, it also cleans up a lot of the existing model logic for implementing the `Node` interface, and introduces another `Common` interface for shared properties of all Slate models.
#### How does this change work?
It introduces a new `interfaces/` directory where common sets of properties can be declared, and mixed in to the models with the new (simple) `mixin` utility.
#### 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?
Fixes: #1952Fixes: #1807
Fixes: https://github.com/ianstormtaylor/slate/issues/2110
* use fragment instead of node transfer type on drag
* remove the range.isCollapsed check in Changes.deleteAtRange so that it will also remove the selection when only a void node is selected
* fix selection before starting the drag
* fix linting errors
* review fixes
* align with new way of handling void nodes via schema
#### Is this adding or improving a _feature_ or fixing a _bug_?
Improvement.
#### What's the new behavior?
This deprecates the `node.isVoid` property in favor of using `schema.isVoid(node)`, which will allow us to remove the hardcoded "void" concept from the data model, and have it depend on the schema instead.
This allows you to build different kinds of editors, with different void semantics, depending on your use case, without having this information hardcoded in the data itself. Even switching the `isVoid` semantics on the fly based on a user toggling a setting for example.
#### How does this change work?
This is the first step, which just deprecates `node.isVoid`, and provides the new alternative of `schema.isVoid(node)`, while still using the `isVoid` value of nodes under the covers.
The next step is to change the logic to search the schema for real, and completely remove the `isVoid` value from nodes.
#### Have you checked that...?
<!--
Please run through this checklist for your pull request:
-->
* [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`.)
* Trying to use memoization and upgrade to react v16
* Fix error
* Fix error
* Fix handlers error
* Add annotation
* Remove EventHandlers
* No state
* Remove un-necessary polyfill
* Remove un-necessary polyfill
* Remove un-necessary handlers settings
* Early Return
* Fix Early Return
* Fix onChange
* Do not run onChange stack twice on same change
* Update annotation
* Better sense of resolve++
* Cache value in onChange and didMount
* Remove un-necessary rechack
* Renaming
* Remove change in leaf.js
* Handlers as this.handlers
* do not re-initialize change in onChange
* Re-run onChange stack only when change happens
* Update value when stack changes
* Rename to memoize-one
* queue changes
* Unify interface
* Fix bug
* Add document
* Remove id
* Do not use map
* Fix bug
* Fix eslint
* Fix update when props.value changes
* Add annotation
* Fix stack
* Inline queueChange
* Restore onChange
* restore onChange
* Refactor change and onChange
* Use onChange as the single interface for update
* Do not flushChange if inside event
* Give a warning about synchronous editor.change call
* Change isInChange in editor.change
* refactor resolution and tmp logic, cleanup code
* Adds Unicode LF character to line endings for clipboard plaintext
This addresses https://github.com/ianstormtaylor/slate/issues/1932
* Fixes plaintext/unicode pastes not having line breaks
* Removes stray spaces for Prettier
* Refactors Value creation to save 4 lines
* Run mocha test with module alias
* Running test with babel module alias
* Fix model alias
* Fix model alias
* Resolve module alias
* Running test with babel module alias
* Connect to codecov
* add codecov to travis
* stop if yarn test has errors
* Still cannot collect data from slate modules
* Try to check whether it works with codecov
* Move config to nycrc
* Remove nyc require
* Update nyc to use src
* better before_script
#### Is this adding or improving a _feature_ or fixing a _bug_?
Improvement.
#### What's the new behavior?
Adds a `Node.createRange` method for more easily creating ranges that are normalized to the current document. As well as a `Node.resolveRange` lower-level method for just doing the normalization on an existing range.
Later we can deprecate `Range.normalize` since it should be on the node instead.
#### Have you checked that...?
<!--
Please run through this checklist for your pull request:
-->
* [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?
Fixes: #2011
#### Is this adding or improving a _feature_ or fixing a _bug_?
Bug.
#### What's the new behavior?
Fixes selection operations from being duplicated.
#### How does this change work?
Previously the selection properties were compared by reference, but paths are immutable `List` objects, which always show up as having changed, resulting in extra selection operations that without any real changes. We now use `Immutable.is` to remove those duplicates, fixing the undo history stack.
#### Have you checked that...?
<!--
Please run through this checklist for your pull request:
-->
* [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?
Fixes: #2006
#### Is this adding or improving a _feature_ or fixing a _bug_?
Improvement.
#### What's the new behavior?
- Tweaking the declarative schema definition syntax to make it easier to represent more complex states, as well as enable it to validate previously impossible things.
- Rename `validateNode` to `normalizeNode` for clarity.
- Introduce `validateNode`, `checkNode`, `assertNode` helpers for more advanced use cases, like front-end API validation of "invalid" fields that need to be fixed before they are sent to the server.
#### How does this change work?
The `schema.blocks/inlines/document` entries are now a shorthand for a more powerful `schema.rules` syntax. For example, this now allows for declaratively validating by a node's data, regardless of type:
```js
{
rules: [
{
match: {
data: { id: '2kd293lry' },
},
nodes: [
{ match: { type: 'paragraph' }},
{ match: { type: 'image' }},
]
}
]
}
```
Previously you'd have to use `validateNode` for this, since the syntax wasn't flexible enough to validate nodes without hard-coding their `type`.
This also simplifies the "concatenation" of schema rules, because under the covers all of them are implemented using the `schema.rules` array, so they simply take effect in order, just like everything else in plugins.
#### Have you checked that...?
<!--
Please run through this checklist for your pull request:
-->
* [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?
Fixes: #1842Fixes: #1923
#### Is this adding or improving a _feature_ or fixing a _bug_?
Feature.
#### What's the new behavior?
This pull request adds paths to `Range` objects, including the selection. The paths and keys are kept in sync automatically, so that you can use whichever is ideal for your use case.
This should allow us to use paths for lots of the internal logic, which are much quicker to work with than keys since they avoid having to lookup the key in the document and can just traverse right to the node in question.
#### How does this change work?
`Range` objects have two new properties:
```js
range.anchorPath
range.focusPath
```
(Eventually these will be `range.anchor.path` and `range.focus.path` when points are introduced.)
When operations occur and whenever ranges are created/normalized, the paths are updated and kept in sync with the keys.
#### Have you checked that...?
<!--
Please run through this checklist for your pull request:
-->
* [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?
Fixes: https://github.com/ianstormtaylor/slate/issues/1408
Fixes: https://github.com/ianstormtaylor/slate/issues/1567
* Use slate rather than relative path
* Move benchmark to one dir
* Use slate-* instead of relative path
* Before and After Function
* Remove un-necessary cross-env
* Hard fix
* Lint the hard fix
* Reset memory in bench()
* Working on Benchmark Frameworks
* Rename to slate-dev-benchmark
* Add packages
* Fix prettier bug
* Benchmark framework is in working
* Do not log in test
* max times test
* mute logger in test
* add hr time
* Better support for maxTime; add support of split runs to save memory space
* Fix maxTries
* Add global.gc
* Global gc for each bench
* Better test interface
* Test max-time
* Test max-time done
* Add Benchmark among packages
* Starting to get benchmark running
* Pure Node lib
* Change babelrc for pure Node benchmark
* Moving Benchmarks
* Get benchmark and test running
* Get benchmark for slate-html-serializer
* add slate-react
* add slate/changes
* all benchmarks are converted
* Run benchmark by yarn
* Run benchmark with expose-gc
* Annotate Bench.js
* Do not bundle slate-dev-benchmark in rollup
* Add annotation
* Allow config file to enable part benchmark compare
* Add config for compare
* support compare.js
* Do not re-allocate memory; due to a large heap taken influence result
* Render with Decorations
* get active marks at range
* Fix bug in showing percents
* Fix percent showing bug
* chore: add more benches
* Better output of benchmark
* Fix linting
* decoration and normal as different benchmark test
* Fix deserialize benchmark
* README.md
* Fix Readme.md
* README.md
* block-spacing config
* safer user config loading
* use package.json to load package in test
* Consistent linting
* move components to parent directory
* Annotation styling in package
* margin line before multi-line block
* Fix naive bug
* Fix naive bug
* Fix a blank line
* only log user and hr
* Better name
* Better annotation for runBundleTasks
* Fix typo
* Better logger
* Move async to test
* Omit skip
* Only log the user space time
* Single line async sleep
* file name fix
* Fix annotation
* Better output of compare
* Remove get-characters(-at-range) benchmarks
* Restore emoji
* Capitalize types
* Remove compare to another area
* Add grep and config interface
* Linting files
* Linting benchmarks
* Linting benchmarks
* Update yarn.lock
* Initial fixes for IE compat of cloneFragment
* Used prettier to fix styling
* Removed solutions that can be polyfilled; added COMPAT comment
* Updated FAQ to reflect ideology towards IE
* Update faq.md
* Update faq.md
* Update faq.md
Right clicks aren't handled by onClick in a content-editable component. So we need access to a onContextMenu handler to handle these events properly.
My use case is to be able to open a context menu with actions when the user right-clicks a specific inline node.
There were three problems preventing drag-and-drop in IE:
* IE [doesn't consider contentEditables as inputs](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/913982/) when it comes to calling `onDrop`.
* Setting `dropEffect` causes an `unspecified error`.
* You can only get a cursor position from a point with `createTextRange` and `moveToPoint`. Also, `moveToPoint` raises an error if it's called during a dropEvent.