diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f9f4f3e..86a3d7f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
- editor
- allow multi widget resizing/dragging
- tweaked ctrl+click/right-click selection behaviors
+ - **new** "Wrap in" context menu
## 0.25.0
diff --git a/src/browser/js/app/editor/context-menu.js b/src/browser/js/app/editor/context-menu.js
index caa33711..9a4f7e19 100644
--- a/src/browser/js/app/editor/context-menu.js
+++ b/src/browser/js/app/editor/context-menu.js
@@ -190,6 +190,33 @@ var handleClick = function(event) {
updateWidget(parent)
}
+ actions[' Wrap in'] = {}
+ for (let c of categories.Containers) {
+ if (c === 'clone') continue
+ actions[' Wrap in'][c] = ()=>{
+ var wrap = {type: c, widgets:[]}
+
+ wrap.widgets = data
+
+ var minTop = Math.min(...data.map(x => isNaN(x.top) ? x.top == 'auto' ? 0 : Infinity : x.top))
+ var minLeft = Math.min(...data.map(x => isNaN(x.left) ? x.left == 'auto' ? 0 : Infinity : x.left))
+
+ wrap.top = minTop === Infinity ? data[0].top : minTop
+ wrap.left= minLeft === Infinity ? data[0].left : minLeft
+
+ for (var w of wrap.widgets) {
+ if (!isNaN(w.top)) w.top = Math.max(w.top - minTop, 0)
+ if (!isNaN(w.left)) w.left = Math.max(w.left - minLeft, 0)
+ }
+
+ for (var i of index) {
+ parent.props.widgets.splice(i,1)
+ }
+ parent.props.widgets.push(wrap)
+ updateWidget(parent)
+ }
+ }
+
}