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(fullRevision.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 copy this
                // as a URL to be used in a note. Instead, if they copy and paste it into a note, it will be an uploaded as a new note
                .attr("src", `data:${fullRevision.mime};base64,${fullRevision.content}`)
                .css("max-width", "100%")
                .css("max-height", "100%"));
        } else if (revisionItem.type === 'file') {
            const $table = $("
")
                // reason why we put this inline as base64 is that we do not want to let user copy this
                // as a URL to be used in a note. Instead, if they copy and paste it into a note, it will be an uploaded as a new note
                .attr("src", `data:${fullRevision.mime};base64,${fullRevision.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 (fullRevision.content) { $table.append($(" | 
| ').append(
                        $(' ').text("Preview:"),
                        $('')
                            .text(fullRevision.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 = fullRevision.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 fullRevision.content as JSON", fullRevision.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.");
        }
    }
}
 | |