mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 15:25:51 +01:00
chore(react/type_widget): bring back read-only temporary disable
This commit is contained in:
@@ -65,12 +65,18 @@ function useNoteInfo() {
|
|||||||
const [ note, setNote ] = useState<FNote | null | undefined>();
|
const [ note, setNote ] = useState<FNote | null | undefined>();
|
||||||
const [ type, setType ] = useState<ExtendedNoteType>();
|
const [ type, setType ] = useState<ExtendedNoteType>();
|
||||||
|
|
||||||
useEffect(() => {
|
function refresh() {
|
||||||
getWidgetType(actualNote, noteContext).then(type => {
|
getWidgetType(actualNote, noteContext).then(type => {
|
||||||
setNote(actualNote);
|
setNote(actualNote);
|
||||||
setType(type);
|
setType(type);
|
||||||
});
|
});
|
||||||
}, [ actualNote, noteContext ]);
|
}
|
||||||
|
|
||||||
|
useEffect(refresh, [ actualNote, noteContext]);
|
||||||
|
useTriliumEvent("readOnlyTemporarilyDisabled", ({ noteContext: eventNoteContext }) => {
|
||||||
|
if (eventNoteContext?.ntxId !== noteContext?.ntxId) return;
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
|
|
||||||
return { note, type, noteContext, parentComponent };
|
return { note, type, noteContext, parentComponent };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ function CodeEditor({ note, parentComponent, ntxId, containerRef: externalContai
|
|||||||
});
|
});
|
||||||
|
|
||||||
useTriliumEvent("focusOnDetail", ({ ntxId: eventNtxId }) => {
|
useTriliumEvent("focusOnDetail", ({ ntxId: eventNtxId }) => {
|
||||||
console.log("Focus on ", ntxId, eventNtxId)
|
|
||||||
if (eventNtxId !== ntxId) return;
|
if (eventNtxId !== ntxId) return;
|
||||||
codeEditorRef.current?.focus();
|
codeEditorRef.current?.focus();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,14 +61,6 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {
|
|||||||
// Do nothing by default.
|
// Do nothing by default.
|
||||||
}
|
}
|
||||||
|
|
||||||
async readOnlyTemporarilyDisabledEvent({ noteContext }: EventData<"readOnlyTemporarilyDisabled">) {
|
|
||||||
if (this.isNoteContext(noteContext.ntxId)) {
|
|
||||||
await this.refresh();
|
|
||||||
|
|
||||||
this.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user