mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 14:34:24 +01:00
Compare commits
19 Commits
79bd49aab8
...
e758a20c5b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e758a20c5b | ||
|
|
8b3afc1f49 | ||
|
|
d5cbf362f8 | ||
|
|
286a8626d1 | ||
|
|
aa62dc3f32 | ||
|
|
045e7977d5 | ||
|
|
e0dc25ad23 | ||
|
|
9d0499a306 | ||
|
|
b971e002ce | ||
|
|
5fd488e210 | ||
|
|
eb84da4c51 | ||
|
|
49243148a2 | ||
|
|
276241cdff | ||
|
|
6772453b3a | ||
|
|
18e2f1f90c | ||
|
|
a81e8adde7 | ||
|
|
5aec9229d4 | ||
|
|
0c954322e4 | ||
|
|
9580d636cf |
@ -240,7 +240,7 @@ export default class FNote {
|
||||
|
||||
const aNote = this.froca.getNoteFromCache(aNoteId);
|
||||
|
||||
if (aNote.isArchived || aNote.isHiddenCompletely()) {
|
||||
if (!aNote || aNote.isArchived || aNote.isHiddenCompletely()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ import ScrollingContainer from "../widgets/containers/scrolling_container.js";
|
||||
import ScrollPadding from "../widgets/scroll_padding.js";
|
||||
import SearchResult from "../widgets/search_result.jsx";
|
||||
import SharedInfo from "../widgets/shared_info.jsx";
|
||||
import OriginInfo from "../widgets/note_origin.jsx";
|
||||
import SpacerWidget from "../widgets/spacer.js";
|
||||
import SplitNoteContainer from "../widgets/containers/split_note_container.js";
|
||||
import SqlResults from "../widgets/sql_result.js";
|
||||
@ -139,6 +140,7 @@ export default class DesktopLayout {
|
||||
.filling()
|
||||
.child(new ContentHeader()
|
||||
.child(<ReadOnlyNoteInfoBar />)
|
||||
.child(<OriginInfo />)
|
||||
.child(<SharedInfo />)
|
||||
)
|
||||
.child(<PromotedAttributes />)
|
||||
|
||||
@ -140,7 +140,13 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
uiIcon: "bx bx-rename",
|
||||
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" },
|
||||
|
||||
|
||||
@ -56,9 +56,14 @@ async function renderIncludedNotes(contentEl: HTMLElement) {
|
||||
// Render and integrate the notes.
|
||||
for (const includeNoteEl of includeNoteEls) {
|
||||
const noteId = includeNoteEl.getAttribute("data-note-id");
|
||||
if (!noteId) return;
|
||||
if (!noteId) continue;
|
||||
|
||||
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;
|
||||
includeNoteEl.replaceChildren(...renderedContent);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ export interface Froca {
|
||||
|
||||
getBlob(entityType: string, entityId: string): Promise<FBlob | null>;
|
||||
getNote(noteId: string, silentNotFoundError?: boolean): Promise<FNote | null>;
|
||||
getNoteFromCache(noteId: string): FNote;
|
||||
getNoteFromCache(noteId: string): FNote | undefined;
|
||||
getNotesFromCache(noteIds: string[], silentNotFoundError?: boolean): FNote[];
|
||||
getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise<FNote[]>;
|
||||
|
||||
|
||||
@ -288,7 +288,7 @@ class FrocaImpl implements Froca {
|
||||
return (await this.getNotes([noteId], silentNotFoundError))[0];
|
||||
}
|
||||
|
||||
getNoteFromCache(noteId: string) {
|
||||
getNoteFromCache(noteId: string): FNote | undefined {
|
||||
if (!noteId) {
|
||||
throw new Error("Empty noteId");
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@
|
||||
"title": "الملاحظات المعدلة"
|
||||
},
|
||||
"note_properties": {
|
||||
"info": "معلومات"
|
||||
"this_note_was_originally_taken_from": ""
|
||||
},
|
||||
"backend_log": {
|
||||
"refresh": "تحديث"
|
||||
|
||||
@ -840,8 +840,7 @@
|
||||
"search": "搜索"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "笔记来源:",
|
||||
"info": "信息"
|
||||
"this_note_was_originally_taken_from": "笔记来源:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "拥有的属性"
|
||||
|
||||
@ -837,8 +837,7 @@
|
||||
"search": "Suchen"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Diese Notiz stammt ursprünglich aus:",
|
||||
"info": "Info"
|
||||
"this_note_was_originally_taken_from": "Diese Notiz stammt ursprünglich aus:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Eigene Attribute"
|
||||
|
||||
@ -841,8 +841,7 @@
|
||||
"search": "Search"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "This note was originally taken from:",
|
||||
"info": "Info"
|
||||
"this_note_was_originally_taken_from": "This note was originally taken from:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Owned Attributes"
|
||||
@ -1633,7 +1632,7 @@
|
||||
"import-into-note": "Import into note",
|
||||
"apply-bulk-actions": "Apply bulk actions",
|
||||
"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"
|
||||
},
|
||||
"shared_info": {
|
||||
|
||||
@ -841,8 +841,7 @@
|
||||
"search": "Buscar"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Esta nota fue tomada originalmente de:",
|
||||
"info": "Información"
|
||||
"this_note_was_originally_taken_from": "Esta nota fue tomada originalmente de:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Atributos propios"
|
||||
|
||||
@ -835,8 +835,7 @@
|
||||
"search": "Recherche"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Cette note est initialement extraite de :",
|
||||
"info": "Infos"
|
||||
"this_note_was_originally_taken_from": "Cette note est initialement extraite de :"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Attributs propres"
|
||||
|
||||
@ -1410,8 +1410,7 @@
|
||||
"search": "Ricerca"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Questa nota è stata originariamente tratta da:",
|
||||
"info": "Informazioni"
|
||||
"this_note_was_originally_taken_from": "Questa nota è stata originariamente tratta da:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Attributi posseduti"
|
||||
|
||||
@ -693,7 +693,6 @@
|
||||
"outside_hoisted": "このパスはホイストされたノートの外側にあるため、ホイストを解除する必要があります。"
|
||||
},
|
||||
"note_properties": {
|
||||
"info": "情報",
|
||||
"this_note_was_originally_taken_from": "このノートは元々以下から引用したものです:"
|
||||
},
|
||||
"similar_notes": {
|
||||
|
||||
@ -447,8 +447,7 @@
|
||||
"search": "Szukaj"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Ta notatka oryginalnie została wzięta z:",
|
||||
"info": "Info"
|
||||
"this_note_was_originally_taken_from": "Ta notatka oryginalnie została wzięta z:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Posiadane atrybuty"
|
||||
|
||||
@ -810,8 +810,7 @@
|
||||
"search": "Pesquisar"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Esta nota foi originalmente obtida de:",
|
||||
"info": "Informações"
|
||||
"this_note_was_originally_taken_from": "Esta nota foi originalmente obtida de:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Atributos próprios"
|
||||
|
||||
@ -1070,8 +1070,7 @@
|
||||
"outside_hoisted": "Este caminho está fora de uma nota fixada e você teria que desafixar."
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Esta nota foi originalmente obtida de:",
|
||||
"info": "Informações"
|
||||
"this_note_was_originally_taken_from": "Esta nota foi originalmente obtida de:"
|
||||
},
|
||||
"promoted_attributes": {
|
||||
"promoted_attributes": "Atributos Promovidos",
|
||||
|
||||
@ -680,7 +680,8 @@
|
||||
"tabShortcuts": "Scurtături pentru tab-uri",
|
||||
"troubleshooting": "Unelte pentru depanare",
|
||||
"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": {
|
||||
"button_title": "Ascunde butoanele"
|
||||
@ -910,7 +911,6 @@
|
||||
"title": "Căile notiței"
|
||||
},
|
||||
"note_properties": {
|
||||
"info": "Informații",
|
||||
"this_note_was_originally_taken_from": "Această notiță a fost preluată original de la:"
|
||||
},
|
||||
"note_type_chooser": {
|
||||
@ -1511,7 +1511,8 @@
|
||||
"hoist-this-note-workspace": "Focalizează spațiul de lucru",
|
||||
"refresh-saved-search-results": "Reîmprospătează căutarea salvată",
|
||||
"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": {
|
||||
"window-on-top": "Menține fereastra mereu vizibilă"
|
||||
@ -1625,7 +1626,8 @@
|
||||
"reset": "Resetează"
|
||||
},
|
||||
"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": {
|
||||
"color-scheme": "Temă de culori",
|
||||
@ -1677,7 +1679,8 @@
|
||||
"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_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": {
|
||||
"clear-text-field": "Șterge conținutul casetei",
|
||||
@ -2101,5 +2104,8 @@
|
||||
"clear-color": "Înlăturați culoarea notiței",
|
||||
"set-color": "Setați culoarea notiței",
|
||||
"set-custom-color": "Setați culoare personalizată pentru notiță"
|
||||
},
|
||||
"popup-editor": {
|
||||
"maximize": "Comută la editorul principal"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1067,7 +1067,6 @@
|
||||
"archived": "Архивировано"
|
||||
},
|
||||
"note_properties": {
|
||||
"info": "Информация",
|
||||
"this_note_was_originally_taken_from": "Эта заметка была первоначально взята из:"
|
||||
},
|
||||
"promoted_attributes": {
|
||||
|
||||
@ -837,8 +837,7 @@
|
||||
"search": "搜尋"
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "筆記來源:",
|
||||
"info": "資訊"
|
||||
"this_note_was_originally_taken_from": "筆記來源:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "自有屬性"
|
||||
|
||||
@ -939,8 +939,7 @@
|
||||
"outside_hoisted": "Цей шлях знаходиться поза межами закріпленої нотатки і вам доведеться відкріпити."
|
||||
},
|
||||
"note_properties": {
|
||||
"this_note_was_originally_taken_from": "Цю нотатку було спочатку взято з:",
|
||||
"info": "Інформація"
|
||||
"this_note_was_originally_taken_from": "Цю нотатку було спочатку взято з:"
|
||||
},
|
||||
"owned_attribute_list": {
|
||||
"owned_attributes": "Власні Атрибути"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
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 "./NoteList.css";
|
||||
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">) {
|
||||
const { note, noteContext, notePath, ntxId, viewScope } = useNoteContext();
|
||||
const viewType = useNoteViewType(note);
|
||||
const noteType = useNoteProperty(note, "type");
|
||||
const [ enabled, setEnabled ] = useState(noteContext?.hasNoteList());
|
||||
useEffect(() => {
|
||||
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} />
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ describe("Board data", () => {
|
||||
parentNoteId: "note1"
|
||||
});
|
||||
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 noteIds = Array.from(data.byColumn.values()).flat().map(item => item.note.noteId);
|
||||
expect(noteIds.length).toBe(3);
|
||||
|
||||
@ -30,7 +30,12 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return;
|
||||
const mapInstance = L.map(containerRef.current, {
|
||||
worldCopyJump: true
|
||||
worldCopyJump: false,
|
||||
maxBounds: [
|
||||
[-90, -180],
|
||||
[90, 180]
|
||||
],
|
||||
minZoom: 2
|
||||
});
|
||||
|
||||
mapRef.current = mapInstance;
|
||||
@ -56,7 +61,8 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi
|
||||
} else {
|
||||
setLayer(L.tileLayer(layerData.url, {
|
||||
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}
|
||||
onChange={(e) => setPrefix((e.target as HTMLInputElement).value)} />
|
||||
{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>
|
||||
</FormGroup>
|
||||
@ -113,7 +113,7 @@ export default function BranchPrefixDialog() {
|
||||
<ul>
|
||||
{branches.map((branch) => {
|
||||
const note = branch.getNoteFromCache();
|
||||
return (
|
||||
return note && (
|
||||
<li key={branch.branchId}>
|
||||
{branch.prefix && <span className="branch-prefix-current">{branch.prefix} - </span>}
|
||||
{note.title}
|
||||
|
||||
@ -21,7 +21,7 @@ export default function RecentChangesDialog() {
|
||||
const [ refreshCounter, setRefreshCounter ] = useState(0);
|
||||
const [ shown, setShown ] = useState(false);
|
||||
|
||||
useTriliumEvent("showRecentChanges", ({ ancestorNoteId }) => {
|
||||
useTriliumEvent("showRecentChanges", ({ ancestorNoteId }) => {
|
||||
setAncestorNoteId(ancestorNoteId ?? hoisted_note.getHoistedNoteId());
|
||||
setShown(true);
|
||||
});
|
||||
@ -91,7 +91,7 @@ function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map
|
||||
return (
|
||||
<li className={isDeleted ? "deleted-note" : ""}>
|
||||
<span title={change.date}>{formattedTime}</span>
|
||||
{ !isDeleted
|
||||
{ notePath && !isDeleted
|
||||
? <NoteLink notePath={notePath} title={change.current_title} />
|
||||
: <DeletedNoteLink change={change} setShown={setShown} /> }
|
||||
</li>
|
||||
|
||||
43
apps/client/src/widgets/note_origin.tsx
Normal file
43
apps/client/src/widgets/note_origin.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
import { t } from "../services/i18n";
|
||||
import { useNoteContext, useTriliumEvent, useTriliumOption } from "./react/hooks";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import attributes from "../services/attributes";
|
||||
import InfoBar from "./react/InfoBar";
|
||||
import RawHtml from "./react/RawHtml";
|
||||
import FNote from "../entities/fnote";
|
||||
|
||||
export default function OriginInfo() {
|
||||
const { note } = useNoteContext();
|
||||
const [link, setLink] = useState<string>();
|
||||
|
||||
function refresh() {
|
||||
if (!note) return;
|
||||
const pageUrl = getPageUrl(note);
|
||||
if (!pageUrl) {
|
||||
setLink(undefined);
|
||||
return;
|
||||
}
|
||||
setLink(`<a href="${pageUrl}" class="external tn-link">${pageUrl}</a>`);
|
||||
}
|
||||
|
||||
useEffect(refresh, [note]);
|
||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||
if (loadResults.getAttributeRows().find((attr) => attr.type === "label" && attr.name?.toString() === "pageUrl" && attributes.isAffecting(attr, note))) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<InfoBar className="origin-info-widget" type="subtle" style={{ display: (!link) ? "none" : undefined }}>
|
||||
{link && (
|
||||
<RawHtml
|
||||
html={`${t("note_properties.this_note_was_originally_taken_from")} ${link}`}
|
||||
/>
|
||||
)}
|
||||
</InfoBar>
|
||||
)
|
||||
}
|
||||
|
||||
function getPageUrl(note: FNote) {
|
||||
return note.getOwnedLabelValue("pageUrl");
|
||||
}
|
||||
@ -574,6 +574,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
.loadSearchNote(noteId)
|
||||
.then(() => {
|
||||
const note = froca.getNoteFromCache(noteId);
|
||||
if (!note) return [];
|
||||
|
||||
let childNoteIds = note.getChildNoteIds();
|
||||
|
||||
@ -585,6 +586,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
})
|
||||
.then(() => {
|
||||
const note = froca.getNoteFromCache(noteId);
|
||||
if (!note) return [];
|
||||
|
||||
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 note = froca.getNoteFromCache(node.data.noteId);
|
||||
|
||||
if (note.isLaunchBarConfig()) {
|
||||
if (note?.isLaunchBarConfig()) {
|
||||
import("../menus/launcher_context_menu.js").then(({ default: LauncherContextMenu }) => {
|
||||
const launcherContextMenu = new LauncherContextMenu(this, node);
|
||||
launcherContextMenu.show(e);
|
||||
@ -775,7 +777,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
if (hideArchivedNotes) {
|
||||
const note = branch.getNoteFromCache();
|
||||
|
||||
if (note.hasLabel("archived")) {
|
||||
if (!note || note.hasLabel("archived")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1754,7 +1756,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
for (const nodeToDuplicate of nodesToDuplicate) {
|
||||
const note = froca.getNoteFromCache(nodeToDuplicate.data.noteId);
|
||||
|
||||
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
if (note?.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/u
|
||||
import { ParentComponent } from "../react/react_utils";
|
||||
import { t } from "../../services/i18n"
|
||||
import { useContext } from "preact/hooks";
|
||||
import { useIsNoteReadOnly } from "../react/hooks";
|
||||
import { useIsNoteReadOnly, useNoteLabel, useNoteProperty } from "../react/hooks";
|
||||
import { useTriliumOption } from "../react/hooks";
|
||||
import ActionButton from "../react/ActionButton"
|
||||
import appContext, { CommandNames } from "../../components/app_context";
|
||||
@ -46,14 +46,16 @@ function RevisionsButton({ note }: { note: FNote }) {
|
||||
|
||||
function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: NoteContext }) {
|
||||
const parentComponent = useContext(ParentComponent);
|
||||
const noteType = useNoteProperty(note, "type") ?? "";
|
||||
const [ viewType ] = useNoteLabel(note, "viewType");
|
||||
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 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 isMac = getIsMac();
|
||||
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(note.type);
|
||||
const isSearchOrBook = ["search", "book"].includes(note.type);
|
||||
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(noteType);
|
||||
const isSearchOrBook = ["search", "book"].includes(noteType);
|
||||
const [ syncServerHost ] = useTriliumOption("syncServerHost");
|
||||
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
||||
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
import { t } from "../../services/i18n";
|
||||
import { useNoteLabel } from "../react/hooks";
|
||||
import { TabContext } from "./ribbon-interface";
|
||||
|
||||
/**
|
||||
* TODO: figure out better name or conceptualize better.
|
||||
*/
|
||||
export default function NotePropertiesTab({ note }: TabContext) {
|
||||
const [ pageUrl ] = useNoteLabel(note, "pageUrl");
|
||||
|
||||
return (
|
||||
<div className="note-properties-widget" style={{ padding: "12px", color: "var(--muted-text-color)" }}>
|
||||
{ pageUrl && (
|
||||
<div style={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
|
||||
{t("note_properties.this_note_was_originally_taken_from")} <a href={pageUrl} class="page-url external">{pageUrl}</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
import ScriptTab from "./ScriptTab";
|
||||
import EditedNotesTab from "./EditedNotesTab";
|
||||
import NotePropertiesTab from "./NotePropertiesTab";
|
||||
import NoteInfoTab from "./NoteInfoTab";
|
||||
import SimilarNotesTab from "./SimilarNotesTab";
|
||||
import FilePropertiesTab from "./FilePropertiesTab";
|
||||
@ -59,13 +58,6 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [
|
||||
show: ({ note }) => note?.type === "book" || note?.type === "search",
|
||||
toggleCommand: "toggleRibbonTabBookProperties"
|
||||
},
|
||||
{
|
||||
title: t("note_properties.info"),
|
||||
icon: "bx bx-info-square",
|
||||
content: NotePropertiesTab,
|
||||
show: ({ note }) => !!note?.getLabelValue("pageUrl"),
|
||||
activate: true
|
||||
},
|
||||
{
|
||||
title: t("file_properties.title"),
|
||||
icon: "bx bx-file",
|
||||
|
||||
@ -24,9 +24,18 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.attachment-title {
|
||||
font-size: 1.1rem;
|
||||
margin: 0;
|
||||
|
||||
a {
|
||||
color: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-title-line {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
@ -50,6 +59,7 @@
|
||||
|
||||
.attachment-detail-wrapper.list-view .attachment-content-wrapper {
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.attachment-detail-wrapper.full-detail {
|
||||
@ -60,8 +70,16 @@
|
||||
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 {
|
||||
max-height: 400px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.attachment-content-wrapper img {
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
.note-detail-code-editor {
|
||||
min-height: 50px;
|
||||
height: 100%;
|
||||
padding: 0 !important;
|
||||
}
|
||||
/* #endregion */
|
||||
|
||||
|
||||
@ -148,11 +148,8 @@ describe("content_renderer", () => {
|
||||
`
|
||||
});
|
||||
const result = getContent(note);
|
||||
expect(result.content).toStrictEqual(trimIndentation`\
|
||||
<p>
|
||||
<a class="reference-link">[missing note]</a>
|
||||
</p>
|
||||
`);
|
||||
const content = (result.content as string).replaceAll(/\s/g, "");
|
||||
expect(content).toStrictEqual("<p>Foo</p>");
|
||||
});
|
||||
|
||||
it("properly escapes note title", () => {
|
||||
|
||||
@ -320,13 +320,13 @@ function renderText(result: Result, note: SNote | BNote) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (linkEl.classList.contains("reference-link")) {
|
||||
cleanUpReferenceLinks(linkEl, getNote);
|
||||
}
|
||||
|
||||
if (href?.startsWith("#")) {
|
||||
handleAttachmentLink(linkEl, href, getNote, getAttachment);
|
||||
}
|
||||
|
||||
if (linkEl.classList.contains("reference-link")) {
|
||||
cleanUpReferenceLinks(linkEl, getNote);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply syntax highlight.
|
||||
@ -402,8 +402,8 @@ function cleanUpReferenceLinks(linkEl: HTMLElement, getNote: GetNoteFunction) {
|
||||
const noteId = href.split("/").at(-1);
|
||||
const note = noteId ? getNote(noteId) : undefined;
|
||||
if (!note) {
|
||||
console.warn("Unable to find note ", noteId);
|
||||
linkEl.innerHTML = "[missing note]";
|
||||
// If a note is not found, simply replace it with a text.
|
||||
linkEl.replaceWith(new TextNode(linkEl.innerText));
|
||||
} else if (note.isProtected) {
|
||||
linkEl.innerHTML = "[protected]";
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user