From 7bcb24df0d13283d0d3ada0da79fb140cd6734f7 Mon Sep 17 00:00:00 2001 From: benweet Date: Mon, 16 Sep 2013 01:03:17 +0100 Subject: [PATCH] Fix partial rendering --- cache.manifest | 2 +- res-min/main.js | 82 +++++++++++++++--------------- res/core.js | 17 +++---- res/extensions/partialRendering.js | 8 +-- res/extensions/welcomeTour.js | 2 +- 5 files changed, 55 insertions(+), 56 deletions(-) diff --git a/cache.manifest b/cache.manifest index dbed9bb1..02e72ea7 100644 --- a/cache.manifest +++ b/cache.manifest @@ -1,5 +1,5 @@ CACHE MANIFEST -#Date Sun Sep 15 2013 22:11:18 +#Date Mon Sep 16 2013 01:02:30 CACHE: index.html diff --git a/res-min/main.js b/res-min/main.js index 94d07a1b..12ee89de 100644 --- a/res-min/main.js +++ b/res-min/main.js @@ -12079,14 +12079,13 @@ define("config", function() {}), define("storage", [ "underscore", "utils" ], fu return n >= t.length || e.text != t[n].text ? (i = n, !0) : void 0; }); var o = -c.length; - if (e.some(c.slice().reverse(), function(e, n) { + e.some(c.slice().reverse(), function(e, n) { return n >= t.length || e.text != t[t.length - n - 1].text ? (o = -n, !0) : void 0; - }), 0 === i || 0 !== i + o) { - var r = c.slice(0, i); - h = t.slice(i, t.length + o); - var s = c.slice(c.length + o, c.length); - p = e.first(s), d = c.slice(i, c.length + o), c = r.concat(h).concat(s); - } + }), i - o > c.length && (o = i - c.length); + var r = c.slice(0, i); + h = t.slice(i, t.length + o); + var s = c.slice(c.length + o, c.length); + p = e.first(s), d = c.slice(i, c.length + o), c = r.concat(h).concat(s); } function r() { e.each(d, function(e) { @@ -19204,7 +19203,7 @@ if (hljs.LANGUAGES.glsl = function(e) { element: ".navbar .action-create-file", title: "New document", content: "Click the New document button to create a new document.", - placement: "bottom", + placement: "left", reflex: !0 }, { element: ".document-panel .collapse-button", @@ -23120,7 +23119,7 @@ if (hljs.LANGUAGES.glsl = function(e) { } function a() { var e = O.val(); - e = d.makeHtml(e), h.html(e), p.onPreviewRefresh(); + e = h.makeHtml(e), p.html(e), f.onPreviewRefresh(); } void 0 !== z && s.onFileClosed(z), z = n, j = void 0; var l = z.content; @@ -23130,46 +23129,47 @@ if (hljs.LANGUAGES.glsl = function(e) { var c = e(".preview-container"); if (!lightMode) { var u = t.debounce(function() { - z.editorScrollTop = I.renderer.getScrollTop(); + void 0 !== j && (z.editorScrollTop = I.renderer.getScrollTop()); }, 100); - I.session.on("changeScrollTop", function() { - void 0 !== j && u(); - }), I.session.selection.on("changeCursor", function() { - void 0 !== j && (console.log("changeCursor"), z.editorSelectRange = I.getSelectionRange()); - }), c.scroll(function() { + I.session.on("changeScrollTop", u); + var d = t.debounce(function() { + void 0 !== j && (z.editorSelectRange = I.getSelectionRange()); + }, 100); + I.session.selection.on("changeSelection", d), I.session.selection.on("changeCursor", d), + c.scroll(function() { void 0 !== j && (z.previewScrollTop = c.scrollTop()); }); } - var d = new Markdown.Converter(); - if (d.hooks.chain("preConversion", function(e) { + var h = new Markdown.Converter(); + if (h.hooks.chain("preConversion", function(e) { s.previewStartTime = new Date(); var t = e + "\n\n", n = [], i = 0; return t.replace(/^```.*\n[\s\S]*?\n```|(^.+[ \t]*\n=+[ \t]*\n+|^.+[ \t]*\n-+[ \t]*\n+|^\#{1,6}[ \t]*.+?[ \t]*\#*\n+)/gm, function(e, o, r) { return o && (n.push(t.substring(i, r)), i = r), ""; }), n.push(t.substring(i, e.length)), s.onSectionsCreated(n), e; }), lightMode) { - var h = e("#wmd-preview"), p = new Markdown.HookCollection(); - p.addNoop("onPreviewRefresh"); - var f = t.debounce(a, 1e3), g = function() { - void 0 === j ? (a(), s.onFileOpen(z)) : f(), i(); + var p = e("#wmd-preview"), f = new Markdown.HookCollection(); + f.addNoop("onPreviewRefresh"); + var g = t.debounce(a, 1e3), m = function() { + void 0 === j ? (a(), s.onFileOpen(z)) : g(), i(); }; - O.on("input propertychange", g), N = { - hooks: p, + O.on("input propertychange", m), N = { + hooks: f, getConverter: function() { - return d; + return h; }, - run: g, - refreshPreview: g + run: m, + refreshPreview: m }; - } else N = new Markdown.Editor(d), N.hooks.set("insertLinkDialog", function(t) { + } else N = new Markdown.Editor(h), N.hooks.set("insertLinkDialog", function(t) { return E.insertLinkCallback = t, o.resetModalInputs(), e(".modal-insert-link").modal(), !0; }), N.hooks.set("insertImageDialog", function(t) { return E.insertLinkCallback = t, E.catchModal ? !0 : (o.resetModalInputs(), e(".modal-insert-image").modal(), !0); }); - var g; - g = r.lazyRendering === !0 ? function(e) { + var m; + m = r.lazyRendering === !0 ? function(e) { var n = t.debounce(e, 500); return function() { void 0 === j ? (e(), c.scrollTop(z.previewScrollTop), t.defer(function() { @@ -23183,19 +23183,19 @@ if (hljs.LANGUAGES.glsl = function(e) { })), i(); }; }, s.onPagedownConfigure(N), N.hooks.chain("onPreviewRefresh", s.onAsyncPreview), - N.run(I, g), I && I.selection.setSelectionRange(z.editorSelectRange), I && I.focus() || O.focus(), + N.run(I, m), I && I.selection.setSelectionRange(z.editorSelectRange), I && I.focus() || O.focus(), e(".wmd-button-row li").addClass("btn btn-success").css("left", 0).find("span").hide(); - var m = e(".wmd-button-group1"); - e("#wmd-bold-button").append(e('')).appendTo(m), e("#wmd-italic-button").append(e('')).appendTo(m); - var m = e(".wmd-button-group2"); - e("#wmd-link-button").append(e('')).appendTo(m), e("#wmd-quote-button").append(e('')).appendTo(m), - e("#wmd-code-button").append(e('')).appendTo(m), e("#wmd-image-button").append(e('')).appendTo(m); - var m = e(".wmd-button-group3"); - e("#wmd-olist-button").append(e('')).appendTo(m), - e("#wmd-ulist-button").append(e('')).appendTo(m), e("#wmd-heading-button").append(e('')).appendTo(m), - e("#wmd-hr-button").append(e('')).appendTo(m); - var m = e(".wmd-button-group4"); - e("#wmd-undo-button").append(e('')).appendTo(m), e("#wmd-redo-button").append(e('')).appendTo(m); + var v = e(".wmd-button-group1"); + e("#wmd-bold-button").append(e('')).appendTo(v), e("#wmd-italic-button").append(e('')).appendTo(v); + var v = e(".wmd-button-group2"); + e("#wmd-link-button").append(e('')).appendTo(v), e("#wmd-quote-button").append(e('')).appendTo(v), + e("#wmd-code-button").append(e('')).appendTo(v), e("#wmd-image-button").append(e('')).appendTo(v); + var v = e(".wmd-button-group3"); + e("#wmd-olist-button").append(e('')).appendTo(v), + e("#wmd-ulist-button").append(e('')).appendTo(v), e("#wmd-heading-button").append(e('')).appendTo(v), + e("#wmd-hr-button").append(e('')).appendTo(v); + var v = e(".wmd-button-group4"); + e("#wmd-undo-button").append(e('')).appendTo(v), e("#wmd-redo-button").append(e('')).appendTo(v); }; var q = !1, W = !1; return E.onReady = function() { diff --git a/res/core.js b/res/core.js index 02384997..43825e84 100644 --- a/res/core.js +++ b/res/core.js @@ -411,21 +411,20 @@ define([ if(!lightMode) { // Store editor scrollTop on scroll event - var debouncedUpdateScroll = _.debounce(function() { - fileDesc.editorScrollTop = aceEditor.renderer.getScrollTop(); - }, 100); - aceEditor.session.on('changeScrollTop', function() { + var saveScroll = _.debounce(function() { if(documentContent !== undefined) { - debouncedUpdateScroll(); + fileDesc.editorScrollTop = aceEditor.renderer.getScrollTop(); } - }); + }, 100); + aceEditor.session.on('changeScrollTop', saveScroll); // Store editor selection on change - aceEditor.session.selection.on('changeCursor', function() { + var saveSelection = _.debounce(function() { if(documentContent !== undefined) { - console.log('changeCursor'); fileDesc.editorSelectRange = aceEditor.getSelectionRange(); } - }); + }, 100); + aceEditor.session.selection.on('changeSelection', saveSelection); + aceEditor.session.selection.on('changeCursor', saveSelection); // Store preview scrollTop on scroll event $previewContainerElt.scroll(function() { if(documentContent !== undefined) { diff --git a/res/extensions/partialRendering.js b/res/extensions/partialRendering.js index c8cdc11e..d2e1b4eb 100644 --- a/res/extensions/partialRendering.js +++ b/res/extensions/partialRendering.js @@ -39,7 +39,7 @@ define([ return true; } }); - + // Find modified section starting from bottom var rightIndex = -sectionList.length; _.some(sectionList.slice().reverse(), function(section, index) { @@ -49,9 +49,9 @@ define([ } }); - if(leftIndex !== 0 && leftIndex + rightIndex === 0) { - // nothing changed - return; + if(leftIndex - rightIndex > sectionList.length) { + // Prevent overlap + rightIndex = leftIndex - sectionList.length; } // Create an array composed of left unmodified, modified, right diff --git a/res/extensions/welcomeTour.js b/res/extensions/welcomeTour.js index 3045a977..9fb99080 100644 --- a/res/extensions/welcomeTour.js +++ b/res/extensions/welcomeTour.js @@ -42,7 +42,7 @@ define([ element: ".navbar .action-create-file", title: "New document", content: "Click the New document button to create a new document.", - placement: "bottom", + placement: "left", reflex: true, }, {