From e1ab1cbca8d01fc4f4778a3168ab7c0797448159 Mon Sep 17 00:00:00 2001 From: benweet Date: Sat, 20 Jul 2013 13:19:43 +0100 Subject: [PATCH] Fixed pagedown button to trigger realtime synchronization --- js/core.js | 29 ++++++++++++----------------- js/libs/Markdown.Editor.js | 1 + js/providers/gdriveProvider.js | 17 ++++++----------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/js/core.js b/js/core.js index 9b141957..d5d2b1b2 100644 --- a/js/core.js +++ b/js/core.js @@ -316,23 +316,18 @@ define([ $(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)").addClass("btn").css("left", 0).find("span").hide(); // Add customized buttons - $("#wmd-bold-button").append($("").addClass("icon-bold")); - $("#wmd-italic-button").append($("").addClass("icon-italic")); - $("#wmd-link-button").append($("").addClass("icon-globe")); - $("#wmd-quote-button").append($("").addClass("icon-indent-left")); - $("#wmd-code-button").append($("").addClass("icon-code")); - $("#wmd-image-button").append($("").addClass("icon-picture")); - $("#wmd-olist-button").append($("").addClass("icon-numbered-list")); - $("#wmd-ulist-button").append($("").addClass("icon-list")); - $("#wmd-heading-button").append($("").addClass("icon-text-height")); - $("#wmd-hr-button").append($("").addClass("icon-hr")); - // Create additional undo/redo button for real time synchronization - var realtimeUndoButton = $('
  • '); - realtimeUndoButton.append($("").addClass("icon-undo")); - $("#wmd-undo-button").append($("").addClass("icon-undo")).after(realtimeUndoButton); - var realtimeRedoButton = $('
  • '); - realtimeRedoButton.append($("").addClass("icon-share-alt")); - $("#wmd-redo-button").append($("").addClass("icon-share-alt")).after(realtimeRedoButton); + $("#wmd-bold-button").append($('')); + $("#wmd-italic-button").append($('')); + $("#wmd-link-button").append($('')); + $("#wmd-quote-button").append($('')); + $("#wmd-code-button").append($('')); + $("#wmd-image-button").append($('')); + $("#wmd-olist-button").append($('')); + $("#wmd-ulist-button").append($('')); + $("#wmd-heading-button").append($('')); + $("#wmd-hr-button").append($('')); + $("#wmd-undo-button").append($('')); + $("#wmd-redo-button").append($('')); extensionMgr.onFileOpen(fileDesc); }; diff --git a/js/libs/Markdown.Editor.js b/js/libs/Markdown.Editor.js index 98d02e10..11bcc932 100644 --- a/js/libs/Markdown.Editor.js +++ b/js/libs/Markdown.Editor.js @@ -1397,6 +1397,7 @@ if (!noCleanup) { fixupInputArea(); + inputBox.dispatchEvent(new Event('input')); } } diff --git a/js/providers/gdriveProvider.js b/js/providers/gdriveProvider.js index deb9bc39..c0c236c7 100644 --- a/js/providers/gdriveProvider.js +++ b/js/providers/gdriveProvider.js @@ -287,20 +287,19 @@ define([ string.addEventListener(gapi.drive.realtime.EventType.TEXT_DELETED, debouncedRefreshPreview); debouncedRefreshPreview(); - // Add event handler for UndoRedoStateChanged events. + // Save undo/redo buttons actions undoExecute = editor.uiManager.buttons.undo.execute; redoExecute = editor.uiManager.buttons.redo.execute; - -// var undoButton = $('#wmd-undo-button-realtime').removeClass("hide"); -// var redoButton = $('#wmd-redo-button-realtime').removeClass("hide"); -// $('#wmd-undo-button').addClass("hide"); -// $('#wmd-redo-button').addClass("hide"); + + // Set new actions for undo/redo buttons editor.uiManager.buttons.undo.execute = function() { model.canUndo && model.undo(); }; editor.uiManager.buttons.redo.execute = function() { model.canRedo && model.redo(); }; + + // Add event handler for UndoRedoStateChanged events. function setUndoRedoState() { editor.uiManager.setButtonState(editor.uiManager.buttons.undo, model.canUndo); editor.uiManager.setButtonState(editor.uiManager.buttons.redo, model.canRedo); @@ -326,14 +325,10 @@ define([ realtimeDocument = undefined; } + // Set back original undo/redo actions editor.uiManager.buttons.undo.execute = undoExecute; editor.uiManager.buttons.redo.execute = redoExecute; editor.uiManager.setUndoRedoButtonStates(); - -// $('#wmd-undo-button-realtime').off('click').addClass("hide"); -// $('#wmd-redo-button-realtime').off('click').addClass("hide"); -// $('#wmd-undo-button').removeClass("hide"); -// $('#wmd-redo-button').removeClass("hide"); }; core.onReady(function() {