From 6a823ddd8ac6f2c3887dea0de9818a316d225995 Mon Sep 17 00:00:00 2001 From: Arthur Almeida Date: Mon, 21 Jan 2019 14:44:02 -0200 Subject: [PATCH] limit width resize to Canvas width --- src/commands/view/SelectComponent.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index 2df42f887..28adeae84 100644 --- a/src/commands/view/SelectComponent.js +++ b/src/commands/view/SelectComponent.js @@ -350,7 +350,7 @@ module.exports = { * @private */ initResize(elem) { - const em = this.em; + const { em, canvas } = this; const editor = em ? em.get('Editor') : ''; const config = em ? em.get('Config') : ''; const pfx = config.stylePrefix || ''; @@ -444,7 +444,13 @@ module.exports = { const style = modelToStyle.getStyle(); if (!onlyHeight) { - style[keyWidth] = autoWidth ? 'auto' : `${rect.w}${unitWidth}`; + const padding = 10; + const frameOffset = canvas.getCanvasView().getFrameOffset(); + const width = + rect.w < frameOffset.width - padding + ? rect.w + : frameOffset.width - padding; + style[keyWidth] = autoWidth ? 'auto' : `${width}${unitWidth}`; } if (!onlyWidth) {