( elem: Element, workspace: Workspace, )
| 515 | |
| 516 | /** Deserializes the given comment state into the given workspace. */ |
| 517 | export function loadWorkspaceComment( |
| 518 | elem: Element, |
| 519 | workspace: Workspace, |
| 520 | ): WorkspaceComment { |
| 521 | const id = elem.getAttribute('id') ?? undefined; |
| 522 | const comment = workspace.rendered |
| 523 | ? new RenderedWorkspaceComment(workspace as WorkspaceSvg, id) |
| 524 | : new WorkspaceComment(workspace, id); |
| 525 | |
| 526 | comment.setText(elem.textContent ?? ''); |
| 527 | |
| 528 | let x = parseInt(elem.getAttribute('x') ?? '', 10); |
| 529 | const y = parseInt(elem.getAttribute('y') ?? '', 10); |
| 530 | if (!isNaN(x) && !isNaN(y)) { |
| 531 | x = workspace.RTL ? workspace.getWidth() - x : x; |
| 532 | comment.moveTo(new Coordinate(x, y)); |
| 533 | } |
| 534 | |
| 535 | const w = parseInt(elem.getAttribute('w') ?? '', 10); |
| 536 | const h = parseInt(elem.getAttribute('h') ?? '', 10); |
| 537 | if (!isNaN(w) && !isNaN(h)) comment.setSize(new Size(w, h)); |
| 538 | |
| 539 | if (elem.getAttribute('collapsed') === 'true') comment.setCollapsed(true); |
| 540 | if (elem.getAttribute('editable') === 'false') comment.setEditable(false); |
| 541 | if (elem.getAttribute('movable') === 'false') comment.setMovable(false); |
| 542 | if (elem.getAttribute('deletable') === 'false') comment.setDeletable(false); |
| 543 | |
| 544 | return comment; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * Decode an XML DOM and create blocks on the workspace. Position the new |
no test coverage detected