From 2f11426ba4737f0b6f17346b85ed1e02f2698678 Mon Sep 17 00:00:00 2001 From: bordun Date: Thu, 23 Aug 2018 15:15:35 +0200 Subject: [PATCH] editor: undo/redo: compute path intersection to make sure all widgets are updated --- src/browser/js/app/editor/index.js | 39 ++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/browser/js/app/editor/index.js b/src/browser/js/app/editor/index.js index ea77dfa7..006c4d68 100644 --- a/src/browser/js/app/editor/index.js +++ b/src/browser/js/app/editor/index.js @@ -544,10 +544,11 @@ var Editor = class Editor { } if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w, {preventSelect: this.selectedWidgets.length > 1})) - this.pushHistory() } + this.pushHistory() + if (newWidgets.length > 1) this.select(newWidgets, {preventSelect: this.selectedWidgets.length > 1}) } @@ -572,10 +573,11 @@ var Editor = class Editor { } newWidgets.push(updateWidget(w, {preventSelect: this.selectedWidgets.length > 1})) - this.pushHistory() } + this.pushHistory() + if (newWidgets.length > 1) this.select(newWidgets) } @@ -625,6 +627,23 @@ var Editor = class Editor { if (!path || path.length > d1[i].path.length) path = d1[i].path } + if (d1.length > 1) { + // path intersection + var stop, j, k, n + for (j = 0; j < path.length; j++) { + for (k = 0; k < d1.length; k++) { + if (d1[k].path[j] !== path[j]) { + stop = true + break + } + } + if (stop) break + } + n = stop ? j : j - 1 + path.splice(n, path.length - n) + } + + this.updateWidgetByPath(path) } @@ -643,6 +662,22 @@ var Editor = class Editor { if (!path || path.length > d1[i].path.length) path = d1[i].path } + if (d1.length > 1) { + // path intersection + var stop, j, k, n + for (j = 0; j < path.length; j++) { + for (k = 0; k < d1.length; k++) { + if (d1[k].path[j] !== path[j]) { + stop = true + break + } + } + if (stop) break + } + n = stop ? j : j - 1 + path.splice(n, path.length - n) + } + this.updateWidgetByPath(path) this.historyState -= 1