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

126 Commits

Author SHA1 Message Date
Dylan Schiemann
c4c14882ed
Update dependencies to React 18, Node 20, TS 5.2, etc. ()
* incremental upgrade to React 18, TS 4.9, etc.

* update yarn config

* fix build

* minor cleanup in type definitions

* incremental updates for TS 5.0

* fix build

* upgrade to typescript 5.2

* update dependencies

* fix lint issues

* update to latest Playwright version

* update changesets dep

* update emotion/css

* incremental dependency updates

* more small dependency updates

* upgrade prettier and eslint

* fix lint issues

* update dependencies rollup

* fix @types/node resolution to restore linting

* update tiny-invariant dependency

* update dependencies

* update dependencies lerna

* upgrade react-router-dom

* update @types/react and @types/node

* update babel dependencies

* udpate simple-git-hooks

* update @types/node resolution

* update lint-staged

* remove cypress from dependency list

* update @types/node to support Node 20

* update workflows to Node 20

* set resolutions for @types/react

* downgrade @types/react to 18.2.28

* update mocha

* update rimraf

* update @types/js-dom

* remove .lintstagedrc.js

* upgrade next to latest

* v0.61.4

* update lerna

* update faker and rollup

* update immer

* fix yarn clean command

* attempt to fix integration tests

* attempt to stabilize integration tests

* wip fix integration tests

* skip unstable integration test

* Add changeset

---------

Co-authored-by: Dalibor Tosic <dalibortosic00@gmail.com>
Co-authored-by: Nikola <nikolabijelic14@gmail.com>
2023-10-20 08:34:24 -07:00
Brian Bucknam
5eb589dbbb
Use mark functions for docs and examples ()
When documenting how to apply character-level styling, use `addMark` and `removeMark` instead of `setNodes`. This avoids new users creating code that only works in the simplest cases.

Similarly, update the Hovering Toolbar example to apply marks instead of setting nodes.

This change was prompted by a discussion on Slack where the developer was disappointed that `markableVoid` did not appear to be working. The problem was they were using `setNodes` to apply Marks, and did not use the same `match` function that `addMark` uses.
2023-06-12 15:08:10 -07:00
Ivan Voskoboinyk
91e388ecd9
Rename <Slate> component value prop to initialValue ()
* Rename `slate-react` Slate component `value` prop to `initialValue`

Fixes 

* Update documentation: `value` -> `initialValue`

* Add a changeset record

* Make props order consistent
2023-05-26 07:53:39 -07:00
Nami
ce5428b143
Remove unnecessary dollar sign from Chromium bug fix () 2023-04-14 11:33:01 -07:00
Joe Anderson
b52e08b0ea
Add support for read-only and non-selectable elements ()
* Add `isElementReadOnly`

fix delete while selected

fix type while selected

fix failing test

add tests

add e2e test

linter fixes

add changeset

* fix yarn build:next

* Add `isSelectable`
2023-04-03 11:02:26 -07:00
Anthony Ciccarello
d42cd005db
enable eslint hooks rules () 2023-03-17 10:45:54 -07:00
Anthony Ciccarello
e587880964
Android mentions fixes ()
* fixes android input events in mention example

Android keyboards use a composition text approach for autocomplete purposes.
Chrome sees the mention text and thinks it is part of the word to complete.
The simplest solution is to add zero width whitespace.

This also adds a click handler on the mention example to help
with the mobile (and desktop) testing experience.

* move mention spacer
2023-03-15 21:02:40 -07:00
qirong77
ee7eac4331
fix the bug of user can't use 'mod + a' to select or delete all nodes when use image(void) element ()
Co-authored-by: linqirong <609413692@qq.com>
2023-03-08 06:51:12 -07:00
宋万盛
54e4ee204c
Fix sourcemap warnings in Windows ()
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. ()
* 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 () 2023-02-07 22:13:09 -07:00
Kyle McLean
9c4097a26f
Simplify implementation of custom editor styling ()
* 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 ()
* 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 ()
Co-authored-by: 锐雯 <wangyichen@xiaohongshu.com>
2023-01-20 05:54:43 -07:00
GengJun
e139c11235
Fix: Mentions Example () 2022-11-17 09:17:51 -07:00
Brian Bucknam
346f6572fc
Allow void elements to receive marks ()
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 () 2022-09-09 20:15:34 -07:00
donaldkicksyourass
e9273366b9
fix(example): no action when cancel a file prompt () 2022-08-18 05:19:14 -07:00
Eric Meier
fbab6331a5
Android input handing rewrite ()
* 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 ()
* 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 () 2022-06-11 08:09:20 -07:00
Eric Meier
f17413086e
Update examples in docs, editable voids example ()
* 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 ()
* 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 ()
* 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 () 2022-03-06 21:43:22 -07:00
Dylan Schiemann
ce1e096df7
update emotion dependency for site () 2022-01-11 08:36:04 -07:00
Adrian
e3a325f8a6
iframe example - use an onLoad callback instead of the ref ()
* 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 ()
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 () 2021-12-22 05:04:14 -07:00
Dan Tello
65708358bb
fix: isBlockActive should use Array.from() ()
* 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() ()
* 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 ()
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 ()
* 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 ()
* 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 ()
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 ()" ()
This reverts commit 9cf2f4eea2878a7acce84273c3a65c09f0d0ea98.
2021-10-17 06:31:33 -07:00
Jake Donham
9cf2f4eea2
in examples, move withReact in front of withHistory () 2021-10-15 16:01:22 -07:00
Jake Donham
ae65ae5f71
revert / ; fix triple-click by unhanging range with void ()
* revert  / ; 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 () 2021-10-07 06:10:50 -07:00
Kristoffer K
29473b0290
chore: follow-up to Yarn update ()
* 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 ()
* 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 ()
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 ()
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 () 2021-08-05 12:08:37 -04:00
Thomas
531707e746
Clean up imports () 2021-08-04 21:56:45 -07:00
Samarjeet
fed9354764
Cypress tests for examples ()
* 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 ()
* 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 () 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 ()
* Revert "Add DefaultEditable and AndroidEditable to exports ()"

This reverts commit 5298e51f6e8a7d62acb71092f7afd6565cbdc65e.

* Revert "Feature/android keyboard support ()"

This reverts commit e03ce7c5614a1a69d039bfbeea94696376585fd0.
2021-05-12 21:24:57 -04:00