diff --git a/bower.json b/bower.json index 0fd5b7f8..72c63759 100644 --- a/bower.json +++ b/bower.json @@ -28,6 +28,7 @@ "MutationObservers": "https://github.com/Polymer/MutationObservers.git#~0.2.1", "rangy": "~1.2.3", "google-diff-match-patch-js": "~1.0.0", - "jsondiffpatch": "~0.1.5" + "jsondiffpatch": "~0.1.5", + "hammerjs": "~1.0.10" } } diff --git a/public/index.html b/public/index.html index 0af97050..040af595 100644 --- a/public/index.html +++ b/public/index.html @@ -9,7 +9,7 @@ - + diff --git a/public/res/editor.js b/public/res/editor.js index 5abd8915..a8c18c93 100644 --- a/public/res/editor.js +++ b/public/res/editor.js @@ -62,7 +62,7 @@ define([ fileDesc = selectedFileDesc; }); - // Watcher used to detect editor changes + // Used to detect editor changes function Watcher() { this.isWatching = false; var contentObserver; @@ -212,9 +212,6 @@ define([ }; })(); this.getCoordinates = function(inputOffset, container, offset) { - if(inputOffset === textContent.length) { - return this.getCoordinates(inputOffset - 1); - } if(!container) { offset = this.findOffset(inputOffset); container = offset.container; @@ -485,6 +482,8 @@ define([ this.currentMode = undefined; lastMode = undefined; contentElt.textContent = content; + // Force this since the content could be the same + checkContentChange(); }; } var undoMgr = new UndoMgr(); @@ -503,12 +502,20 @@ define([ var trailingLfNode; function checkContentChange() { var newTextContent = inputElt.textContent; - if(contentElt.lastChild === trailingLfNode && trailingLfNode.textContent.slice(-1) === '\n') { + if(contentElt.lastChild === trailingLfNode && trailingLfNode.textContent.slice(-1) == '\n') { newTextContent = newTextContent.slice(0, -1); } if(fileChanged === false) { - if(contentElt.children.length && newTextContent == textContent) { + if(newTextContent == textContent) { + // User has removed the empty section + if(contentElt.children.length === 0) { + contentElt.innerHTML = ''; + sectionList.forEach(function(section) { + contentElt.appendChild(section.elt); + }); + addTrailingLfNode(); + } return; } undoMgr.currentMode = undoMgr.currentMode || 'typing'; @@ -609,6 +616,15 @@ define([ fileDesc.previewScrollTop = previewElt.scrollTop; } }); + + // See https://gist.github.com/shimondoodkin/1081133 + if(/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)) { + var $editableFix = $('').appendTo('html'); + $contentElt.blur(function () { + $editableFix[0].setSelectionRange(0, 0); + $editableFix.blur(); + }); + } inputElt.focus = focus; @@ -704,10 +720,8 @@ define([ actions[action](state, options); setValue(state.before + state.selection + state.after); - _.defer(function() { - selectionMgr.setSelectionStartEnd(state.selectionStart, state.selectionEnd); - //$inputElt.trigger('input'); - }); + selectionMgr.setSelectionStartEnd(state.selectionStart, state.selectionEnd); + }; var actions = { @@ -873,12 +887,19 @@ define([ childNode = nextNode; } } - trailingLfNode = document.createTextNode('\n'); - contentElt.appendChild(trailingLfNode); + addTrailingLfNode(); selectionMgr.setSelectionStartEnd(); }); } + function addTrailingLfNode() { + trailingLfNode = crel('span', { + class: 'token lf', + }); + trailingLfNode.textContent = '\n'; + contentElt.appendChild(trailingLfNode); + } + var escape = (function() { var entityMap = { "&": "&", diff --git a/public/res/extensions/buttonPublish.js b/public/res/extensions/buttonPublish.js index b7e78275..e67a86f5 100644 --- a/public/res/extensions/buttonPublish.js +++ b/public/res/extensions/buttonPublish.js @@ -73,9 +73,13 @@ define([ checkPublication(); }; + buttonPublish.onReady = function() { + $(".action-update-publication").click(publisher.publish); + }; + buttonPublish.onPublishRemoved = checkPublication; buttonPublish.onNewPublishSuccess = checkPublication; return buttonPublish; -}); \ No newline at end of file +}); diff --git a/public/res/extensions/buttonSync.js b/public/res/extensions/buttonSync.js index bd0cc05b..cdcf9314 100644 --- a/public/res/extensions/buttonSync.js +++ b/public/res/extensions/buttonSync.js @@ -87,14 +87,17 @@ define([ isOffline = isOfflineParameter; updateButtonState(); }; - + buttonSync.onReady = function() { mousetrap.bind(buttonSync.config.syncShortcut, function(e) { synchronizer.sync() && (lastSync = utils.currentTime); e.preventDefault(); }); + $(".action-force-synchronization").click(function() { + synchronizer.sync() && (lastSync = utils.currentTime); + }); }; return buttonSync; -}); \ No newline at end of file +}); diff --git a/public/res/extensions/dialogManageSynchronization.js b/public/res/extensions/dialogManageSynchronization.js index 7523108c..dbd5da2a 100644 --- a/public/res/extensions/dialogManageSynchronization.js +++ b/public/res/extensions/dialogManageSynchronization.js @@ -21,6 +21,7 @@ define([ var syncListElt; var $msgSyncListElt; var $msgNoSyncElt; + var $showAlreadySynchronizedElt; var refreshDialog = function(fileDescParameter) { if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) { return; @@ -35,6 +36,8 @@ define([ $msgNoSyncElt.removeClass("hide"); } + $showAlreadySynchronizedElt.toggleClass("hide", _.size(fileDesc.syncLocations) === 0); + var syncListHtml = _.reduce(fileDesc.syncLocations, function(result, syncAttributes) { return result + _.template(dialogManageSynchronizationLocationHTML, { syncAttributes: syncAttributes, @@ -66,6 +69,8 @@ define([ syncListElt = modalElt.querySelector(".sync-list"); $msgSyncListElt = $(modalElt.querySelectorAll(".msg-sync-list")); $msgNoSyncElt = $(modalElt.querySelectorAll(".msg-no-sync")); + + $showAlreadySynchronizedElt = $(document.querySelectorAll(".show-already-synchronized")); }; return dialogManageSynchronization; diff --git a/public/res/extensions/shortcutsDefaultMapping.js b/public/res/extensions/shortcutsDefaultMapping.js index 1c20c4f4..f526d1d9 100644 --- a/public/res/extensions/shortcutsDefaultMapping.js +++ b/public/res/extensions/shortcutsDefaultMapping.js @@ -12,7 +12,7 @@ 'mod+z': bindPagedownButton('undo'), 'mod+y': bindPagedownButton('redo'), 'mod+shift+z': bindPagedownButton('redo'), - 'mod+p': function(evt) { + 'mod+d': function(evt) { $('.button-open-discussion').click(); evt.preventDefault(); }, diff --git a/public/res/html/bodyIndex.html b/public/res/html/bodyIndex.html index 78f2ef89..12b18569 100644 --- a/public/res/html/bodyIndex.html +++ b/public/res/html/bodyIndex.html @@ -74,18 +74,25 @@
+ - StackEdit Viewer + class="list-group-item"> + StackEdit Viewer +
-
+ Synchronize... + class="list-group-item"> +
Synchronize
+ Backup, collaborate in the cloud + Publish... + class="list-group-item"> +
Publish
+ Export on the web + - Sharing links + class="action-reset-input list-group-item"> +
Sharing
+ Share document links + +
+
+ Export to disk -
- -
- Open from - Dropbox - Open from - Google Drive - Open from - Google Drive (2nd account) - Open from - Google Drive (3rd account) +