mirror of
https://github.com/zadam/trilium.git
synced 2025-12-29 10:44:25 +01:00
chore(client): format ListOrGridView
This commit is contained in:
parent
28d3e61199
commit
3207f37ac3
@ -1,16 +1,18 @@
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import FNote from "../../../entities/fnote";
|
||||
import Icon from "../../react/Icon";
|
||||
import { ViewModeProps } from "../interface";
|
||||
import { useImperativeSearchHighlighlighting, useNoteLabel } from "../../react/hooks";
|
||||
import NoteLink from "../../react/NoteLink";
|
||||
import "./ListOrGridView.css";
|
||||
import content_renderer from "../../../services/content_renderer";
|
||||
import { Pager, usePagination } from "../Pagination";
|
||||
import tree from "../../../services/tree";
|
||||
import link from "../../../services/link";
|
||||
import { t } from "../../../services/i18n";
|
||||
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
|
||||
import FNote from "../../../entities/fnote";
|
||||
import attribute_renderer from "../../../services/attribute_renderer";
|
||||
import content_renderer from "../../../services/content_renderer";
|
||||
import { t } from "../../../services/i18n";
|
||||
import link from "../../../services/link";
|
||||
import tree from "../../../services/tree";
|
||||
import { useImperativeSearchHighlighlighting, useNoteLabel } from "../../react/hooks";
|
||||
import Icon from "../../react/Icon";
|
||||
import NoteLink from "../../react/NoteLink";
|
||||
import { ViewModeProps } from "../interface";
|
||||
import { Pager, usePagination } from "../Pagination";
|
||||
import { filterChildNotes, useFilteredNoteIds } from "./utils";
|
||||
|
||||
export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
|
||||
@ -91,7 +93,7 @@ function ListNoteCard({ note, parentNote, highlightedTokens, currentLevel, expan
|
||||
<NoteChildren note={note} parentNote={parentNote} highlightedTokens={highlightedTokens} currentLevel={currentLevel} expandDepth={expandDepth} />
|
||||
</>}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, parentNote: FNote, highlightedTokens: string[] | null | undefined }) {
|
||||
@ -124,7 +126,7 @@ function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, pa
|
||||
highlightedTokens={highlightedTokens}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function NoteAttributes({ note }: { note: FNote }) {
|
||||
@ -135,7 +137,7 @@ function NoteAttributes({ note }: { note: FNote }) {
|
||||
});
|
||||
}, [ note ]);
|
||||
|
||||
return <span className="note-list-attributes" ref={ref} />
|
||||
return <span className="note-list-attributes" ref={ref} />;
|
||||
}
|
||||
|
||||
function NoteContent({ note, trim, noChildrenList, highlightedTokens }: { note: FNote, trim?: boolean, noChildrenList?: boolean, highlightedTokens: string[] | null | undefined }) {
|
||||
@ -161,7 +163,7 @@ function NoteContent({ note, trim, noChildrenList, highlightedTokens }: { note:
|
||||
console.warn(`Caught error while rendering note '${note.noteId}' of type '${note.type}'`);
|
||||
console.error(e);
|
||||
contentRef.current?.replaceChildren(t("collections.rendering_error"));
|
||||
})
|
||||
});
|
||||
}, [ note, highlightedTokens ]);
|
||||
|
||||
return <div ref={contentRef} className="note-book-content" />;
|
||||
@ -185,16 +187,16 @@ function NoteChildren({ note, parentNote, highlightedTokens, currentLevel, expan
|
||||
parentNote={parentNote}
|
||||
highlightedTokens={highlightedTokens}
|
||||
currentLevel={currentLevel + 1} expandDepth={expandDepth}
|
||||
/>)
|
||||
/>);
|
||||
}
|
||||
|
||||
function getNotePath(parentNote: FNote, childNote: FNote) {
|
||||
if (parentNote.type === "search") {
|
||||
// for search note parent, we want to display a non-search path
|
||||
return childNote.noteId;
|
||||
} else {
|
||||
return `${parentNote.noteId}/${childNote.noteId}`
|
||||
}
|
||||
}
|
||||
return `${parentNote.noteId}/${childNote.noteId}`;
|
||||
|
||||
}
|
||||
|
||||
function useExpansionDepth(note: FNote) {
|
||||
@ -206,7 +208,7 @@ function useExpansionDepth(note: FNote) {
|
||||
return 1;
|
||||
} else if (expandDepth === "all") {
|
||||
return Number.MAX_SAFE_INTEGER;
|
||||
} else {
|
||||
return parseInt(expandDepth, 10);
|
||||
}
|
||||
}
|
||||
return parseInt(expandDepth, 10);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user