import utils from '../../services/utils.js'; import server from '../../services/server.js'; import toastService from "../../services/toast.js"; import appContext from "../../components/app_context.js"; import libraryLoader from "../../services/library_loader.js"; import openService from "../../services/open.js"; import protectedSessionHolder from "../../services/protected_session_holder.js"; import BasicWidget from "../basic_widget.js"; import dialogService from "../../services/dialog.js"; const TPL = `
").text(fullNoteRevision.content)); } else if (revisionItem.type === 'image') { this.$content.html($("") // reason why we put this inline as base64 is that we do not want to let user to copy this // as a URL to be used in a note. Instead if they copy and paste it into a note, it will be a uploaded as a new note .attr("src", `data:${note.mime};base64,${fullNoteRevision.content}`) .css("max-width", "100%") .css("max-height", "100%")); } else if (revisionItem.type === 'file') { const $table = $("
").text("MIME: "), $(" | ").text(revisionItem.mime) )) .append($(" |
---|---|
").text("File size:"), $(" | ").text(`${revisionItem.contentLength} bytes`) )); if (fullNoteRevision.content) { $table.append($(" |
').append(
$(' ').text("Preview:"),
$('')
.text(fullNoteRevision.content)
)
));
}
this.$content.html($table);
}
else if (revisionItem.type === 'canvas') {
/**
* FIXME: We load a font called Virgil.wof2, which originates from excalidraw.com
* REMOVE external dependency!!!! This is defined in the svg in defs.style
*/
const content = fullNoteRevision.content;
try {
const data = JSON.parse(content)
const svg = data.svg || "no svg present."
/**
* maxWidth: 100% use full width of container but do not enlarge!
* height:auto to ensure that height scales with width
*/
const $svgHtml = $(svg).css({maxWidth: "100%", height: "auto"});
this.$content.html($(' ').append($svgHtml));
} catch(err) {
console.error("error parsing fullNoteRevision.content as JSON", fullNoteRevision.content, err);
this.$content.html($(" ").text("Error parsing content. Please check console.error() for more details."));
}
}
else {
this.$content.text("Preview isn't available for this note type.");
}
}
}
|