mirror of
https://github.com/zadam/trilium.git
synced 2025-12-29 10:44:25 +01:00
feat(share): ignore unsupported icon packs
This commit is contained in:
parent
b00cb52da5
commit
290f488c78
@ -140,6 +140,7 @@ export function renderNoteContent(note: SNote) {
|
||||
iconPackCss: iconPacks.map(p => generateCss(p, true))
|
||||
.filter(Boolean)
|
||||
.join("\n\n"),
|
||||
iconPackSupportedPrefixes: iconPacks.map(p => p.manifest.prefix)
|
||||
});
|
||||
}
|
||||
|
||||
@ -153,6 +154,7 @@ interface RenderArgs {
|
||||
isStatic: boolean;
|
||||
faviconUrl: string;
|
||||
iconPackCss: string;
|
||||
iconPackSupportedPrefixes: string[];
|
||||
}
|
||||
|
||||
function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) {
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
import sql from "../../sql.js";
|
||||
import utils from "../../../services/utils.js";
|
||||
import AbstractShacaEntity from "./abstract_shaca_entity.js";
|
||||
import escape from "escape-html";
|
||||
|
||||
import { NOTE_TYPE_ICONS } from "../../../becca/entities/bnote.js";
|
||||
import type { Blob } from "../../../services/blob-interface.js";
|
||||
import utils from "../../../services/utils.js";
|
||||
import sql from "../../sql.js";
|
||||
import AbstractShacaEntity from "./abstract_shaca_entity.js";
|
||||
import type { SNoteRow } from "./rows.js";
|
||||
import type SAttachment from "./sattachment.js";
|
||||
import type SAttribute from "./sattribute.js";
|
||||
import type SBranch from "./sbranch.js";
|
||||
import type { SNoteRow } from "./rows.js";
|
||||
import { NOTE_TYPE_ICONS } from "../../../becca/entities/bnote.js";
|
||||
|
||||
const LABEL = "label";
|
||||
const RELATION = "relation";
|
||||
@ -101,18 +100,16 @@ class SNote extends AbstractShacaEntity {
|
||||
if (!row) {
|
||||
if (silentNotFoundError) {
|
||||
return undefined;
|
||||
} else {
|
||||
throw new Error(`Cannot find note content for note '${this.noteId}', blob '${this.blobId}'`);
|
||||
}
|
||||
throw new Error(`Cannot find note content for note '${this.noteId}', blob '${this.blobId}'`);
|
||||
}
|
||||
|
||||
const content = row.content;
|
||||
|
||||
if (this.hasStringContent()) {
|
||||
return content === null ? "" : content.toString("utf-8");
|
||||
} else {
|
||||
return content;
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/** @returns true if the note has string content (not binary) */
|
||||
@ -137,9 +134,8 @@ class SNote extends AbstractShacaEntity {
|
||||
return attributeCache.filter((attr) => attr.type === type && !isCredentials(attr));
|
||||
} else if (name) {
|
||||
return attributeCache.filter((attr) => attr.name === name && !isCredentials(attr));
|
||||
} else {
|
||||
return attributeCache.filter((attr) => !isCredentials(attr));
|
||||
}
|
||||
return attributeCache.filter((attr) => !isCredentials(attr));
|
||||
}
|
||||
|
||||
getCredentials() {
|
||||
@ -460,9 +456,8 @@ class SNote extends AbstractShacaEntity {
|
||||
return this.ownedAttributes.filter((attr) => attr.type === type);
|
||||
} else if (name) {
|
||||
return this.ownedAttributes.filter((attr) => attr.name === name);
|
||||
} else {
|
||||
return this.ownedAttributes.slice();
|
||||
}
|
||||
return this.ownedAttributes.slice();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -532,8 +527,13 @@ class SNote extends AbstractShacaEntity {
|
||||
};
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
const iconClassLabels = this.getLabels("iconClass");
|
||||
getIcon(filterByPrefix: string[] = []) {
|
||||
const iconClassLabels = this.getLabels("iconClass").filter(label => {
|
||||
if (filterByPrefix.length === 0) {
|
||||
return true;
|
||||
}
|
||||
return filterByPrefix.some(prefix => label.value.startsWith(prefix));
|
||||
});
|
||||
|
||||
if (iconClassLabels && iconClassLabels.length > 0) {
|
||||
return iconClassLabels[0].value;
|
||||
@ -545,14 +545,12 @@ class SNote extends AbstractShacaEntity {
|
||||
} else if (this.type === "text") {
|
||||
if (this.isFolder()) {
|
||||
return "bx bx-folder";
|
||||
} else {
|
||||
return "bx bx-note";
|
||||
}
|
||||
return "bx bx-note";
|
||||
} else if (this.type === "code" && this.mime.startsWith("text/x-sql")) {
|
||||
return "bx bx-data";
|
||||
} else {
|
||||
return NOTE_TYPE_ICONS[this.type];
|
||||
}
|
||||
return NOTE_TYPE_ICONS[this.type];
|
||||
}
|
||||
|
||||
isFolder() {
|
||||
|
||||
@ -15,7 +15,7 @@ const target = isExternalLink ? ` target="_blank" rel="noopener noreferrer"` : "
|
||||
<% if (note.noteId !== subRoot.note.noteId) { %>
|
||||
<a class="<%= linkClass %>" href="<%= linkHref %>"<%= target %>>
|
||||
<% if (note.hasVisibleChildren()) { %><button class="collapse-button" aria-label="<%= t("share_theme.expand") %>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon right-triangle"><path d="M3 8L12 17L21 8"></path></svg></button><% } %>
|
||||
<span><i class="<%= note.getIcon() %>"></i> <%= note.title %></span>
|
||||
<span><i class="<%= note.getIcon(iconPackSupportedPrefixes) %>"></i> <%= note.title %></span>
|
||||
</a>
|
||||
<% } %>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user