mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 22:34:23 +01:00
feat(floating_buttons): handle case when empty
This commit is contained in:
parent
c44bb6c203
commit
9b21e042ec
@ -2196,5 +2196,9 @@
|
|||||||
"note_paths_other": "{{count}} paths",
|
"note_paths_other": "{{count}} paths",
|
||||||
"note_paths_title": "Note paths",
|
"note_paths_title": "Note paths",
|
||||||
"code_note_switcher": "Change language mode"
|
"code_note_switcher": "Change language mode"
|
||||||
|
},
|
||||||
|
"right_pane": {
|
||||||
|
"empty_message": "Nothing to show for this note",
|
||||||
|
"empty_button": "Hide the panel"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { headingIsHorizontal } from "@excalidraw/excalidraw/element/heading";
|
|
||||||
import { CKTextEditor, ModelText } from "@triliumnext/ckeditor5";
|
import { CKTextEditor, ModelText } from "@triliumnext/ckeditor5";
|
||||||
import { useCallback, useEffect, useState } from "preact/hooks";
|
import { useCallback, useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
@ -23,9 +22,9 @@ export default function HighlightsList() {
|
|||||||
const noteType = useNoteProperty(note, "type");
|
const noteType = useNoteProperty(note, "type");
|
||||||
const { isReadOnly } = useIsNoteReadOnly(note, noteContext);
|
const { isReadOnly } = useIsNoteReadOnly(note, noteContext);
|
||||||
|
|
||||||
return (
|
return (noteType === "text") && (
|
||||||
<RightPanelWidget id="highlights" title={t("highlights_list_2.title")}>
|
<RightPanelWidget id="highlights" title={t("highlights_list_2.title")}>
|
||||||
{((noteType === "text" && isReadOnly) || (noteType === "doc")) && <ReadOnlyTextHighlightsList />}
|
{noteType === "text" && isReadOnly && <ReadOnlyTextHighlightsList />}
|
||||||
{noteType === "text" && !isReadOnly && <EditableTextHighlightsList />}
|
{noteType === "text" && !isReadOnly && <EditableTextHighlightsList />}
|
||||||
</RightPanelWidget>
|
</RightPanelWidget>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -33,4 +33,21 @@ body.experimental-feature-new-layout #right-pane {
|
|||||||
.gutter-vertical + .card .card-header {
|
.gutter-vertical + .card .card-header {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-items {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
color: var(--muted-text-color);
|
||||||
|
|
||||||
|
.bx {
|
||||||
|
font-size: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,18 +2,49 @@
|
|||||||
import "./RightPanelContainer.css";
|
import "./RightPanelContainer.css";
|
||||||
|
|
||||||
import Split from "@triliumnext/split.js";
|
import Split from "@triliumnext/split.js";
|
||||||
import { createContext } from "preact";
|
import { useEffect } from "preact/hooks";
|
||||||
import { useEffect, useRef } from "preact/hooks";
|
|
||||||
|
|
||||||
|
import { t } from "../../services/i18n";
|
||||||
import options from "../../services/options";
|
import options from "../../services/options";
|
||||||
import { DEFAULT_GUTTER_SIZE } from "../../services/resizer";
|
import { DEFAULT_GUTTER_SIZE } from "../../services/resizer";
|
||||||
import { clamp } from "../../services/utils";
|
import Button from "../react/Button";
|
||||||
|
import { useActiveNoteContext, useNoteProperty, useTriliumOptionBool } from "../react/hooks";
|
||||||
|
import Icon from "../react/Icon";
|
||||||
import HighlightsList from "./HighlightsList";
|
import HighlightsList from "./HighlightsList";
|
||||||
import TableOfContents from "./TableOfContents";
|
import TableOfContents from "./TableOfContents";
|
||||||
|
|
||||||
const MIN_WIDTH_PERCENT = 5;
|
const MIN_WIDTH_PERCENT = 5;
|
||||||
|
|
||||||
export default function RightPanelContainer() {
|
export default function RightPanelContainer() {
|
||||||
|
useSplit();
|
||||||
|
|
||||||
|
const [ rightPaneVisible, setRightPaneVisible ] = useTriliumOptionBool("rightPaneVisible");
|
||||||
|
const { note } = useActiveNoteContext();
|
||||||
|
const noteType = useNoteProperty(note, "type");
|
||||||
|
const items = [
|
||||||
|
noteType === "text" || noteType === "doc" && <TableOfContents />,
|
||||||
|
noteType === "text" && <HighlightsList />
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div id="right-pane">
|
||||||
|
{items.length > 0 ? (
|
||||||
|
items
|
||||||
|
) : (
|
||||||
|
<div className="no-items">
|
||||||
|
<Icon icon="bx bx-sidebar" />
|
||||||
|
{t("right_pane.empty_message")}
|
||||||
|
<Button
|
||||||
|
text={t("right_pane.empty_button")}
|
||||||
|
onClick={() => setRightPaneVisible(!rightPaneVisible)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function useSplit() {
|
||||||
// Split between right pane and the content pane.
|
// Split between right pane and the content pane.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// We are intentionally omitting useTriliumOption to avoid re-render due to size change.
|
// We are intentionally omitting useTriliumOption to avoid re-render due to size change.
|
||||||
@ -27,11 +58,4 @@ export default function RightPanelContainer() {
|
|||||||
});
|
});
|
||||||
return () => splitInstance.destroy();
|
return () => splitInstance.destroy();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
|
||||||
<div id="right-pane">
|
|
||||||
<TableOfContents />
|
|
||||||
<HighlightsList />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export default function TableOfContents() {
|
|||||||
const noteType = useNoteProperty(note, "type");
|
const noteType = useNoteProperty(note, "type");
|
||||||
const { isReadOnly } = useIsNoteReadOnly(note, noteContext);
|
const { isReadOnly } = useIsNoteReadOnly(note, noteContext);
|
||||||
|
|
||||||
return (
|
return (noteType === "text" || noteType === "doc") && (
|
||||||
<RightPanelWidget id="toc" title={t("toc.table_of_contents")}>
|
<RightPanelWidget id="toc" title={t("toc.table_of_contents")}>
|
||||||
{((noteType === "text" && isReadOnly) || (noteType === "doc")) && <ReadOnlyTextTableOfContents />}
|
{((noteType === "text" && isReadOnly) || (noteType === "doc")) && <ReadOnlyTextTableOfContents />}
|
||||||
{noteType === "text" && !isReadOnly && <EditableTextTableOfContents />}
|
{noteType === "text" && !isReadOnly && <EditableTextTableOfContents />}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user