mirror of
https://github.com/zadam/trilium.git
synced 2026-01-06 14:44:25 +01:00
chore(right_pane): address requested changes
This commit is contained in:
parent
f1ca8881a1
commit
1e885625f6
@ -22,7 +22,8 @@ import shortcuts, { Handler, removeIndividualBinding } from "../../services/shor
|
||||
import SpacedUpdate from "../../services/spaced_update";
|
||||
import toast, { ToastOptions } from "../../services/toast";
|
||||
import tree from "../../services/tree";
|
||||
import utils, { escapeRegExp, randomString, reloadFrontendApp } from "../../services/utils";
|
||||
import utils, { escapeRegExp, getErrorMessage, randomString, reloadFrontendApp } from "../../services/utils";
|
||||
import ws from "../../services/ws";
|
||||
import BasicWidget, { ReactWrappedWidget } from "../basic_widget";
|
||||
import NoteContextAwareWidget from "../note_context_aware_widget";
|
||||
import { DragData } from "../note_tree";
|
||||
@ -168,14 +169,20 @@ export function useTriliumOption(name: OptionNames, needsRefresh?: boolean): [st
|
||||
|
||||
const wrappedSetValue = useMemo(() => {
|
||||
return async (newValue: OptionValue) => {
|
||||
const originalValue = value;
|
||||
setValue(String(newValue));
|
||||
await options.save(name, newValue);
|
||||
try {
|
||||
await options.save(name, newValue);
|
||||
} catch (e: unknown) {
|
||||
ws.logError(getErrorMessage(e));
|
||||
setValue(originalValue);
|
||||
}
|
||||
|
||||
if (needsRefresh) {
|
||||
reloadFrontendApp(`option change: ${name}`);
|
||||
}
|
||||
};
|
||||
}, [ name, needsRefresh ]);
|
||||
}, [ name, needsRefresh, value ]);
|
||||
|
||||
useTriliumEvent("entitiesReloaded", useCallback(({ loadResults }) => {
|
||||
if (loadResults.getOptionNames().includes(name)) {
|
||||
|
||||
@ -222,7 +222,7 @@ interface DomHighlight extends RawHighlight {
|
||||
function ReadOnlyTextHighlightsList() {
|
||||
const { noteContext } = useActiveNoteContext();
|
||||
const contentEl = useContentElement(noteContext);
|
||||
const highlights = extractHeadingsFromStaticHtml(contentEl);
|
||||
const highlights = extractHighlightsFromStaticHtml(contentEl);
|
||||
|
||||
const scrollToHighlight = useCallback((highlight: DomHighlight) => {
|
||||
highlight.element.scrollIntoView();
|
||||
@ -234,7 +234,7 @@ function ReadOnlyTextHighlightsList() {
|
||||
/>;
|
||||
}
|
||||
|
||||
function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
|
||||
function extractHighlightsFromStaticHtml(el: HTMLElement | null) {
|
||||
if (!el) return [];
|
||||
|
||||
const { color: defaultColor, backgroundColor: defaultBackgroundColor } = getComputedStyle(el);
|
||||
|
||||
@ -5,7 +5,6 @@ import { useContext, useState } from "preact/hooks";
|
||||
import contextMenu, { MenuItem } from "../../menus/context_menu";
|
||||
import ActionButton from "../react/ActionButton";
|
||||
import { useSyncedRef, useTriliumOptionJson } from "../react/hooks";
|
||||
import Icon from "../react/Icon";
|
||||
import { ParentComponent } from "../react/react_utils";
|
||||
|
||||
interface RightPanelWidgetProps {
|
||||
@ -47,9 +46,7 @@ export default function RightPanelWidget({ id, title, buttons, children, contain
|
||||
} else {
|
||||
rightPaneCollapsedItemsSet.add(id);
|
||||
}
|
||||
if (rightPaneCollapsedItemsSet.size !== rightPaneCollapsedItems.length) {
|
||||
setRightPaneCollapsedItems(Array.from(rightPaneCollapsedItemsSet));
|
||||
}
|
||||
setRightPaneCollapsedItems(Array.from(rightPaneCollapsedItemsSet));
|
||||
}}
|
||||
>
|
||||
<ActionButton icon="bx bx-chevron-down" text="" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user