1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-21 07:32:24 +01:00

118 Commits

Author SHA1 Message Date
宋万盛
54e4ee204c
Fix sourcemap warnings in Windows (#5301)
https://github.com/ianstormtaylor/slate/issues/5300
2023-02-20 08:46:57 -07:00
Sergei Dedkov
9635b992a0
Compare only decorations offsets in MemoizedText. Code highlighting example improvements. (#5271)
* add basePath prop to Range inside slate-react custom types, calculate absolute ranges on passing them into TextComponent

* code highlighting example improvements, minor markdown preview refactoring

* changeset added

* Revert "add basePath prop to Range inside slate-react custom types, calculate absolute ranges on passing them into TextComponent"

This reverts commit afa085c289bc67ce3d27dd33b1f074ab8153efe8.

* add basePath prop to Point inside slate-react custom types, resolve relative ranges on passing them to TextComponent

* Update changeset

* linter fixes

* remove redundant checks inside renderElement function

* custom types fixes for Range and Point in examples

* wrap intervals and ranges extractors in useMemo hook for running them only if editor.children is changed

* revert basePath changes, compare only offsets for MemoizedText decorations

* use an element as a key in decorations ranges map instead of id

* simplify code highlighting implementation, make code block nested

* fix code-highlighting example, add toolbar code block button

* remove redundant code

* fix code highlighting playwright integration test
2023-02-09 11:53:21 -07:00
Sergei Dedkov
fc84fdbd99
fix hovering-toolbar playwright integration test (#5284) 2023-02-07 22:13:09 -07:00
Kyle McLean
9c4097a26f
Simplify implementation of custom editor styling (#5278)
* Switch back to using inline styles for default editor styles

* Add example page and test for editor styling

* Add section in docs for editor styling

* Add test for editor height being set to placeholder height

* Add changeset
2023-01-31 19:17:27 -07:00
Ravi Lamkoti
c691bb3aae
fix: isVoid, isBlock, isInline types (#5254)
* fix: isVoid, isBlock, isInline types

* fix: remove isElement check with isEditor
2023-01-25 15:35:46 -08:00
eagowang
e9c9d9f4db
Fix forced-layout example trigger insert untitle node (#5263)
Co-authored-by: 锐雯 <wangyichen@xiaohongshu.com>
2023-01-20 05:54:43 -07:00
GengJun
e139c11235
Fix: Mentions Example (#5191) 2022-11-17 09:17:51 -07:00
Brian Bucknam
346f6572fc
Allow void elements to receive marks (#5135)
Some void elements are effectively stand-ins for text, such as with the mentions example,
where the mention element renders the character's name. Users might want to format Void
elements like this with bold, or set their font and size, so `editor.markableVoid` tells
Slate whether or not to apply Marks to the text children of void elements.

- Adds `markableVoid()` as a schema-specific overrideable test.
- Changes `addMark` and `removeMark` so marks can apply to voids. Also changes behavior
of collapsed selection so that if a markable Void is selected, the mark will be applied /
removed.
- Shows how `markableVoid()` can work in the mentions example
2022-11-08 05:38:15 -07:00
Julian Benegas
16a9292aaf
only preventDefault if the input is actually a format action (#5113) 2022-09-09 20:15:34 -07:00
donaldkicksyourass
e9273366b9
fix(example): no action when cancel a file prompt (#5082) 2022-08-18 05:19:14 -07:00
Eric Meier
fbab6331a5
Android input handing rewrite (#4988)
* wip

* wip

* wip - fully working without hard marks

* fix editor crashes when inserting/deleting at the edges of marks

* fix various restore dom related crashes

* fix delete with pending changes, zero widths on android, mutation tracking

* track placeholder delete in detached strings, zero-widths

* wip mark placeholders

* get rid of mutation detection in favor of beforeinput

* fix various selection race conditions

* fix various crashes when deleting at the beginning of nodes

* wip diff transforms, selection handling fixes

* cleanup restoreDOM and fix noop restore edge-case

* fix mark placeholders

* fix toSlatePoint edge-case

* properly flush user select with pending changes

* Prevent editor crash when deleting before a non-contenteditable element

* wip markdown shortcut example

* transform pending changes and selection by remote changes, simplify pending actions, handle all input types

* improve change transform, mark(-placeholder) handling

* manually handle gboard bug, fix restoredom nested editor

* fix parent mutation condition

* cleanup, mark placeholder fixes

* mark placeholder fixes

* fix mark placeholder condition

* hide placeholder if we have pending diffs

* cleanup

* yarn install

* add workaround for swiftkey placeholder issue

* cleanup

* add changeset

* feat(slate-react): fix edge-case crash, add androidPendingDiffs, rename scheduleFlushPendingChanges

* flush pending selection on same line without pending changes/action

* keep formatting of pending diffs when adding/removing selection marks

* unref selection ref on unmatching dom state

* improve markdown shortcut example flush trigger to show how a more generic solution would work

* fix markdown shortcut example trigger logic

* fix isInsertAfterMarkPlaceholder logic
2022-07-29 04:04:33 -07:00
Bryan Haakman
11a93e65de
Upgrade next.js to 12 and related packages (#5042)
* Upgrade next.js and source-map-loader

* Add changeset

* Upgrade eslint and typescript

* improve reliability of iframe test

* fix lint
2022-07-15 06:14:18 -07:00
pubuzhixing8
2b294b30d7
fix(mentions): correct spacer tag position to avoid IME input being interrupted Cannot input chinese directly after the mention in mention demo #3490 (#5013) 2022-06-11 08:09:20 -07:00
Eric Meier
f17413086e
Update examples in docs, editable voids example (#4925)
* Update examples in docs, editable voids example

* Update typescript docs
2022-04-03 09:57:38 -07:00
Eric Meier
9892cf0ffb
Make onChange prop optional, update examples and docs to treat slate as uncontrolled (#4922)
* Make onChange prop optional, update examples and docs to treat slate as uncontrolled

* Add changeset
2022-04-03 08:52:32 -07:00
Jan Paepke
53f47b01d1
EXAMPLES: fix focus bug for hovering toolbar example (#4866)
* fix focus bug for hovering toolbar example

* added test
2022-03-06 21:43:58 -07:00
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
Kristoffer K
29473b0290
chore: follow-up to Yarn update (#4478)
* fix(site): `require.resolve` webpack loader

* chore: add pnp sdk

* ci: cache dependencies

* ci: add release `version` command
2021-09-02 04:42:45 -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
Sunny Hirai
506d9bce53 Add syntax highlighting example to menu 2021-07-01 17:10:35 -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
4eec49de16 rename master to main 2021-04-01 13:40:25 -04:00
Ian Storm Taylor
7723935b68 port remove link button pr to master 2021-03-31 21:59:57 -04:00