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

91 Commits

Author SHA1 Message Date
Daniel Shotonwa
8f646ce84e
Add Simple Alignment to richtext example (#4867) 2022-03-06 21:43:22 -07:00
Dylan Schiemann
ce1e096df7
update emotion dependency for site (#4783) 2022-01-11 08:36:04 -07:00
Adrian
e3a325f8a6
iframe example - use an onLoad callback instead of the ref (#4758)
* use an onLoad callback instead of the ref

* expect body to not be null on the iframe test

* remove onLoad prop
2022-01-10 16:21:20 -07:00
Jim Fisher
4b2d4de4bf
Show example of a workaround for Chrome bug that puts cursor in wrong place (#4772)
There is a Chromium bug where, if you have an inline at the end of a block,
clicking the end of a block puts the cursor inside the inline
instead of inside the final {text: ''} node.

This commit updates the inlines example to show the problem, and to show
a known workaround for the problem.

See for context: https://github.com/ianstormtaylor/slate/issues/4704
2022-01-06 13:15:14 -07:00
Doug Reeder
c90ec8e837
Adds documentation for PathRef (#4740) 2021-12-22 05:04:14 -07:00
Dan Tello
65708358bb
fix: isBlockActive should use Array.from() (#4662)
* fix: isBlockActive should use Array.from()

The richtext.tsx example `isBlockActive`  was not working for me in my environtment because `Editor.nodes` returns a Generator, not an Array. So `isBlockActive` always returned false. Wrapping it in `Array.from` fixes the example.

* run prettier

Co-authored-by: Dan Tello <dtello@medallia.com>
2021-12-17 05:34:18 -07:00
Ivan Voskoboinyk
e0f41514a1
Improve props argument type in Transforms.setNodes() (#4638)
* Fix `setNodes()` props argument type

Because Typescript can know which type of nodes we are modifying thanks to the `T` inferred from `match` function, 
it can also properly narrow down the `props` argument type.

* Fix TS errors in examples

* Add a changeset
2021-11-04 04:43:18 -07:00
Jim Fisher
0b256b211e
Editable button example: emulate button to work around browser bug (#4630)
It's important to have 100% working examples. Unfortunately this example
I introduced has a bug on Chrome and Safari, where the cursor jumps
around wrongly when using the "up" and "down" keys to navigate. This
is due to a browser bug with display:inline-block elements, and there
is no known workaround except to use display:inline.
2021-10-26 21:12:36 -07:00
Jim Fisher
77d9f60ab5
Fix crash when a void node deletes itself on click (#4616)
* Fix crash when a void node deletes itself on click

Fixes https://github.com/ianstormtaylor/slate/issues/4240

* Add 'image delete' feature to example

My immediate motivation is to demonstrate the bug that this fixes. But
this is also a very common editor feature, and I think it's valuable
to show how to achieve it.

* add changeset

* fix:eslint

* revert changes to mentions.tsx
2021-10-24 07:31:00 -07:00
Jim Fisher
f1b7d18f43
Official custom inlines example (#4615)
* Official custom inlines example

This generalizes the "links" example to an "inlines" example, adding
a new example of an inline: an "editable button".

Firstly, this is important to demonstrate that Slate really does allow
_custom_ elements, and not just "standard" ones like links that you'll
find in any editor.

Secondly, it's important to show an example of an inline where "offset"
movement should be used. With links, it's arguable that the cursor
positions <link>foo<cursor/></link> and <link>foo</link><cursor/>
should be considered the same, because they display in the same
position. But with the editable button, the cursor is clearly in a
different position, and so offset movement should be used.

* lint

* fix integration test

* update readme

* try again
2021-10-22 13:19:41 -07:00
Jim Fisher
cab8edea7b
Add "selected shadow" to link example (#4609)
Due to standard link CSS, the cursor at the end of the link looks the
same as the cursor immediately after the link, and the cursor at the
start of the link looks the same as the cursor immediately before the
link. However, these are semantically different locations. I've had
several problems with Slate misinterpreting these locations, and had
trouble showing these problems to others using the standard examples,
because the only example of an editable inline element is the link.

To fix this, I've added a box-shadow to the link when it's selected. It
should now be clear to the user whether the cursor is inside or
outside the element.
2021-10-19 06:48:03 -07:00
Dylan Schiemann
f1607da4ad
Revert "in examples, move withReact in front of withHistory (#4604)" (#4607)
This reverts commit 9cf2f4eea2878a7acce84273c3a65c09f0d0ea98.
2021-10-17 06:31:33 -07:00
Jake Donham
9cf2f4eea2
in examples, move withReact in front of withHistory (#4604) 2021-10-15 16:01:22 -07:00
Jake Donham
ae65ae5f71
revert #4455 / #4512; fix triple-click by unhanging range with void (#4588)
* revert #4455 / #4512; fix triple-click by unhanging range with void

* added changeset
2021-10-11 05:15:04 -07:00
Jas
a2558b37b0
Fix boolean not assignable to string typescript error (#4568) 2021-10-07 06:10:50 -07:00
Dylan Schiemann
3e7ff3bb0d
Layout example fix (#4463)
* Update forced-layout example

Enforce layout to an explicit block index to allow for other block types

* Update site/examples/forced-layout.tsx

* fix layout example to comply with linting rules

Co-authored-by: Lukas Murdock <lukas.murdock@gmail.com>
2021-08-21 04:32:04 -07:00
Georgy Perepecho
d32ce0f49b
fix example paste-html if children are empty (#4446)
Co-authored-by: Georgii Perepecho <georgii.perepecho@revolut.com>
2021-08-12 14:54:01 -07:00
Devesh Kumar
40a12d7511
small UI fix for the search icon and placeholder of the search higlighting (#4422)
no changeset as it doesn't change a package, just an example.
2021-08-07 08:20:07 -07:00
Samarjeet
8def57665c
cypress: shadow-dom example test (#4413) 2021-08-05 12:08:37 -04:00
Thomas
531707e746
Clean up imports (#4319) 2021-08-04 21:56:45 -07:00
Samarjeet
fed9354764
Cypress tests for examples (#4389)
* cypress: mentions example test

* cypress: search highlighting test

* cypress: tables example test

* cypress: check html in richtext

* Update cypress/integration/mentions.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Update cypress/integration/search-highlighting.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* cypress: reset page before each test case

* cypress: Custom command dataCy

* cypress: seperate directory for examples' tests

* cypress: remove comments

* cypress: add placeholder test

* cypress: add plain text test

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>
2021-08-03 16:19:46 -04:00
Anish Aggarwal
a35fe46bff
added cypress test for check-list page (#4383)
* added cypress test for check-list page

* Update cypress/integration/checkLists.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Update cypress/integration/checkLists.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Update cypress/integration/checkLists.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Added beforeEach() call

* moved the checkLists.ts example to the examples folder

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>
2021-08-02 11:19:10 -07:00
Sunny Hirai
c217dbb5b9
Fix scroll into view to scroll parent scrollables (#4369) 2021-07-09 15:12:13 -07:00
Claudéric Demers
4f50211984
Temporarily revert Android commits in order to create a release of Slate focused solely on Android (#4256)
* Revert "Add DefaultEditable and AndroidEditable to exports (#4255)"

This reverts commit 5298e51f6e8a7d62acb71092f7afd6565cbdc65e.

* Revert "Feature/android keyboard support (#4200)"

This reverts commit e03ce7c5614a1a69d039bfbeea94696376585fd0.
2021-05-12 21:24:57 -04:00
Wayne Leroux
e03ce7c561
Feature/android keyboard support (#4200)
* Added Android Keyboard Support

* Added changeset for android keyboard support

* Removed dead code in android editable that supported non-android environments

* Removed unnecessary attributes observation for android-editable

* Removed dead code

* Added no-error boundary

* Fixed issues with linters
2021-05-12 16:30:39 -07:00
katsew
c70e30f83d
fix: shadow-dom example not found in examples (#4226) 2021-04-26 10:35:54 +01:00
Julian Krispel-Samsel
ea2eefefb8
Add renderPlaceholder (#4190) 2021-04-23 21:22:11 +01:00
Julian Krispel-Samsel
602f170156
Update readonly example and add test (#4212)
* fixes #4039, update readonly example

* add cypress test for readonly mode
2021-04-21 09:29:19 +01:00
case
6a6d9f614d
Fix Underline <FormatButton /> in Hovering Toolbar Example (#4128)
* Fix Underline <FormatButton /> in `Hovering Toolbar Example`

* Update hovering-toolbar.tsx

Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
2021-04-13 10:57:39 -04:00
hoangbits
8c3c7ada87
Update images.tsx (#4180) 2021-04-08 19:59:36 -04:00
Ian Storm Taylor
7723935b68 port remove link button pr to master 2021-03-31 21:59:57 -04:00
kenzobanaag
2db9a36f93
Added isImageUrl validation to button, added alert when not image (#3933)
* Added isImageUrl validation to button, added alert when not image

* Fixed lint error
2021-03-31 18:03:36 -04:00
David Ruisinger
0473d0bf93
Use shadow dom if available (#3749)
* getDirtyPaths can now be customized by Slate users (#4012)

* Moved getDirtyPaths() into the editor object so it can be customized via plugin

* docs: Update document in Chinese (#4017)

Co-authored-by: liuchengshuai001 <liuchengshuai001@ke.com>

* Removed unused import

* Use shadowRoot if available

* Removed optional chaining

* Added workaround for chrom bug in ShadowDOM

* Added shadow DOM example

* Add a shadow DOM example

Shadow DOM brings different behaviours for selection and active
elements. This adds an example where the editor is found within a shadow
DOM, in fact, the editor is two levels deep in nested shadow DOMs.

The handling of selections means that this editor doesn't work properly
so Slate will need to be made aware of the shadow DOM in order to fix
this.

* User DocumentOrShadowRoot for selection and active elements

If the editor is within a ShadowDom, the selections and active element
APIs are implemented on the ShadowRoot for Chrome. Other browsers still
use the Document's version of these APIs for the shadow DOM.

Instead of defaulting to `window.document`, find the appropriate root to
use for the editor in question.

* Add compatibility for Chrome's isCollapsed bug

Chrome will always return true for isCollapsed on a selection from the
shadow DOM. Work around this by instead computing this property on
Chrome.

https://bugs.chromium.org/p/chromium/issues/detail?id=447523

* Removed duplicated example

* Fixed possible null value

* Use existing PlainTextExample

* Re-added local Editor to have clear initialValue

* Optimize shadowRoot checkup

* Remove getDocumentOrShadowRoot util in favor of findDocumentOrShadowRoot

* Re-added getDocumentOrShadowRoot

* Put selectionchange listener on window.document

* Resetted changes from main branch

* Create tiny-walls-deliver.md

* Update tiny-walls-deliver.md

* Update tiny-walls-deliver.md

Co-authored-by: Tommy Dong <contact@tomdong.io>
Co-authored-by: Jacob <40483898+jacob-lcs@users.noreply.github.com>
Co-authored-by: liuchengshuai001 <liuchengshuai001@ke.com>
Co-authored-by: Andrew Scull <andrew.scull@live.com>
Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
2021-03-31 15:47:28 -04:00
Sunny Hirai
c803e5ffd0 Switch initialValue type in examples to Descendant 2021-03-29 09:49:44 -07:00
Sunny Hirai
4661f19d4b Add language type for examples Readme.md code blocks 2021-03-29 09:38:20 -07:00
Sunny Hirai
b88149c2f9 Remove unused imports from all examples 2021-03-29 09:37:24 -07:00
Sunny Hirai
3caf0e1849
Allow useSlate and useSlateStatic to use a generic to return a Custom Editor (#4135)
* Have useSlate and useSlateStatic return the Custom Editor

* v0.60.12

* Add generic to useSlate and useSlateStatic

* v0.60.13

* Fix useSlate and useSlateStatic to return customized Editor type

* v0.60.14
2021-03-20 20:49:58 -07:00
Sunny Hirai
a72958e6c3
Improved Types (#4119)
* Experimental release to see if CustomTypes holds up through a publish

* Add experimental release script

* Fix lint

* v0.60.5-alpha.0

* Allow null properties in setNodes

* v0.60.6-alpha.0

* Revert null properties on Transforms.setNodes

* v0.60.7-alpha.0

* Update examples to use custom Element and Text with discriminated unions

* Add documentation for using TypeScript improvements

* Be explicit about typescript version in package.json

* Force lerna bootstrap to fix build issues on CI and fix a few type examples

* Add slate devDependencies with * back

* v0.60.7

* Switch to a non prerelease version to fix lerna not linking in root

* Add documentation for not using prerelease versions and on how to create experimental releases

* Try removing lerna bootstrap and see if it works
2021-03-11 11:48:31 -08:00
Jacob
5267f07175
fix: fix 404 status of iframe example page (#4092) 2021-02-28 23:00:33 -05:00
Sunny Hirai
513771c82a
slate-react: MVP for working with non-global window objects (fix for #3819) (#4079)
* mvp implementation for working with non-global window instances

* remove unused element renderer

* fix typo in comment

* fix wrong example reference

* Add @babel/helper-call-delegate to fix build error

Co-authored-by: Lukas Buenger <lukasbuenger@gmail.com>
2021-02-16 19:40:15 -08:00
Steve Marquis
e4936c3f32
Fix broken attribute references (#4011) 2021-02-11 18:29:03 -05:00
Sunny Hirai
08275f68f3
Custom TypeScript Types (#3835)
This PR adds better TypeScript types into Slate and is based on the proposal here: https://github.com/ianstormtaylor/slate/issues/3725

* Extend Slate's types like Element and Text

* Supports type discrimination (ie. if an element has type === "table" then we get a reduced set of properties)

* added custom types

* files

* more extensions

* files

* changed fixtures

* changes eslint file

* changed element.children to descendant

* updated types

* more type changes

* changed a lot of typing, still getting building errors

* extended text type in slate-react

* removed type assertions

* Clean up of custom types and a couple uneeded comments.

* Rename headingElement-true.tsx.tsx to headingElement-true.tsx

* moved basetext and baselement

* Update packages/slate/src/interfaces/text.ts

Co-authored-by: Brent Farese <25846953+BrentFarese@users.noreply.github.com>

* Fix some type issues with core functions.

* Clean up text and element files.

* Convert other types to extended types.

* Change the type of editor.marks to the appropriate type.

* Add version 100.0.0 to package.json

* Revert "Add version 100.0.0 to package.json"

This reverts commit 329e44e43d968700655b1c46f968bfd3147e7339.

* added custom types

* files

* more extensions

* files

* changed fixtures

* changes eslint file

* changed element.children to descendant

* updated types

* more type changes

* changed a lot of typing, still getting building errors

* extended text type in slate-react

* removed type assertions

* Clean up of custom types and a couple uneeded comments.

* Rename headingElement-true.tsx.tsx to headingElement-true.tsx

* moved basetext and baselement

* Update packages/slate/src/interfaces/text.ts

Co-authored-by: Brent Farese <25846953+BrentFarese@users.noreply.github.com>

* Fix some type issues with core functions.

* Clean up text and element files.

* Convert other types to extended types.

* Change the type of editor.marks to the appropriate type.

* Run linter.

* Remove key:string uknown from the base types.

* Clean up types after removing key:string unknown.

* Lint and prettier fixes.

* Implement custom-types

Co-authored-by: mdmjg <mdj308@nyu.edu>

* added custom types to examples

* reset yarn lock

* added ts to fixtures

* examples custom types

* Working fix

* ts-thesunny-try

* Extract interface types.

* Fix minor return type in create-editor.

* Fix the typing issue with Location having compile time CustomTypes

* Extract types for Transforms.

* Update README.

* Fix dependency on slate-history in slate-react

Co-authored-by: mdmjg <mdj308@nyu.edu>
Co-authored-by: Brent Farese <brentfarese@gmail.com>
Co-authored-by: Brent Farese <25846953+BrentFarese@users.noreply.github.com>
Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>
2020-11-24 12:30:06 -08:00
Wendell Hu
59ee7f8488
doc: change example readme doc link (#3853) 2020-11-03 12:38:08 -05:00
Song You
4ae58e5c95
Differentiate between useSlate and useEditor hooks (#3941)
* Rename useEditor function to useSlateStatic

* Expose useEditor hook with deprecated flag

* Clarify useEditor deprecation in file and in docs
2020-10-29 15:39:21 -04:00
Wendell Hu
912d4b79da
docs: convert examples to typescript (#3766)
* docs: convert examples to typescript

* docs: convert remaining examples

* docs: update next.js

* ci: fix lint

* docs: fix next.js path

* docs: cleanup

* update

Co-authored-by: wendellhu <wendellhu@tencent.com>
2020-08-19 09:14:51 -07:00
Maria Jaramillo
d5eaa1164d
Fixed html (#3809)
* Add version 100.0.0 to package.json

* Revert "Add version 100.0.0 to package.json"

This reverts commit 329e44e43d968700655b1c46f968bfd3147e7339.

* fixed typo in html file

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>
2020-08-05 15:57:48 -07:00
Maria Jaramillo
a35b8737b7
syntax highlighting (#3762)
* syntax highlighting

* Delete package-lock.json

* Update package.json

* Update package.json

* Delete syntax-highlighting.js

* Update [example].js

* Update [example].js

* Update [example].js

* added correct file

* linting

* Update site/examples/code-highlighting.js

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Update site/examples/code-highlighting.js

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Update site/examples/code-highlighting.js

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* updated pull request with some linting

* moved getLength fcn

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>
2020-07-09 18:23:56 -04:00
whyour
08f7ef588c
fix hovering toolbar format hotkeys (#3667) 2020-05-10 23:01:35 -07:00
Entkenntnis
1d7ab97429
use state to avoid cursor jumping in controlled input (#3552)
Co-authored-by: dal <test@x.com>
2020-03-24 18:16:32 -07:00
pavlyna
16ff44d056
3536 cover beforeinput behavior on edge legacy browser (#3537)
* 3536 support flat functionality + beforeinput in Edge

* 3536 support flat functionality + beforeinput in Edge

* 3536 remove support for flat functionality

* 3536 added description of regexp

Co-authored-by: Pavlyna Bevz <pavlynabevz@pbevz-mbp.local>
2020-03-11 08:20:30 -07:00