From d41beb0df501c214bf567e7336d34e651e5aad0a Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 13 Mar 2018 20:16:05 +0100 Subject: [PATCH] clone: copy all classes from target widget (fixes #219); apply target's default size if there's one; --- CHANGELOG.md | 1 + src/browser/js/app/widgets/containers/clone.js | 13 +++++++++---- src/browser/scss/widgets/_panel.scss | 9 +++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f76e9762..742305a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - strip: nested strips were inheriting their parent's `spacing` - modal: prevent error when retrieving a child's property - modal: prevent touch event from affecting elements behind the popup when closing it + - clone: some properies in target widget were not applied to the clone - text: vertical centering issues in narrow widgets - editor - wrap in: insert wrapper at selected widget's index diff --git a/src/browser/js/app/widgets/containers/clone.js b/src/browser/js/app/widgets/containers/clone.js index 5e32322e..c6ec50e8 100644 --- a/src/browser/js/app/widgets/containers/clone.js +++ b/src/browser/js/app/widgets/containers/clone.js @@ -42,8 +42,10 @@ module.exports = class Clone extends Widget { this.cloneLock = false this.cloneTarget = null - this.cloneClass = '_' + this.cloneClass = [] + this.container.classList.add('empty') + this.getCloneTarget() if (this.cloneTarget) this.createClone() @@ -102,7 +104,9 @@ module.exports = class Clone extends Widget { widgetManager.removeWidgets(this.childrenHashes) this.widget.innerHTML = '' this.childrenHashes = [] - this.container.classList.remove(this.cloneClass) + this.container.classList.remove(...this.cloneClass) + this.container.classList.add('clone-container', 'empty') + this.cloneClass = [] } @@ -113,8 +117,9 @@ module.exports = class Clone extends Widget { this.cleanClone() - this.cloneClass = this.cloneTarget.container.getAttribute('class').match(/[^\s]*-container/)[0] - this.container.classList.add(this.cloneClass) + this.cloneClass = this.cloneTarget.container.classList + this.container.classList.remove('empty') + this.container.classList.add(...this.cloneClass) parser.parse([{...Widget.deepCopy(this.cloneTarget.props), ...this.getProp('props')}], this.widget, this) diff --git a/src/browser/scss/widgets/_panel.scss b/src/browser/scss/widgets/_panel.scss index 9c236a75..60ac2e41 100644 --- a/src/browser/scss/widgets/_panel.scss +++ b/src/browser/scss/widgets/_panel.scss @@ -292,11 +292,16 @@ } .clone-container { - width: 100rem; - height: 100rem; + + &.empty { + width: 100rem; + height: 100rem; + } + > .label { display: none; } + .clone { position: relative; height: 100%;