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

2551 Commits

Author SHA1 Message Date
Ian Storm Taylor
1748a4b0c1
Refactor tests (#2021)
* add slate-dev-test-utils, refactor tests to use fixtures util

* cleanup top-level test files

* tweaks
2018-08-01 09:16:02 -07:00
Florian
f7fd0b7a4e Docs: Remove leading semicolon in code snippet (#2020)
* Remove leading semicolon in code snippet

* Update changes.md
2018-08-01 09:04:12 -07:00
Cheng Zheng
142d9a82f6 Add Products: Taskade (#2008)
* Add Products: Taskade

* Alphabet order

* remove empty line
2018-07-31 22:39:32 -07:00
Martti Laine
1ff1dfa4b8 Add slate-react to the bundled source guide (#2010) 2018-07-31 16:46:30 -07:00
Ian Storm Taylor
64000a97aa Publish
- slate-base64-serializer@0.2.44
 - slate-html-serializer@0.6.16
 - slate-hyperscript@0.6.2
 - slate-plain-serializer@0.5.25
 - slate-prop-types@0.4.42
 - slate-react@0.14.2
 - slate-schema-violations@0.1.23
 - slate-simulator@0.4.42
 - slate@0.36.1
slate@0.36.1 slate-simulator@0.4.42 slate-schema-violations@0.1.23 slate-react@0.14.2 slate-prop-types@0.4.42 slate-plain-serializer@0.5.25 slate-hyperscript@0.6.2 slate-html-serializer@0.6.16 slate-base64-serializer@0.2.44
2018-07-31 16:31:54 -07:00
Ian Storm Taylor
06bca539dc
fix getFragmentAtRange to use paths properly (#2012)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Bug.

#### What's the new behavior?

Fixes `Node.getFragmentAtRange` to use the proper argument signature when calling `Node.splitNode`, and refactors it to use paths for all of its logic.

#### 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: #2009
2018-07-31 16:26:52 -07:00
Ian Storm Taylor
638d3e8e61 Publish
- slate-base64-serializer@0.2.43
 - slate-dev-logger@0.1.41
 - slate-html-serializer@0.6.15
 - slate-hyperscript@0.6.1
 - slate-plain-serializer@0.5.24
 - slate-prop-types@0.4.41
 - slate-react@0.14.1
 - slate-schema-violations@0.1.22
 - slate-simulator@0.4.41
 - slate@0.36.0
slate@0.36.0 slate-simulator@0.4.41 slate-schema-violations@0.1.22 slate-react@0.14.1 slate-prop-types@0.4.41 slate-plain-serializer@0.5.24 slate-hyperscript@0.6.1 slate-html-serializer@0.6.15 slate-dev-logger@0.1.41 slate-base64-serializer@0.2.43
2018-07-27 15:50:29 -07:00
Ian Storm Taylor
46a6086968 fix lint 2018-07-27 15:46:35 -07:00
Ian Storm Taylor
d461fdae72 fix sibling validation error names 2018-07-27 15:45:27 -07:00
Ian Storm Taylor
2092981e0c update changelog 2018-07-27 15:40:07 -07:00
Ian Storm Taylor
49ee734241 update changelog 2018-07-27 15:34:40 -07:00
Ian Storm Taylor
764cd12dec update changelog 2018-07-27 15:34:31 -07:00
Ian Storm Taylor
9a6372ca4e update changelog 2018-07-27 15:32:50 -07:00
Ian Storm Taylor
ded82812b0
Refactor schema (#1993)
#### 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: #1842
Fixes: #1923
2018-07-27 15:27:07 -07:00
Germán Méndez Bravo
d01c441f68 Accept legacy "ranges" additionally to "leaves" (#1990)
* Accept ranges additionally to leaves

For compatibility with older slate JSON documents, additionally to
the new "leaves" property, also accept "ranges" with a deprecation
warning.

* Fix accepting JSON arrays for "ranges" compatibility
2018-07-27 15:13:32 -07:00
Jinxuan Zhu
c64c2ff025 Ensure no deprecate exists in slate-core development (#1991)
* Throw error in test mode

* Ensure process

* Allow deprecate with user config

* Style fix

* fix grammer typo
2018-07-27 15:01:35 -07:00
Ian Storm Taylor
8deecc4461 Publish
- slate-base64-serializer@0.2.42
 - slate-dev-benchmark@0.0.3
 - slate-dev-environment@0.1.3
 - slate-dev-logger@0.1.40
 - slate-hotkeys@0.1.3
 - slate-html-serializer@0.6.14
 - slate-hyperscript@0.6.0
 - slate-plain-serializer@0.5.23
 - slate-prop-types@0.4.40
 - slate-react@0.14.0
 - slate-schema-violations@0.1.21
 - slate-simulator@0.4.40
 - slate@0.35.0
slate@0.35.0 slate-simulator@0.4.40 slate-schema-violations@0.1.21 slate-react@0.14.0 slate-prop-types@0.4.40 slate-plain-serializer@0.5.23 slate-hyperscript@0.6.0 slate-html-serializer@0.6.14 slate-hotkeys@0.1.3 slate-dev-logger@0.1.40 slate-dev-environment@0.1.3 slate-dev-benchmark@0.0.3 slate-base64-serializer@0.2.42
2018-07-27 12:42:43 -07:00
Ian Storm Taylor
01405be31b
add paths to ranges (#1997)
#### 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
2018-07-27 12:40:04 -07:00
Ian Storm Taylor
05b8b8ce7e update benchmarks 2018-07-27 10:07:08 -07:00
Ian Storm Taylor
014e37b319 update benchmarks 2018-07-26 08:19:53 -07:00
Ian Storm Taylor
695f83bd40 Publish
- slate-base64-serializer@0.2.41
 - slate-html-serializer@0.6.13
 - slate-hyperscript@0.5.22
 - slate-plain-serializer@0.5.22
 - slate-prop-types@0.4.39
 - slate-react@0.13.4
 - slate-schema-violations@0.1.20
 - slate-simulator@0.4.39
 - slate@0.34.7
slate@0.34.7 slate-simulator@0.4.39 slate-schema-violations@0.1.20 slate-react@0.13.4 slate-prop-types@0.4.39 slate-plain-serializer@0.5.22 slate-hyperscript@0.5.22 slate-html-serializer@0.6.13 slate-base64-serializer@0.2.41
2018-07-23 12:57:22 -07:00
Justin Weiss
57a4938703 Move insertBlocks outside of void inlines (#1987)
When inserting a block, we shouldn't split void inlines -- otherwise,
they're duplicated. Instead, move the insert to either before or after
the void node.
2018-07-23 12:51:54 -07:00
Michael Telatynski
c046652a71 allow fromJSON to restore history (#1979)
* allow fromJSON to restore history

* allow History.toJSON to be passed operations in Arrays instead of Lists
(for example when they have been serialized and deserialized)

* tweak if condition to not make a new List from a List, waste of perf

* s/createList/createOperationsList/ in history.js
2018-07-20 12:04:40 -07:00
Ian Storm Taylor
1c3415b950 Publish
- slate-base64-serializer@0.2.40
 - slate-dev-benchmark@0.0.2
 - slate-html-serializer@0.6.12
 - slate-hyperscript@0.5.21
 - slate-plain-serializer@0.5.21
 - slate-prop-types@0.4.38
 - slate-react@0.13.3
 - slate-schema-violations@0.1.19
 - slate-simulator@0.4.38
 - slate@0.34.6
slate@0.34.6 slate-simulator@0.4.38 slate-schema-violations@0.1.19 slate-react@0.13.3 slate-prop-types@0.4.38 slate-plain-serializer@0.5.21 slate-hyperscript@0.5.21 slate-html-serializer@0.6.12 slate-dev-benchmark@0.0.2 slate-base64-serializer@0.2.40
2018-07-19 14:05:25 -07:00
Jinxuan Zhu
8f9bfdac2b Benchmark consistence && Allow users to select benches to run (#1765)
* 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
2018-07-19 13:01:55 -07:00
Dylan Phelan
09c93a6cd4 Initial fixes for IE compat of cloneFragment (#1943)
* 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
2018-07-19 12:53:38 -07:00
Cris Ward
c4471a5f37 Fix #1463: don't split inline tags when wrapping a range in an inline (#1876)
* Added failing test for #1463

* wip

* test passing

* cleaned up, more tests

* lint

* inside inlines working with marks

* lint

* working with leaves

* tidy

* lint issues

* lint - spacing

* using splitText
2018-07-19 12:53:25 -07:00
Rik
3405e2f822 Allow onContextMenu even handler (#1956)
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.
2018-07-19 12:13:13 -07:00
Wout Mertens
eab4361d92 plugins reference: update available properties (#1957) 2018-07-19 12:10:09 -07:00
Enzo Ferey
939787969b Improved slate-simulator docs. (#1972)
* Improved slate-simulator docs.

* Update index.md
2018-07-19 12:08:31 -07:00
Jinxuan Zhu
715fde4f43 Fix a missing focus in test (#1976) 2018-07-19 12:08:05 -07:00
Michael Telatynski
f83b3114db rebuild selection from anchorPath and focusPath if keys were dropped (#1980) 2018-07-19 12:07:22 -07:00
Justin Weiss
6e749e2f0e Fix drag-and-drop issues in IE11 (#1967)
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.
2018-07-19 12:01:46 -07:00
Enzo Ferey
31ca817f18 Added onKeyUp event suppor to slate-simulator and updated docs. (#1973) 2018-07-19 12:00:32 -07:00
Enzo Ferey
39d50b39e5 Added slate-instante-replace plugin to docs and direct links to NPM and Yarn for slate plugins. (#1968) 2018-07-19 11:57:26 -07:00
Michael Telatynski
ad9831f458 add null-guard in case marks = undefined (default state) (#1958) 2018-07-19 11:56:07 -07:00
Nicolas Gaborit
910e983215 More tests for addMarks and Leaf.splitLeaves (#1953)
* Add tests

* Add failing test

* Start adding tests for Leaf.splitLeaves

* More tests for splitLeaves

* Fix test actually

* Lint and rename test
2018-07-05 08:59:51 -07:00
Ian Storm Taylor
4b15481f92 Publish
- slate-base64-serializer@0.2.39
 - slate-html-serializer@0.6.11
 - slate-hyperscript@0.5.20
 - slate-plain-serializer@0.5.20
 - slate-prop-types@0.4.37
 - slate-react@0.13.2
 - slate-schema-violations@0.1.18
 - slate-simulator@0.4.37
 - slate@0.34.5
slate@0.34.5 slate-simulator@0.4.37 slate-schema-violations@0.1.18 slate-react@0.13.2 slate-prop-types@0.4.37 slate-plain-serializer@0.5.20 slate-hyperscript@0.5.20 slate-html-serializer@0.6.11 slate-base64-serializer@0.2.39
2018-07-05 08:57:50 -07:00
Ian Storm Taylor
30d0d055b5 unpeg monorepo dev dependencies 2018-07-05 08:56:08 -07:00
Ian Storm Taylor
facd857111 Publish
- slate-base64-serializer@0.2.38
 - slate-html-serializer@0.6.10
 - slate-hyperscript@0.5.19
 - slate-plain-serializer@0.5.19
 - slate-prop-types@0.4.36
 - slate-react@0.13.1
 - slate-schema-violations@0.1.17
 - slate-simulator@0.4.36
 - slate@0.34.4
slate@0.34.4 slate-simulator@0.4.36 slate-schema-violations@0.1.17 slate-react@0.13.1 slate-prop-types@0.4.36 slate-plain-serializer@0.5.19 slate-hyperscript@0.5.19 slate-html-serializer@0.6.10 slate-base64-serializer@0.2.38
2018-07-05 08:47:29 -07:00
Nicolas Gaborit
ec2b17c2d6 Fix newText condition (#1838) 2018-07-05 08:43:17 -07:00
Ian Storm Taylor
57138de130 Publish
- slate-base64-serializer@0.2.37
 - slate-html-serializer@0.6.9
 - slate-hyperscript@0.5.18
 - slate-plain-serializer@0.5.18
 - slate-prop-types@0.4.35
 - slate-react@0.13.0
 - slate-schema-violations@0.1.16
 - slate-simulator@0.4.35
 - slate@0.34.3
slate@0.34.3 slate-simulator@0.4.35 slate-schema-violations@0.1.16 slate-react@0.13.0 slate-prop-types@0.4.35 slate-plain-serializer@0.5.18 slate-hyperscript@0.5.18 slate-html-serializer@0.6.9 slate-base64-serializer@0.2.37
2018-07-03 16:12:47 -07:00
Ian Storm Taylor
e2135c3853 update changelog 2018-07-03 16:11:02 -07:00
Samy Pessé
0ceefea2e7 Add prop "isFocused" / "isSelected" for custom nodes (#1950)
* Change the definition of isSelected and add isFocused

* Document prop "isFocused"

* Add unit tests for isFocused / isSelected

* Adapt examples

* Lint
2018-07-03 16:07:38 -07:00
Ian Storm Taylor
37418643e2
add start of glossary (#1946)
This is the start of a glossary in the docs for terms that folks might not know when first learning Slate. Hopefully it makes it easier to learn. If anyone wants to help fill it out, that would be amazing. Thanks!
2018-07-02 10:27:35 -06:00
Zach Schneider
001460fa52 Define NODE_ENV to use the production build of React on slatejs.org (#1939) 2018-07-01 15:21:51 -06:00
Enzo Ferey
a698d4a74e Added missing paste event handler. (#1942)
Acording to https://github.com/ianstormtaylor/slate/blob/master/packages/slate-simulator/src/index.js onPaste event is suported by slate-simulator.
2018-07-01 15:15:36 -06:00
Ian Storm Taylor
257b28aa84
Improve and refactor examples (#1930)
This just refactors the examples to make the styled defined inline with each example, to make it easier to follow for folks. And in the process fixes a few issues that people brought up.

Fixes https://github.com/ianstormtaylor/slate/issues/1920
Fixes https://github.com/ianstormtaylor/slate/issues/1925
2018-07-01 15:13:29 -06:00
Ian Storm Taylor
1923888af1
Update resources.md 2018-06-30 15:08:28 -07:00
Jan Vlcek
6518afc83e Update schema rule marks documentation (#1931) 2018-06-23 06:20:28 -07:00