mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes in opml export and note content loading
This commit is contained in:
parent
6be8a3f343
commit
8aa7e2d0a0
@ -67,6 +67,10 @@ class Note extends Entity {
|
|||||||
if (!this.noteContent) {
|
if (!this.noteContent) {
|
||||||
throw new Error("Note content not found for noteId=" + this.noteId);
|
throw new Error("Note content not found for noteId=" + this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isStringNote()) {
|
||||||
|
this.noteContent.content = this.noteContent.content.toString("UTF-8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.noteContent;
|
return this.noteContent;
|
||||||
@ -126,6 +130,11 @@ class Note extends Entity {
|
|||||||
return (this.type === "code" || this.type === "file" || this.type === "render") && this.mime === "text/html";
|
return (this.type === "code" || this.type === "file" || this.type === "render") && this.mime === "text/html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {boolean} true if the note has string content (not binary) */
|
||||||
|
isStringNote() {
|
||||||
|
return ["text", "code", "relation-map"].includes(this.type) || this.mime.startsWith('text/');
|
||||||
|
}
|
||||||
|
|
||||||
/** @returns {string} JS script environment - either "frontend" or "backend" */
|
/** @returns {string} JS script environment - either "frontend" or "backend" */
|
||||||
getScriptEnv() {
|
getScriptEnv() {
|
||||||
if (this.isHtml() || (this.isJavaScript() && this.mime.endsWith('env=frontend'))) {
|
if (this.isHtml() || (this.isJavaScript() && this.mime.endsWith('env=frontend'))) {
|
||||||
|
@ -21,6 +21,7 @@ let exportId = '';
|
|||||||
async function showDialog(defaultType) {
|
async function showDialog(defaultType) {
|
||||||
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
|
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
|
||||||
exportId = '';
|
exportId = '';
|
||||||
|
$exportButton.removeAttr("disabled");
|
||||||
$exportNoteCountWrapper.hide();
|
$exportNoteCountWrapper.hide();
|
||||||
$exportNoteCount.text('0');
|
$exportNoteCount.text('0');
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ async function showDialog(defaultType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form.submit(() => {
|
$form.submit(() => {
|
||||||
|
// disabling so export can't be triggered again
|
||||||
$exportButton.attr("disabled", "disabled");
|
$exportButton.attr("disabled", "disabled");
|
||||||
|
|
||||||
const exportType = $dialog.find("input[name='export-type']:checked").val();
|
const exportType = $dialog.find("input[name='export-type']:checked").val();
|
||||||
|
@ -12,11 +12,9 @@ async function getNote(req) {
|
|||||||
return [404, "Note " + noteId + " has not been found."];
|
return [404, "Note " + noteId + " has not been found."];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["text", "code", "relation-map"].includes(note.type) || note.mime.startsWith('text/')) {
|
if (note.isStringNote()) {
|
||||||
const noteContent = await note.getNoteContent();
|
const noteContent = await note.getNoteContent();
|
||||||
|
|
||||||
noteContent.content = noteContent.content.toString("UTF-8");
|
|
||||||
|
|
||||||
if (note.type === 'file') {
|
if (note.type === 'file') {
|
||||||
noteContent.content = noteContent.content.substr(0, 10000);
|
noteContent.content = noteContent.content.substr(0, 10000);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ async function exportToOpml(exportContext, branch, res) {
|
|||||||
const branch = await repository.getBranch(branchId);
|
const branch = await repository.getBranch(branchId);
|
||||||
const note = await branch.getNote();
|
const note = await branch.getNote();
|
||||||
|
|
||||||
if (await note.hasLabel('excludeFromExport')) {
|
if (!note.isStringNote() || await note.hasLabel('excludeFromExport')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user