mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 14:24:27 +01:00
chore(right_pane_widget): respect highlight settings
This commit is contained in:
parent
7a5d24f968
commit
e94704ce64
@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from "preact/hooks";
|
|||||||
|
|
||||||
import { t } from "../../services/i18n";
|
import { t } from "../../services/i18n";
|
||||||
import ActionButton from "../react/ActionButton";
|
import ActionButton from "../react/ActionButton";
|
||||||
import { useActiveNoteContext, useContentElement, useIsNoteReadOnly, useNoteProperty, useTextEditor } from "../react/hooks";
|
import { useActiveNoteContext, useContentElement, useIsNoteReadOnly, useNoteProperty, useTextEditor, useTriliumOptionJson } from "../react/hooks";
|
||||||
import Modal from "../react/Modal";
|
import Modal from "../react/Modal";
|
||||||
import { HighlightsListOptions } from "../type_widgets/options/text_notes";
|
import { HighlightsListOptions } from "../type_widgets/options/text_notes";
|
||||||
import RightPanelWidget from "./RightPanelWidget";
|
import RightPanelWidget from "./RightPanelWidget";
|
||||||
@ -69,10 +69,24 @@ function AbstractHighlightsList<T extends RawHighlight>({ highlights, scrollToHi
|
|||||||
highlights: T[],
|
highlights: T[],
|
||||||
scrollToHighlight(highlight: T): void;
|
scrollToHighlight(highlight: T): void;
|
||||||
}) {
|
}) {
|
||||||
|
const [ highlightsList ] = useTriliumOptionJson<["bold" | "italic" | "underline" | "color" | "bgColor"]>("highlightsList");
|
||||||
|
const highlightsListSet = new Set(highlightsList || []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="highlights-list">
|
<span className="highlights-list">
|
||||||
<ol>
|
<ol>
|
||||||
{highlights.map(highlight => (
|
{highlights
|
||||||
|
.filter(highlight => {
|
||||||
|
const { attrs } = highlight;
|
||||||
|
return (
|
||||||
|
(highlightsListSet.has("bold") && attrs.bold) ||
|
||||||
|
(highlightsListSet.has("italic") && attrs.italic) ||
|
||||||
|
(highlightsListSet.has("underline") && attrs.underline) ||
|
||||||
|
(highlightsListSet.has("color") && !!attrs.color) ||
|
||||||
|
(highlightsListSet.has("bgColor") && !!attrs.background)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map(highlight => (
|
||||||
<li
|
<li
|
||||||
key={highlight.id}
|
key={highlight.id}
|
||||||
onClick={() => scrollToHighlight(highlight)}
|
onClick={() => scrollToHighlight(highlight)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user