Merge remote-tracking branch 'origin/main' into feature/pdfjs_sidebar_experiments

This commit is contained in:
Elian Doran 2025-12-30 01:40:03 +02:00
commit 7a883c62df
No known key found for this signature in database
4 changed files with 58 additions and 21 deletions

View File

@ -692,18 +692,20 @@ paths:
application/json; charset=utf-8: application/json; charset=utf-8:
schema: schema:
$ref: "#/components/schemas/Error" $ref: "#/components/schemas/Error"
/calendar/weeks/{date}: /calendar/weeks/{week}:
get: get:
description: returns a week note for a given date. Gets created if doesn't exist. summary: Get a week note
operationId: getWeekFirstDayNote description: Returns a week note for a given ISO week (format YYYY-Www, e.g., 2025-W01). The note is created if it doesn't exist.
operationId: getWeekNote
parameters: parameters:
- name: date - name: week
in: path in: path
required: true required: true
description: The ISO 8601 week identifier (YYYY-Www).
schema: schema:
type: string type: string
format: date pattern: "[0-9]{4}-W[0-9]{2}"
example: 2022-02-22 example: "2025-W01"
responses: responses:
"200": "200":
description: week note description: week note
@ -930,7 +932,24 @@ components:
type: string type: string
type: type:
type: string type: string
enum: [text, code, render, file, image, search, relationMap, book, noteMap, mermaid, webView, shortcut, doc, contentWidget, launcher] enum:
[
text,
code,
render,
file,
image,
search,
relationMap,
book,
noteMap,
mermaid,
webView,
shortcut,
doc,
contentWidget,
launcher,
]
mime: mime:
type: string type: string
isProtected: isProtected:

View File

@ -74,6 +74,7 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
whitespaceCharacters: "\t\r\n\f\u200b\u00a0\u2002" whitespaceCharacters: "\t\r\n\f\u200b\u00a0\u2002"
}) : ""; }) : "";
// TODO: This will probably never match, but should it be exclude from running on code/jsFrontend notes?
content = renderNoteForExport(note, branch, basePath, noteMeta.notePath.slice(0, -1), this.iconPacks); content = renderNoteForExport(note, branch, basePath, noteMeta.notePath.slice(0, -1), this.iconPacks);
if (typeof content === "string") { if (typeof content === "string") {
// Rewrite attachment download links // Rewrite attachment download links
@ -130,6 +131,10 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
return null; return null;
} }
if (mime.startsWith("application/javascript")) {
return "js";
}
// Don't add .html if the file already has .zip extension (for attachments). // Don't add .html if the file already has .zip extension (for attachments).
if (existingExtension === ".zip") { if (existingExtension === ".zip") {
return null; return null;

View File

@ -165,6 +165,15 @@ interface RenderArgs {
} }
function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) { function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) {
// When rendering static share, non-protected JavaScript notes should be rendered as-is.
if (renderArgs.isStatic && note.mime.startsWith("application/javascript")) {
if (note.isProtected) {
return `console.log("Protected note cannot be exported.");`;
}
return note.getContent() ?? "";
}
const { header, content, isEmpty } = getContent(note); const { header, content, isEmpty } = getContent(note);
const showLoginInShareTheme = options.getOption("showLoginInShareTheme"); const showLoginInShareTheme = options.getOption("showLoginInShareTheme");
const opts = { const opts = {

View File

@ -15,13 +15,17 @@
// We are not the first child at this level so previous // We are not the first child at this level so previous
// should go to the end of the previous tree // should go to the end of the previous tree
let candidate = children[index - 1]; let candidate = children[index - 1];
while (candidate.hasVisibleChildren()) { while (candidate?.hasVisibleChildren()) {
const children = candidate.getVisibleChildNotes(); const visibleChildren = candidate.getVisibleChildNotes();
const lastChild = children[children.length - 1];
candidate = lastChild; if (visibleChildren.length === 0) {
break;
}
candidate = visibleChildren[visibleChildren.length - 1];
} }
return candidate; return candidate ?? null;
})(); })();
const nextNote = (() => { const nextNote = (() => {