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

548 Commits

Author SHA1 Message Date
Ian Storm Taylor
aba8f19d0e Publish
- slate-base64-serializer@0.2.68
 - slate-html-serializer@0.7.7
 - slate-hyperscript@0.10.7
 - slate-plain-serializer@0.6.7
 - slate-prop-types@0.4.66
 - slate-react@0.18.10
 - slate-simulator@0.4.66
 - slate@0.41.2
2018-09-26 13:20:34 -07:00
Ian Storm Taylor
7b4eca5e16 Merge branch 'master' of github.com:ianstormtaylor/slate 2018-09-26 13:12:42 -07:00
Ian Storm Taylor
af8432f639 fix onClick when not finding a node 2018-09-26 13:12:35 -07:00
Grey Osten
329dac72d3 Normalize copying void inline nodes (#2198)
When a void inline nodes is selected along with other text/content it can be copied to the clipboard. When it’s the only thing selected it is ignored because anything marked contentedtiable=false is.
Updated isInEditor to return true if a contenteditable=false has a parent that is a void inline node.
2018-09-22 11:13:22 -07:00
Ian Storm Taylor
bf9b03e634 Publish
- slate-base64-serializer@0.2.67
 - slate-html-serializer@0.7.6
 - slate-hyperscript@0.10.6
 - slate-plain-serializer@0.6.6
 - slate-prop-types@0.4.65
 - slate-react@0.18.9
 - slate-simulator@0.4.65
 - slate@0.41.1
2018-09-21 15:09:49 -07:00
Ian Storm Taylor
ca6920a88f Publish
- slate-base64-serializer@0.2.66
 - slate-html-serializer@0.7.5
 - slate-hyperscript@0.10.5
 - slate-plain-serializer@0.6.5
 - slate-prop-types@0.4.64
 - slate-react@0.18.8
 - slate-simulator@0.4.64
 - slate@0.41.0
2018-09-21 11:19:48 -07:00
Ian Storm Taylor
c9cf16d019
refactor normalization to be operations-based (#2193)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Improvement.

#### What's the new behavior?

This changes the normalization logic to be operations (and `key`) based, instead of the current logic which is more haphazard, and which has bugs that lead to non-normalized documents in certain cases.

#### How does this change work?

Now, every time a change method is called, after it applies its operations, those operations will be normalized. Based on each operation we can know exactly which nodes are "dirty" and need to be re-validated.

This change also makes it easy for the `withoutNormalizing` (previously `withoutNormalization`) helper to be much more performant, and only normalize the "dirty" nodes instead of being forced to handle the entire document.

To accommodate this new behavior, the old "operation flags" have been removed, replaced with a set of more consistent helpers:

- `withoutNormalizing`
- `withoutSaving`
- `withoutMerging`

All of them take functions that will be run with the desired behavior in scope, similar to how Immutable.js's own `withMutations` works. Previously this was done with a more complex set of flags, which could be set and unset in a confusing number of different ways, and it was generally not very well thought out. Hopefully this cleans it up, and makes it more approachable for people.

We also automatically use the `withoutNormalizing` helper function for all of the changes that occur as part of schema `normalize` functions. Previously people had to use `{ normalize: false }` everywhere in those functions which was error-prone.

With this new architecture, you sure almost never need to think about normalization. Except for cases where you explicitly want to move through an interim state that is invalid according to Slate's default schema or your own custom schema. In which case you'd use `withoutNormalizing` to allow the invalid interim state to be moved through.

#### 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: #1363
Fixes: #2134
Fixes: #2135
Fixes: #2136
Fixes: #1579
Fixes: #2132
Fixes: #1657
2018-09-21 11:15:04 -07:00
Ian Storm Taylor
fd1832c73f Publish
- slate-base64-serializer@0.2.65
 - slate-hotkeys@0.2.5
 - slate-html-serializer@0.7.4
 - slate-hyperscript@0.10.4
 - slate-plain-serializer@0.6.4
 - slate-prop-types@0.4.63
 - slate-react@0.18.7
 - slate-simulator@0.4.63
 - slate@0.40.4
2018-09-21 09:43:39 -07:00
Ian Storm Taylor
fd87c746f8 fix versions... 2018-09-21 09:42:05 -07:00
Ian Storm Taylor
018ada8b88 fix selection.marks preservation from #2181 2018-09-18 10:08:33 -07:00
Nicolas Gaborit
4749cfc8b1 Actually fix marks being cleared on selection events (#2181)
* Fix marks being cleared on selection events

* Fix mistake
2018-09-18 09:49:18 -07:00
Bjørge Næss
3e7116dce1 Gracefully handle permission denied error when checking for element.nodeType (#2178) 2018-09-17 18:38:49 -07:00
Nicolas Gaborit
ea950ac1af Fix marks being cleared on selection events (#2158) 2018-09-17 18:33:01 -07:00
Per-Kristian Nordnes
f75a274c0e Fix deprecated .move > .moveForward in the after plugin (#2179) 2018-09-17 18:28:22 -07:00
Damien Erambert
222f746e85 Avoid crash in updateSelection() in content when window.getSelection() returns null (#2163) 2018-09-17 18:27:10 -07:00
Per-Kristian Nordnes
6340469266
Fix deprecated moveToStartOf and moveToEndOf (#2155)
In slate-react module (get-event-range)
2018-09-08 01:34:12 +02:00
Ian Storm Taylor
6369d0523a Publish
- slate-react@0.18.5
2018-09-04 12:00:41 -07:00
Eric Edem
3db717761e fix(content): attach the right onNativeSelectionChange. (#2150)
This undoes a recent change https://github.com/ianstormtaylor/slate/pull/2131

Which hooked up `this.handlers.onNativeSelectionChange` to `'selectionchange'` as well as `this.handlers.onBeforeInput` to `'beforeinput'`.

It turns out that in order to fix the iOS issues, we only needed the change to `onBeforeInput`. The corect handler for `'selectionchange'` is the instance method `this.onNativeSelectionChange`. This broke a whole bunch of focus related issues.
2018-09-04 10:36:48 -07:00
Ian Storm Taylor
54611b7dd7 Publish
- slate-react@0.18.4
2018-08-29 14:03:31 -07:00
Eric Edem
9d0546fad3 fix(content): use handlers that actually exist in event listeners (#2131)
* fix(content): use handlers that actually exist in event listeners

In a recent change, handlers now only exist in `Content#handlers`, but there were still a couple of places where they were being dereferenced directly from the instance. This was causing some side effects in iOS.

Fixes #2125
Fixes #2129

* fix(content): also fix removeEventListeners
2018-08-29 12:32:48 -07:00
Ian Storm Taylor
ba9b79112e Publish
- slate-base64-serializer@0.2.63
 - slate-html-serializer@0.7.2
 - slate-hyperscript@0.10.2
 - slate-plain-serializer@0.6.2
 - slate-prop-types@0.4.61
 - slate-react@0.18.3
 - slate-simulator@0.4.61
 - slate@0.40.2
2018-08-24 09:01:31 -07:00
Ian Storm Taylor
584ffec626 Publish
- slate-base64-serializer@0.2.62
 - slate-html-serializer@0.7.1
 - slate-hyperscript@0.10.1
 - slate-plain-serializer@0.6.1
 - slate-prop-types@0.4.60
 - slate-react@0.18.2
 - slate-simulator@0.4.60
 - slate@0.40.1
2018-08-23 13:54:58 -07:00
Ian Storm Taylor
8358d3777f Publish
- slate-react@0.18.1
2018-08-23 11:34:31 -07:00
Ian Storm Taylor
5d0f53da3f fix assertPathByKey, fixes #2119 2018-08-23 11:32:30 -07:00
Ian Storm Taylor
729727d91e Publish
- slate-base64-serializer@0.2.61
 - slate-dev-warning@0.0.1
 - slate-html-serializer@0.7.0
 - slate-hyperscript@0.10.0
 - slate-plain-serializer@0.6.0
 - slate-prop-types@0.4.59
 - slate-react@0.18.0
 - slate-simulator@0.4.59
 - slate@0.40.0
2018-08-22 18:31:50 -07:00
Ian Storm Taylor
36ed4397d8
Remove deprecations (#2113)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Debt.

#### What's the new behavior?

This removes almost all existing deprecations from previous API changes, to save on filesize and reduce complexity in the codebase going forward.

It also changes from using the `slate-dev-logger` to using the Facebook-inspired `slate-dev-warning` which can be compiled out of production builds with [`babel-plugin-dev-expression`](https://github.com/4Catalyzer/babel-plugin-dev-expression) to save even further on file size.

The only deprecations it keeps are in the `fromJSON` methods for data model changes like `.kind` and `.leaves` which may still may not have been migrated in databases, since this is a bigger pain point.

#### 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: #1922 
Fixes: #2105
Fixes: #646 
Fixes: #2109
Fixes: #2107 
Fixes: #2018
2018-08-22 18:22:40 -07:00
Ian Storm Taylor
3d48f7a3e0 Publish
- slate-base64-serializer@0.2.60
 - slate-html-serializer@0.6.32
 - slate-hyperscript@0.9.3
 - slate-plain-serializer@0.5.41
 - slate-prop-types@0.4.58
 - slate-react@0.17.3
 - slate-schema-violations@0.1.39
 - slate-simulator@0.4.58
 - slate@0.39.3
2018-08-22 15:43:19 -07:00
Ian Storm Taylor
ec678540cf Publish
- slate-base64-serializer@0.2.59
 - slate-html-serializer@0.6.31
 - slate-hyperscript@0.9.2
 - slate-plain-serializer@0.5.40
 - slate-prop-types@0.4.57
 - slate-react@0.17.2
 - slate-schema-violations@0.1.38
 - slate-simulator@0.4.57
 - slate@0.39.2
2018-08-22 14:34:06 -07:00
Ian Storm Taylor
a07f526192 Publish
- slate-base64-serializer@0.2.58
 - slate-html-serializer@0.6.30
 - slate-hyperscript@0.9.1
 - slate-plain-serializer@0.5.39
 - slate-prop-types@0.4.56
 - slate-react@0.17.1
 - slate-schema-violations@0.1.37
 - slate-simulator@0.4.56
 - slate@0.39.1
2018-08-22 14:14:48 -07:00
Ian Storm Taylor
357239dbec Publish
- slate-base64-serializer@0.2.57
 - slate-html-serializer@0.6.29
 - slate-hyperscript@0.9.0
 - slate-plain-serializer@0.5.38
 - slate-prop-types@0.4.55
 - slate-react@0.17.0
 - slate-schema-violations@0.1.36
 - slate-simulator@0.4.55
 - slate@0.39.0
2018-08-22 12:27:46 -07:00
Ian Storm Taylor
ecf48926cc
add Decoration and Selection models (#2112)
#### 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: #1952 
Fixes: #1807 
Fixes: https://github.com/ianstormtaylor/slate/issues/2110
2018-08-22 12:25:22 -07:00
Ian Storm Taylor
1f317cd9b4 Publish
- slate-base64-serializer@0.2.56
 - slate-html-serializer@0.6.28
 - slate-hyperscript@0.8.5
 - slate-plain-serializer@0.5.37
 - slate-prop-types@0.4.54
 - slate-react@0.16.2
 - slate-schema-violations@0.1.35
 - slate-simulator@0.4.54
 - slate@0.38.2
2018-08-22 12:22:03 -07:00
Bryan Haakman
b379a19ac3 use fragment instead of node transfer type on drag (#2090)
* 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
2018-08-22 12:15:55 -07:00
Ian Storm Taylor
c7521225cf Publish
- slate-base64-serializer@0.2.55
 - slate-html-serializer@0.6.27
 - slate-hyperscript@0.8.4
 - slate-plain-serializer@0.5.36
 - slate-prop-types@0.4.53
 - slate-react@0.16.1
 - slate-schema-violations@0.1.34
 - slate-simulator@0.4.53
 - slate@0.38.1
2018-08-21 20:38:40 -07:00
Ian Storm Taylor
7e8ee5b0e8 add value deprecations 2018-08-21 20:37:08 -07:00
Ian Storm Taylor
46898fe7f7 Publish
- slate-base64-serializer@0.2.54
 - slate-html-serializer@0.6.26
 - slate-hyperscript@0.8.3
 - slate-plain-serializer@0.5.35
 - slate-prop-types@0.4.52
 - slate-react@0.16.0
 - slate-schema-violations@0.1.33
 - slate-simulator@0.4.52
 - slate@0.38.0
2018-08-21 15:59:17 -07:00
Ian Storm Taylor
0f9749e462 update changelog 2018-08-21 15:57:31 -07:00
Ian Storm Taylor
00d5785226
deprecate isVoid and related properties/methods (#2102)
#### 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`.)
2018-08-21 15:52:44 -07:00
Ian Storm Taylor
fa343c07f4 Publish
- slate-dev-environment@0.2.0
 - slate-hotkeys@0.2.3
 - slate-react@0.15.9
2018-08-16 15:26:05 -07:00
Ian Storm Taylor
0b74a37928 Publish
- slate-base64-serializer@0.2.53
 - slate-dev-environment@0.1.6
 - slate-hotkeys@0.2.2
 - slate-html-serializer@0.6.25
 - slate-hyperscript@0.8.2
 - slate-plain-serializer@0.5.34
 - slate-prop-types@0.4.51
 - slate-react@0.15.8
 - slate-schema-violations@0.1.32
 - slate-simulator@0.4.51
 - slate@0.37.7
2018-08-16 15:19:34 -07:00
Jinxuan Zhu
877dea16bf Upgrade to React v16 lifecycle (#1975)
* 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
2018-08-16 14:59:29 -07:00
Ian Storm Taylor
d05e90e546 Publish
- slate-base64-serializer@0.2.52
 - slate-html-serializer@0.6.24
 - slate-hyperscript@0.8.1
 - slate-plain-serializer@0.5.33
 - slate-prop-types@0.4.50
 - slate-react@0.15.7
 - slate-schema-violations@0.1.31
 - slate-simulator@0.4.50
 - slate@0.37.6
2018-08-15 18:03:10 -07:00
Ian Storm Taylor
55f09995a3 Publish
- slate-base64-serializer@0.2.51
 - slate-html-serializer@0.6.23
 - slate-hyperscript@0.8.0
 - slate-plain-serializer@0.5.32
 - slate-prop-types@0.4.49
 - slate-react@0.15.6
 - slate-schema-violations@0.1.30
 - slate-simulator@0.4.49
 - slate@0.37.5
2018-08-15 12:44:46 -07:00
Ian Storm Taylor
acfffe0c2a Publish
- slate-base64-serializer@0.2.50
 - slate-dev-environment@0.1.5
 - slate-dev-logger@0.1.43
 - slate-hotkeys@0.2.1
 - slate-html-serializer@0.6.22
 - slate-hyperscript@0.7.4
 - slate-plain-serializer@0.5.31
 - slate-prop-types@0.4.48
 - slate-react@0.15.5
 - slate-schema-violations@0.1.29
 - slate-simulator@0.4.48
 - slate@0.37.4
2018-08-15 12:40:25 -07:00
Jinxuan Zhu
dc95ad66a5 Do not use requestAnimation if DataTransfer is available (#2052)
*  not to requestAnimationFrame in modern browser

* Fix bugs

* Fix bugs

* Fix bugs

* Use callback
2018-08-10 10:40:14 -07:00
Ian Storm Taylor
f812816b7d
refactor native beforeinput handling (#2063)
* refactor native beforeinput handling

* fix lint
2018-08-09 01:06:31 -07:00
Ian Storm Taylor
a396d013ef Publish
- slate-base64-serializer@0.2.49
 - slate-html-serializer@0.6.21
 - slate-hyperscript@0.7.3
 - slate-plain-serializer@0.5.30
 - slate-prop-types@0.4.47
 - slate-react@0.15.4
 - slate-schema-violations@0.1.28
 - slate-simulator@0.4.47
 - slate@0.37.3
2018-08-08 16:31:10 -07:00
Ian Storm Taylor
d4b52e3eb5 Publish
- slate-base64-serializer@0.2.48
 - slate-html-serializer@0.6.20
 - slate-hyperscript@0.7.2
 - slate-plain-serializer@0.5.29
 - slate-prop-types@0.4.46
 - slate-react@0.15.3
 - slate-schema-violations@0.1.27
 - slate-simulator@0.4.46
 - slate@0.37.2
2018-08-07 19:31:35 -07:00
Ian Storm Taylor
1efe55602f Publish
- slate-hotkeys@0.2.0
 - slate-react@0.15.2
2018-08-07 16:03:20 -07:00
Ian Storm Taylor
fd9243b8f5
refactor slate-hotkeys, fix deleting at start of block (#2048) 2018-08-07 15:58:33 -07:00