Guest User

Untitled

a guest
Aug 5th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 11.30 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4. <head>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6.     <link type="text/css" rel="stylesheet" href="css/note-ui.css" />
  7.     <script type="text/javascript" src="tinymce.min.js"></script>
  8.     <script type="text/javascript" src="locale.js"></script>
  9.  
  10.     <!-- katex start https://github.com/tinymce/tinymce/issues/3997 // http://fiddle.tinymce.com/ncgaab/2 -->
  11.     <link type="text/css" rel="stylesheet" href="css/katex.css" />
  12.     <script type="text/javascript" src="katex.js"></script>
  13.     <!-- katex end  -->
  14.  
  15.  
  16.     <script type="text/javascript">
  17.         // katex start
  18.         var katexannotationelem = document.getElementsByTagName("annotation");
  19.         var katexformula = [];
  20.         for (var i = 0; i < katexannotationelem.length; i++) {
  21.            katexformula[i] = katexannotationelem[i].childNodes[0].nodeValue;
  22.        }
  23.        var myNode = document.getElementsByClassName("tinymcekatex");
  24.        for (var i = 0; i < myNode.length; i++) {
  25.            while (myNode[i].firstChild) {
  26.                myNode[i].removeChild(myNode[i].firstChild);
  27.            }
  28.            myNode[i].appendChild(document.createElement("span").appendChild(document.createTextNode(katexformula[i])));
  29.            myNode[i].style.background = "#EEF";
  30.        }
  31.        //  katex end
  32.  
  33.  
  34.  
  35.        tinymce.init({
  36.            body_id: "zotero-tinymce-note",
  37.            content_css: "css/note-content.css",
  38.  
  39.            browser_spellcheck: true,
  40.            convert_urls: false,
  41.            entity_encoding: 'raw',
  42.            fix_list_elements: true,
  43.            paste_retain_style_properties: 'all',
  44.            paste_data_images: true,
  45.  
  46.            plugins: "autolink,code,contextmenu,directionality,link,lists,nonbreaking,paste,searchreplace,textcolor",
  47.  
  48.            toolbar1: "bold italic underline strikethrough | subscript superscript | forecolor backcolor | removeformat | blockquote link",
  49.            toolbar2: "formatselect | alignleft aligncenter alignright | bullist numlist outdent indent | %DIR% | searchreplace",
  50.            toolbar_items_size: 'small',
  51.            menubar: false,
  52.            resize: false,
  53.            statusbar: false,
  54.  
  55.            contextmenu: "cut copy paste | link | alignmentmenu | dir | code",
  56.            link_context_toolbar: true,
  57.            link_assume_external_targets: true,
  58.            nonbreaking_force_tab: 4,
  59.  
  60.            // More restrictive version of default set, with JS/etc. removed
  61.            valid_elements: "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang]," +
  62.                "a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class]," +
  63.                "strong/b," +
  64.                "em/i," +
  65.                "strike," +
  66.                "u," +
  67.                "#p," +
  68.                "-ol[type|compact]," +
  69.                "-ul[type|compact]," +
  70.                "-li," +
  71.                "br," +
  72.                "img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align]," +
  73.                "-sub,-sup," +
  74.                "-blockquote[cite]," +
  75.                "-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor]," +
  76.                "-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor]," +
  77.                "tbody,thead,tfoot," +
  78.                "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope]," +
  79.                "#th[colspan|rowspan|width|height|align|valign|scope]," +
  80.                "caption," +
  81.                "-div," +
  82.                "-span," +
  83.                "-code," +
  84.                "-pre," +
  85.                "address," +
  86.                "-h1,-h2,-h3,-h4,-h5,-h6," +
  87.                "hr[size|noshade]," +
  88.                "-font[face|size|color]," +
  89.                "dd,dl,dt," +
  90.                "cite," +
  91.                "abbr," +
  92.                "acronym," +
  93.                "del[datetime|cite],ins[datetime|cite]," +
  94.                "bdo," +
  95.                "col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width]," +
  96.                "dfn," +
  97.                "kbd," +
  98.                "label[for]," +
  99.                "legend," +
  100.                "q[cite]," +
  101.                "samp," +
  102.                "var,",
  103.  
  104.            target_list: false,
  105.  
  106.            setup: function (editor) {
  107.                setLocale(editor);
  108.  
  109.                // Add alignment submenu to context menu
  110.                editor.addMenuItem(
  111.                    'alignmentmenu', {
  112.                        icon: 'alignleft',
  113.                        text: 'Alignment',
  114.                        menu: [{
  115.                                icon: 'alignleft',
  116.                                text: 'Align Left',
  117.                                onclick: function () {
  118.                                    tinyMCE.execCommand('JustifyLeft');
  119.                                },
  120.                                context: 'insert'
  121.                            },
  122.                            {
  123.                                icon: 'aligncenter',
  124.                                text: 'Align Center',
  125.                                onclick: function () {
  126.                                    tinyMCE.execCommand('JustifyCenter');
  127.                                },
  128.                                context: 'insert'
  129.                            },
  130.                            {
  131.                                icon: 'alignright',
  132.                                text: 'Align Right',
  133.                                onclick: function () {
  134.                                    tinyMCE.execCommand('JustifyRight');
  135.                                },
  136.                                context: 'insert'
  137.                            },
  138.                            {
  139.                                icon: 'alignjustify',
  140.                                text: 'Justify',
  141.                                onclick: function () {
  142.                                    tinyMCE.execCommand('JustifyFull');
  143.                                },
  144.                                context: 'insert'
  145.                            },
  146.                            // katex start
  147.                            {
  148.                                icon: 'alignjustify',
  149.                                text: 'Latex',
  150.                                onclick: function () {
  151.                                    tinyremoved();
  152.                                },
  153.                                context: 'insert'
  154.                            }
  155.                            // katex end
  156.                        ]
  157.                    }
  158.                );
  159.  
  160.                // Add alignment split-button menu
  161.                //
  162.                // https://codepen.io/alangill/pen/oLJAOd
  163.                //
  164.                // Not currently used, but useful if we need more toolbar space
  165.                /*editor.addButton(
  166.                     'alignmentsplit', {
  167.                         type: 'splitbutton',
  168.                         text: '',
  169.                         icon: 'alignleft',
  170.                         onclick: function(e) {
  171.                             tinyMCE.execCommand(this.value);
  172.                         },
  173.                         menu: [
  174.                             {
  175.                                 icon: 'alignleft',
  176.                                 text: 'Align Left',
  177.                                 onclick: function() {
  178.                                 tinyMCE.execCommand('JustifyLeft');
  179.                                     this.parent().parent().icon('alignleft');
  180.                                     this.parent().parent().value = 'JustifyLeft';
  181.                                 }
  182.                             },
  183.                             {
  184.                                 icon: 'aligncenter',
  185.                                 text: 'Align Center',
  186.                                 onclick: function() {
  187.                                     tinyMCE.execCommand('JustifyCenter');
  188.                                     this.parent().parent().icon('aligncenter');
  189.                                     this.parent().parent().value = 'JustifyCenter';
  190.                                 }
  191.                             },
  192.                             {
  193.                                 icon: 'alignright',
  194.                                 text: 'Align Right',
  195.                                 onclick: function() {
  196.                                     tinyMCE.execCommand('JustifyRight');
  197.                                     this.parent().parent().icon('alignright');
  198.                                     this.parent().parent().value = 'JustifyRight';
  199.                                 }
  200.                             },
  201.                             {
  202.                                 icon: 'alignjustify',
  203.                                 text: 'Justify',
  204.                                 onclick: function() {
  205.                                     tinyMCE.execCommand('JustifyFull');
  206.                                     this.parent().parent().icon('alignjustify');
  207.                                     this.parent().parent().value = 'JustifyFull';
  208.                                 }
  209.                             }
  210.                         ],
  211.                         onPostRender: function() {
  212.                             // Select the first item by default
  213.                             this.value ='JustifyLeft';
  214.                         }
  215.                     }
  216.                );*/
  217.  
  218.                // Set text direction
  219.                var dir = window.location.href.match(/dir=(ltr|rtl)/)[1];
  220.                var opDir = dir.split("").reverse().join("");
  221.                editor.settings.directionality = dir;
  222.                editor.addMenuItem('dir', {
  223.                    icon: opDir,
  224.                    // TODO: Show correct label based on current line
  225.                    text: opDir == 'rtl' ? "Right to left" : "Left to right",
  226.                    onclick: function () {
  227.                        editor.execCommand('mceDirection' + opDir.toUpperCase());
  228.                    },
  229.                    context: 'insert',
  230.                    prependToContext: true
  231.                });
  232.            },
  233.  
  234.            init_instance_callback: function (editor) {
  235.                zoteroInit(editor);
  236.  
  237.                ['Change', 'KeyDown', 'KeyPress', 'Undo', 'Redo'].forEach(eventName =>
  238.                     editor.on(eventName, event => zoteroHandleEvent(event))
  239.                 );
  240.  
  241.                 ["Cut", "Copy", "Paste"].forEach(function (command) {
  242.                     let cmd = command;
  243.                     editor.addCommand(command, function (ui, value) {
  244.                         zoteroExecCommand(editor.getDoc(), cmd, ui, value);
  245.                     });
  246.                 });
  247.  
  248.                 ["ZoteroLinkClick"].forEach(function (command) {
  249.                     editor.addCommand(command, function (ui, value) {
  250.                         zoteroHandleEvent({
  251.                             type: command,
  252.                             value
  253.                         });
  254.                     });
  255.                 });
  256.             }
  257.         });
  258.         tinymce.execCommand("mceAddEditor", true, "tinymce");
  259.  
  260.         // katex start
  261.         function tinyremoved() {
  262.             var myNode = document.getElementsByClassName("tinymcekatex");
  263.             for (var i = 0; i < myNode.length; i++) {
  264.                myNode[i].style.background = "#FFF";
  265.                myNode[i].innerHTML = katex.renderToString(myNode[i].innerHTML);
  266.            }
  267.        }
  268.  
  269.        // katex end
  270.    </script>
  271. </head>
  272.  
  273. <body>
  274.     <div id="tinymce"></div>
  275. </body>
  276. <script>
  277.     // katex start
  278.     tinyremoved();
  279.     // katex end
  280. </script>
  281.  
  282. </html>
Add Comment
Please, Sign In to add comment