editor.md icon indicating copy to clipboard operation
editor.md copied to clipboard

export PDF

Open tmxdyf opened this issue 5 years ago • 1 comments

Unfortunately cannot export PDF

tmxdyf avatar Dec 24 '19 10:12 tmxdyf

May help somebody out there but if EditorMD is used as a component in an application using NW.js or similar then it is quite easy to implement as a toolbar button.

Code:

        toolbarIconsClass    : {
            undo             : "fa-undo",

            ...

            "print-preview"  : "fa-print"
        },        

        lang : {
            name : "en",
            description : "Open source online Markdown editor.",
            tocTitle    : "Table of Contents",
            toolbar : {
                undo             : "Undo(Ctrl+Z)",
                
                ...

                "print-preview"  : "fa-print"
            },



    editormd.toolbarHandlers = {

    ...

        "print-preview" : function() {

            var content = this.preview[0].outerHTML;

            var printWindow = window.open('', '_blank');
    //        printWindow.document.write('<html><head>' + tryadonkey + '</head><body>');
            printWindow.document.write('<html><head><link rel="stylesheet" type="text/css" href="../../components/resources/thirdparty/editormd/css/editormd.css"></head><body>');
            printWindow.document.write(content);
            printWindow.document.write('</body></html>');
            printWindow.document.close();
            printWindow.print();
        } 
    }

    Note: tryadonkey is CSS within <style> tags which worked OK - couldn't get the style link rel to work tho'.



            var hippoeditor = editormd("hippoeditor", {
                ...
                toolbarIcons : function() {
                    return ["undo", ... ,"print-preview"]
                }

            });

printdialog

toolbar

Blatman avatar Mar 01 '24 12:03 Blatman