File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export function saveWorkspaceComment(
6868 if ( ! skipId ) elem . setAttribute ( 'id' , comment . id ) ;
6969
7070 const workspace = comment . workspace ;
71- const loc = comment . getRelativeToSurfaceXY ( ) ;
71+ const loc = comment . getRelativeToSurfaceXY ( ) . clone ( ) ;
7272 loc . x = workspace . RTL ? workspace . getWidth ( ) - loc . x : loc . x ;
7373 elem . setAttribute ( 'x' , `${ loc . x } ` ) ;
7474 elem . setAttribute ( 'y' , `${ loc . y } ` ) ;
Original file line number Diff line number Diff line change @@ -236,5 +236,28 @@ suite('Clipboard', function () {
236236 new Blockly . utils . Coordinate ( 40 , 40 ) ,
237237 ) ;
238238 } ) ;
239+
240+ test ( 'pasted comments are bumped to not overlap in RTL' , function ( ) {
241+ this . workspace . dispose ( ) ;
242+ this . workspace = Blockly . inject ( 'blocklyDiv' , { rtl : true } ) ;
243+ Blockly . Xml . domToWorkspace (
244+ Blockly . utils . xml . textToDom (
245+ '<xml><comment id="test" x=10 y=10/></xml>' ,
246+ ) ,
247+ this . workspace ,
248+ ) ;
249+ const comment = this . workspace . getTopComments ( false ) [ 0 ] ;
250+ const data = comment . toCopyData ( ) ;
251+
252+ const newComment = Blockly . clipboard . paste ( data , this . workspace ) ;
253+ const oldCommentXY = comment . getRelativeToSurfaceXY ( ) ;
254+ assert . deepEqual (
255+ newComment . getRelativeToSurfaceXY ( ) ,
256+ new Blockly . utils . Coordinate ( oldCommentXY . x - 30 , oldCommentXY . y + 30 ) ,
257+ ) ;
258+ // Restore an LTR workspace.
259+ this . workspace . dispose ( ) ;
260+ this . workspace = Blockly . inject ( 'blocklyDiv' ) ;
261+ } ) ;
239262 } ) ;
240263} ) ;
You can’t perform that action at this time.
0 commit comments