mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
fix: comment position in RTL (#7934)
* fix: how comments are laid out in RTL * fix: comment positioning with JSON * fix: comment positioning with XML
This commit is contained in:
14
core/xml.ts
14
core/xml.ts
@@ -62,8 +62,11 @@ function saveWorkspaceComment(
|
||||
const elem = utilsXml.createElement('comment');
|
||||
if (!skipId) elem.setAttribute('id', comment.id);
|
||||
|
||||
elem.setAttribute('x', `${comment.getRelativeToSurfaceXY().x}`);
|
||||
elem.setAttribute('y', `${comment.getRelativeToSurfaceXY().y}`);
|
||||
const workspace = comment.workspace;
|
||||
const loc = comment.getRelativeToSurfaceXY();
|
||||
loc.x = workspace.RTL ? workspace.getWidth() - loc.x : loc.x;
|
||||
elem.setAttribute('x', `${loc.x}`);
|
||||
elem.setAttribute('y', `${loc.y}`);
|
||||
elem.setAttribute('w', `${comment.getSize().width}`);
|
||||
elem.setAttribute('h', `${comment.getSize().height}`);
|
||||
|
||||
@@ -503,9 +506,12 @@ function loadWorkspaceComment(
|
||||
|
||||
comment.setText(elem.textContent ?? '');
|
||||
|
||||
const x = parseInt(elem.getAttribute('x') ?? '', 10);
|
||||
let x = parseInt(elem.getAttribute('x') ?? '', 10);
|
||||
const y = parseInt(elem.getAttribute('y') ?? '', 10);
|
||||
if (!isNaN(x) && !isNaN(y)) comment.moveTo(new Coordinate(x, y));
|
||||
if (!isNaN(x) && !isNaN(y)) {
|
||||
x = workspace.RTL ? workspace.getWidth() - x : x;
|
||||
comment.moveTo(new Coordinate(x, y));
|
||||
}
|
||||
|
||||
const w = parseInt(elem.getAttribute('w') ?? '', 10);
|
||||
const h = parseInt(elem.getAttribute('h') ?? '', 10);
|
||||
|
||||
Reference in New Issue
Block a user