1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-19 14:27:07 +01:00

28 Commits

Author SHA1 Message Date
Irwan Fario Subastian
cedc7dc2a5 lint & example fixes (#3160)
* fix import extensions of eslint

* revert next.config.cjs

* fix eslint globbing

* add migrating to docs’ sidebar

* fix prettier error on Contributing.md

* put quotes for glob matching for windows user

* remove type: module from  package.json
2019-11-29 00:16:39 -05:00
Ian Storm Taylor
4ff6972096
Next (#3093)
* remove some key usage from core, refactor Operations.apply

* undeprecate some methods

* convert more key usage to paths

* update deprecations

* convert selection commands to use all paths

* refactor word boundary selection logic

* convert many at-range commands to use paths

* convert wrapBlock and wrapInline to not use keys

* cleanup

* remove chainability from editor

* simplify commands, queries and middleware

* convert deleteAtRange

* remove key usage from schema, deprecate *ByKey methods

* migrate *ByKey tests, remove index from *ByPath signatures

* rename at-current-range tests

* deprecate mode key usage, migrate more tests away from keys

* deprecate range and point methods which rely on keys to work

* refactor insertBlock, without fixing warnings

* add pathRef/pointRef, fix insertBlock/Inline deprecations, work on insertFragment

* refactor insertFragment

* get rich-text example rendering

* fix lint

* refactor query files, fix more tests

* remove unused queries, refactor others

* deprecate splitDescendantsByPath

* merge master

* add typescript, convert slate, slate-hyperscript, slate-plain-serializer

* add Point, Path, Range, Annotation tests

* add Annotation, Change, Element, Fragment, Mark, Range, Selection, Value interfaces tests

* add Operation and Text tests

* add Node tests

* get operations and normalization tests working for slate

* get *AtPath command tests passing

* rename *AtPath command tests

* rename

* get *AtPoint tests working

* rename

* rename

* add value queries tests

* add element, mark and path queries tests

* convert most on-selection tests

* convert on-selection commands

* rename

* get addMarks and delete commands working

* rename

* rename

* rename

* refactor value.positions(), work on delete tests

* progress on delete tests

* more delete work

* finish delete tests

* start converting to at-based commands

* restructure query tests

* restructure operations tests

* more work converting to multi-purpose commands

* lots of progress on converting to at-based commands

* add unwrapNodes

* remove setValue

* more progress

* refactor node commands to use consistent matching logic

* cleanup, get non-fragment commands passing

* remove annotations and isAtomic

* rename surround/pluck to cover/uncover

* add location concept, change at-path to from-path for iterables

* refactor batches

* add location-based queries

* refactor hanging logic

* more location query work

* renaming

* use getMatch more

* add split to wrap/unwrap

* flip levels/ancestors ordering

* switch splitNodes to use levels

* change split to always:false by default

* fix tests

* add more queries tests

* fixing more delete logic

* add more splitNodes tests

* get rest of delete tests passing

* fix location-based logic in some commands

* cleanup

* get previous packages tests passing again

* add slate-history package

* start slate-schema work

* start of react working

* rendering fixes

* get rich and plain text examples working

* get image example working with hooks and dropping

* refactor onDrop to be internal

* inline more event handlers

* refactor lots of event-related logic

* change rendering to use render props

* delete unused stuff

* cleanup dom utils

* remove unused deps

* remove unnecessary packages, add placeholder

* remove slate-react-placeholder package

* remove unused dep

* remove unnecessary tests, fix readonly example

* convert checklists example

* switch to next from webpack

* get link example working

* convert more examples

* preserve keys, memoized leafs/texts, fix node lookup

* fix to always useLayoutEffect for ordering

* fix annotations to be maps, memoize elements

* remove Change interface

* remove String interface

* rename Node.entries to Node.nodes

* remove unnecessary value queries

* default to selection when iterating, cleanup

* remove unused files

* update scroll into view logic

* fix undoing, remove constructor types

* dont sync selection while composing

* add workflows

* remove unused deps

* convert mentions example

* tweaks

* convert remaining examples

* rename h to jsx, update schema

* fix schema tests

* fix slate-schema logic and tests

* really fix slate-schema and forced-layout example

* get start of insertFragment tests working

* remove Fragment interface

* remove debugger

* get all non-skipped tests passing

* cleanup deps

* run prettier

* configure eslint for typescript

* more eslint fixes...

* more passing

* update some docs

* fix examples

* port windows undo hotkey change

* fix deps, add basic firefox support

* add event overriding, update walkthroughs

* add commands, remove classes, cleanup examples

* cleanup rollup config

* update tests

* rename queries tests

* update other tests

* update walkthroughs

* cleanup interface exports

* cleanup, change mark transforms to require location

* undo mark transform change

* more

* fix tests

* fix example

* update walkthroughs

* update docs

* update docs

* remove annotations

* remove value, move selection and children to editor

* add migrating doc

* fix lint

* fix tests

* fix DOM types aliasing

* add next export

* update deps, fix prod build

* fix prod build

* update scripts

* update docs and changelogs

* update workflow and pull request template
2019-11-27 20:54:42 -05:00
Dominic Amato
3dce916074 Use strict equality except for null/undefined for improved performance and behavior (#2514)
* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* undo strict null checking

* remove added semicolons

* Prettier Formatting Changes

* Update .eslintrc

add smart strict equality rule

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert Non-strict to strict equality checking
Convert non-strict equality checking, using `==`, to the strict version, using `===`.

* Convert files to use strict equality

* fix prettier eslint errors

* fix remaining prettier complaints

* use strict null equality in serializer
2019-03-06 16:48:41 -05:00
Ian Storm Taylor
8dd919dc34
remove change, fold into editor (#2337)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Improvement / debt.

#### What's the new behavior?

This pull request removes the `Change` object as we know it, and folds all of its behaviors into the new `Editor` controller instead, simplifying a lot of the confusion around what is a "change vs. editor" and when to use which. It makes the standard API a **lot** nicer to use I think.

---

###### NEW

**The `editor.command` and `editor.query` methods can take functions.** Previously they only accepted a `type` string and would look up the command or query by type. Now, they also accept a custom function. This is helpful for plugin authors, who want to accept a "command option", since it gives users more flexibility to write one-off commands or queries. For example a plugin could be passed either:

```js
Hotkey({
  hotkey: 'cmd+b',
  command: 'addBoldMark',
})
```

Or a custom command function:

```js
Hotkey({
  hotkey: 'cmd+b',
  command: editor => editor.addBoldMark().moveToEnd()
})
```

###### BREAKING

**The `Change` object has been removed.** The `Change` object as we know it previously has been removed, and all of its behaviors have been folded into the `Editor` controller. This includes the top-level commands and queries methods, as well as methods like `applyOperation` and `normalize`. _All places that used to receive `change` now receive `editor`, which is API equivalent._

**Changes are now flushed to `onChange` asynchronously.** Previously this was done synchronously, which resulted in some strange race conditions in React environments. Now they will always be flushed asynchronously, just like `setState`.

**The `render*` and `decorate*` middleware signatures have changed!** Previously the `render*` and `decorate*` middleware was passed `(props, next)`. However now, for consistency with the other middleware they are all passed `(props, editor, next)`. This way, all middleware always receive `editor` and `next` as their final two arguments.

**The `normalize*` and `validate*` middleware signatures have changed!** Previously the `normalize*` and `validate*` middleware was passed `(node, next)`. However now, for consistency with the other middleware they are all passed `(node, editor, next)`. This way, all middleware always receive `editor` and `next` as their final two arguments.

**The `editor.event` method has been removed.** Previously this is what you'd use when writing tests to simulate events being fired—which were slightly different to other running other middleware. With the simplification to the editor and to the newly-consistent middleware signatures, you can now use `editor.run` directly to simulate events:

```js
editor.run('onKeyDown', { key: 'Tab', ... })
```

###### DEPRECATED

**The `editor.change` method is deprecated.** With the removal of the `Change` object, there's no need anymore to create the small closures with `editor.change()`. Instead you can directly invoke commands on the editor in series, and all of the changes will be emitted asynchronously on the next tick.

```js
editor
  .insertText('word')
  .moveFocusForward(10)
  .addMark('bold')
```

**The `applyOperations` method is deprecated.** Instead you can loop a set of operations and apply each one using `applyOperation`. This is to reduce the number of methods exposed on the `Editor` to keep it simpler.

**The `change.call` method is deprecated.** Previously this was used to call a one-off function as a change method. Now this behavior is equivalent to calling `editor.command(fn)` instead.

---

Fixes: https://github.com/ianstormtaylor/slate/issues/2334
Fixes: https://github.com/ianstormtaylor/slate/issues/2282
2018-10-27 12:18:23 -07:00
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
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
Jinxuan Zhu
0322f7a1b8 Fix a linter bug in a semi-colon case (#1928) 2018-06-22 08:48:36 -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
Renaud Chaput
3339d088e1 Add Prettier with ESLint integration (#1589)
* Add Prettier, with basic config and ESLint integration

* Apply Prettier to all files using `yarn lint --fix`

* Tell Prettier to ignore an empty text in a test output.

* Run Prettier on JS files not handled by ESLint, and lint them too
2018-02-06 15:12:00 -08:00
Zach Schneider
00165a3155 Convert to babel-preset-env and upgrade build and linting packages. (#1557) 2018-01-26 10:55:29 -08:00
Ian Storm Taylor
fb0bdfa28b fix linter 2017-10-16 20:35:18 -07:00
Ian Storm Taylor
276ed274b1 fix drag/drop 2017-10-16 20:33:04 -07:00
Ian Storm Taylor
617fba2ac0 Split core plugin (#1242)
* split core into before/after, add onBeforeInput to before

* migrate handlers to before plugin, add event handlers constants

* cleanup

* refactor hotkeys into constants file

* fix serializer, disable core plugin tests

* fix linter
2017-10-16 17:31:43 -07:00
Ian Storm Taylor
ace9f47930 change slate to be a monorepo using lerna (#1106)
* init lerna, move files into ./packages

* move test files into ./packages

* more moving around

* fill out package.json files

* fixing imports

* more fixing of imports, and horribleness

* convert examples, fix linting errors

* add documentation

* update docs

* get tests passing

* update travis.yml

* update travis.yml

* update travis.yml

* update test script

* update travis.yml

* update scripts

* try simplifying travis.yml

* ocd stuff

* remove slate-core-test-helpers package

* add package readmes

* update reference docs structure

* refactor slate-simulator into its own package

* add docs for new packages

* update docs

* separate benchmarks into packages, and refactor them
2017-09-11 18:11:45 -07:00
Ian Storm Taylor
2b168541dc restrict globals that are permitted for linting (#1077) 2017-09-07 08:54:35 -07:00
Ian Storm Taylor
7470a6dd53 Expose transforms (#836)
* refactor to extract applyOperation util

* change handlers to receive transform instead of state

* change onChange to receive a transform, update rich-text example

* fix stack iterationg, convert check-list example

* convert code-highlighting, embeds, emojis examples

* change operations to use full paths, not indexes

* switch split and join to be recursive

* fix linter

* fix onChange calls

* make all operations invertable, add src/operations/* logic

* rename "join" to "merge"

* remove .length property of nodes

* fix node.getFragmentAtRange logic

* convert remaining examples, fix existing changes

* fix .apply() calls and tests

* change setSave and setIsNative transforms

* fix insert_text operations to include marks always

* cleanup and fixes

* fix node inheritance

* fix core onCut handler

* skip constructor in node inheritance

* cleanup

* change updateDescendant to updateNode

* add and update docs

* eliminate need for .apply(), change history to mutable

* add missing file

* add deprecation support to Transform objects

* rename "transform" to "change"

* update benchmark

* add deprecation util to logger

* update transform isNative attr

* fix remaining warn use

* simplify history checkpointing logic

* fix tests

* revert history to being immutable

* fix history

* fix normalize

* fix syntax error from merge
2017-09-05 18:03:41 -07:00
Ian Storm Taylor
c316a4b60a refactor node methods, memoize more, update history 2017-03-03 12:50:17 -08:00
Ian Storm Taylor
c3578d12ad tighten linting rules 2017-02-25 10:13:21 -08:00
Ian Storm Taylor
6f67ac70c9 fix linting 2016-11-17 18:10:30 -08:00
Soreine
a319499f7c Enforce 2-spaces indentation 2016-11-10 11:04:49 +01:00
Soreine
e81708e82f Update eslint and add sensible rules (including important React rules) 2016-10-25 13:11:19 +02:00
Samy Pesse
c7f0c655ab Add normalize nodes to transforms bykey 2016-10-24 09:33:58 +02:00
Ian Storm Taylor
6ab2d963cd fix html serializer for cases without children 2016-08-11 12:28:41 -07:00
Ian Storm Taylor
3448dac17b fix to greatly improve performance, and void selections in void nodes 2016-07-26 16:58:42 -07:00
Ian Storm Taylor
b5bbac02d0 remove rule from eslint 2016-07-25 14:46:26 -07:00
Ian Storm Taylor
2aa8239448 fix wrapInline selecting, add rendering tests 2016-07-13 18:56:03 -07:00
Ian Storm Taylor
db1151bd15 add linting to examples 2016-07-07 08:35:13 -07:00
Ian Storm Taylor
226b6592dc add linting 2016-07-06 20:19:19 -07:00