1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

595 Commits

Author SHA1 Message Date
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
e9c3c39d69 update changelog 2018-08-21 20:40:25 -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
d94326512c remove old SUPPORTED_EVENTS logic 2018-08-16 15:24:19 -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
Ian Storm Taylor
3bfec770e0 fix slate-dev-environment SUPPORTED_EVENTS export 2018-08-16 15:09:40 -07:00
danielsarin
4d31983a94 IE11 html serializer parser fix (#2087)
#### Is this adding or improving a _feature_ or fixing a _bug_?

This should fix `Unable to get property 'childNodes' of undefined or null reference` error in IE11 when using slate-html-serializer and deserializing an empty string (#1757, #1756).

#### What's the new behavior?

The `defaultParseHtml` now returns an empty body element if the parsed body is null. 

I tested this in the latest Chrome, Firefox and Safari, and they all seemed to work similarly. If the html param was an empty string, `parseFromString` returned a document element, which had a body property which was an empty body element. In IE11 though the body property was null, which caused the undefined or null reference later.

#### 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`.)
2018-08-16 15:05:08 -07:00
Jinxuan Zhu
183a5d36ff Introduce Range.updatePoints (#2080)
* With Mutation

* Use updatePoints

* Remove mapRanges changes

* Remove mapRanges changes

* Remove mapRanges changes
2018-08-16 15:04:05 -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
3cf62ef394 add schema text validators to be functions 2018-08-15 17:58:02 -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
1a0979b849 update changelog 2018-08-15 12:42:45 -07:00
David Chang
f37dd21137 [hyperscript] rename decorators option in params to decorations (#2074)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Debt.

#### What's the new behavior?

`createHyperscript` takes an options object that now looks for the `decorations` property instead of the `decorators` property

#### How does this change work?

Pretty straightforward rename of an option, then all of its uses and wherever the term decorators showed up in docs

#### 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: #1996
Reviewers: @ianstormtaylor
2018-08-15 12:41:39 -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
Ian Storm Taylor
aa0ef4d24f
fix schema defaultNormalize to use normalize:false (#2083)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Bug.

#### What's the new behavior?

All normalizing change methods should use `normalize: false` otherwise the normalization can recurse and cause strange errors.

#### 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-15 12:34:50 -07:00
Jinxuan Zhu
5c7211e0fe Warn about duplicate keys (#2081)
* Fix duplicate key in insert node

* Add warning on duplicate keys

* A lot of keys are duplicated

* Ensure error logging

* Finally Fixed

* Change PR

* bug fix

* comment fix

* Add getKeysToPathsTable into text

* refactor forbidden interface

* Refactor forbidden function

* Linting

* Change warn message

* Fix doc
2018-08-15 12:27:47 -07:00
Jinxuan Zhu
48e5c6e04b Refactor code with immutable-js in Model (#2077)
* Ugly Commit

* Small Styling issues about immutable-js

* Remove an unnecessary List
2018-08-14 10:19:56 -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
Bryan Haakman
7ff7a89ea7 fix pointForward and pointBackward (#2053)
* fix next being undefined in pointForward. Adds a check that next exists

* fix both pointForward and pointBackward

* fix for lint tests
2018-08-08 15:59: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
Slapbox
4d97496299 Fixes inability to deleteWordBackward at line start (#2046)
* 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

* Allows for Ctrl+Backspace on line start

Previously Ctrl+Backspace would do nothing instead of continuing on to the above block.

* Tests that deleteWordBackwards joins lines properly
2018-08-07 16:21:30 -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
Slapbox
3eabdea8d6 Adds Unicode LF character to line endings for clipboard plaintext (#2040)
* 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
2018-08-07 08:43:17 -07:00
Jinxuan Zhu
2e9b94b481 [Docs] Fix Packages/Readme.md (#1859)
* Fix document

* Fix lint
2018-08-06 13:22:31 -07:00
Ian Storm Taylor
7e0929bd22 Publish
- slate-base64-serializer@0.2.47
 - slate-html-serializer@0.6.19
 - slate-hyperscript@0.7.1
 - slate-plain-serializer@0.5.28
 - slate-prop-types@0.4.45
 - slate-react@0.15.1
 - slate-schema-violations@0.1.26
 - slate-simulator@0.4.45
 - slate@0.37.1
2018-08-06 13:16:46 -07:00
Ian Storm Taylor
52fc5611fc fix moveToEndOfPreviousBlock selection methods 2018-08-06 13:10:26 -07:00
Ian Storm Taylor
ffd9ead175 update changes docs, add missing selection changes 2018-08-06 11:46:42 -07:00
Jinxuan Zhu
58c644323f Add coverage test with mocha and codecov (#2037)
* 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
2018-08-06 10:31:42 -07:00
Ian Storm Taylor
07d7f51bbc Publish
- slate-base64-serializer@0.2.46
 - slate-html-serializer@0.6.18
 - slate-hyperscript@0.7.0
 - slate-plain-serializer@0.5.27
 - slate-prop-types@0.4.44
 - slate-react@0.15.0
 - slate-schema-violations@0.1.25
 - slate-simulator@0.4.44
 - slate@0.37.0
2018-08-03 15:41:27 -07:00
Ian Storm Taylor
adfc093e4e add more selection tests 2018-08-03 15:36:43 -07:00
Ian Storm Taylor
ff598bc5a1 update changelog 2018-08-03 15:28:02 -07:00
Ian Storm Taylor
e317892f44 update changelog 2018-08-03 15:27:20 -07:00
Zach Schneider
70d9e7951b Remove the deprecated Character model, and methods that reference it (#2016)
Closes #1999
2018-08-03 15:24:05 -07:00
Ian Storm Taylor
1695f5a20c update changelog 2018-08-03 15:19:18 -07:00
Ian Storm Taylor
38918c5e1c update changelog 2018-08-03 15:18:02 -07:00
Ian Storm Taylor
ea6c4d9da2 update peerDependencies 2018-08-03 15:11:28 -07:00
Ian Storm Taylor
152a4aeb54 update changelog 2018-08-03 15:10:58 -07:00
Ian Storm Taylor
d2f6e06a66 update setters and docs 2018-08-03 15:08:20 -07:00
Ian Storm Taylor
f6065e9eb8 update changelog 2018-08-03 15:05:43 -07:00