From 1f7c81851e7b235390dcfd02b9efd50fbfa03759 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 16 Dec 2013 18:20:24 +0000 Subject: [PATCH] Strip trailing linebreaks on paste due to Chrome bug When pasting into a selected paragraph, or emptying a paragraph Chrome adds a linebreak. Our paste into empty uses a selected paragraph for context so the converter picks up this extra linebreak. It is possible that this breaks are intentional but not likely so better just to trim than to leave the user with a break which doesn't even render clearly. Bug: 58347 Change-Id: Ia6b22cdaeedf1a75bb529c9a5312add9c3ce182c --- modules/ve/ce/ve.ce.Surface.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index b7d8cb5136..fc1220da4a 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -1058,6 +1058,10 @@ ve.ce.Surface.prototype.afterPaste = function () { right--; context.splice( context.getLength() - 1, 1 ); } + // HACK: Strip trailing linebreaks probably introduced by Chrome bug + while ( data.getType( right - 1 ) === 'break' ) { + right--; + } contextRange = new ve.Range( left, right ); }