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

401 Commits

Author SHA1 Message Date
Eric Edem
b1073f5672 fix: extend forward / backward (#2314)
#### Is this adding or improving a _feature_ or fixing a _bug_?

_bug_

#### What's the new behavior?

Fix behavior for <kbd>shift + left</kbd> and <kbd>shift + right</kbd>. Now they will correctly move forward / backward.

#### How does this change work?

turns out that the hotkey `'left'` would also pick up with a modifier key `'shift+left'` so checking for `Hotkeys.isExtendForward()` needs to come before `Hotkeys.isMoveForward()` and it needs to short circuit with `return true`. Likewise for backward.

#### 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: #2307 
Reviewers: @ianstormtaylor
2018-10-24 14:50:20 -07:00
Ian Storm Taylor
10bf13804f refactor plugins example, fixes #2243 2018-10-10 10:10:27 -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
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
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
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
Ian Storm Taylor
1d53c5b1ef
Add input tester example (#2068)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Example.

#### What's the new behavior?

Adds a new example that is an input event logger, for more easily seeing which input/keyboard/selection events are firing when editing in a Slate editor.

![image](https://user-images.githubusercontent.com/311752/43937175-ea9231e2-9c10-11e8-8e29-2cd9a24ca78d.png)

#### 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-09 20:30:23 -07:00
Ian Storm Taylor
092193a15e fix lint command 2018-08-06 13:13:40 -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
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
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
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
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
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
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
ae4758e1b7
fix release building process for umds (#1889) 2018-06-10 16:48:45 -07:00
Ian Storm Taylor
ec10ab4d7d fix ci, remove bootstrap command 2018-04-27 15:39:33 -07:00
Nicolas Gaborit
42ff90e9cd Remove unused dependencies (#1796)
* Remove unused slate-sugar

* Remove unused dependencies
2018-04-27 13:27:25 -07:00
Zach Schneider
2bf04b4a8c Use source-map-loader for more fine-grained sourcemaps. (#1666) 2018-02-21 19:35:27 -08:00
Ian Storm Taylor
0935f20c11 update webpack config 2018-02-21 18:35:27 -08:00
Ian Storm Taylor
e6638f7822 update webpack building 2018-02-21 18:03:17 -08:00
Ian Storm Taylor
bc524bd43a update webpack and rollup configs 2018-02-21 17:48:08 -08:00
Zach Schneider
1fbf999c41 Add back babel-cli as a development dependency. (#1665) 2018-02-21 17:44:13 -08:00
Zach Schneider
2ebf3b462b Set up webpack configuration for building examples (#1642)
* Set up webpack configuration for building examples

* Configure react-hot-loader in development

* Improve config, set gh-pages to use examples/dist directory

* PR feedback

* Rename App.js in git
2018-02-21 17:19:56 -08:00
Conor Cussell
a43c3fbb61 Update plugins used in plugins example (#1637) 2018-02-21 12:40:55 -08:00
Renaud Chaput
de4c9e478a Lint JSON, CSS and Markdown files with Prettier (#1612)
* Process and Lint CSS, Markdown and JSON files with Prettier

* Run `yarn prettier` to re-format Markdown, CSS and JSON files
2018-02-07 07:58:41 -08:00
Ian Storm Taylor
83ec966113 refactor rollup, prettier and benchmark configuration 2018-02-06 19:41:03 -08: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
Jinxuan Zhu
1f254aebec Fix BABEL_ENV bug in yarn benchmark (#1607) 2018-02-05 16:29:33 -05:00
Zach Schneider
b26bed1c88 Improvements to developer experience with building packages (#1595)
* Improvements to developer experience with building packages

* Add note to Contributing.md about watch:packages
2018-02-03 17:02:46 -08:00
DamareYoh
aee01ae703 fixed build for windows (#1592) 2018-02-02 17:20:06 -08:00
Zach Schneider
228b97ff29 Switch to using Rollup for bundling (#1568)
* Implement first working rollup config for main slate pkg

* Convert slate-base64-serializer to rollup

* Convert slate-dev-logger to rollup

* Convert slate-html-serializer to rollup

* Convert slate-hyperscript to rollup

* Convert slate-plain-serializer to rollup

* Convert slate-prop-types to rollup

* Convert (mostly) slate-react to rollup

* Convert slate-simulator to rollup

* Misc cleanup and configuration tweaks/fixes

* Convert slate-schema-violations to rollup

* Successful rollup build for top-level examples

* Add plugin to replace process.env.NODE_ENV

* Only rebuild modules and dev examples in watch mode

* Enable sourcemaps for development builds

* Force debug to use browser version, remove builtins plugin

* Remove is-image from example
It relies on node `path` and wouldn't work well in-browser anyway

* Use browser version of react-dom/server

* Move stray require to import

* Configure examples to watch child package output

* Fix tests

* Remove unneeded preferBuiltins from resolve config

* Use more precise files array to ensure sourcemaps aren't included

* Use lodash instead of lodash.throttle
It's pulled in anyway since slate-react needs slate, so using the
minipackage actually causes code duplication

* Improve naming/fix UMD builds, update UMD doc

* Add rollup configs to linting, add a missing dep to package.json

* Use longform rollup CLI flags

* Add rollup-plugin-auto-external to reduce external module configuration

* Combine rollup config into a unioned helper

* Centralize to a single rollup configuration

* Update dist structure and package field naming for PR feedback

* Add comments and address PR feedback on rollup config

* i.e. -> e.g.

* Add some spacing to the configuration to improve readability

* Add a bit more spacing

* Remove umd from example Slate unpkg link
2018-02-02 15:46:36 -08:00
Ian Storm Taylor
10eea06a8a refactor schema violations to be a separate package 2018-01-26 12:28:40 -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
Zach Schneider
508cc74e3a Upgrade to lerna 2.7 to correct peer dependency management (#1539) 2018-01-25 13:14:55 -08:00
Conor Cussell
62ffb4681b Remove parse5 (#1531)
Fix stripUnwantedAttrs

Remove .only

Remove parse5 from deps

Better imports

Cleanup

More succint removal of attributes
2018-01-13 15:41:48 -08:00
Ian Storm Taylor
85f4a7618c Merge branch 'master' of github.com:ianstormtaylor/slate 2018-01-04 15:27:06 -08:00
Ian Storm Taylor
5444a300b8
rename kind to object for clarity (#1501)
* rename `kind` to `object` for clarity

* add deprecation warning for direct access

* add deprecation warning for node creation
2018-01-04 15:26:53 -08:00
Ian Storm Taylor
e01a2e2dfb switch html-serializer tests to use jsdom 2018-01-04 15:20:02 -08:00
Ian Storm Taylor
b76c26e980 update clean script 2017-10-31 19:05:24 -07:00
Ian Storm Taylor
b375660aa9 refactor hotkeys to constants, and add transforms (#1251)
* refactor hotkeys to constants, and add transforms

* update hotkey helper
2017-10-17 18:18:27 -07:00
Ian Storm Taylor
a341f4d4eb fix docs pages and plugins example 2017-10-17 09:22:08 -07:00
Ian Storm Taylor
f69d2c4a12 remove keyboard data.* properties (#1235)
* update examples and walkthroughs

* deprecate data keyboard properties

* update examples

* add is-hotkey to resources doc

* udpate docs

* update docs

* fix split-block test
2017-10-15 19:23:07 -07:00
Ian Storm Taylor
5c1d43e3f9 fix block void node spacing, closes #1226 2017-10-13 18:00:51 -07:00
Ian Storm Taylor
9d5873ec94 remove react-addons-perf 2017-10-13 15:02:19 -07:00
Renaud Chaput
e960918f87 Upgrade to React 16 (#1178)
* Allow React 16 in peerDeps and use it for dev

* Make tests pass with React 16

Changes are cosmetic:
- React 16 no longer adds a trailing `;` to `style` attributes
- React 16 outputs `0` and not `0px` for sizes in `style`
2017-10-13 15:01:18 -07:00
Ian Storm Taylor
2a8cf8561e update contributing docs, update release script 2017-09-13 11:26:27 -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
4d73f19dc7 0.23.1 2017-09-11 17:51:10 -07:00
Ian Storm Taylor
4f59771453 remove problematic unused dep 2017-09-11 17:40:31 -07:00