-
-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Core Plugin QueryCacheToSate #3221
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
|
||
const { apply } = editor; | ||
|
||
editor.apply = (operation) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think editor.onChange
is a better fit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments pertaining to this on Discord. https://discord.com/channels/1026227597115396188/1237021058067075072
}; | ||
}; | ||
|
||
export const withQueryCachToState = < |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name the plugin cache
instead of queryCacheToState
|
||
export type QueryCachToSateEditor<V extends Value> = { | ||
state: { | ||
aboveEntries?: Generator<TNodeEntry<ENode<V>>, void, undefined>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's reuse the same naming convention than Slate queries. For example Transforms.above
-> above
. For Plate exclusive, just try to follow the same pattern
import { createPluginFactory } from '../utils/createPluginFactory'; | ||
|
||
export type QueryCachToSateEditor<V extends Value> = { | ||
state: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache
may be better. What do you think @12joan ?
@@ -19,5 +19,9 @@ export function PlateEffects< | |||
>({ children, ...props }: PlateEffectsProps<V, E>) { | |||
usePlateEffects<V, E>(props); | |||
|
|||
return <>{children}</>; | |||
return ( | |||
<div data-id={props.id} id="plate-editor"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toc Plugin need the container dom node to scroll to heading.I haven't thought of a good method to obtain container nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get Slate's root contenteditable by passing the editor
to toDOMNode
.
export const KEY_QUERY_CACHE_TO_STATE = 'queryCacheToSate'; | ||
|
||
export const createQueryCachToStatePlugin = createPluginFactory({ | ||
key: KEY_QUERY_CACHE_TO_STATE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a boolean option for each query: don't run if false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments pertaining to this on Discord. https://discord.com/channels/1026227597115396188/1237021058067075072
Description
QueryCacheToSate:
editor.apply
is appropriate.PlateEffects:
I will fix the test cases and add a changeset just before merging.