1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-03-06 05:49:47 +01:00

578 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
d29fc26edf Publish
- slate-base64-serializer@0.2.36
 - slate-html-serializer@0.6.8
 - slate-hyperscript@0.5.17
 - slate-plain-serializer@0.5.17
 - slate-prop-types@0.4.34
 - slate-react@0.12.11
 - slate-schema-violations@0.1.15
 - slate-simulator@0.4.34
 - slate@0.34.2
2018-06-22 08:56:51 -07:00
Quentin Gérôme
ec51444df1 fix(Safari): Set a text value in dataTransfer to have the cursor on Safari when dragging a text node (#1927) 2018-06-22 08:52:02 -07:00
Quentin Gérôme
d8d0b5ff3c fix(DragAndDrop): isDraggingInternally should not be reset by the onDragOver handler (#1929)
Fixes #1871
2018-06-22 08:50:51 -07:00
Jinxuan Zhu
0322f7a1b8 Fix a linter bug in a semi-colon case (#1928) 2018-06-22 08:48:36 -07:00
David Chang
2652680850 [core/models] add replaceMark method on Change, tests, docs (#1910)
* [core/models/change] add replaceMark method on Change, tests, docs

* Update change.md
2018-06-21 19:46:40 -07:00
Jinxuan Zhu
e4ff1972d7 Ensure multi-line expressions are padded by eslint (#1924)
* Fix eslint rule and upgrade eslint

* Fix for switch case

* Linting files
2018-06-21 19:27:10 -07:00
Ian Storm Taylor
1cc486e28c Publish
- slate-base64-serializer@0.2.35
 - slate-html-serializer@0.6.7
 - slate-hyperscript@0.5.16
 - slate-plain-serializer@0.5.16
 - slate-prop-types@0.4.33
 - slate-react@0.12.10
 - slate-schema-violations@0.1.14
 - slate-simulator@0.4.33
 - slate@0.34.1
2018-06-19 19:36:03 -07:00
Irwan Fario Subastian
cab3f71e7a fix removeText with Mark of length 1 (#1917) 2018-06-19 19:29:19 -07:00
Irwan Fario Subastian
afb9dce48a use updated leaves instead of taking this.leaves (#1904) 2018-06-15 08:41:56 -07:00
Ian Storm Taylor
d884be872d Publish
- slate-base64-serializer@0.2.34
 - slate-html-serializer@0.6.6
 - slate-hyperscript@0.5.15
 - slate-plain-serializer@0.5.15
 - slate-prop-types@0.4.32
 - slate-react@0.12.9
 - slate-schema-violations@0.1.13
 - slate-simulator@0.4.32
 - slate@0.34.0
2018-06-14 19:55:55 -07:00
Ian Storm Taylor
2f8708149d update changelog 2018-06-14 19:53:03 -07:00
Ian Storm Taylor
e94cb01a29 update changelog 2018-06-14 19:47:49 -07:00
Jinxuan Zhu
cb3a9a5528 Characters to leaves (#1816)
* Preparing tests

* splitNode replacement

* Remove slow splice; replace mergeNode

* normalize Leaves

* Partially remove characters

* Partially remove characters

* styling

* Fix bugs; almost all characters are replaced

* Fixes almost existing tests; preparing adding tests for text

* Remove un-necessary check

* Empty leaf

* fix characters in getMarks

* Faster fromJSON

* Some corner cases for empty text

* Fix naive bug

* Supporting empty text with marks

* Supporting empty text with marks in hyperscript

* changes tests for marks in empty text

* Support splitNode marks with empty text

* Add tests for splitNode->insert

* Faster removeText

* Add warning ; remove getMarksAtIndex cache

* Remove characters in getInsertMarkAtRange

* Adding tests

* Change names of tests

* Update marks test

* Add a test confirm for invalid offsets:

* Add test for get active marks between offsets

* Fix document

* Add testing for insert-text

* Better remove text

* More sensible marks in empty text

* Allow marks of empty text after deleting partially marked text

* Add test for removing on partially marked text

* chnage test structure

* Add test for removeText

* Add test for removeText

* Avoid conflict between empty marked text and cursor

* Simple style fixes

* Simple style fixes

* Line break fixes

* Line break fixes

* Annotate the createLeaves

* Line breaks in test

* Line breaks fix

* add add-marks test

* add merge test

* Fix version update

* Remove empty_leaf optimization; optimize of that will be other PRs

* Clean up getMarksAtPosition

* Fix get-insert-marks-at-range

* clean up get-marks-at-position

* Fix spaces
2018-06-14 19:39:41 -07:00
jasonphillips
c500becf81 Operations update decorations (#1778)
* initial simple decorations (mark-like), many tests added

* allow decorators to be set by focus, anchor tags - add tests

* handle one more edge case with decorations in hyperscript

* apply prettier cleanup

* apply linting rules

* update changelog

* ensure always normalize decoration ranges

* reapply prettier after latest adjustments

* all operations apply now update decorations with selection

* ranges can now be 'atomic', will invalidate if contents change

* lint, prettier cleanups

* add atomic invalidation tests, update hyperscript usage

* fix linter errors

* minor cleanup

* slight refactor for simplicity

* remove a couple superfluous lines

* update in response to review

* drop unnecessarily committed add'l file

* remove the need for explicit anchor, focus prop on decoration tags

* update hyperscript use to match latest syntax in #1777

* atomic -> isAtomic
2018-06-14 19:33:02 -07:00
Ian Storm Taylor
63eae6b48b Publish
- slate-base64-serializer@0.2.33
 - slate-html-serializer@0.6.5
 - slate-hyperscript@0.5.14
 - slate-plain-serializer@0.5.14
 - slate-prop-types@0.4.31
 - slate-react@0.12.8
 - slate-schema-violations@0.1.12
 - slate-simulator@0.4.31
 - slate@0.33.8
2018-06-14 19:22:05 -07:00
David Chang
5eb04f3650 [slate-react] Pass renderEditor prop through into editor plugin (#1899) 2018-06-14 18:17:44 -07:00
DylanPaulusSEL
9660c4bdaa Fix issue with pasting in IE11 (#1901)
* Fix issue with pasting in IE11

Fixing the issue where dataTransfer or clipboardData are not populated,
in IE 11 under event.NativeEvent. Instead, if we are using IE11, use
the base event object instead which contains a valid dataTrasnfer/clipboardData object.

* Run prettier on code changes
2018-06-14 18:15:09 -07:00
Jinxuan Zhu
5aa993e81d Allow user to use immutable 4.0.0-rc without yarn warning (#1869)
* Allow user to use immutable 4.0.0-rc without yarn warning

* Fix versions

* Fix immutable version to most recent

* Fix versions for react
2018-06-14 18:08:45 -07:00
Irwan Fario Subastian
9afffd418d update schema customizer to merge marks (#1839)
* update schema customizer to merge marks

* update comment
2018-06-14 17:53:33 -07:00
Jinxuan Zhu
b26535fd94 Fix cycle reference in slate-core (#1881)
* Switch to isType

* Fix fromJSON in circular reference

* Remove un-necessary files

* fix characters

* Import from node.js

* Export from block... models file
2018-06-10 17:23:11 -07:00
Jinxuan Zhu
e04021f02e Perhaps Faster stack (#1847)
* Faster stack

* Faster stack

* Use memoize; but use reduceRight still

* Use memoize; but use reduceRight still
2018-06-10 17:16:01 -07:00
Ian Storm Taylor
b13affefd6 Publish
- slate-base64-serializer@0.2.32
 - slate-html-serializer@0.6.4
 - slate-hyperscript@0.5.13
 - slate-plain-serializer@0.5.13
 - slate-prop-types@0.4.30
 - slate-react@0.12.7
 - slate-schema-violations@0.1.11
 - slate-simulator@0.4.30
 - slate@0.33.7
2018-06-10 17:05:20 -07:00
Irwan Fario Subastian
7f91d0b557 Inline Void block cursor (#1886)
* add contentEditable=false to void block wrapper

* put contentEditable fals on inline void

fix from https://github.com/ianstormtaylor/slate/pull/1734 works for block but inline void have a cursor which shouldn’t be there as typing inside inline void won’t work. so only removing contentEditable on blocks but not inline

* update test
2018-06-10 16:59:16 -07:00
Tobias Andersen
ee8bc1b695 Use cleaned up text content when copying into plain/text (#1865) 2018-06-10 16:48:28 -07:00
Jinxuan Zhu
1383b38546 Fix the characters count in deleteForward (#1864)
* Fix the characters bug in deleteForward

* Adding tests

* Fix void positions in tests

* add tests for n===0
2018-06-10 16:35:24 -07:00