microboard-temp 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -752,7 +752,7 @@ __export(exports_browser, {
752
752
  ConnectorData: () => ConnectorData2,
753
753
  Connector: () => Connector2,
754
754
  ConnectionLineWidths: () => ConnectionLineWidths,
755
- Comment: () => Comment2,
755
+ Comment: () => Comment,
756
756
  Camera: () => Camera,
757
757
  CURSORS_IDLE_CLEANUP_DELAY: () => CURSORS_IDLE_CLEANUP_DELAY,
758
758
  CURSORS_ANIMATION_DURATION: () => CURSORS_ANIMATION_DURATION,
@@ -1630,6 +1630,9 @@ class Line {
1630
1630
  getStartPoint() {
1631
1631
  return this.start;
1632
1632
  }
1633
+ getEndPoint() {
1634
+ return this.end;
1635
+ }
1633
1636
  getLength() {
1634
1637
  const { start, end } = this;
1635
1638
  const deltaX = end.x - start.x;
@@ -3227,6 +3230,9 @@ class QuadraticBezier extends BaseCurve {
3227
3230
  getStartPoint() {
3228
3231
  return this.start;
3229
3232
  }
3233
+ getEndPoint() {
3234
+ return this.end;
3235
+ }
3230
3236
  moveToStart(ctx) {
3231
3237
  ctx.moveTo(this.start.x, this.start.y);
3232
3238
  }
@@ -3270,6 +3276,9 @@ class CubicBezier extends BaseCurve {
3270
3276
  getStartPoint() {
3271
3277
  return this.start;
3272
3278
  }
3279
+ getEndPoint() {
3280
+ return this.end;
3281
+ }
3273
3282
  moveToStart(ctx) {
3274
3283
  ctx.moveTo(this.start.x, this.start.y);
3275
3284
  }
@@ -7372,25 +7381,33 @@ class TransformationCommand {
7372
7381
  x: 1 / op2.x,
7373
7382
  y: 1 / op2.y
7374
7383
  };
7384
+ } else {
7385
+ reverseOp = {
7386
+ ...op2,
7387
+ x: 1,
7388
+ y: 1
7389
+ };
7375
7390
  }
7376
7391
  return { item: currTrans, operation: reverseOp };
7377
7392
  });
7378
7393
  }
7379
7394
  case "locked": {
7395
+ const op2 = this.operation;
7380
7396
  return mapItemsByOperation(this.transformation, () => {
7381
7397
  return {
7382
- ...this.operation,
7383
- item: [...op.item],
7398
+ ...op2,
7399
+ item: [...op2.item],
7384
7400
  method: "unlocked",
7385
7401
  locked: false
7386
7402
  };
7387
7403
  });
7388
7404
  }
7389
7405
  case "unlocked": {
7406
+ const op2 = this.operation;
7390
7407
  return mapItemsByOperation(this.transformation, () => {
7391
7408
  return {
7392
- ...this.operation,
7393
- item: [...op.item],
7409
+ ...op2,
7410
+ item: [...op2.item],
7394
7411
  method: "locked",
7395
7412
  locked: true
7396
7413
  };
@@ -9001,6 +9018,13 @@ var tagByType = {
9001
9018
  Comment: "comment-item",
9002
9019
  Group: ""
9003
9020
  };
9021
+ var headingTagsMap = {
9022
+ h1: "heading_one",
9023
+ h2: "heading_two",
9024
+ h3: "heading_three",
9025
+ h4: "heading_four",
9026
+ h5: "heading_five"
9027
+ };
9004
9028
  var parsersHTML = {
9005
9029
  "sticker-item": parseHTMLSticker,
9006
9030
  "shape-item": parseHTMLShape,
@@ -9025,12 +9049,12 @@ function getTransformationData(el) {
9025
9049
  if (transformMatch) {
9026
9050
  const [, translateX, translateY, scaleX, scaleY] = transformMatch.map(Number);
9027
9051
  const matrix = new Matrix2(translateX, translateY, scaleX, scaleY);
9028
- return { ...matrix, rotate: 0 };
9052
+ return { ...matrix, rotate: 0, isLocked: false };
9029
9053
  }
9030
- return { ...new Matrix2, rotate: 0 };
9054
+ return { ...new Matrix2, rotate: 0, isLocked: false };
9031
9055
  }
9032
9056
  function parseHTMLRichText(el, options) {
9033
- const parseNode = (node) => {
9057
+ const parseNode = (node, nestingLevel = 1) => {
9034
9058
  const isLinkNode = node.tagName.toLowerCase() === "a";
9035
9059
  if (node.tagName.toLowerCase() === "span" || isLinkNode && node.children.length === 0) {
9036
9060
  const isSingleSpace = node.textContent?.length === 1 && node.textContent?.trim() === "";
@@ -9053,7 +9077,7 @@ function parseHTMLRichText(el, options) {
9053
9077
  superscript: false
9054
9078
  };
9055
9079
  }
9056
- const children2 = Array.from(node.children).map((child) => parseNode(child));
9080
+ const children2 = Array.from(node.children).map((child) => parseNode(child, nestingLevel + 1));
9057
9081
  const tagName = node.tagName.toLowerCase();
9058
9082
  const extractCommonProps = () => ({
9059
9083
  horisontalAlignment: node.style.textAlign || "left",
@@ -9061,23 +9085,19 @@ function parseHTMLRichText(el, options) {
9061
9085
  paddingBottom: parseFloat(node.style.paddingBottom) || undefined
9062
9086
  });
9063
9087
  switch (tagName) {
9064
- case "blockquote":
9065
- return {
9066
- type: "block-quote",
9067
- ...extractCommonProps(),
9068
- children: children2
9069
- };
9070
9088
  case "ul":
9071
9089
  return {
9072
9090
  type: "ul_list",
9073
9091
  ...extractCommonProps(),
9074
- children: children2
9092
+ children: children2,
9093
+ listLevel: nestingLevel
9075
9094
  };
9076
9095
  case "ol":
9077
9096
  return {
9078
9097
  type: "ol_list",
9079
9098
  ...extractCommonProps(),
9080
- children: children2
9099
+ children: children2,
9100
+ listLevel: nestingLevel
9081
9101
  };
9082
9102
  case "li":
9083
9103
  return {
@@ -9099,11 +9119,9 @@ function parseHTMLRichText(el, options) {
9099
9119
  case "h2":
9100
9120
  case "h3":
9101
9121
  case "h4":
9102
- case "h5":
9103
- case "h6": {
9104
- const headingType = `heading_${["one", "two", "three", "four", "five", "six"][parseInt(tagName[1]) - 1]}`;
9122
+ case "h5": {
9105
9123
  return {
9106
- type: headingType,
9124
+ type: headingTagsMap[tagName],
9107
9125
  ...extractCommonProps(),
9108
9126
  children: children2
9109
9127
  };
@@ -9307,6 +9325,7 @@ function parseHTMLConnector(el) {
9307
9325
  ...endPointType === "FixedConnector" ? { segment: startSegment, tangent: endTangent } : {}
9308
9326
  };
9309
9327
  const connectorData = {
9328
+ middlePoint: null,
9310
9329
  id: el.id,
9311
9330
  itemType: "Connector",
9312
9331
  transformation,
@@ -9367,6 +9386,7 @@ function parseHTMLDrawing(el) {
9367
9386
  }
9368
9387
  function parseHTMLAINode(el) {
9369
9388
  const aiNodeData = {
9389
+ threadDirection: 3,
9370
9390
  id: el.id,
9371
9391
  itemType: "AINode",
9372
9392
  parentNodeId: el.getAttribute("parent-node-id") || undefined,
@@ -17219,7 +17239,9 @@ function setNodeChildrenStyles({
17219
17239
  }) {
17220
17240
  let fontStyles = conf.DEFAULT_TEXT_STYLES;
17221
17241
  if (editor) {
17222
- fontStyles = import_slate19.Editor.marks(editor) || conf.DEFAULT_TEXT_STYLES;
17242
+ const marks = import_slate19.Editor.marks(editor);
17243
+ const fontSize = marks?.fontSize ? marks.fontSize === "auto" ? conf.DEFAULT_TEXT_STYLES.fontSize : marks.fontSize : conf.DEFAULT_TEXT_STYLES.fontSize;
17244
+ fontStyles = marks ? { ...conf.DEFAULT_TEXT_STYLES, ...marks, fontSize } : conf.DEFAULT_TEXT_STYLES;
17223
17245
  }
17224
17246
  switch (node2.type) {
17225
17247
  case "heading_one":
@@ -17269,6 +17291,9 @@ function setNodeStyles({
17269
17291
  editor,
17270
17292
  horisontalAlignment
17271
17293
  }) {
17294
+ if (node2.type === "list_item") {
17295
+ return;
17296
+ }
17272
17297
  if (node2.type === "ol_list" || node2.type === "ul_list") {
17273
17298
  node2.listLevel = listLevel;
17274
17299
  for (const listItem of node2.children) {
@@ -17419,9 +17444,10 @@ class MarkdownProcessor {
17419
17444
  } else {
17420
17445
  const lastParagraphPath = this.getText().length - 1;
17421
17446
  const lastParagraph = this.getText()[lastParagraphPath];
17447
+ const lastParagraphText = lastParagraph.children[lastParagraph.children.length - 1];
17422
17448
  const insertLocation = {
17423
17449
  path: [lastParagraphPath, lastParagraph.children.length - 1],
17424
- offset: lastParagraph.children[lastParagraph.children.length - 1].text.length
17450
+ offset: lastParagraphText.text.length
17425
17451
  };
17426
17452
  import_slate20.Transforms.insertText(this.editor, combinedText, {
17427
17453
  at: insertLocation
@@ -18436,14 +18462,6 @@ class RichTextCommand {
18436
18462
  fontColor: this.board.items.getById(id)?.getRichText()?.getFontColor() || conf.DEFAULT_TEXT_STYLES.fontColor
18437
18463
  }
18438
18464
  }));
18439
- case "setBlockType":
18440
- return items.map((id) => ({
18441
- item: id,
18442
- operation: {
18443
- ...this.operation,
18444
- type: this.board.items.getById(id)?.getRichText()?.getBlockType() || "paragraph"
18445
- }
18446
- }));
18447
18465
  case "setFontStyle":
18448
18466
  return items.map((id) => ({
18449
18467
  item: id,
@@ -18546,7 +18564,8 @@ class RichTextGroupCommand {
18546
18564
  class: "RichText",
18547
18565
  method: "edit",
18548
18566
  item: [richText.getId() ?? ""],
18549
- ops
18567
+ ops,
18568
+ selection: null
18550
18569
  }
18551
18570
  });
18552
18571
  }
@@ -18563,7 +18582,8 @@ class RichTextGroupCommand {
18563
18582
  class: "RichText",
18564
18583
  method: "edit",
18565
18584
  item: [richText.getId() ?? ""],
18566
- ops: ops.map((op) => import_slate34.Operation.inverse(op)).reverse()
18585
+ ops: ops.map((op) => import_slate34.Operation.inverse(op)).reverse(),
18586
+ selection: null
18567
18587
  }
18568
18588
  });
18569
18589
  }
@@ -18933,7 +18953,7 @@ var v4_default = v4;
18933
18953
  // src/Items/Comment/Comment.ts
18934
18954
  var ANONYMOUS_ID = 9999999999;
18935
18955
 
18936
- class Comment2 {
18956
+ class Comment {
18937
18957
  anchor;
18938
18958
  events;
18939
18959
  id;
@@ -19213,6 +19233,9 @@ class Comment2 {
19213
19233
  const anchor = this.anchor.copy();
19214
19234
  return new Mbr(anchor.x, anchor.y, anchor.x, anchor.y);
19215
19235
  }
19236
+ getPathMbr() {
19237
+ return this.getMbr();
19238
+ }
19216
19239
  getNearestEdgePointTo(point3) {
19217
19240
  return this.anchor;
19218
19241
  }
@@ -19700,6 +19723,12 @@ class BaseItem extends Mbr {
19700
19723
  onRemove() {
19701
19724
  this.onRemoveCallbacks.forEach((cb) => cb());
19702
19725
  }
19726
+ getPathMbr() {
19727
+ return this.getMbr().copy();
19728
+ }
19729
+ getPath() {
19730
+ return new Path(this.getMbr().getLines());
19731
+ }
19703
19732
  render(context) {}
19704
19733
  renderHTML(documentFactory) {
19705
19734
  return documentFactory.createElement("div");
@@ -20225,7 +20254,10 @@ class RichText extends BaseItem {
20225
20254
  }
20226
20255
  getFontSize() {
20227
20256
  const marks = this.editor.getSelectionMarks();
20228
- const fontSize = marks?.fontSize ?? this.initialTextStyles.fontSize;
20257
+ let fontSize = marks?.fontSize ?? this.initialTextStyles.fontSize;
20258
+ if (fontSize === "auto") {
20259
+ fontSize = this.initialTextStyles.fontSize;
20260
+ }
20229
20261
  if (this.autoSize) {
20230
20262
  return fontSize * this.autoSizeScale;
20231
20263
  }
@@ -20243,7 +20275,7 @@ class RichText extends BaseItem {
20243
20275
  for (const [node2] of textNodes) {
20244
20276
  const fontSize = node2.fontSize || node2 && node2.fontSize;
20245
20277
  if (fontSize) {
20246
- fontSizes.push(fontSize);
20278
+ fontSizes.push(fontSize === "auto" ? this.initialTextStyles.fontSize : fontSize);
20247
20279
  }
20248
20280
  }
20249
20281
  if (fontSizes.length > 0) {
@@ -20256,7 +20288,7 @@ class RichText extends BaseItem {
20256
20288
  return marks?.fontHighlight ?? this.initialTextStyles.fontHighlight;
20257
20289
  }
20258
20290
  getBlockType() {
20259
- const blockNode = getSelectedBlockNode(this.editor);
20291
+ const blockNode = getSelectedBlockNode(this.editor.editor);
20260
20292
  return blockNode ? blockNode.type : "paragraph";
20261
20293
  }
20262
20294
  getHorisontalAlignment() {
@@ -20287,16 +20319,18 @@ class RichText extends BaseItem {
20287
20319
  const refMbr = new Mbr(domMbr.left, domMbr.top, domMbr.right, domMbr.bottom);
20288
20320
  if (refMbr.isInside(point3) && (conf.documentFactory.caretPositionFromPoint || conf.documentFactory.caretRangeFromPoint)) {
20289
20321
  const domRange = conf.documentFactory.caretPositionFromPoint ? conf.documentFactory.caretPositionFromPoint(point3.x, point3.y) : conf.documentFactory.caretRangeFromPoint(point3.x, point3.y);
20290
- const textNode = conf.documentFactory.caretPositionFromPoint ? domRange.offsetNode : domRange.startContainer;
20291
- const offset = conf.documentFactory.caretPositionFromPoint ? domRange.offset : domRange.startOffset;
20292
- const slatePoint = conf.reactEditorToSlatePoint(this.editor.editor, textNode, offset, {
20293
- exactMatch: false,
20294
- suppressThrow: false
20295
- });
20296
- if (slatePoint) {
20297
- const nRange = { anchor: slatePoint, focus: slatePoint };
20298
- this.editorTransforms.select(this.editor.editor, nRange);
20299
- conf.reactEditorFocus(this.editor.editor);
20322
+ if (domRange) {
20323
+ const textNode = conf.documentFactory.caretPositionFromPoint ? domRange.offsetNode : domRange.startContainer;
20324
+ const offset = conf.documentFactory.caretPositionFromPoint ? domRange.offset : domRange.startOffset;
20325
+ const slatePoint = conf.reactEditorToSlatePoint(this.editor.editor, textNode, offset, {
20326
+ exactMatch: false,
20327
+ suppressThrow: false
20328
+ });
20329
+ if (slatePoint) {
20330
+ const nRange = { anchor: slatePoint, focus: slatePoint };
20331
+ this.editorTransforms.select(this.editor.editor, nRange);
20332
+ conf.reactEditorFocus(this.editor.editor);
20333
+ }
20300
20334
  }
20301
20335
  } else {
20302
20336
  if (!(conf.documentFactory.caretPositionFromPoint || conf.documentFactory.caretRangeFromPoint)) {
@@ -37504,6 +37538,9 @@ class Shape extends BaseItem {
37504
37538
  getMbr() {
37505
37539
  return this.mbr.copy();
37506
37540
  }
37541
+ getPathMbr() {
37542
+ return this.getPath().getMbr();
37543
+ }
37507
37544
  getNearestEdgePointTo(point5) {
37508
37545
  return this.path.getNearestEdgePointTo(point5);
37509
37546
  }
@@ -38463,10 +38500,6 @@ class Frame extends BaseItem {
38463
38500
  return this.mbr.copy();
38464
38501
  }
38465
38502
  doResize(resizeType, pointer, mbr, opposite, startMbr, timeStamp) {
38466
- if (this.transformation.isLocked) {
38467
- this.board?.pointer.setCursor("default");
38468
- return false;
38469
- }
38470
38503
  const res = this.getCanChangeRatio() ? getResize(resizeType, pointer, mbr, opposite) : getProportionalResize(resizeType, pointer, mbr, opposite);
38471
38504
  if (!res) {
38472
38505
  return {
@@ -41044,7 +41077,7 @@ function createComment(id, data, board) {
41044
41077
  if (!isCommentData(data)) {
41045
41078
  throw new Error("Invalid data for Comment");
41046
41079
  }
41047
- const comment2 = new Comment2(new Point, board.events).setId(id).deserialize(data);
41080
+ const comment2 = new Comment(new Point, board.events).setId(id).deserialize(data);
41048
41081
  return comment2;
41049
41082
  }
41050
41083
  function createAINode(id, data, board) {
@@ -41248,7 +41281,7 @@ class AddComment extends BoardTool {
41248
41281
  leftButtonUp() {
41249
41282
  this.isDown = false;
41250
41283
  this.board.selection.removeAll();
41251
- this.comment = this.board.add(this.board, new Comment(this.board.pointer.point));
41284
+ this.comment = this.board.add(new Comment(this.board.pointer.point));
41252
41285
  this.board.tools.publish();
41253
41286
  return true;
41254
41287
  }
@@ -41568,7 +41601,6 @@ class ConnectorSnap {
41568
41601
 
41569
41602
  // src/Tools/AddConnector/AddConnector.ts
41570
41603
  class AddConnector extends BoardTool {
41571
- board;
41572
41604
  connector = null;
41573
41605
  lineStyle = "curved";
41574
41606
  startPointer;
@@ -41583,7 +41615,6 @@ class AddConnector extends BoardTool {
41583
41615
  isQuickAdd = false;
41584
41616
  constructor(board, itemToStart, position4) {
41585
41617
  super(board);
41586
- this.board = board;
41587
41618
  this.snap = new ConnectorSnap(this.board);
41588
41619
  this.setCursor();
41589
41620
  const storage = new SessionStorage;
@@ -41645,16 +41676,16 @@ class AddConnector extends BoardTool {
41645
41676
  this.board.tools.publish();
41646
41677
  return true;
41647
41678
  }
41648
- async leftButtonUp() {
41679
+ leftButtonUp() {
41649
41680
  this.isDown = false;
41650
41681
  if (!this.connector) {
41651
41682
  return true;
41652
41683
  }
41653
41684
  if (this.isDoneSecondPoint) {
41654
- await this.board.add(this.connector);
41685
+ this.board.add(this.connector);
41655
41686
  this.board.tools.select();
41656
41687
  } else if (this.isDraggingFromFirstToSecond) {
41657
- const addedConnector = await this.board.add(this.connector);
41688
+ const addedConnector = this.board.add(this.connector);
41658
41689
  const endPoint = this.connector.getEndPoint();
41659
41690
  this.board.tools.select();
41660
41691
  if (this.isQuickAdd && endPoint.pointType === "Board") {
@@ -43284,13 +43315,8 @@ function createCanvasDrawer(board) {
43284
43315
  // src/Selection/QuickAddButtons/quickAddHelpers.ts
43285
43316
  function getControlPointData(item, index2, isRichText = false) {
43286
43317
  const itemScale = isRichText ? { x: 1, y: 1 } : item.transformation.getScale();
43287
- const width2 = item.itemType === "Shape" ? item.getPath().getMbr().getWidth() : item.getMbr().getWidth();
43288
- let height3;
43289
- if (item.itemType === "Shape" && index2 !== 2 && index2 !== 3) {
43290
- height3 = item.getPath().getMbr().getHeight();
43291
- } else {
43292
- height3 = item.getMbr().getHeight();
43293
- }
43318
+ const width2 = item.getPathMbr().getWidth();
43319
+ let height3 = item.getPathMbr().getHeight();
43294
43320
  const adjMapScaled = {
43295
43321
  0: { x: 0, y: height3 / 2 / itemScale.y },
43296
43322
  1: {
@@ -43323,7 +43349,7 @@ function quickAddItem(board, type, connector) {
43323
43349
  optionalItem = new Sticker(board);
43324
43350
  break;
43325
43351
  case "AINode":
43326
- optionalItem = createAINode2(board, startPoint?.item?.getId(), 3);
43352
+ optionalItem = createAINode2(board, 3, "item" in startPoint ? startPoint?.item?.getId() : undefined);
43327
43353
  break;
43328
43354
  }
43329
43355
  let itemMbr = optionalItem.getMbr();
@@ -43350,20 +43376,25 @@ function quickAddItem(board, type, connector) {
43350
43376
  if ("text" in guarded && guarded.itemType !== "AINode" && guarded.itemType !== "RichText") {
43351
43377
  delete guarded.text;
43352
43378
  }
43379
+ if (!itemData.transformation) {
43380
+ itemData.transformation = new DefaultTransformationData;
43381
+ }
43353
43382
  itemData.transformation.translateX = endPoint.x;
43354
43383
  itemData.transformation.translateY = endPoint.y;
43355
43384
  const lines = connector.lines.getSegments();
43356
43385
  const lastLine = lines[lines.length - 1];
43357
- let dir2 = getDirection(lastLine.start, lastLine.end);
43386
+ const lastLineStart = lastLine.getStartPoint();
43387
+ const lastLineEnd = lastLine.getEndPoint();
43388
+ let dir2 = getDirection(lastLineStart, lastLineEnd);
43389
+ const firstLineStart = lines[0].getEndPoint();
43358
43390
  if (!dir2) {
43359
- const firstLine = lines[0];
43360
- const xDiff = Math.abs(firstLine.start.x - lastLine.end.x);
43361
- const yDiff = Math.abs(firstLine.start.y - lastLine.end.y);
43391
+ const xDiff = Math.abs(firstLineStart.x - lastLineEnd.x);
43392
+ const yDiff = Math.abs(firstLineStart.y - lastLineEnd.y);
43362
43393
  dir2 = xDiff > yDiff ? "horizontal" : "vertical";
43363
43394
  }
43364
43395
  let dirIndex = -1;
43365
43396
  if (dir2 === "vertical") {
43366
- if (lines[0].start.y > lastLine.end.y) {
43397
+ if (firstLineStart.y > lastLineEnd.y) {
43367
43398
  itemData.transformation.translateX -= itemMbr.getWidth() / 2;
43368
43399
  itemData.transformation.translateY -= itemMbr.getHeight();
43369
43400
  dirIndex = 3;
@@ -43372,7 +43403,7 @@ function quickAddItem(board, type, connector) {
43372
43403
  dirIndex = 2;
43373
43404
  }
43374
43405
  } else if (dir2 === "horizontal") {
43375
- if (lines[0].start.x > lastLine.end.x) {
43406
+ if (firstLineStart.x > lastLineEnd.x) {
43376
43407
  itemData.transformation.translateX -= itemMbr.getWidth();
43377
43408
  itemData.transformation.translateY -= itemMbr.getHeight() / 2;
43378
43409
  dirIndex = 1;
@@ -43394,7 +43425,7 @@ function quickAddItem(board, type, connector) {
43394
43425
  connector.setEndPoint(newEndPoint);
43395
43426
  board.selection.removeAll();
43396
43427
  board.selection.add(added);
43397
- if (added.itemType === "RichText" || added.itemType === "AINode") {
43428
+ if (added instanceof RichText || added instanceof AINode) {
43398
43429
  const text5 = added.getRichText();
43399
43430
  text5.editor.setMaxWidth(text5.editor.maxWidth || 600);
43400
43431
  board.selection.editText();
@@ -43402,7 +43433,7 @@ function quickAddItem(board, type, connector) {
43402
43433
  board.selection.setContext("EditUnderPointer");
43403
43434
  }
43404
43435
  }
43405
- function createAINode2(board, parentNodeId, directionIndex) {
43436
+ function createAINode2(board, directionIndex, parentNodeId) {
43406
43437
  const node2 = new AINode(board, true, parentNodeId, undefined, directionIndex);
43407
43438
  const nodeRichText = node2.getRichText();
43408
43439
  nodeRichText.applyMaxWidth(600);
@@ -43436,17 +43467,17 @@ function getQuickAddButtons(selection, board) {
43436
43467
  let quickAddItems = undefined;
43437
43468
  function calculateQuickAddPosition(index2, selectedItem, connectorStartPoint) {
43438
43469
  const connectorStorage = new SessionStorage;
43439
- const currMbr = selectedItem.getMbr();
43470
+ const currMbr = selectedItem.getPathMbr();
43440
43471
  const selectedItemData = selectedItem.serialize();
43441
- const width2 = selectedItem.itemType === "Shape" ? selectedItem.getPath().getMbr().getWidth() : currMbr.getWidth();
43442
- const height3 = selectedItem.itemType === "Shape" ? selectedItem.getPath().getMbr().getHeight() : currMbr.getHeight();
43472
+ const width2 = currMbr.getWidth();
43473
+ const height3 = currMbr.getHeight();
43443
43474
  let offsetX = width2;
43444
43475
  let offsetY = height3;
43445
43476
  let newWidth = width2;
43446
43477
  let newHeight = height3;
43447
43478
  let itemData;
43448
43479
  if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
43449
- const item = selectedItem.itemType === "AINode" ? createAINode2(board, selectedItem.getId(), index2) : createRichText2(board);
43480
+ const item = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
43450
43481
  newWidth = item.getMbr().getWidth();
43451
43482
  newHeight = item.getMbr().getHeight();
43452
43483
  itemData = item.serialize();
@@ -43495,9 +43526,9 @@ function getQuickAddButtons(selection, board) {
43495
43526
  const endPoints = getQuickButtonsPositions(newMbr);
43496
43527
  const reverseIndexMap = { 0: 1, 1: 0, 2: 3, 3: 2 };
43497
43528
  const connectorEndPoint = endPoints?.positions[reverseIndexMap[index2]] || new Point;
43498
- const fontSize = selectedItem.itemType === "RichText" ? selectedItem.getFontSize() : 14;
43529
+ const fontSize = selectedItem instanceof RichText ? selectedItem.getFontSize() : 14;
43499
43530
  const newItem = board.createItem(board.getNewItemId(), newItemData);
43500
- if (newItem.itemType === "RichText") {
43531
+ if (newItem instanceof RichText) {
43501
43532
  const storage = new SessionStorage;
43502
43533
  storage.setFontSize("RichText", fontSize);
43503
43534
  newItem.editor.selectWholeText();
@@ -43510,6 +43541,10 @@ function getQuickAddButtons(selection, board) {
43510
43541
  const scaleX = newItemMbr.getWidth() / 100;
43511
43542
  const scaleY = newItemMbr.getHeight() / 100;
43512
43543
  shapeData.transformation = {
43544
+ isLocked: false,
43545
+ rotate: 0,
43546
+ translateX: 0,
43547
+ translateY: 0,
43513
43548
  ...newItemData.transformation,
43514
43549
  scaleX,
43515
43550
  scaleY
@@ -43566,7 +43601,7 @@ function getQuickAddButtons(selection, board) {
43566
43601
  }
43567
43602
  let pathCenter;
43568
43603
  if (single.itemType === "Shape") {
43569
- pathCenter = single.getPath().getMbr().getCenter();
43604
+ pathCenter = single.getPathMbr().getCenter();
43570
43605
  }
43571
43606
  const center = itemMbr.getCenter();
43572
43607
  const width2 = itemMbr.getWidth();
@@ -43761,7 +43796,7 @@ class AlignmentHelper {
43761
43796
  if (i === 0) {
43762
43797
  return acc;
43763
43798
  }
43764
- const itemMbr = item.itemType === "Shape" ? item.getPath().getMbr() : item.getMbr();
43799
+ const itemMbr = item.getPathMbr();
43765
43800
  return acc.combine(itemMbr);
43766
43801
  }, items[0].getMbr());
43767
43802
  }
@@ -44080,9 +44115,11 @@ class AlignmentHelper {
44080
44115
  const translation = this.board.selection.getManyItemsTranslation(x, y);
44081
44116
  this.board.selection.transformMany(translation, timeStamp);
44082
44117
  } else {
44083
- const key = item.getId();
44118
+ const id = item.getId();
44084
44119
  const transformMap = {};
44085
- transformMap[key] = {
44120
+ transformMap[id] = {
44121
+ class: "Transformation",
44122
+ item: [id],
44086
44123
  method: "translateBy",
44087
44124
  x,
44088
44125
  y,
@@ -44387,7 +44424,7 @@ class Select extends Tool {
44387
44424
  const itemCenter = this.downOnItem.getMbr().getCenter();
44388
44425
  this.initialCursorPos = new Point(this.board.pointer.point.x - itemCenter.x, this.board.pointer.point.y - itemCenter.y);
44389
44426
  }
44390
- if (this.downOnItem.itemType === "Connector" && this.downOnItem.isConnectedOnePoint() && !this.board.keyboard.isCtrl) {
44427
+ if (this.downOnItem instanceof Connector2 && this.downOnItem.isConnectedOnePoint() && !this.board.keyboard.isCtrl) {
44391
44428
  this.board.selection.editUnderPointer();
44392
44429
  this.board.tools.publish();
44393
44430
  this.clear();
@@ -44436,7 +44473,7 @@ class Select extends Tool {
44436
44473
  const isDrawingSelectionMbr = this.isDrawingRectangle && this.line && this.rect;
44437
44474
  if (isDrawingSelectionMbr) {
44438
44475
  const point5 = this.board.pointer.point.copy();
44439
- this.line = new Line(this.line.start, point5);
44476
+ this.line = new Line(this.line?.start, point5);
44440
44477
  this.rect = this.line.getMbr();
44441
44478
  this.rect.borderColor = conf.SELECTION_COLOR;
44442
44479
  this.rect.backgroundColor = conf.SELECTION_BACKGROUND;
@@ -44677,7 +44714,7 @@ class Select extends Tool {
44677
44714
  const isNotInSelection = this.board.selection.items.findById(underPointer.getId()) === null;
44678
44715
  if (isNotInSelection) {
44679
44716
  this.board.selection.add(underPointer);
44680
- if (underPointer.itemType === "Frame") {
44717
+ if (underPointer instanceof Frame) {
44681
44718
  const { left, right, top, bottom } = underPointer.getMbr();
44682
44719
  const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => underPointer.getChildrenIds().includes(item.getId()));
44683
44720
  this.board.selection.add(itemsInFrame);
@@ -44805,13 +44842,13 @@ class Select extends Tool {
44805
44842
  }
44806
44843
  onConfirm() {
44807
44844
  const single = this.board.selection.items.getSingle();
44808
- if (this.board.selection.showQuickAddPanel && single && single.itemType === "Connector") {
44809
- quickAddItem(this.board, "copy", single);
44845
+ if (this.board.selection.showQuickAddPanel && single && single instanceof Connector2) {
44846
+ quickAddItem(this.board, "Rectangle", single);
44810
44847
  } else if (single && this.board.selection.getContext() !== "EditTextUnderPointer" && !this.board.selection.getIsLockedSelection()) {
44811
44848
  this.board.selection.editText(undefined, true);
44812
44849
  } else if (isSafari() && this.board.selection.getContext() === "EditTextUnderPointer" && !this.board.selection.getIsLockedSelection()) {
44813
- if (single && "text" in single || single?.itemType === "RichText") {
44814
- const text5 = single.itemType === "RichText" ? single : single.text;
44850
+ if (single && "text" in single || single instanceof RichText) {
44851
+ const text5 = single instanceof RichText ? single : single.text;
44815
44852
  text5.editor.splitNode();
44816
44853
  }
44817
44854
  }
@@ -47935,7 +47972,7 @@ class Presence {
47935
47972
  };
47936
47973
  });
47937
47974
  ctx2.restore();
47938
- this.pointerAnimationId = safeRequestAnimationFrame(renderLoop);
47975
+ this.pointerAnimationId = safeRequestAnimationFrame(renderLoop) || null;
47939
47976
  };
47940
47977
  renderLoop();
47941
47978
  }
@@ -49426,10 +49463,10 @@ class Items {
49426
49463
  }
49427
49464
  const { nearest } = enclosed.reduce((acc, item) => {
49428
49465
  const area = item.getMbr().getHeight() * item.getMbr().getWidth();
49429
- if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
49466
+ if (item instanceof Drawing && !item.isPointNearLine(this.pointer.point)) {
49430
49467
  return acc;
49431
49468
  }
49432
- const isItemTransparent = item?.itemType === "Shape" && item?.getBackgroundColor() === "none";
49469
+ const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
49433
49470
  const itemZIndex = this.getZIndex(item);
49434
49471
  const accZIndex = this.getZIndex(acc.nearest);
49435
49472
  if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
@@ -49460,7 +49497,7 @@ class Items {
49460
49497
  }
49461
49498
  getLinkedConnectorsById(id) {
49462
49499
  return this.listAll().filter((item) => {
49463
- if (item.itemType !== "Connector") {
49500
+ if (!(item instanceof Connector2)) {
49464
49501
  return false;
49465
49502
  }
49466
49503
  const { startItem, endItem } = item.getConnectedItems();
@@ -49475,7 +49512,7 @@ class Items {
49475
49512
  return [];
49476
49513
  }
49477
49514
  return this.listAll().filter((item) => {
49478
- if (item.itemType !== "Connector" || !item.isConnected()) {
49515
+ if (!(item instanceof Connector2) || !item.isConnected()) {
49479
49516
  return false;
49480
49517
  }
49481
49518
  const { startItem, endItem } = item.getConnectedItems();
@@ -49650,7 +49687,7 @@ class SelectionItems {
49650
49687
  return ids;
49651
49688
  }
49652
49689
  getSingle() {
49653
- return this.isSingle() ? this.items.values().next().value : null;
49690
+ return this.isSingle() ? this.items.values().next().value || null : null;
49654
49691
  }
49655
49692
  listByIds(itemIdList) {
49656
49693
  return itemIdList.map((id) => this.items.get(id)).filter((item) => item !== undefined);
@@ -49698,7 +49735,7 @@ class ConnectorTransformer extends Tool {
49698
49735
  getConnector(items) {
49699
49736
  if (items.isSingle()) {
49700
49737
  const connector = items.getSingle();
49701
- if (connector?.itemType === "Connector") {
49738
+ if (connector instanceof Connector2) {
49702
49739
  return connector;
49703
49740
  }
49704
49741
  }
@@ -50004,7 +50041,7 @@ function getItemTranslation({
50004
50041
  scale: { x: 1, y: 1 }
50005
50042
  };
50006
50043
  } else {
50007
- if (item.itemType === "Frame" && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
50044
+ if (item instanceof Frame && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
50008
50045
  item.setFrameType("Custom");
50009
50046
  }
50010
50047
  return {
@@ -50017,7 +50054,7 @@ function getItemTranslation({
50017
50054
  }
50018
50055
  }
50019
50056
 
50020
- // src/Selection/Transformer/TransformerHelpers/ransformShape.ts
50057
+ // src/Selection/Transformer/TransformerHelpers/transformShape.ts
50021
50058
  function transformShape({
50022
50059
  mbr,
50023
50060
  board,
@@ -50287,7 +50324,7 @@ function transformItems({
50287
50324
  if (includesProportionalItem && (isWidth || isHeight)) {
50288
50325
  return null;
50289
50326
  }
50290
- const isIncludesFixedFrame = items.some((item) => item.itemType === "Frame" && !item.getCanChangeRatio());
50327
+ const isIncludesFixedFrame = items.some((item) => item instanceof Frame && !item.getCanChangeRatio());
50291
50328
  const shouldBeProportionalResize = isIncludesFixedFrame || includesProportionalItem || isShiftPressed || !isWidth && !isHeight;
50292
50329
  const resize = shouldBeProportionalResize ? getProportionalResize(resizeType, board.pointer.point, mbr, oppositePoint) : getResize(resizeType, board.pointer.point, mbr, oppositePoint);
50293
50330
  if (canvasDrawer.getLastCreatedCanvas() && !debounceUpd.shouldUpd()) {
@@ -50459,7 +50496,7 @@ class Transformer extends Tool {
50459
50496
  return resizeType;
50460
50497
  }
50461
50498
  updateAlignmentBySnapLines(single) {
50462
- if (single) {
50499
+ if (single && this.resizeType) {
50463
50500
  this.snapLines = this.alignmentHelper.checkAlignment(single);
50464
50501
  const snapped = this.alignmentHelper.snapToSide(single, this.snapLines, this.beginTimeStamp, this.resizeType);
50465
50502
  if (snapped) {
@@ -51168,10 +51205,10 @@ class BoardSelection {
51168
51205
  }
51169
51206
  copiedItemsMap[item.getId()] = { ...serializedData, zIndex };
51170
51207
  }
51171
- copy(skipImageBlobCopy = false) {
51208
+ copy(skipImageBlobCopy) {
51172
51209
  const copiedItemsMap = {};
51173
51210
  const single = this.items.getSingle();
51174
- if (!skipImageBlobCopy && single && single.itemType === "Image") {
51211
+ if (!skipImageBlobCopy && single && single instanceof ImageItem) {
51175
51212
  this.handleItemCopy(single, copiedItemsMap);
51176
51213
  return { imageElement: single.image, imageData: copiedItemsMap };
51177
51214
  }
@@ -51196,7 +51233,7 @@ class BoardSelection {
51196
51233
  return copiedItemsMap;
51197
51234
  }
51198
51235
  cut() {
51199
- const items = this.copy();
51236
+ const items = this.copy(true);
51200
51237
  this.removeFromBoard();
51201
51238
  return items;
51202
51239
  }
@@ -51347,7 +51384,7 @@ class BoardSelection {
51347
51384
  });
51348
51385
  Object.values(selectedMap).forEach((val) => {
51349
51386
  const parentFrame = this.board.items.getById(val.item.parent);
51350
- const isParentFrame = parentFrame?.itemType === "Frame";
51387
+ const isParentFrame = parentFrame instanceof Frame;
51351
51388
  const parentFrameId = isParentFrame ? parentFrame.getId() : null;
51352
51389
  if (val.nested) {
51353
51390
  const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentFrameId);
@@ -51362,7 +51399,7 @@ class BoardSelection {
51362
51399
  console.warn(`Didnt find frame with id ${val.item.parent}`);
51363
51400
  }
51364
51401
  }
51365
- if (val.item.itemType === "Frame" && checkFrames) {
51402
+ if (val.item instanceof Frame && checkFrames) {
51366
51403
  const currFrame = val.item;
51367
51404
  const currMbr = currFrame.getMbr();
51368
51405
  const children = val.item.getChildrenIds().map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
@@ -51770,12 +51807,6 @@ class BoardSelection {
51770
51807
  text5.setEditorFocus(this.context);
51771
51808
  }
51772
51809
  }
51773
- getMediaStorageIds() {
51774
- return this.items.list().filter((item) => {
51775
- const shouldClearStorageUsage = item.itemType === "Image" || item.itemType === "Video" && item.getIsStorageUrl() || item.itemType === "Audio" && item.getIsStorageUrl();
51776
- return shouldClearStorageUsage;
51777
- }).map((item) => item.getStorageId());
51778
- }
51779
51810
  removeFromBoard() {
51780
51811
  const isLocked = this.items.list().some((item) => item.transformation.isLocked);
51781
51812
  if (isLocked) {
@@ -51790,7 +51821,6 @@ class BoardSelection {
51790
51821
  const connectors = itemIds.flatMap((id) => {
51791
51822
  return this.board.items.getLinkedConnectorsById(id);
51792
51823
  }).map((connector) => connector.getId());
51793
- conf.hooks.beforeMediaRemove(this.getMediaStorageIds(), this.board.getBoardId());
51794
51824
  this.emit({
51795
51825
  class: "Board",
51796
51826
  method: "remove",
@@ -51827,7 +51857,15 @@ class BoardSelection {
51827
51857
  this.board.sendToBack(this.items.list());
51828
51858
  }
51829
51859
  async duplicate() {
51830
- const mediaIds = this.getMediaStorageIds();
51860
+ const mediaIds = [];
51861
+ this.items.list().forEach((item) => {
51862
+ if ("getStorageId" in item) {
51863
+ const storageId = item.getStorageId();
51864
+ if (storageId) {
51865
+ mediaIds.push(storageId);
51866
+ }
51867
+ }
51868
+ });
51831
51869
  const canDuplicate = mediaIds.length ? await conf.hooks.beforeMediaUpload(mediaIds, this.board.getBoardId()) : true;
51832
51870
  if (!canDuplicate) {
51833
51871
  return;
@@ -51895,7 +51933,7 @@ class BoardSelection {
51895
51933
  }
51896
51934
  }
51897
51935
  const contextItems = [];
51898
- if (single && single.itemType === "AINode") {
51936
+ if (single && single instanceof AINode) {
51899
51937
  const contextItemsIds = single.getContextItems();
51900
51938
  if (contextItemsIds.length) {
51901
51939
  const newContextItems = this.board.items.listAll().filter((item) => contextItemsIds.includes(item.getId()));
@@ -51917,7 +51955,7 @@ class BoardSelection {
51917
51955
  }
51918
51956
  }
51919
51957
  contextItems.forEach((item) => {
51920
- if (item.itemType === "AINode") {
51958
+ if (item instanceof AINode) {
51921
51959
  const path2 = item.getPath();
51922
51960
  path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
51923
51961
  path2.setBorderWidth(2);
@@ -51932,6 +51970,416 @@ class BoardSelection {
51932
51970
  });
51933
51971
  }
51934
51972
  }
51973
+ // src/public/customWebComponents.js
51974
+ var customWebComponents_default = `/* eslint-disable max-classes-per-file, @typescript-eslint/no-useless-constructor */
51975
+ class RichTextElement extends HTMLElement {
51976
+ constructor() {
51977
+ super();
51978
+ }
51979
+ }
51980
+
51981
+ class ShapeItemElement extends HTMLElement {
51982
+ constructor() {
51983
+ super();
51984
+ }
51985
+ }
51986
+
51987
+ class StickerElement extends HTMLElement {
51988
+ constructor() {
51989
+ super();
51990
+ }
51991
+ }
51992
+
51993
+ class DrawingElement extends HTMLElement {
51994
+ constructor() {
51995
+ super();
51996
+ }
51997
+ }
51998
+
51999
+ class ConnectorElement extends HTMLElement {
52000
+ constructor() {
52001
+ super();
52002
+ }
52003
+ }
52004
+
52005
+ class FrameItemElement extends HTMLElement {
52006
+ constructor() {
52007
+ super();
52008
+ }
52009
+ }
52010
+
52011
+ class ImageItemElement extends HTMLElement {
52012
+ constructor() {
52013
+ super();
52014
+ }
52015
+ }
52016
+
52017
+ class LinkItemElement extends HTMLElement {
52018
+ constructor() {
52019
+ super();
52020
+ }
52021
+ }
52022
+
52023
+ class AINodeItemElement extends HTMLElement {
52024
+ constructor() {
52025
+ super();
52026
+ }
52027
+ }
52028
+
52029
+ class VideoItemElement extends HTMLElement {
52030
+ constructor() {
52031
+ super();
52032
+ }
52033
+ }
52034
+
52035
+ class CommentElement extends HTMLElement {
52036
+ constructor() {
52037
+ super();
52038
+ }
52039
+ }
52040
+
52041
+ class AudioItemElement extends HTMLElement {
52042
+ constructor() {
52043
+ super();
52044
+ }
52045
+ }
52046
+
52047
+ customElements.define("rich-text", RichTextElement);
52048
+ customElements.define("shape-item", ShapeItemElement);
52049
+ customElements.define("sticker-item", StickerElement);
52050
+ customElements.define("drawing-item", DrawingElement);
52051
+ customElements.define("connector-item", ConnectorElement);
52052
+ customElements.define("frame-item", FrameItemElement);
52053
+ customElements.define("image-item", ImageItemElement);
52054
+ customElements.define("link-item", LinkItemElement);
52055
+ customElements.define("ainode-item", AINodeItemElement);
52056
+ customElements.define("video-item", VideoItemElement);
52057
+ customElements.define("comment-item", CommentElement);
52058
+ customElements.define("audio-item", AudioItemElement);
52059
+
52060
+ document.addEventListener("DOMContentLoaded", () => {
52061
+ const itemsDiv = document.querySelector("#items");
52062
+ if (!itemsDiv) {
52063
+ console.error("ITEMS DIV NOT FOUND!");
52064
+ return;
52065
+ }
52066
+ let isDragging = false;
52067
+ let startX, startY;
52068
+ let translateX = 0;
52069
+ let translateY = 0;
52070
+ let scale = 1;
52071
+
52072
+ itemsDiv.style.transformOrigin = "0 0";
52073
+ document.body.style.cursor = "grab";
52074
+
52075
+ function updateTransform() {
52076
+ itemsDiv.style.transform =
52077
+ "translate(" +
52078
+ translateX +
52079
+ "px, " +
52080
+ translateY +
52081
+ "px) scale(" +
52082
+ scale +
52083
+ ")";
52084
+ }
52085
+
52086
+ function handleMouseDown(ev) {
52087
+ isDragging = true;
52088
+ startX = ev.clientX;
52089
+ startY = ev.clientY;
52090
+ itemsDiv.style.cursor = "grabbing";
52091
+ }
52092
+
52093
+ function handleMouseMove(ev) {
52094
+ if (!isDragging) {
52095
+ return;
52096
+ }
52097
+ const dx = ev.clientX - startX;
52098
+ const dy = ev.clientY - startY;
52099
+ startX += dx;
52100
+ startY += dy;
52101
+ translateX += dx;
52102
+ translateY += dy;
52103
+ updateTransform();
52104
+ }
52105
+
52106
+ function handleMouseUp(ev) {
52107
+ if (!isDragging) {
52108
+ return;
52109
+ }
52110
+ isDragging = false;
52111
+ itemsDiv.style.cursor = "grab";
52112
+ }
52113
+
52114
+ function handleWheel(ev) {
52115
+ ev.preventDefault();
52116
+ const factor = ev.deltaY < 0 ? 1.1 : 0.9;
52117
+ translateX = ev.clientX - (ev.clientX - translateX) * factor;
52118
+ translateY = ev.clientY - (ev.clientY - translateY) * factor;
52119
+ scale *= factor;
52120
+ updateTransform();
52121
+ }
52122
+
52123
+ document.addEventListener("mousedown", handleMouseDown);
52124
+ document.addEventListener("mousemove", handleMouseMove);
52125
+ document.addEventListener("mouseup", handleMouseUp);
52126
+ document.addEventListener("wheel", handleWheel, { passive: false });
52127
+
52128
+ const titlePanel = document.createElement("div");
52129
+ titlePanel.style.boxShadow = "0px 10px 16px -3px rgba(20, 21, 26, 0.08)";
52130
+ titlePanel.style.position = "fixed";
52131
+ titlePanel.style.left = "12px";
52132
+ titlePanel.style.top = "12px";
52133
+ titlePanel.style.borderRadius = "12px";
52134
+ titlePanel.style.backgroundColor = "#ffff";
52135
+ titlePanel.style.display = "flex";
52136
+ titlePanel.style.alignItems = "center";
52137
+ titlePanel.style.gap = "8px";
52138
+ titlePanel.style.padding = "0 12px";
52139
+ titlePanel.style.height = "48px";
52140
+ const editButton = document.createElement("button");
52141
+ const editIcon = document.createElementNS(
52142
+ "http://www.w3.org/2000/svg",
52143
+ "svg",
52144
+ );
52145
+ editIcon.setAttribute("width", "13");
52146
+ editIcon.setAttribute("height", "13");
52147
+ editIcon.setAttribute("viewBox", "0 0 13 13");
52148
+ editIcon.setAttribute("fill", "none");
52149
+ editIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
52150
+ const editIconPath = document.createElementNS(
52151
+ "http://www.w3.org/2000/svg",
52152
+ "path",
52153
+ );
52154
+ editIconPath.setAttribute(
52155
+ "d",
52156
+ "M7.838 0.999902V2.33324H1.33333V11.6666H10.6667V5.1619H12V12.3332C12 12.51 11.9298 12.6796 11.8047 12.8046C11.6797 12.9297 11.5101 12.9999 11.3333 12.9999H0.666667C0.489856 12.9999 0.320286 12.9297 0.195262 12.8046C0.0702379 12.6796 0 12.51 0 12.3332V1.66657C0 1.48976 0.0702379 1.32019 0.195262 1.19516C0.320286 1.07014 0.489856 0.999902 0.666667 0.999902H7.838ZM11.1847 0.872018C11.4453 0.611315 11.868 0.611355 12.1285 0.872108C12.3889 1.1327 12.3889 1.55503 12.1284 1.81553L6.472 7.4719L5.53067 7.4739L5.52933 6.52924L11.1847 0.872018Z",
52157
+ );
52158
+ editIconPath.setAttribute("fill", "#ffff");
52159
+ editIcon.appendChild(editIconPath);
52160
+ editButton.appendChild(editIcon);
52161
+ const editFileText = document.createElement("p");
52162
+ const isSnapshotInIframe =
52163
+ window.parent &&
52164
+ window.parent !== window &&
52165
+ window.parent.location.href.includes("/snapshots/");
52166
+ editFileText.textContent = isSnapshotInIframe ? "Edit copy" : "Edit file";
52167
+ editButton.appendChild(editFileText);
52168
+
52169
+ editButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
52170
+ editButton.style.cursor = "pointer";
52171
+ editButton.style.boxShadow = "0px 1px 2px 0px rgba(20, 21, 26, 0.05)";
52172
+ editButton.style.color = "#ffff";
52173
+ editButton.style.fontSize = "14px";
52174
+ editButton.style.lineHeight = "20px";
52175
+ editButton.style.display = "flex";
52176
+ editButton.style.alignItems = "center";
52177
+ editButton.style.gap = "8px";
52178
+ editButton.style.padding = "8px";
52179
+ editButton.style.borderRadius = "10px";
52180
+ const separator = document.createElement("div");
52181
+ separator.style.borderRight = "1px solid rgba(222, 224, 227, 1)";
52182
+ separator.style.height = "100%";
52183
+ const boardName = document.createElement("div");
52184
+ const fileIcon = document.createElementNS(
52185
+ "http://www.w3.org/2000/svg",
52186
+ "svg",
52187
+ );
52188
+ fileIcon.setAttribute("width", "16");
52189
+ fileIcon.setAttribute("height", "18");
52190
+ fileIcon.setAttribute("viewBox", "0 0 16 18");
52191
+ fileIcon.setAttribute("fill", "none");
52192
+ fileIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
52193
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
52194
+ path.setAttribute(
52195
+ "d",
52196
+ "M10.5 2.33341H2.16667V15.6667H13.8333V5.66675H10.5V2.33341ZM0.5 1.49341C0.5 1.03675 0.8725 0.666748 1.3325 0.666748H11.3333L15.5 4.83342V16.4942C15.5008 16.6037 15.48 16.7122 15.4388 16.8136C15.3976 16.915 15.3369 17.0073 15.2601 17.0852C15.1832 17.1631 15.0918 17.2252 14.991 17.2678C14.8902 17.3103 14.7819 17.3327 14.6725 17.3334H1.3275C1.10865 17.3319 0.899181 17.2443 0.744348 17.0897C0.589515 16.935 0.501746 16.7256 0.5 16.5067V1.49341ZM7.16667 8.16675V5.66675H8.83333V8.16675H11.3333V9.83342H8.83333V12.3334H7.16667V9.83342H4.66667V8.16675H7.16667Z",
52197
+ );
52198
+ path.setAttribute("fill", "#696B76");
52199
+ fileIcon.appendChild(path);
52200
+ boardName.appendChild(fileIcon);
52201
+ const boardNameTag = document.querySelector('meta[name="board-name"]');
52202
+ let boardNameStr = "Untitled";
52203
+ if (boardNameTag) {
52204
+ boardNameStr = boardNameTag.getAttribute("content");
52205
+ }
52206
+ const p = document.createElement("p");
52207
+ p.textContent = boardNameStr;
52208
+ p.style.fontSize = "16px";
52209
+ p.style.lineHeight = "24px";
52210
+ boardName.appendChild(p);
52211
+ const cloudIcon = document.createElementNS(
52212
+ "http://www.w3.org/2000/svg",
52213
+ "svg",
52214
+ );
52215
+ cloudIcon.setAttribute("width", "20");
52216
+ cloudIcon.setAttribute("height", "18");
52217
+ cloudIcon.setAttribute("viewBox", "0 0 20 18");
52218
+ cloudIcon.setAttribute("fill", "none");
52219
+ cloudIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
52220
+ const cloudIconPath = document.createElementNS(
52221
+ "http://www.w3.org/2000/svg",
52222
+ "path",
52223
+ );
52224
+ cloudIconPath.setAttribute(
52225
+ "d",
52226
+ "M2.92711 0.75009L18.8371 16.6601L17.6579 17.8393L15.9796 16.1601C15.401 16.3854 14.7855 16.5007 14.1646 16.5001H5.83128C4.65063 16.5008 3.50782 16.0838 2.60518 15.3227C1.70255 14.5617 1.09833 13.5058 0.89953 12.342C0.700726 11.1782 0.920157 9.98165 1.51897 8.96413C2.11778 7.94662 3.05734 7.17382 4.17128 6.78259C4.13561 6.05854 4.23538 5.3342 4.46544 4.64676L1.74794 1.92842L2.92711 0.75009ZM5.83128 6.50009C5.83128 6.56759 5.83294 6.63592 5.83628 6.70259L5.89461 7.94259L4.72461 8.35426C3.98336 8.6164 3.35857 9.132 2.96052 9.81003C2.56248 10.4881 2.41678 11.2849 2.54916 12.0599C2.68153 12.8349 3.08347 13.5383 3.684 14.0457C4.28453 14.5532 5.04504 14.8322 5.83128 14.8334H14.1646C14.3196 14.8334 14.4721 14.8226 14.6213 14.8026L5.85628 6.03759C5.83961 6.18926 5.83128 6.34342 5.83128 6.50009ZM9.99794 0.666756C10.7878 0.666732 11.5694 0.827112 12.2954 1.13817C13.0214 1.44923 13.6767 1.90449 14.2215 2.47635C14.7664 3.04821 15.1894 3.72476 15.4649 4.46498C15.7405 5.2052 15.8629 5.99367 15.8246 6.78259C16.5167 7.02639 17.1467 7.41945 17.6699 7.93391C18.1931 8.44837 18.5967 9.07163 18.8521 9.75951C19.1076 10.4474 19.2085 11.183 19.1479 11.9143C19.0873 12.6455 18.8665 13.3545 18.5013 13.9909L17.2571 12.7468C17.5023 12.1401 17.5636 11.4747 17.4331 10.8335C17.3027 10.1924 16.9864 9.60375 16.5237 9.14112C16.061 8.67849 15.4723 8.36232 14.8311 8.23202C14.1899 8.10173 13.5245 8.16308 12.9179 8.40842L11.6729 7.16259C12.4071 6.74176 13.2571 6.50009 14.1646 6.50009C14.1646 5.73714 13.9551 4.98884 13.559 4.33679C13.1629 3.68473 12.5953 3.15396 11.9182 2.80235C11.2411 2.45073 10.4805 2.29177 9.71923 2.34281C8.95799 2.39384 8.22538 2.65291 7.60127 3.09176L6.40961 1.90009C7.43392 1.09887 8.69749 0.664571 9.99794 0.666756Z",
52227
+ );
52228
+ cloudIconPath.setAttribute("fill", "#696B76");
52229
+ cloudIcon.appendChild(cloudIconPath);
52230
+ boardName.appendChild(cloudIcon);
52231
+ boardName.style.display = "flex";
52232
+ boardName.style.alignItems = "center";
52233
+ boardName.style.gap = "8px";
52234
+ titlePanel.appendChild(boardName);
52235
+ titlePanel.appendChild(separator);
52236
+ titlePanel.appendChild(editButton);
52237
+ document.body.appendChild(titlePanel);
52238
+
52239
+ editButton.onclick = async () => {
52240
+ editButton.disabled = true;
52241
+ editButton.textContent = "Loading...";
52242
+
52243
+ try {
52244
+ document.removeEventListener("mousedown", handleMouseDown);
52245
+ document.removeEventListener("mousemove", handleMouseMove);
52246
+ document.removeEventListener("mouseup", handleMouseUp);
52247
+ document.removeEventListener("wheel", handleWheel, {
52248
+ passive: false,
52249
+ });
52250
+ translateX = 0;
52251
+ translateY = 0;
52252
+ scale = 1;
52253
+ updateTransform();
52254
+
52255
+ const { initBrowserSettings } = await import(
52256
+ "https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.js"
52257
+ );
52258
+ initBrowserSettings();
52259
+
52260
+ const { createApp } = await import(
52261
+ "https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.js"
52262
+ );
52263
+
52264
+ const app = createApp();
52265
+ window.app = app;
52266
+ const stringed = await app.openAndEditFile();
52267
+
52268
+ if (stringed) {
52269
+ await app.openBoardFromFile();
52270
+ app.getBoard().deserializeHTML(stringed);
52271
+ app.localRender("items");
52272
+ }
52273
+
52274
+ const response = await fetch(
52275
+ "https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.css",
52276
+ );
52277
+ const cssText = await response.text();
52278
+ const styleEl = document.createElement("style");
52279
+ styleEl.textContent = cssText;
52280
+ document.body.appendChild(styleEl);
52281
+
52282
+ const responseSvg = await fetch(
52283
+ "https://www.unpkg.com/test_package_board@0.0.99/dist/sprite.svg",
52284
+ );
52285
+ const svgText = await responseSvg.text();
52286
+ const div = document.createElement("div");
52287
+ div.style.display = "none";
52288
+ div.id = "sprite";
52289
+ div.innerHTML = svgText;
52290
+ document.body.appendChild(div);
52291
+ } finally {
52292
+ editButton.disabled = false;
52293
+ editButton.textContent = "Edit board";
52294
+ }
52295
+ };
52296
+ });
52297
+ `;
52298
+
52299
+ // src/public/loadLinkImages.js
52300
+ var loadLinkImages_default = `document.addEventListener("DOMContentLoaded", function () {
52301
+ document.querySelectorAll(".link-object").forEach(linkItem => {
52302
+ const linkImage = linkItem.querySelector(".link-image");
52303
+ const linkContainer = linkItem.querySelector("a");
52304
+ linkImage.onerror = () => {
52305
+ linkImage.onerror = null;
52306
+ linkImage.style.display = "none";
52307
+ const svgNamespace = "http://www.w3.org/2000/svg";
52308
+ const svg = document.createElementNS(svgNamespace, "svg");
52309
+ svg.setAttribute("width", "20");
52310
+ svg.setAttribute("height", "20");
52311
+ svg.setAttribute("viewBox", "0 0 13 14");
52312
+ svg.setAttribute("fill", "none");
52313
+
52314
+ const path = document.createElementNS(svgNamespace, "path");
52315
+ path.setAttribute(
52316
+ "d",
52317
+ "M11.0054 3.414L2.39838 12.021L0.984375 10.607L9.59037 2H2.00538V0H13.0054V11H11.0054V3.414Z",
52318
+ );
52319
+ path.setAttribute("fill", "#924FE8");
52320
+ svg.appendChild(path);
52321
+
52322
+ linkContainer.appendChild(svg);
52323
+ };
52324
+ });
52325
+ });
52326
+ `;
52327
+
52328
+ // src/public/index.css
52329
+ var public_default = `@import "https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap";
52330
+ @import "https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap";
52331
+
52332
+ /* ../src/index.css */
52333
+ :root {
52334
+ --background-surface-default: rgb(255, 255, 255);
52335
+ --background-button-secondary: rgb(255, 255, 255);
52336
+ --background-button-secondary-hover: rgb(247, 247, 248);
52337
+ --background-badge-purple-disabled: rgb(247, 241, 253);
52338
+ --background-badge-gray: rgb(233, 234, 236);
52339
+ --background-accent-purple: rgb(146, 79, 232);
52340
+ --border-action-normal: rgb(222, 223, 227);
52341
+ --border-action-focus: rgb(146, 79, 232);
52342
+ --border-select-primary: rgb(146, 79, 232);
52343
+ --text-base-primary: rgb(20, 21, 26);
52344
+ --text-base-secondary: rgba(15, 19, 36, 0.6);
52345
+ --text-base-quaternary: rgb(10, 15, 41, 0.25);
52346
+ --text-accent-purple: rgb(152, 89, 233);
52347
+ --icon-base-primary: rgb(20, 21, 26);
52348
+ --icon-base-secondary: rgb(105, 107, 118);
52349
+ --icon-accent-purple: rgb(146, 79, 232);
52350
+ --absolute-position-panel-padding: 12px;
52351
+ }
52352
+ * {
52353
+ box-sizing: border-box;
52354
+ padding: 0;
52355
+ margin: 0;
52356
+ border: none;
52357
+ background: none;
52358
+ font-family: inherit;
52359
+ }
52360
+ html {
52361
+ font-size: 62.5%;
52362
+ }
52363
+ body {
52364
+ color: var(--text-base-primary);
52365
+ font-size: 1.6rem;
52366
+ font-optical-sizing: auto;
52367
+ font-style: normal;
52368
+ font-family: "Manrope", sans-serif;
52369
+ }
52370
+ html,
52371
+ body {
52372
+ overscroll-behavior-x: none;
52373
+ -webkit-user-select: none;
52374
+ }
52375
+ input:-webkit-autofill,
52376
+ input:-webkit-autofill:hover,
52377
+ input:-webkit-autofill:focus,
52378
+ input:-webkit-autofill:active {
52379
+ -webkit-box-shadow: 0 0 0 30px white inset !important;
52380
+ }
52381
+ `;
52382
+
51935
52383
  // src/Board.ts
51936
52384
  class Board {
51937
52385
  boardId;
@@ -52314,9 +52762,9 @@ class Board {
52314
52762
  return this.copy();
52315
52763
  }
52316
52764
  serializeHTML() {
52317
- const customTagsScript = CUSTOM_WEB_COMPONENTS_JS;
52318
- const loadLinksImagesScript = LOAD_LINKS_IMAGES_JS;
52319
- const css = INDEX_CSS;
52765
+ const customTagsScript = customWebComponents_default;
52766
+ const loadLinksImagesScript = loadLinkImages_default;
52767
+ const css = public_default;
52320
52768
  const boardName = this.getName() || this.getBoardId();
52321
52769
  const items = this.items.getWholeHTML(conf.documentFactory);
52322
52770
  const itemsDiv = `<div id="items">${items}</div>`;
@@ -52729,7 +53177,7 @@ class Board {
52729
53177
  }
52730
53178
  removeVoidComments() {
52731
53179
  const voidComments = this.items.listAll().filter((item) => {
52732
- return item instanceof Comment2 && !item.getThread().length;
53180
+ return item instanceof Comment && !item.getThread().length;
52733
53181
  });
52734
53182
  if (voidComments) {
52735
53183
  for (const comment2 of voidComments) {