fix: preserve cursor position on code editor saves (#683)
This commit is contained in:
parent
7a25f953c7
commit
c5a57fd7a8
3 changed files with 5 additions and 3 deletions
|
|
@ -428,9 +428,7 @@ function PureBlock({
|
||||||
<BlockCloseButton />
|
<BlockCloseButton />
|
||||||
|
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<div className="font-medium">
|
<div className="font-medium">{block.title}</div>
|
||||||
{document?.title ?? block.title}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{isContentDirty ? (
|
{isContentDirty ? (
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="text-sm text-muted-foreground">
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,12 @@ function PureCodeEditor({ content, saveContent, status }: EditorProps) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const currentSelection = editorRef.current.state.selection;
|
||||||
|
|
||||||
const newState = EditorState.create({
|
const newState = EditorState.create({
|
||||||
doc: editorRef.current.state.doc,
|
doc: editorRef.current.state.doc,
|
||||||
extensions: [basicSetup, python(), oneDark, updateListener],
|
extensions: [basicSetup, python(), oneDark, updateListener],
|
||||||
|
selection: currentSelection,
|
||||||
});
|
});
|
||||||
|
|
||||||
editorRef.current.setState(newState);
|
editorRef.current.setState(newState);
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ const PureHitboxLayer = ({
|
||||||
? { ...block, isVisible: true }
|
? { ...block, isVisible: true }
|
||||||
: {
|
: {
|
||||||
...block,
|
...block,
|
||||||
|
title: result.title,
|
||||||
documentId: result.id,
|
documentId: result.id,
|
||||||
kind: result.kind,
|
kind: result.kind,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue