mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
feat(react/floating_buttons): port highlights list
This commit is contained in:
@@ -53,9 +53,14 @@ const FLOATING_BUTTON_DEFINITIONS: FloatingButtonDefinition[] = [
|
||||
{
|
||||
component: ShowTocWidgetButton,
|
||||
isEnabled: ({ note, noteContext }) =>
|
||||
note.type === "text"
|
||||
&& noteContext?.viewScope?.viewMode === "default"
|
||||
note.type === "text" && noteContext?.viewScope?.viewMode === "default"
|
||||
&& !!noteContext.viewScope?.tocTemporarilyHidden
|
||||
},
|
||||
{
|
||||
component: ShowHighlightsListWidgetButton,
|
||||
isEnabled: ({ note, noteContext }) =>
|
||||
note.type === "text" && noteContext?.viewScope?.viewMode === "default"
|
||||
&& !!noteContext.viewScope?.highlightsListTemporarilyHidden
|
||||
}
|
||||
];
|
||||
|
||||
@@ -101,7 +106,7 @@ export default function FloatingButtons() {
|
||||
setRefreshCounter(refreshCounter + 1);
|
||||
}
|
||||
});
|
||||
useTriliumEvent("reEvaluateTocWidgetVisibility", ({ noteId }) => {
|
||||
useTriliumEvents(["reEvaluateTocWidgetVisibility", "reEvaluateHighlightsListWidgetVisibility"], ({ noteId }) => {
|
||||
if (noteId === note?.noteId) {
|
||||
setRefreshCounter(refreshCounter + 1);
|
||||
}
|
||||
@@ -195,6 +200,19 @@ function ShowTocWidgetButton({ noteContext }: FloatingButtonContext) {
|
||||
/>
|
||||
}
|
||||
|
||||
function ShowHighlightsListWidgetButton({ noteContext }: FloatingButtonContext) {
|
||||
return <ActionButton
|
||||
text={t("show_highlights_list_widget_button.show_highlights_list")}
|
||||
icon="bx bx-bookmarks"
|
||||
onClick={() => {
|
||||
if (noteContext?.viewScope && noteContext.noteId) {
|
||||
noteContext.viewScope.highlightsListTemporarilyHidden = false;
|
||||
appContext.triggerEvent("showHighlightsListWidget", { noteId: noteContext.noteId });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
}
|
||||
|
||||
/**
|
||||
* Show button that displays floating button after click on close button
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user