1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-18 22:08:18 +01:00

579 Commits

Author SHA1 Message Date
Dan Schuman
376015df6c Text documentation update (#2758)
`text` property is no longer computed. Add `marks` field.
2019-05-10 10:47:58 -07:00
fchenTelus
7cbf15e3cc insertBlock is missing description (#2682) 2019-04-24 17:09:15 -07:00
Bryan Haakman
bb5d6beffa Make all ops invertible and remove value from ops (#2225) 2019-04-02 06:34:06 -07:00
Dominik Serafin
071424cda0 Use <s> for strikethrough example (#2676)
`<strike>` is obsolete and discouraged https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strike

`<s>` is better alternative https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s
2019-04-02 06:26:05 -07:00
Tom Locke
2380aa094f Clarify semantics of return from deserialize (#2665)
This can trip folks up who are using compile-to-JS languages (ClojureScript in my case), where return semantics may be different.
2019-03-26 07:29:41 -07:00
Aaron Greenlee
edbafa6fcb Glossary Enhancements (#2663)
* Rephrased to removed idiom and better describe Slate.

* Added links to educate folks about the core DOM concepts

* Renamed headline to `Slate Mirrors the Dom`

* Rephrased immutable js introduction

* Corrected spelling error

* Simplified language introducing how one can change values.

* Simplified statement about collection methods

* Added encouraging language for Immutable JS learning suggestion

* Quoted mozilla links

* Suggestions to improve readability of data-model documentation

* Added serialized example value

* Resolved one prettier complaints

* `yarn run prettier`

* anchor/focus point glossary content

* normalized term identifiers

* added mark

* Added plugin

* Added schema

* `yarn run prettier` and enhancements to collapsed, focus, and value
2019-03-26 07:27:48 -07:00
Ivan Ha
b3107fc142 docs: fix immutablejs doc domain (#2655) 2019-03-25 19:23:53 -07:00
Mate Paiva
bd7ee85c9b Fix missing break in last example (#2629)
In the last chunk of code, it was missing the `break` (or `return`). So, if used as is, the bold key will toggle the `code` feature as well.
2019-03-06 16:45:08 -05:00
Brendan
646ff2a80f
Fix onCommand docs that referenced query instead of command (#2625) 2019-03-06 15:44:41 -06:00
Mate Paiva
e5e1e570b8 Remove return true on key down function (#2628)
Correct me if I am wrong, but I believe that this `return true` is a no-op. I removed it and everything kept working as usual. And, when I was following the tutorial, that particular line created an interrogation mark in my brain. So, my suggestion is to remove that line to avoid creating entropy for no reason.
2019-03-06 16:44:35 -05:00
Brendan
a3f91e139f Add @convertkit/slate-lists to plugins page (#2615) 2019-02-28 12:08:34 -08:00
Bryan Haakman
8e659dbd28 Small doc fix for isNodeInRange (#2580) 2019-02-04 16:29:18 -08:00
Brendan
58709123dd Add @convertkit/slate-code to docs (#2568) 2019-01-30 12:12:05 -08:00
Konrad Lisiczyński
63cbfb3266 Clarify children access in renderEditor in docs (#2286)
* Clarify children access in renderEditor in docs

* Applied review changes of renderEditor doc update

* Updated renderEditor docs to match Slate 0.43

* Prettified plugins.md
2019-01-29 16:05:03 -08:00
Vritant Bhardwaj
6bf36a35d4 Update link to source (#2497)
The link to the package directory previously lead to a 404 page.
2019-01-29 16:04:05 -08:00
Nandu
7a6de8725c Add break in the Switch statement for Custom Formatting Walkthrough (#2550)
The Custom Formatting Walkthrough does not work as expected. When
Ctrl + B is pressed it applies both Bold and Code styles to the
content. This is because of the case statement running beyond
the Bold case due to the absence of a break keyword.
2019-01-21 18:27:43 -08:00
Tom Moor
43ee38e39d Update commands.md (#2551)
Fixed incorrect documentation for `moveToRangeOfNode`
2019-01-21 18:25:09 -08:00
Dundercover
76a88a649a Add editor.HasCommand and editor.HasQuery (#2438)
* Add `editor.hasCommand` method

* Add `editor.hasQuery` method

* Rename directories `hasCommand` and `hasQuery` to kebab case

* Add tests for `editor.hasCommand` of React component

* Add tests for `editor.hasQuery` of React component
2018-12-11 11:25:53 -08:00
Ralph Feltis
5cca509db2 Fix typo in resources.md (#2484)
* Adding Guilded to Products list

* Fixing typo
2018-12-05 12:22:37 -08:00
Gijs Nelissen
ab91240af7 Add prezly.com to resources.md (#2483) 2018-12-04 20:57:10 -08:00
Ralph Feltis
bc252de9e1 Adding Guilded to Products list (#2482) 2018-12-04 20:53:19 -08:00
Shawn Erquhart
ce8bfa56a6 add Netlify CMS to products list (#2478) 2018-12-04 11:07:28 -08:00
Denys Vuika
59d184b153 Update saving-and-loading-html-content.md (#2452)
fix example code
2018-12-02 13:15:16 -08:00
Eric Edem
b8420fce3f docs: replace change with editor (#2433)
Just in a couple places.
2018-12-02 13:12:41 -08:00
Knut Melvær
6d8df18f01 Add Sanity.io to the list of products (#2441)
Hi Ian! Took the liberty to add Sanity.io to the list 🙌
2018-11-19 14:43:43 -08:00
Ian Storm Taylor
c615a89fec
Update Introduction.md 2018-11-15 08:33:05 -08:00
Ian Storm Taylor
c184be6da4
Update Introduction.md 2018-11-15 08:32:18 -08:00
Ankit Goel
5849dcb810 Fix broken links (#2426) 2018-11-15 08:08:05 -08:00
Dundercover
4df88cfaeb Add node.isNodeInRange (#2401)
* Add `node.isNodeInRange`

* Add tests for `node.isNodeInRange`
2018-11-08 15:38:18 -08:00
Dundercover
13107b0c43 Add optional id prop to the Editor component (#2402) 2018-11-08 15:36:44 -08:00
Krzysztof Mędrzycki
746b63db7e Improve schema validation for nodes and min/max (#2388)
* Better schema violations for underflow and overflow

* Rename child_required_under/overflow to child_min/max_invalid

* Remove tailing whitespace

* Add tests to cover more branches

* Insert missing comma
2018-11-08 13:05:59 -08:00
Dundercover
698edc24d8 Add node.getLeafXAtRange and node.getRootXAtRange (#2399)
#### Is this adding or improving a _feature_ or fixing a _bug_?

Adding and improving

#### What's the new behavior?

Renames the following node methods (deprecating the old ones):

- `getBlocksAtRangeAsArray` -> `getLeafBlocksAtRangeAsArray`
- `getBlocksAtRange` -> `getLeafBlocksAtRange`
- `getInlinesAtRangeAsArray` -> `getLeafInlinesAtRangeAsArray`
- `getInlinesAtRange` -> `getLeafInlinesAtRange`

Adds the following nodes methods:

- `getRootBlocksAtRange`
- `getRootInlinesAtRange`

#### How does this change work?

Have not changed the implementation of the renamed methods. Added tests for both renamed methods and added methods.

#### 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?

Discussed in #2351
2018-11-08 13:04:27 -08:00
Dundercover
e6d611d726 Add node.getNodesAtRange (#2398)
* Add `Node.getNodesAtRange`

* Add tests for `Node.getNodesAtRange`
2018-11-08 11:31:54 -08:00
CameronAckermanSEL
88aa5a5cc8 added the schema reference to the list of documents for gitbook, renamed Readme.md to Summary to be consistent with conventions. (#2387) 2018-11-06 12:15:43 -08:00
Dundercover
a8972f3f3d Add documentation for the Operation.data property (#2377)
* Add documentation for the `Operation.data` property

* Fix typo in documentation for `Operation` model
2018-11-05 08:29:18 -08:00
Ian Storm Taylor
a09c3c2fdf
Remove renderPlaceholder (#2370)
* add placeholder plugin in slate-react

* remove renderPlaceholder logic

* extract placeholder into a plugin

* remove other old placeholder-based logic

* update changelogs
2018-11-02 17:04:20 -07:00
Dylan
ea3443eb42 Fix a typo (#2362) 2018-11-01 12:15:13 -07: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
Max Nesov
1032d14ffb Update change.md (#2310)
moveToRangeOf => moveToRangeOfDocument
2018-10-24 09:11:41 -07:00
kyrisu
f56f28a8fa Fixed KeyDown handler signature in code snippet (#2294)
The paragraph mentioned handle signature being `event, change, next` but the snippet had a signature with `event, change, editor`
2018-10-22 11:19:55 -07:00
Alan Christopher Thomas
175b25ae51 Fix docs on queries to show editor argument (#2285) 2018-10-20 00:05:53 -07:00
Pier Bover
0deb2e2695 Fixed link (#2270) 2018-10-16 11:35:14 -07:00
Dundercover
7192a97600 Add range comparison methods to Point (#2248)
* Rename compare function in path-utils to compareOfSameSize
To make way for a new function that makes a full comparison

* Add compare function to path-utils that handles paths of different sizes

* Add function isAfterRange to Point

* Add function isBeforeRange to Point

* Add function isAtStartOfRange to Point

* Add function isAtEndOfRange to Point

* Add function isInRange to Point

* Add range comparison methods to the documentation of the Point model

* Remove `compareOfSameSize` in `path-utils.js`
Using `compare` instead

* Add `Point.isBeforePoint`

* Add `Point.isAfterPoint`

* Use own methods internally for range comparisons in `Point`

* Return null if paths don't finally match in `compare` method of `path-utils`
To convey that it is not a normal scenario

* Add first test for `Point` model (testing `isAfterPoint`)

* Add tests for `Point.isAfterPoint`

* Add tests for `Point.isBeforePoint`

* Add tests for `Point.isAfterRange`

* Add tests for `Point.isBeforeRange`

* Add tests for `Point.isAtEndOfRange`

* Add tests for `Point.isAtStartOfRange`

* Add tests for `Point.isInRange`
2018-10-15 15:44:09 -07:00
Kashif
c0c0eb65f2 Add missing import (#2252) 2018-10-11 21:34:23 -07:00
Ian Storm Taylor
3528bb7366 fix plugins stack ordering and defaulting 2018-10-09 18:43:47 -07:00
Ian Storm Taylor
7a71de387c
Add controller (#2221)
* fold Stack into Editor

* switch Change objects to be tied to editors, not values

* introduce controller

* add the "commands" concept

* convert history into commands on `value.data`

* add the ability to not normalize on editor creation/setting

* convert schema to a mutable constructor

* add editor.command method

* convert plugin handlers to receive `next`

* switch commands to use the onCommand middleware

* add queries support, convert schema to queries

* split out browser plugin

* remove noop util

* fixes

* fixes

* start fixing tests, refactor hyperscript to be more literal

* fix slate-html-serializer tests

* fix schema tests with hyperscript

* fix text model tests with hyperscript

* fix more tests

* get all tests passing

* fix lint

* undo decorations example update

* update examples

* small changes to the api to make it nicer

* update docs

* update commands/queries plugin logic

* change normalizeNode and validateNode to be middleware

* fix decoration removal

* rename commands tests

* add useful errors to existing APIs

* update changelogs

* cleanup

* fixes

* update docs

* add editor docs
2018-10-09 14:03:27 -07:00
Andrei Cacio
de9a07900e Fixed broken HTML serializer link (#2239) 2018-10-09 08:51:36 -07:00
Eric Edem
6dc8b4baa5 docs(plugins): update signature docs (#2057)
`onChange()` also receives the editor as an argument.
2018-09-27 23:37:01 -07:00
Eric Edem
f60100bd93 Update products to include Cake (#2207)
Now that Cake is coming out of invite only mode, figured it was a good time to add it. :)
2018-09-25 13:29:15 -07:00
Nick Quaranto
237dd8395f Update resources with Chatterslate (#2204)
Just a quick update here with a link to https://github.com/chatterbugapp/chatterslate !
2018-09-25 11:27:39 -07:00