Revert page name when page name element blurs
This commit is contained in:
parent
53408feed5
commit
dd34805071
@ -38,14 +38,14 @@ export function TopBar({
|
|||||||
unsavedChanges: boolean;
|
unsavedChanges: boolean;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
notifications: Notification[];
|
notifications: Notification[];
|
||||||
onRename: (newName: string) => void;
|
onRename: (newName?: string) => void;
|
||||||
actionButtons: ActionButton[];
|
actionButtons: ActionButton[];
|
||||||
lhs?: ComponentChildren;
|
lhs?: ComponentChildren;
|
||||||
rhs?: ComponentChildren;
|
rhs?: ComponentChildren;
|
||||||
}) {
|
}) {
|
||||||
const [theme, setTheme] = useState<string>(localStorage.theme ?? "light");
|
// const [theme, setTheme] = useState<string>(localStorage.theme ?? "light");
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const isMac = isMacLike();
|
// const isMac = isMacLike();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="sb-top">
|
<div id="sb-top">
|
||||||
@ -66,6 +66,9 @@ export function TopBar({
|
|||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
value={pageName}
|
value={pageName}
|
||||||
className="sb-edit-page-name"
|
className="sb-edit-page-name"
|
||||||
|
onBlur={(e) => {
|
||||||
|
(e.target as any).value = pageName;
|
||||||
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
@ -73,6 +76,9 @@ export function TopBar({
|
|||||||
const newName = (e.target as any).value;
|
const newName = (e.target as any).value;
|
||||||
onRename(newName);
|
onRename(newName);
|
||||||
}
|
}
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
onRename();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
@ -838,6 +838,9 @@ export class Editor {
|
|||||||
unsavedChanges={viewState.unsavedChanges}
|
unsavedChanges={viewState.unsavedChanges}
|
||||||
isLoading={viewState.isLoading}
|
isLoading={viewState.isLoading}
|
||||||
onRename={(newName) => {
|
onRename={(newName) => {
|
||||||
|
if (!newName) {
|
||||||
|
return editor.focus();
|
||||||
|
}
|
||||||
console.log("Now renaming page to...", newName);
|
console.log("Now renaming page to...", newName);
|
||||||
editor.system.loadedPlugs.get("core")!.invoke(
|
editor.system.loadedPlugs.get("core")!.invoke(
|
||||||
"renamePage",
|
"renamePage",
|
||||||
|
Loading…
Reference in New Issue
Block a user