MathJax WMD-уценка обновляется только при альтернативных нажатиях клавиш

Я пытаюсь заставить MatJax и Markdown работать вместе, используя почти стандартный код, я смог заставить его работать, но теперь я столкнулся со странной проблемой. Мой предварительный просмотр ОМУ обновляется только при альтернативных нажатиях клавиш...!!

Javascript для инициации ОМУ является следующим

Preview.Init();

    (function() {
        var converter1 = Markdown.getSanitizingConverter();
        var editor1 = new Markdown.Editor(converter1);
        converter1.hooks.chain("postConversion", function(text) {   
            Preview.CreatePreview();
            return text; 
        });
        editor1.hooks.set("insertImageDialog", function(callback) {
            setTimeout(function() {
                $('#uploadmodal').modal({
                    keyboard : true,
                    backdrop:false
                });
                fileCallback = callback
            }, 500);
            return true; // tell the editor that we'll take care of getting the image url
        });
        editor1.run();
    })();

а также

Интеграция MathJAX осуществляется с помощью следующего кода

var Preview = {
          delay: 150,        // delay after keystroke before updating

          preview: null,     // filled in by Init below
          buffer: null,      // filled in by Init below

          timeout: null,     // store setTimout id
          mjRunning: false,  // true when MathJax is processing
          oldText: null,     // used to check if an update is needed

          Init: function () {
            this.preview = document.getElementById("wmd-preview");
            this.buffer =   document.getElementById("MathBuffer");
          },

          SwapBuffers: function () {
            var buffer = this.preview, preview = this.buffer;
            this.buffer = buffer; this.preview = preview;
            buffer.style.visibility = "hidden"; buffer.style.position = "absolute";
            preview.style.position = ""; preview.style.visibility = "";
          },
          Update: function () {
            if (this.timeout) {clearTimeout(this.timeout)}
            this.timeout = setTimeout(this.callback,this.delay);
          },

          CreatePreview: function () {
            Preview.timeout = null;
            if (this.mjRunning) return;
            var text = document.getElementById("wmd-preview").innerHTML;
            if (text === this.oldtext) return;
            this.buffer.innerHTML = this.oldtext = text;
            this.mjRunning = true;
            MathJax.Hub.Queue(
              ["Typeset",MathJax.Hub,this.buffer],
              ["PreviewDone",this]
            );
          },
          PreviewDone: function () {
            this.mjRunning = false;
            this.SwapBuffers();
          }

        };

Здесь есть демонстрационная страница проблемы http://easytha.com/question/demoQuestion

0 ответов

Другие вопросы по тегам