1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-20 23:22:56 +01:00

67 Commits

Author SHA1 Message Date
Ian Storm Taylor
08f270dc1b
Add a Point model, and standardize Range/Point logic (#2035)
* add `Node.createRange` for range resolution

* fix lint

* fix range offset defaults to be `null`

* change `isBackward` to be computed from paths

* remove debuggers

* add point model, update range with deprecations, update hyperscript

* got all tests passing

* get tests passing, convert changes

* fix lint

* fix examples

* update deprecations

* update docs

* update slate-react point utils

* fix document.normalizeRange

* fix lint
2018-08-03 14:45:40 -07:00
Florian
8a1d75025a Fix typo: "the your" -> "your" (#2032) 2018-08-03 11:39:38 -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
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
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
David Chang
bcf41a96b4 Update docs (#1893) 2018-06-12 10:42:09 -07:00
Dominic Eden
5b03db6e36 [fix/add-image-details-to-changes-guide] add extra details on how to … (#1870)
* [fix/add-image-details-to-changes-guide] add extra details on how to insert an image into a Slate Value.

* [fix/add-image-details-to-changes-guide] fix linting errors with Prettier

* Update changes.md

* Update changes.md
2018-06-10 16:59:35 -07:00
Jinxuan Zhu
6e6e9cf710 Fix spell check bug (#1753)
* Fix spell check bug by add data-text:true

* Fix spell check bug by spell check add length to a leaf

* Fix tests to use data-text:true for marks

* Rename data-text to data-slate-leaf; Remove setRef; unlift attributes in leaf

* Update examples with data-*

* Add attributes to document

* Fix renderMark in all documents

* Prettier markdown
2018-04-27 14:06:24 -07:00
Lars Karbo
c071df36ea add js to markdown ``` code syntax (#1727) 2018-03-26 07:08:28 -07:00
Andrew Fleming
7238c6a82e Improve grammar in schemas.md (#1685)
Grammar correction
2018-03-03 18:59:14 -05:00
Andrew Fleming
91101465fa Update data-model.md (#1682)
Typo corrected
2018-03-03 18:58:30 -05: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
CameronAckermanSEL
ef5106e30f Improve normalize suppression to make less verbose and safer (#1549)
* change normalization can be set with setOperationFlag, and changes can be executed in sequence with automatic suppression with guaranteed document normalization at the end.

* responded to developer feedback by renaming execute to withMutations (to mirror immutable JS), implemented tests, updated documentation

* fixed typos discovered in review.

* fixed missing normalize flag usages and added withMutations to the schemas guide

* responded to developer feedback

* fixed lint errors and cleaned up code

* readd missing tests

* getFlag now allows options to override the change flags

* removed normalize restoration asserts from unit tests

* unit test cleanup
2018-01-26 11:32:37 -08:00
Francesco Agnoletto
cfe5dac0f8 Fix broken links on docs (#1529)
@ianstormtaylor plugins + typo in core-plugins link
2018-01-13 09:24:52 -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
Conor Cussell
7032339ca2 Fix small error in docs (#1435)
- make the placeholder have an opacity
- correct `contentEditable` jsx attribute
2017-12-02 12:34:38 -08:00
Tobias Andersen
1abc7e74b8 fix some typos in docs/guides (#1412) 2017-11-16 11:14:38 -08:00
Ian Storm Taylor
3482437e5c update docs to get it to rebuild? 2017-10-28 14:32:45 -07:00
Ian Storm Taylor
c9f1168cd7 add rendering and schema guides 2017-10-27 18:59:20 -07:00
Ian Storm Taylor
adb2678732
Rename "state" to "value" everywhere (#1313)
* rename state to value in slate core, as deprecation

* rename all references to state to value in slate core

* migrate slate-base64-serializer

* migrate slate-html-serializer

* migrate slate-hyperscript

* migrate slate-plain-serializer

* migrate slate-prop-types

* migrate slate-simulator

* fix change.setState compat

* deprecate references to state in slate-react

* remove all references to state in slate-react

* remove `value` and `schema` from props to all components

* fix default renderPlaceholder

* fix tests

* update examples

* update walkthroughs

* update guides

* update reference
2017-10-27 13:39:06 -07:00
Ian Storm Taylor
44addc8140 update plugins guide 2017-10-27 13:12:26 -07:00
Ian Storm Taylor
759979f995 add extra code sample to plugins guide 2017-10-27 13:11:30 -07:00
Ian Storm Taylor
2ab806189a update docs 2017-10-26 09:22:06 -07:00
Ian Storm Taylor
b215e5b7ac update docs 2017-10-25 20:23:22 -07:00
Ian Storm Taylor
c22839c6eb add data model guide, update docs 2017-10-25 20:13:52 -07:00
Ian Storm Taylor
509d3d50fc remove rendering from schema & make it expressive (#1262)
* split rendering out of schema

* remove default components

* first stab at new schema

* make default normalizations smarter

* revert to forcing defaults to be verbose?

* refactor reason constants

* split nodes into blocks/inlines

* get tests passing

* restructure schema tests

* add parent test

* cleanup

* remove defaults from schema

* refactor schema rule.nodes validation, update example

* embed schema in state objects

* fixes

* update examples, and fixes

* update walkthroughs

* update docs

* remove old schemas doc page

* add more tests

* update benchmarks
2017-10-25 17:32:29 -07:00
Ian Storm Taylor
3f25e6a902 update plugins guide 2017-10-25 11:18:48 -07:00
Ian Storm Taylor
0694daf26a add plugins guide 2017-10-25 11:04:37 -07:00
Ian Storm Taylor
c442e52ca6 update docs 2017-10-18 08:58:23 -07:00
Ian Storm Taylor
63855ed15c fix operation link in docs 2017-10-18 08:50:24 -07:00
Alan Christopher Thomas
1237016c9e Mention schema rules as a valid place to make changes (#1256)
* Update Change guide to mention schema rules

* Fix typos
2017-10-18 08:49:31 -07:00
Ian Storm Taylor
d66e127e7d update editor.change() to use change.call(), update docs 2017-10-18 01:42:36 -07:00
Ian Storm Taylor
a802e74bb0 update docs 2017-10-18 01:16:14 -07:00
Ian Storm Taylor
8d60943645 update docs 2017-10-18 01:12:43 -07:00
Ian Storm Taylor
117d8c55cc update docs 2017-10-17 20:53:38 -07:00
Ian Storm Taylor
68e4e090f0 update docs 2017-10-17 20:30:11 -07:00
Ian Storm Taylor
204f491b6b update docs 2017-10-17 20:07:14 -07:00
Ian Storm Taylor
c98ad903c8 Upgrade docs (#1182)
* remove table of contents

* remove more hard-coded table of contents

* remove comparisons, rewrite "why" section to be more general

* update intro
2017-09-25 11:50:23 -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
5091587814 simplify schema rules, update docs 2016-08-14 15:51:07 -07:00
Ian Storm Taylor
06af3de5e5 start adding docs 2016-08-14 14:38:27 -07:00
Ian Storm Taylor
cd9c745a27 add bundled guide to readme 2016-08-07 17:40:28 -07:00
Ian Storm Taylor
030beab8cd fix bundled file, add bundled installation guide 2016-08-07 17:25:43 -07:00
Gonçalo Margalho
3128c26b82 Fix typo in serialize methods (#230) 2016-08-07 12:48:09 -07:00
adamlong5
58691691a9 Fix error in Hello World of installation guide (#170) 2016-07-24 17:14:42 -07:00
Ian Storm Taylor
d4433b8ec3 update installing slate guide to omit ranges 2016-07-21 16:42:24 -07:00
Ian Storm Taylor
054aaf419f update formatting guide with toggleMark 2016-07-21 12:02:26 -07:00
Ian Storm Taylor
00ee5c3c70 add prebundled notice to the installing guide 2016-07-20 14:43:11 -07:00
Ian Storm Taylor
f50c37f847 update saving html guide 2016-07-20 10:20:10 -07:00
Ian Storm Taylor
3b49833e8e add saving and loading html content guide to docs 2016-07-20 10:17:39 -07:00