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:
Beka Westberg
2024-03-22 17:46:42 +00:00
committed by GitHub
parent 11c219c537
commit d01f9a73fe
4 changed files with 67 additions and 31 deletions

View File

@@ -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);