Skip to content
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

fix pressing Arrow Up #3066

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-experts-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-indent-list": patch
---

fix pressing Arrow Up the cursor abnormal
46 changes: 21 additions & 25 deletions packages/indent-list/src/injectIndentListComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,27 @@ export const injectIndentListComponent = (

return (
<div className={`${className}`} style={style}>
{markerComponent ? (
markerComponent({
checked: checked,
onChange: (v: boolean) => {
const path = findNodePath(editor, element);
setNodes(editor, { checked: v }, { at: path });
},
})
) : (
<input
contentEditable={false}
data-slate-void
type="checkbox"
style={{
marginRight: 5,
marginLeft: -17,
paddingTop: -10,
}}
checked={checked}
onChange={(v) => {
const path = findNodePath(editor, element);
setNodes(editor, { checked: v.target.checked }, { at: path });
}}
/>
)}
<div contentEditable={false} data-slate-void>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding data-slate-void tells Slate that the DIV represents a void element, which is untrue here. The DIV itself is no Slate element, and the enclosing Slate element is not a void. Does removing the data-slate-void change the behaviour at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ianstormtaylor/slate#5435 .
I remember that I will occur the above error in my applacation. Add this to fix it find in the comment.but now I remove it in Plate,There doesn't seem to be a problem

{markerComponent ? (
markerComponent({
checked: checked,
onChange: (v: boolean) => {
const path = findNodePath(editor, element);
setNodes(editor, { checked: v }, { at: path });
},
})
) : (
<input
type="checkbox"
style={{ position: 'absolute', left: -19, top: 6 }}
checked={checked}
onChange={(v) => {
const path = findNodePath(editor, element);
setNodes(editor, { checked: v.target.checked }, { at: path });
}}
/>
)}
</div>
<span>{children}</span>
</div>
);
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6672,12 +6672,12 @@ __metadata:
languageName: unknown
linkType: soft

"@udecode/plate-indent-list@npm:31.0.0, @udecode/plate-indent-list@workspace:^, @udecode/plate-indent-list@workspace:packages/indent-list":
"@udecode/plate-indent-list@npm:31.1.0, @udecode/plate-indent-list@workspace:^, @udecode/plate-indent-list@workspace:packages/indent-list":
version: 0.0.0-use.local
resolution: "@udecode/plate-indent-list@workspace:packages/indent-list"
dependencies:
"@udecode/plate-common": "workspace:^"
"@udecode/plate-indent": "npm:31.0.0"
"@udecode/plate-indent": "npm:31.1.0"
"@udecode/plate-list": "npm:31.0.0"
clsx: "npm:^1.2.1"
peerDependencies:
Expand All @@ -6691,7 +6691,7 @@ __metadata:
languageName: unknown
linkType: soft

"@udecode/plate-indent@npm:31.0.0, @udecode/plate-indent@workspace:^, @udecode/plate-indent@workspace:packages/indent":
"@udecode/plate-indent@npm:31.1.0, @udecode/plate-indent@workspace:^, @udecode/plate-indent@workspace:packages/indent":
version: 0.0.0-use.local
resolution: "@udecode/plate-indent@workspace:packages/indent"
dependencies:
Expand Down Expand Up @@ -6961,14 +6961,14 @@ __metadata:
languageName: unknown
linkType: soft

"@udecode/plate-serializer-docx@npm:31.0.0, @udecode/plate-serializer-docx@workspace:^, @udecode/plate-serializer-docx@workspace:packages/serializer-docx":
"@udecode/plate-serializer-docx@npm:31.1.0, @udecode/plate-serializer-docx@workspace:^, @udecode/plate-serializer-docx@workspace:packages/serializer-docx":
version: 0.0.0-use.local
resolution: "@udecode/plate-serializer-docx@workspace:packages/serializer-docx"
dependencies:
"@udecode/plate-common": "workspace:^"
"@udecode/plate-heading": "npm:31.0.0"
"@udecode/plate-indent": "npm:31.0.0"
"@udecode/plate-indent-list": "npm:31.0.0"
"@udecode/plate-indent": "npm:31.1.0"
"@udecode/plate-indent-list": "npm:31.1.0"
"@udecode/plate-media": "npm:31.0.0"
"@udecode/plate-paragraph": "npm:31.0.0"
"@udecode/plate-table": "npm:31.0.0"
Expand All @@ -6984,7 +6984,7 @@ __metadata:
languageName: unknown
linkType: soft

"@udecode/plate-serializer-html@npm:31.0.0, @udecode/plate-serializer-html@workspace:^, @udecode/plate-serializer-html@workspace:packages/serializer-html":
"@udecode/plate-serializer-html@npm:31.1.0, @udecode/plate-serializer-html@workspace:^, @udecode/plate-serializer-html@workspace:packages/serializer-html":
version: 0.0.0-use.local
resolution: "@udecode/plate-serializer-html@workspace:packages/serializer-html"
dependencies:
Expand Down Expand Up @@ -7090,12 +7090,12 @@ __metadata:
languageName: unknown
linkType: soft

"@udecode/plate-toggle@npm:31.0.0, @udecode/plate-toggle@workspace:^, @udecode/plate-toggle@workspace:packages/toggle":
"@udecode/plate-toggle@npm:31.1.0, @udecode/plate-toggle@workspace:^, @udecode/plate-toggle@workspace:packages/toggle":
version: 0.0.0-use.local
resolution: "@udecode/plate-toggle@workspace:packages/toggle"
dependencies:
"@udecode/plate-common": "workspace:^"
"@udecode/plate-indent": "npm:31.0.0"
"@udecode/plate-indent": "npm:31.1.0"
"@udecode/plate-node-id": "npm:31.0.0"
lodash: "npm:^4.17.21"
peerDependencies:
Expand Down Expand Up @@ -7218,8 +7218,8 @@ __metadata:
"@udecode/plate-heading": "npm:31.0.0"
"@udecode/plate-highlight": "npm:31.0.0"
"@udecode/plate-horizontal-rule": "npm:31.0.0"
"@udecode/plate-indent": "npm:31.0.0"
"@udecode/plate-indent-list": "npm:31.0.0"
"@udecode/plate-indent": "npm:31.1.0"
"@udecode/plate-indent-list": "npm:31.1.0"
"@udecode/plate-kbd": "npm:31.0.0"
"@udecode/plate-line-height": "npm:31.0.0"
"@udecode/plate-link": "npm:31.0.0"
Expand All @@ -7233,13 +7233,13 @@ __metadata:
"@udecode/plate-resizable": "npm:31.0.0"
"@udecode/plate-select": "npm:31.0.0"
"@udecode/plate-serializer-csv": "npm:31.0.0"
"@udecode/plate-serializer-docx": "npm:31.0.0"
"@udecode/plate-serializer-html": "npm:31.0.0"
"@udecode/plate-serializer-docx": "npm:31.1.0"
"@udecode/plate-serializer-html": "npm:31.1.0"
"@udecode/plate-serializer-md": "npm:31.0.0"
"@udecode/plate-suggestion": "npm:31.0.0"
"@udecode/plate-tabbable": "npm:31.0.0"
"@udecode/plate-table": "npm:31.0.0"
"@udecode/plate-toggle": "npm:31.0.0"
"@udecode/plate-toggle": "npm:31.1.0"
"@udecode/plate-trailing-block": "npm:31.0.0"
peerDependencies:
react: ">=16.8.0"
Expand Down