mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +01:00
Compare commits
17 Commits
aa1780c027
...
fdcc90880c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdcc90880c | ||
|
|
8b3afc1f49 | ||
|
|
d5cbf362f8 | ||
|
|
286a8626d1 | ||
|
|
aa62dc3f32 | ||
|
|
045e7977d5 | ||
|
|
e0dc25ad23 | ||
|
|
9d0499a306 | ||
|
|
b971e002ce | ||
|
|
5fd488e210 | ||
|
|
eb84da4c51 | ||
|
|
49243148a2 | ||
|
|
276241cdff | ||
|
|
6772453b3a | ||
|
|
18e2f1f90c | ||
|
|
a1c0314334 | ||
|
|
3ecdcd9ea0 |
@ -240,7 +240,7 @@ export default class FNote {
|
|||||||
|
|
||||||
const aNote = this.froca.getNoteFromCache(aNoteId);
|
const aNote = this.froca.getNoteFromCache(aNoteId);
|
||||||
|
|
||||||
if (aNote.isArchived || aNote.isHiddenCompletely()) {
|
if (!aNote || aNote.isArchived || aNote.isHiddenCompletely()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,13 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
|||||||
uiIcon: "bx bx-rename",
|
uiIcon: "bx bx-rename",
|
||||||
enabled: isNotRoot && parentNotSearch && notOptionsOrHelp
|
enabled: isNotRoot && parentNotSearch && notOptionsOrHelp
|
||||||
},
|
},
|
||||||
{ title: t("tree-context-menu.convert-to-attachment"), command: "convertNoteToAttachment", uiIcon: "bx bx-paperclip", enabled: isNotRoot && !isHoisted && notOptionsOrHelp },
|
{
|
||||||
|
title:
|
||||||
|
t("tree-context-menu.convert-to-attachment"),
|
||||||
|
command: "convertNoteToAttachment",
|
||||||
|
uiIcon: "bx bx-paperclip",
|
||||||
|
enabled: isNotRoot && !isHoisted && notOptionsOrHelp && selectedNotes.some(note => note.isEligibleForConversionToAttachment())
|
||||||
|
},
|
||||||
|
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
|
|
||||||
|
|||||||
@ -56,9 +56,14 @@ async function renderIncludedNotes(contentEl: HTMLElement) {
|
|||||||
// Render and integrate the notes.
|
// Render and integrate the notes.
|
||||||
for (const includeNoteEl of includeNoteEls) {
|
for (const includeNoteEl of includeNoteEls) {
|
||||||
const noteId = includeNoteEl.getAttribute("data-note-id");
|
const noteId = includeNoteEl.getAttribute("data-note-id");
|
||||||
if (!noteId) return;
|
if (!noteId) continue;
|
||||||
|
|
||||||
const note = froca.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
if (!note) {
|
||||||
|
console.warn(`Unable to include ${noteId} because it could not be found.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const renderedContent = (await content_renderer.getRenderedContent(note)).$renderedContent;
|
const renderedContent = (await content_renderer.getRenderedContent(note)).$renderedContent;
|
||||||
includeNoteEl.replaceChildren(...renderedContent);
|
includeNoteEl.replaceChildren(...renderedContent);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export interface Froca {
|
|||||||
|
|
||||||
getBlob(entityType: string, entityId: string): Promise<FBlob | null>;
|
getBlob(entityType: string, entityId: string): Promise<FBlob | null>;
|
||||||
getNote(noteId: string, silentNotFoundError?: boolean): Promise<FNote | null>;
|
getNote(noteId: string, silentNotFoundError?: boolean): Promise<FNote | null>;
|
||||||
getNoteFromCache(noteId: string): FNote;
|
getNoteFromCache(noteId: string): FNote | undefined;
|
||||||
getNotesFromCache(noteIds: string[], silentNotFoundError?: boolean): FNote[];
|
getNotesFromCache(noteIds: string[], silentNotFoundError?: boolean): FNote[];
|
||||||
getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise<FNote[]>;
|
getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise<FNote[]>;
|
||||||
|
|
||||||
|
|||||||
@ -288,7 +288,7 @@ class FrocaImpl implements Froca {
|
|||||||
return (await this.getNotes([noteId], silentNotFoundError))[0];
|
return (await this.getNotes([noteId], silentNotFoundError))[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
getNoteFromCache(noteId: string) {
|
getNoteFromCache(noteId: string): FNote | undefined {
|
||||||
if (!noteId) {
|
if (!noteId) {
|
||||||
throw new Error("Empty noteId");
|
throw new Error("Empty noteId");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1633,7 +1633,7 @@
|
|||||||
"import-into-note": "Import into note",
|
"import-into-note": "Import into note",
|
||||||
"apply-bulk-actions": "Apply bulk actions",
|
"apply-bulk-actions": "Apply bulk actions",
|
||||||
"converted-to-attachments": "{{count}} notes have been converted to attachments.",
|
"converted-to-attachments": "{{count}} notes have been converted to attachments.",
|
||||||
"convert-to-attachment-confirm": "Are you sure you want to convert note selected notes into attachments of their parent notes?",
|
"convert-to-attachment-confirm": "Are you sure you want to convert the selected notes into attachments of their parent notes? This operation only applies to Image notes, other notes will be skipped.",
|
||||||
"open-in-popup": "Quick edit"
|
"open-in-popup": "Quick edit"
|
||||||
},
|
},
|
||||||
"shared_info": {
|
"shared_info": {
|
||||||
|
|||||||
@ -680,7 +680,8 @@
|
|||||||
"tabShortcuts": "Scurtături pentru tab-uri",
|
"tabShortcuts": "Scurtături pentru tab-uri",
|
||||||
"troubleshooting": "Unelte pentru depanare",
|
"troubleshooting": "Unelte pentru depanare",
|
||||||
"newTabWithActivationNoteLink": "pe o legătură către o notiță deschide și activează notița într-un tab nou",
|
"newTabWithActivationNoteLink": "pe o legătură către o notiță deschide și activează notița într-un tab nou",
|
||||||
"title": "Ghid rapid"
|
"title": "Ghid rapid",
|
||||||
|
"editShortcuts": "Editează scurtăturile de la tastatură"
|
||||||
},
|
},
|
||||||
"hide_floating_buttons_button": {
|
"hide_floating_buttons_button": {
|
||||||
"button_title": "Ascunde butoanele"
|
"button_title": "Ascunde butoanele"
|
||||||
@ -1511,7 +1512,8 @@
|
|||||||
"hoist-this-note-workspace": "Focalizează spațiul de lucru",
|
"hoist-this-note-workspace": "Focalizează spațiul de lucru",
|
||||||
"refresh-saved-search-results": "Reîmprospătează căutarea salvată",
|
"refresh-saved-search-results": "Reîmprospătează căutarea salvată",
|
||||||
"unhoist": "Defocalizează notița",
|
"unhoist": "Defocalizează notița",
|
||||||
"toggle-sidebar": "Comută bara laterală"
|
"toggle-sidebar": "Comută bara laterală",
|
||||||
|
"dropping-not-allowed": "Aici nu este permisă plasarea notițelor."
|
||||||
},
|
},
|
||||||
"title_bar_buttons": {
|
"title_bar_buttons": {
|
||||||
"window-on-top": "Menține fereastra mereu vizibilă"
|
"window-on-top": "Menține fereastra mereu vizibilă"
|
||||||
@ -1625,7 +1627,8 @@
|
|||||||
"reset": "Resetează"
|
"reset": "Resetează"
|
||||||
},
|
},
|
||||||
"editable-text": {
|
"editable-text": {
|
||||||
"auto-detect-language": "Automat"
|
"auto-detect-language": "Automat",
|
||||||
|
"keeps-crashing": "Componenta de editare se blochează în continuu. Încercați să reporniți Trilium. Dacă problema persistă, luați în considerare să raportați această problemă."
|
||||||
},
|
},
|
||||||
"highlighting": {
|
"highlighting": {
|
||||||
"color-scheme": "Temă de culori",
|
"color-scheme": "Temă de culori",
|
||||||
@ -1677,7 +1680,8 @@
|
|||||||
"open_note_in_new_split": "Deschide notița într-un panou nou",
|
"open_note_in_new_split": "Deschide notița într-un panou nou",
|
||||||
"open_note_in_new_tab": "Deschide notița într-un tab nou",
|
"open_note_in_new_tab": "Deschide notița într-un tab nou",
|
||||||
"open_note_in_new_window": "Deschide notița într-o fereastră nouă",
|
"open_note_in_new_window": "Deschide notița într-o fereastră nouă",
|
||||||
"open_note_in_popup": "Editare rapidă"
|
"open_note_in_popup": "Editare rapidă",
|
||||||
|
"open_note_in_other_split": "Deschide notița în celălalt panou"
|
||||||
},
|
},
|
||||||
"note_autocomplete": {
|
"note_autocomplete": {
|
||||||
"clear-text-field": "Șterge conținutul casetei",
|
"clear-text-field": "Șterge conținutul casetei",
|
||||||
@ -2101,5 +2105,8 @@
|
|||||||
"clear-color": "Înlăturați culoarea notiței",
|
"clear-color": "Înlăturați culoarea notiței",
|
||||||
"set-color": "Setați culoarea notiței",
|
"set-color": "Setați culoarea notiței",
|
||||||
"set-custom-color": "Setați culoare personalizată pentru notiță"
|
"set-custom-color": "Setați culoare personalizată pentru notiță"
|
||||||
|
},
|
||||||
|
"popup-editor": {
|
||||||
|
"maximize": "Comută la editorul principal"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { allViewTypes, ViewModeMedia, ViewModeProps, ViewTypeOptions } from "./interface";
|
import { allViewTypes, ViewModeMedia, ViewModeProps, ViewTypeOptions } from "./interface";
|
||||||
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } from "../react/hooks";
|
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useTriliumEvent } from "../react/hooks";
|
||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
import "./NoteList.css";
|
import "./NoteList.css";
|
||||||
import { useEffect, useRef, useState } from "preact/hooks";
|
import { useEffect, useRef, useState } from "preact/hooks";
|
||||||
@ -53,10 +53,11 @@ const ViewComponents: Record<ViewTypeOptions, { normal: LazyLoadedComponent, pri
|
|||||||
export default function NoteList(props: Pick<NoteListProps, "displayOnlyCollections" | "media" | "onReady" | "onProgressChanged">) {
|
export default function NoteList(props: Pick<NoteListProps, "displayOnlyCollections" | "media" | "onReady" | "onProgressChanged">) {
|
||||||
const { note, noteContext, notePath, ntxId, viewScope } = useNoteContext();
|
const { note, noteContext, notePath, ntxId, viewScope } = useNoteContext();
|
||||||
const viewType = useNoteViewType(note);
|
const viewType = useNoteViewType(note);
|
||||||
|
const noteType = useNoteProperty(note, "type");
|
||||||
const [ enabled, setEnabled ] = useState(noteContext?.hasNoteList());
|
const [ enabled, setEnabled ] = useState(noteContext?.hasNoteList());
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEnabled(noteContext?.hasNoteList());
|
setEnabled(noteContext?.hasNoteList());
|
||||||
}, [ note, noteContext, viewType, viewScope?.viewMode ])
|
}, [ note, noteContext, viewType, viewScope?.viewMode, noteType ])
|
||||||
return <CustomNoteList viewType={viewType} note={note} isEnabled={!!enabled} notePath={notePath} ntxId={ntxId} {...props} />
|
return <CustomNoteList viewType={viewType} note={note} isEnabled={!!enabled} notePath={notePath} ntxId={ntxId} {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ describe("Board data", () => {
|
|||||||
parentNoteId: "note1"
|
parentNoteId: "note1"
|
||||||
});
|
});
|
||||||
froca.branches["note1_note2"] = branch;
|
froca.branches["note1_note2"] = branch;
|
||||||
froca.getNoteFromCache("note1").addChild("note2", "note1_note2", false);
|
froca.getNoteFromCache("note1")!.addChild("note2", "note1_note2", false);
|
||||||
const data = await getBoardData(parentNote, "status", {}, false);
|
const data = await getBoardData(parentNote, "status", {}, false);
|
||||||
const noteIds = Array.from(data.byColumn.values()).flat().map(item => item.note.noteId);
|
const noteIds = Array.from(data.byColumn.values()).flat().map(item => item.note.noteId);
|
||||||
expect(noteIds.length).toBe(3);
|
expect(noteIds.length).toBe(3);
|
||||||
|
|||||||
@ -30,7 +30,12 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!containerRef.current) return;
|
if (!containerRef.current) return;
|
||||||
const mapInstance = L.map(containerRef.current, {
|
const mapInstance = L.map(containerRef.current, {
|
||||||
worldCopyJump: true
|
worldCopyJump: false,
|
||||||
|
maxBounds: [
|
||||||
|
[-90, -180],
|
||||||
|
[90, 180]
|
||||||
|
],
|
||||||
|
minZoom: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
mapRef.current = mapInstance;
|
mapRef.current = mapInstance;
|
||||||
@ -56,7 +61,8 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi
|
|||||||
} else {
|
} else {
|
||||||
setLayer(L.tileLayer(layerData.url, {
|
setLayer(L.tileLayer(layerData.url, {
|
||||||
attribution: layerData.attribution,
|
attribution: layerData.attribution,
|
||||||
detectRetina: true
|
detectRetina: true,
|
||||||
|
noWrap: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,7 @@ export default function BranchPrefixDialog() {
|
|||||||
<input class="branch-prefix-input form-control" value={prefix} ref={branchInput}
|
<input class="branch-prefix-input form-control" value={prefix} ref={branchInput}
|
||||||
onChange={(e) => setPrefix((e.target as HTMLInputElement).value)} />
|
onChange={(e) => setPrefix((e.target as HTMLInputElement).value)} />
|
||||||
{isSingleBranch && branches[0] && (
|
{isSingleBranch && branches[0] && (
|
||||||
<div class="branch-prefix-note-title input-group-text"> - {branches[0].getNoteFromCache().title}</div>
|
<div class="branch-prefix-note-title input-group-text"> - {branches[0].getNoteFromCache()?.title}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
@ -113,7 +113,7 @@ export default function BranchPrefixDialog() {
|
|||||||
<ul>
|
<ul>
|
||||||
{branches.map((branch) => {
|
{branches.map((branch) => {
|
||||||
const note = branch.getNoteFromCache();
|
const note = branch.getNoteFromCache();
|
||||||
return (
|
return note && (
|
||||||
<li key={branch.branchId}>
|
<li key={branch.branchId}>
|
||||||
{branch.prefix && <span className="branch-prefix-current">{branch.prefix} - </span>}
|
{branch.prefix && <span className="branch-prefix-current">{branch.prefix} - </span>}
|
||||||
{note.title}
|
{note.title}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map
|
|||||||
return (
|
return (
|
||||||
<li className={isDeleted ? "deleted-note" : ""}>
|
<li className={isDeleted ? "deleted-note" : ""}>
|
||||||
<span title={change.date}>{formattedTime}</span>
|
<span title={change.date}>{formattedTime}</span>
|
||||||
{ !isDeleted
|
{ notePath && !isDeleted
|
||||||
? <NoteLink notePath={notePath} title={change.current_title} />
|
? <NoteLink notePath={notePath} title={change.current_title} />
|
||||||
: <DeletedNoteLink change={change} setShown={setShown} /> }
|
: <DeletedNoteLink change={change} setShown={setShown} /> }
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -574,6 +574,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
.loadSearchNote(noteId)
|
.loadSearchNote(noteId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const note = froca.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
if (!note) return [];
|
||||||
|
|
||||||
let childNoteIds = note.getChildNoteIds();
|
let childNoteIds = note.getChildNoteIds();
|
||||||
|
|
||||||
@ -585,6 +586,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const note = froca.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
if (!note) return [];
|
||||||
|
|
||||||
return this.prepareChildren(note);
|
return this.prepareChildren(note);
|
||||||
});
|
});
|
||||||
@ -740,7 +742,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
const node = $.ui.fancytree.getNode(e as unknown as Event);
|
const node = $.ui.fancytree.getNode(e as unknown as Event);
|
||||||
const note = froca.getNoteFromCache(node.data.noteId);
|
const note = froca.getNoteFromCache(node.data.noteId);
|
||||||
|
|
||||||
if (note.isLaunchBarConfig()) {
|
if (note?.isLaunchBarConfig()) {
|
||||||
import("../menus/launcher_context_menu.js").then(({ default: LauncherContextMenu }) => {
|
import("../menus/launcher_context_menu.js").then(({ default: LauncherContextMenu }) => {
|
||||||
const launcherContextMenu = new LauncherContextMenu(this, node);
|
const launcherContextMenu = new LauncherContextMenu(this, node);
|
||||||
launcherContextMenu.show(e);
|
launcherContextMenu.show(e);
|
||||||
@ -775,7 +777,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
if (hideArchivedNotes) {
|
if (hideArchivedNotes) {
|
||||||
const note = branch.getNoteFromCache();
|
const note = branch.getNoteFromCache();
|
||||||
|
|
||||||
if (note.hasLabel("archived")) {
|
if (!note || note.hasLabel("archived")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1754,7 +1756,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
for (const nodeToDuplicate of nodesToDuplicate) {
|
for (const nodeToDuplicate of nodesToDuplicate) {
|
||||||
const note = froca.getNoteFromCache(nodeToDuplicate.data.noteId);
|
const note = froca.getNoteFromCache(nodeToDuplicate.data.noteId);
|
||||||
|
|
||||||
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
if (note?.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/u
|
|||||||
import { ParentComponent } from "../react/react_utils";
|
import { ParentComponent } from "../react/react_utils";
|
||||||
import { t } from "../../services/i18n"
|
import { t } from "../../services/i18n"
|
||||||
import { useContext } from "preact/hooks";
|
import { useContext } from "preact/hooks";
|
||||||
import { useIsNoteReadOnly } from "../react/hooks";
|
import { useIsNoteReadOnly, useNoteLabel, useNoteProperty } from "../react/hooks";
|
||||||
import { useTriliumOption } from "../react/hooks";
|
import { useTriliumOption } from "../react/hooks";
|
||||||
import ActionButton from "../react/ActionButton"
|
import ActionButton from "../react/ActionButton"
|
||||||
import appContext, { CommandNames } from "../../components/app_context";
|
import appContext, { CommandNames } from "../../components/app_context";
|
||||||
@ -46,14 +46,16 @@ function RevisionsButton({ note }: { note: FNote }) {
|
|||||||
|
|
||||||
function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: NoteContext }) {
|
function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: NoteContext }) {
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
|
const noteType = useNoteProperty(note, "type") ?? "";
|
||||||
|
const [ viewType ] = useNoteLabel(note, "viewType");
|
||||||
const canBeConvertedToAttachment = note?.isEligibleForConversionToAttachment();
|
const canBeConvertedToAttachment = note?.isEligibleForConversionToAttachment();
|
||||||
const isSearchable = ["text", "code", "book", "mindMap", "doc"].includes(note.type);
|
const isSearchable = ["text", "code", "book", "mindMap", "doc"].includes(noteType);
|
||||||
const isInOptionsOrHelp = note?.noteId.startsWith("_options") || note?.noteId.startsWith("_help");
|
const isInOptionsOrHelp = note?.noteId.startsWith("_options") || note?.noteId.startsWith("_help");
|
||||||
const isPrintable = ["text", "code"].includes(note.type) || (note.type === "book" && ["presentation", "list", "table"].includes(note.getLabelValue("viewType") ?? ""));
|
const isPrintable = ["text", "code"].includes(noteType) || (noteType === "book" && ["presentation", "list", "table"].includes(viewType ?? ""));
|
||||||
const isElectron = getIsElectron();
|
const isElectron = getIsElectron();
|
||||||
const isMac = getIsMac();
|
const isMac = getIsMac();
|
||||||
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(note.type);
|
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(noteType);
|
||||||
const isSearchOrBook = ["search", "book"].includes(note.type);
|
const isSearchOrBook = ["search", "book"].includes(noteType);
|
||||||
const [ syncServerHost ] = useTriliumOption("syncServerHost");
|
const [ syncServerHost ] = useTriliumOption("syncServerHost");
|
||||||
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
||||||
|
|
||||||
|
|||||||
@ -24,9 +24,18 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.attachment-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.attachment-title-line {
|
.attachment-title-line {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: center;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +59,7 @@
|
|||||||
|
|
||||||
.attachment-detail-wrapper.list-view .attachment-content-wrapper {
|
.attachment-detail-wrapper.list-view .attachment-content-wrapper {
|
||||||
max-height: 300px;
|
max-height: 300px;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment-detail-wrapper.full-detail {
|
.attachment-detail-wrapper.full-detail {
|
||||||
@ -60,8 +70,16 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.attachment-detail-wrapper.list-view {
|
||||||
|
border-radius: 12px;
|
||||||
|
background-color: var(--card-background-color);
|
||||||
|
padding: 0 6px;
|
||||||
|
box-shadow: var(--card-box-shadow);
|
||||||
|
}
|
||||||
|
|
||||||
.attachment-detail-wrapper.list-view .attachment-content-wrapper pre {
|
.attachment-detail-wrapper.list-view .attachment-content-wrapper pre {
|
||||||
max-height: 400px;
|
max-height: 400px;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment-content-wrapper img {
|
.attachment-content-wrapper img {
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
.note-detail-code-editor {
|
.note-detail-code-editor {
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
/* #endregion */
|
/* #endregion */
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,23 @@ describe("Tree", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("sorts notes by title (base case)", () => {
|
||||||
|
|
||||||
|
const note = buildNote({
|
||||||
|
children: [
|
||||||
|
{title: "1"},
|
||||||
|
{title: "2"},
|
||||||
|
{title: "3"},
|
||||||
|
],
|
||||||
|
"#sorted": "",
|
||||||
|
});
|
||||||
|
cls.init(() => {
|
||||||
|
tree.sortNotesIfNeeded(note.noteId);
|
||||||
|
});
|
||||||
|
const orderedTitles = note.children.map((child) => child.title);
|
||||||
|
expect(orderedTitles).toStrictEqual(["1", "2", "3"]);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
it("custom sort order is idempotent", () => {
|
it("custom sort order is idempotent", () => {
|
||||||
rootNote.label("sorted", "order");
|
rootNote.label("sorted", "order");
|
||||||
@ -56,13 +73,15 @@ describe("Tree", () => {
|
|||||||
for (let i = 0; i <= 5; i++) {
|
for (let i = 0; i <= 5; i++) {
|
||||||
rootNote.child(note(String(i)).label("order", String(i)));
|
rootNote.child(note(String(i)).label("order", String(i)));
|
||||||
}
|
}
|
||||||
|
rootNote.child(note("top").label("top"));
|
||||||
|
rootNote.child(note("bottom").label("bottom"));
|
||||||
|
|
||||||
// Add a few values which have no defined order.
|
// Add a few values which have no defined order.
|
||||||
for (let i = 6; i < 10; i++) {
|
for (let i = 6; i < 10; i++) {
|
||||||
rootNote.child(note(String(i)));
|
rootNote.child(note(String(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedOrder = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ];
|
const expectedOrder = ["top", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "bottom"];
|
||||||
|
|
||||||
// Sort a few times to ensure that the resulting order is the same.
|
// Sort a few times to ensure that the resulting order is the same.
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
@ -113,4 +132,48 @@ describe("Tree", () => {
|
|||||||
const orderedTitles = note.children.map((child) => child.title);
|
const orderedTitles = note.children.map((child) => child.title);
|
||||||
expect(orderedTitles).toStrictEqual(["top", "5", "3", "2", "1", "bottom"]);
|
expect(orderedTitles).toStrictEqual(["top", "5", "3", "2", "1", "bottom"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps folder notes on top when #sortFolderFirst is set, but not above #top", () => {
|
||||||
|
const note = buildNote({
|
||||||
|
children: [
|
||||||
|
{title: "bottom", "#bottom": ""},
|
||||||
|
{title: "1"},
|
||||||
|
{title: "2"},
|
||||||
|
{title: "p1", children: [{title: "1.1"}, {title: "1.2"}]},
|
||||||
|
{title: "p2", children: [{title: "2.1"}, {title: "2.2"}]},
|
||||||
|
{title: "3"},
|
||||||
|
{title: "5"},
|
||||||
|
{title: "top", "#top": ""}
|
||||||
|
],
|
||||||
|
"#sorted": "",
|
||||||
|
"#sortFoldersFirst": ""
|
||||||
|
});
|
||||||
|
cls.init(() => {
|
||||||
|
tree.sortNotesIfNeeded(note.noteId);
|
||||||
|
});
|
||||||
|
const orderedTitles = note.children.map((child) => child.title);
|
||||||
|
expect(orderedTitles).toStrictEqual(["top", "p1", "p2", "1", "2", "3", "5", "bottom"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("sorts notes accordingly when #sortNatural is set", () => {
|
||||||
|
const note = buildNote({
|
||||||
|
children: [
|
||||||
|
{title: "bottom", "#bottom": ""},
|
||||||
|
{title: "1"},
|
||||||
|
{title: "2"},
|
||||||
|
{title: "10"},
|
||||||
|
{title: "20"},
|
||||||
|
{title: "3"},
|
||||||
|
{title: "top", "#top": ""}
|
||||||
|
],
|
||||||
|
"#sorted": "",
|
||||||
|
"#sortNatural": ""
|
||||||
|
});
|
||||||
|
cls.init(() => {
|
||||||
|
tree.sortNotesIfNeeded(note.noteId);
|
||||||
|
});
|
||||||
|
const orderedTitles = note.children.map((child) => child.title);
|
||||||
|
expect(orderedTitles).toStrictEqual(["top", "1", "2", "3", "10", "20", "bottom"]);
|
||||||
|
}
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@ -98,15 +98,6 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
|
|||||||
}
|
}
|
||||||
|
|
||||||
notes.sort((a, b) => {
|
notes.sort((a, b) => {
|
||||||
if (foldersFirst) {
|
|
||||||
const aHasChildren = a.hasChildren();
|
|
||||||
const bHasChildren = b.hasChildren();
|
|
||||||
|
|
||||||
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
|
|
||||||
// exactly one note of the two is a directory, so the sorting will be done based on this status
|
|
||||||
return aHasChildren ? -1 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchValue(note: BNote, key: string) {
|
function fetchValue(note: BNote, key: string) {
|
||||||
let rawValue: string | null;
|
let rawValue: string | null;
|
||||||
@ -154,6 +145,16 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
|
|||||||
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
|
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foldersFirst) {
|
||||||
|
const aHasChildren = a.hasChildren();
|
||||||
|
const bHasChildren = b.hasChildren();
|
||||||
|
|
||||||
|
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
|
||||||
|
// exactly one note of the two is a directory, so the sorting will be done based on this status
|
||||||
|
return aHasChildren ? -1 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const customAEl = fetchValue(a, customSortBy) ?? fetchValue(a, "title") as string;
|
const customAEl = fetchValue(a, customSortBy) ?? fetchValue(a, "title") as string;
|
||||||
const customBEl = fetchValue(b, customSortBy) ?? fetchValue(b, "title") as string;
|
const customBEl = fetchValue(b, customSortBy) ?? fetchValue(b, "title") as string;
|
||||||
|
|
||||||
|
|||||||
@ -148,11 +148,8 @@ describe("content_renderer", () => {
|
|||||||
`
|
`
|
||||||
});
|
});
|
||||||
const result = getContent(note);
|
const result = getContent(note);
|
||||||
expect(result.content).toStrictEqual(trimIndentation`\
|
const content = (result.content as string).replaceAll(/\s/g, "");
|
||||||
<p>
|
expect(content).toStrictEqual("<p>Foo</p>");
|
||||||
<a class="reference-link">[missing note]</a>
|
|
||||||
</p>
|
|
||||||
`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("properly escapes note title", () => {
|
it("properly escapes note title", () => {
|
||||||
|
|||||||
@ -320,13 +320,13 @@ function renderText(result: Result, note: SNote | BNote) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linkEl.classList.contains("reference-link")) {
|
|
||||||
cleanUpReferenceLinks(linkEl, getNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (href?.startsWith("#")) {
|
if (href?.startsWith("#")) {
|
||||||
handleAttachmentLink(linkEl, href, getNote, getAttachment);
|
handleAttachmentLink(linkEl, href, getNote, getAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (linkEl.classList.contains("reference-link")) {
|
||||||
|
cleanUpReferenceLinks(linkEl, getNote);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply syntax highlight.
|
// Apply syntax highlight.
|
||||||
@ -402,8 +402,8 @@ function cleanUpReferenceLinks(linkEl: HTMLElement, getNote: GetNoteFunction) {
|
|||||||
const noteId = href.split("/").at(-1);
|
const noteId = href.split("/").at(-1);
|
||||||
const note = noteId ? getNote(noteId) : undefined;
|
const note = noteId ? getNote(noteId) : undefined;
|
||||||
if (!note) {
|
if (!note) {
|
||||||
console.warn("Unable to find note ", noteId);
|
// If a note is not found, simply replace it with a text.
|
||||||
linkEl.innerHTML = "[missing note]";
|
linkEl.replaceWith(new TextNode(linkEl.innerText));
|
||||||
} else if (note.isProtected) {
|
} else if (note.isProtected) {
|
||||||
linkEl.innerHTML = "[protected]";
|
linkEl.innerHTML = "[protected]";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user