@excalidraw/excalidraw 0.18.0-6d870b1c8 → 0.18.0-7b8a5f54c

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.
@@ -2,7 +2,7 @@ import {
2
2
  decodePngMetadata,
3
3
  encodePngMetadata,
4
4
  getTEXtChunk
5
- } from "../chunk-D5WIFFIO.js";
5
+ } from "../chunk-CRKRRBMD.js";
6
6
  import "../chunk-CP5DND7P.js";
7
7
  import "../chunk-XDFCUUT6.js";
8
8
  export {
@@ -10,4 +10,4 @@ export {
10
10
  encodePngMetadata,
11
11
  getTEXtChunk
12
12
  };
13
- //# sourceMappingURL=image-WMAXQLTI.js.map
13
+ //# sourceMappingURL=image-IWGLHPIX.js.map
package/dist/dev/index.js CHANGED
@@ -69,7 +69,7 @@ import {
69
69
  serializeLibraryAsJSON,
70
70
  strokeEllipseWithRotation,
71
71
  strokeRectWithRotation
72
- } from "./chunk-D5WIFFIO.js";
72
+ } from "./chunk-CRKRRBMD.js";
73
73
  import {
74
74
  define_import_meta_env_default
75
75
  } from "./chunk-CP5DND7P.js";
@@ -204,7 +204,7 @@ import {
204
204
  updateBoundElements as updateBoundElements3,
205
205
  getSuggestedBindingsForArrows,
206
206
  LinearElementEditor as LinearElementEditor12,
207
- newElementWith as newElementWith10,
207
+ newElementWith as newElementWith11,
208
208
  newFrameElement as newFrameElement3,
209
209
  newFreeDrawElement,
210
210
  newEmbeddableElement,
@@ -319,7 +319,8 @@ import {
319
319
  CaptureUpdateAction as CaptureUpdateAction37,
320
320
  hitElementBoundingBox as hitElementBoundingBox2,
321
321
  isLineElement as isLineElement7,
322
- isSimpleArrow
322
+ isSimpleArrow,
323
+ StoreDelta as StoreDelta2
323
324
  } from "@excalidraw/element";
324
325
 
325
326
  // actions/actionDeleteSelected.tsx
@@ -7805,7 +7806,11 @@ import {
7805
7806
  bindOrUnbindLinearElement,
7806
7807
  isBindingEnabled
7807
7808
  } from "@excalidraw/element/binding";
7808
- import { isValidPolygon, LinearElementEditor as LinearElementEditor5 } from "@excalidraw/element";
7809
+ import {
7810
+ isValidPolygon,
7811
+ LinearElementEditor as LinearElementEditor5,
7812
+ newElementWith as newElementWith4
7813
+ } from "@excalidraw/element";
7809
7814
  import {
7810
7815
  isBindingElement,
7811
7816
  isFreeDrawElement,
@@ -7850,7 +7855,14 @@ var actionFinalize = register({
7850
7855
  if (linearElementEditor !== appState.selectedLinearElement) {
7851
7856
  let newElements2 = elements;
7852
7857
  if (element2 && isInvisiblySmallElement(element2)) {
7853
- newElements2 = newElements2.filter((el) => el.id !== element2.id);
7858
+ newElements2 = newElements2.map((el) => {
7859
+ if (el.id === element2.id) {
7860
+ return newElementWith4(el, {
7861
+ isDeleted: true
7862
+ });
7863
+ }
7864
+ return el;
7865
+ });
7854
7866
  }
7855
7867
  return {
7856
7868
  elements: newElements2,
@@ -7883,7 +7895,12 @@ var actionFinalize = register({
7883
7895
  });
7884
7896
  }
7885
7897
  return {
7886
- elements: element2.points.length < 2 || isInvisiblySmallElement(element2) ? elements.filter((el) => el.id !== element2.id) : void 0,
7898
+ elements: element2.points.length < 2 || isInvisiblySmallElement(element2) ? elements.map((el) => {
7899
+ if (el.id === element2.id) {
7900
+ return newElementWith4(el, { isDeleted: true });
7901
+ }
7902
+ return el;
7903
+ }) : void 0,
7887
7904
  appState: {
7888
7905
  ...appState,
7889
7906
  cursorButton: "up",
@@ -7925,7 +7942,12 @@ var actionFinalize = register({
7925
7942
  }
7926
7943
  }
7927
7944
  if (element && isInvisiblySmallElement(element)) {
7928
- newElements = newElements.filter((el) => el.id !== element.id);
7945
+ newElements = newElements.map((el) => {
7946
+ if (el.id === element?.id) {
7947
+ return newElementWith4(el, { isDeleted: true });
7948
+ }
7949
+ return el;
7950
+ });
7929
7951
  }
7930
7952
  if (isLinearElement3(element) || isFreeDrawElement(element)) {
7931
7953
  const isLoop = isPathALoop(element.points, appState.zoom.value);
@@ -8937,7 +8959,7 @@ var exportCanvas = async (type, elements, appState, files, {
8937
8959
  let blob = canvasToBlob(tempCanvas);
8938
8960
  if (appState.exportEmbedScene) {
8939
8961
  blob = blob.then(
8940
- (blob2) => import("./data/image-WMAXQLTI.js").then(
8962
+ (blob2) => import("./data/image-IWGLHPIX.js").then(
8941
8963
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
8942
8964
  blob: blob2,
8943
8965
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -9278,7 +9300,7 @@ import {
9278
9300
  KEYS as KEYS16,
9279
9301
  getLineHeight as getLineHeight2
9280
9302
  } from "@excalidraw/common";
9281
- import { newElementWith as newElementWith4 } from "@excalidraw/element";
9303
+ import { newElementWith as newElementWith5 } from "@excalidraw/element";
9282
9304
  import {
9283
9305
  hasBoundTextElement,
9284
9306
  canApplyRoundnessTypeToElement,
@@ -9349,7 +9371,7 @@ var actionPasteStyles = register({
9349
9371
  if (!elementStylesToCopyFrom) {
9350
9372
  return element;
9351
9373
  }
9352
- let newElement6 = newElementWith4(element, {
9374
+ let newElement6 = newElementWith5(element, {
9353
9375
  backgroundColor: elementStylesToCopyFrom?.backgroundColor,
9354
9376
  strokeWidth: elementStylesToCopyFrom?.strokeWidth,
9355
9377
  strokeColor: elementStylesToCopyFrom?.strokeColor,
@@ -9365,7 +9387,7 @@ var actionPasteStyles = register({
9365
9387
  if (isTextElement3(newElement6)) {
9366
9388
  const fontSize = elementStylesToCopyFrom.fontSize || DEFAULT_FONT_SIZE3;
9367
9389
  const fontFamily = elementStylesToCopyFrom.fontFamily || DEFAULT_FONT_FAMILY3;
9368
- newElement6 = newElementWith4(newElement6, {
9390
+ newElement6 = newElementWith5(newElement6, {
9369
9391
  fontSize,
9370
9392
  fontFamily,
9371
9393
  textAlign: elementStylesToCopyFrom.textAlign || DEFAULT_TEXT_ALIGN,
@@ -9380,13 +9402,13 @@ var actionPasteStyles = register({
9380
9402
  redrawTextBoundingBox2(newElement6, container, app.scene);
9381
9403
  }
9382
9404
  if (newElement6.type === "arrow" && isArrowElement2(elementStylesToCopyFrom)) {
9383
- newElement6 = newElementWith4(newElement6, {
9405
+ newElement6 = newElementWith5(newElement6, {
9384
9406
  startArrowhead: elementStylesToCopyFrom.startArrowhead,
9385
9407
  endArrowhead: elementStylesToCopyFrom.endArrowhead
9386
9408
  });
9387
9409
  }
9388
9410
  if (isFrameLikeElement4(element)) {
9389
- newElement6 = newElementWith4(newElement6, {
9411
+ newElement6 = newElementWith5(newElement6, {
9390
9412
  roundness: null,
9391
9413
  backgroundColor: "transparent"
9392
9414
  });
@@ -9480,7 +9502,7 @@ var actionShortcuts = register({
9480
9502
 
9481
9503
  // actions/actionGroup.tsx
9482
9504
  import { getNonDeletedElements as getNonDeletedElements9 } from "@excalidraw/element";
9483
- import { newElementWith as newElementWith5 } from "@excalidraw/element";
9505
+ import { newElementWith as newElementWith6 } from "@excalidraw/element";
9484
9506
  import { isBoundToContainer as isBoundToContainer3 } from "@excalidraw/element";
9485
9507
  import {
9486
9508
  frameAndChildrenSelectedTogether,
@@ -9584,7 +9606,7 @@ var actionGroup = register({
9584
9606
  if (!selectElementIds.get(element.id)) {
9585
9607
  return element;
9586
9608
  }
9587
- return newElementWith5(element, {
9609
+ return newElementWith6(element, {
9588
9610
  groupIds: addToGroup(
9589
9611
  element.groupIds,
9590
9612
  newGroupId,
@@ -9661,7 +9683,7 @@ var actionUngroup = register({
9661
9683
  if (nextGroupIds.length === element.groupIds.length) {
9662
9684
  return element;
9663
9685
  }
9664
- return newElementWith5(element, {
9686
+ return newElementWith6(element, {
9665
9687
  groupIds: nextGroupIds
9666
9688
  });
9667
9689
  });
@@ -10460,7 +10482,7 @@ import {
10460
10482
  isBindingEnabled as isBindingEnabled2
10461
10483
  } from "@excalidraw/element";
10462
10484
  import { getCommonBoundingBox } from "@excalidraw/element";
10463
- import { newElementWith as newElementWith6 } from "@excalidraw/element";
10485
+ import { newElementWith as newElementWith7 } from "@excalidraw/element";
10464
10486
  import { deepCopyElement as deepCopyElement3 } from "@excalidraw/element";
10465
10487
  import { resizeMultipleElements } from "@excalidraw/element";
10466
10488
  import {
@@ -10546,7 +10568,7 @@ var flipElements = (selectedElements, elementsMap, appState, flipDirection, app)
10546
10568
  )) {
10547
10569
  return selectedElements.map((element) => {
10548
10570
  const _element = element;
10549
- return newElementWith6(_element, {
10571
+ return newElementWith7(_element, {
10550
10572
  startArrowhead: _element.endArrowhead,
10551
10573
  endArrowhead: _element.startArrowhead
10552
10574
  });
@@ -11617,7 +11639,7 @@ var actionLink = register({
11617
11639
  import { KEYS as KEYS29, arrayToMap as arrayToMap11, randomId as randomId4 } from "@excalidraw/common";
11618
11640
  import {
11619
11641
  elementsAreInSameGroup,
11620
- newElementWith as newElementWith7,
11642
+ newElementWith as newElementWith8,
11621
11643
  selectGroupsFromGivenElements
11622
11644
  } from "@excalidraw/element";
11623
11645
  import { CaptureUpdateAction as CaptureUpdateAction25 } from "@excalidraw/element";
@@ -11678,7 +11700,7 @@ var actionToggleElementLock = register({
11678
11700
  (groupId) => !appState.lockedMultiSelections[groupId]
11679
11701
  );
11680
11702
  }
11681
- return newElementWith7(element, {
11703
+ return newElementWith8(element, {
11682
11704
  locked: nextLockState,
11683
11705
  // do not recreate the array unncessarily
11684
11706
  groupIds: nextGroupIds.length !== element.groupIds.length ? nextGroupIds : element.groupIds
@@ -11727,7 +11749,7 @@ var actionUnlockAllElements = register({
11727
11749
  const nextGroupIds = element.groupIds.filter(
11728
11750
  (gid) => !appState.lockedMultiSelections[gid]
11729
11751
  );
11730
- return newElementWith7(element, {
11752
+ return newElementWith8(element, {
11731
11753
  locked: false,
11732
11754
  groupIds: (
11733
11755
  // do not recreate the array unncessarily
@@ -12844,7 +12866,7 @@ var exportToCanvas2 = ({
12844
12866
  { elements, appState },
12845
12867
  null,
12846
12868
  null,
12847
- { deleteEmptyTextElements: true }
12869
+ { deleteInvisibleElements: true }
12848
12870
  );
12849
12871
  const { exportBackground, viewBackgroundColor } = restoredAppState;
12850
12872
  return exportToCanvas(
@@ -12939,7 +12961,7 @@ var exportToSvg2 = async ({
12939
12961
  { elements, appState },
12940
12962
  null,
12941
12963
  null,
12942
- { deleteEmptyTextElements: true }
12964
+ { deleteInvisibleElements: true }
12943
12965
  );
12944
12966
  const exportAppState = {
12945
12967
  ...restoredAppState,
@@ -18228,7 +18250,7 @@ var generateElbowArrowShape = (points, radius) => {
18228
18250
  };
18229
18251
 
18230
18252
  // ../element/src/mutateElement.ts
18231
- var newElementWith8 = (element, updates, force = false) => {
18253
+ var newElementWith9 = (element, updates, force = false) => {
18232
18254
  let didChange = false;
18233
18255
  for (const key in updates) {
18234
18256
  const value = updates[key];
@@ -18357,7 +18379,7 @@ var actionTogglePolygon = register({
18357
18379
  if (!targetElementsMap.has(element.id) || !isLineElement4(element)) {
18358
18380
  return element;
18359
18381
  }
18360
- return newElementWith8(element, {
18382
+ return newElementWith9(element, {
18361
18383
  backgroundColor: nextPolygonState ? element.backgroundColor : "transparent",
18362
18384
  ...toggleLinePolygonState3(element, nextPolygonState)
18363
18385
  });
@@ -18949,7 +18971,7 @@ var createRedoAction = (history) => ({
18949
18971
 
18950
18972
  // actions/actionTextAutoResize.ts
18951
18973
  import { getFontString as getFontString6 } from "@excalidraw/common";
18952
- import { newElementWith as newElementWith9 } from "@excalidraw/element";
18974
+ import { newElementWith as newElementWith10 } from "@excalidraw/element";
18953
18975
  import { measureText as measureText4 } from "@excalidraw/element";
18954
18976
  import { isTextElement as isTextElement9 } from "@excalidraw/element";
18955
18977
  import { CaptureUpdateAction as CaptureUpdateAction34 } from "@excalidraw/element";
@@ -18973,7 +18995,7 @@ var actionTextAutoResize = register({
18973
18995
  getFontString6(element),
18974
18996
  element.lineHeight
18975
18997
  );
18976
- return newElementWith9(element, {
18998
+ return newElementWith10(element, {
18977
18999
  autoResize: true,
18978
19000
  width: metrics.width,
18979
19001
  height: metrics.height,
@@ -31603,7 +31625,7 @@ var App = class _App extends React43.Component {
31603
31625
  this.updateScene({
31604
31626
  elements: this.scene.getElementsIncludingDeleted().map((el) => {
31605
31627
  if (this.state.selectedElementIds[el.id]) {
31606
- return newElementWith10(el, {
31628
+ return newElementWith11(el, {
31607
31629
  [shouldUpdateStrokeColor ? "strokeColor" : "backgroundColor"]: color
31608
31630
  });
31609
31631
  }
@@ -31769,7 +31791,7 @@ var App = class _App extends React43.Component {
31769
31791
  }
31770
31792
  const scene = restore(initialData, null, null, {
31771
31793
  repairBindings: true,
31772
- deleteEmptyTextElements: true
31794
+ deleteInvisibleElements: true
31773
31795
  });
31774
31796
  scene.appState = {
31775
31797
  ...scene.appState,
@@ -32091,7 +32113,7 @@ var App = class _App extends React43.Component {
32091
32113
  ));
32092
32114
  __publicField(this, "addElementsFromPasteOrLibrary", (opts) => {
32093
32115
  const elements = restoreElements(opts.elements, null, {
32094
- deleteEmptyTextElements: true
32116
+ deleteInvisibleElements: true
32095
32117
  });
32096
32118
  const [minX, minY, maxX, maxY] = getCommonBounds12(elements);
32097
32119
  const elementsCenterX = distance2(minX, maxX) / 2;
@@ -32108,7 +32130,7 @@ var App = class _App extends React43.Component {
32108
32130
  const { duplicatedElements } = duplicateElements3({
32109
32131
  type: "everything",
32110
32132
  elements: elements.map((element) => {
32111
- return newElementWith10(element, {
32133
+ return newElementWith11(element, {
32112
32134
  x: element.x + gridX - minX,
32113
32135
  y: element.y + gridY - minY
32114
32136
  });
@@ -32455,6 +32477,18 @@ var App = class _App extends React43.Component {
32455
32477
  }
32456
32478
  }
32457
32479
  ));
32480
+ __publicField(this, "applyDeltas", (deltas, options) => {
32481
+ const nextElements = new Map(
32482
+ this.scene.getElementsMapIncludingDeleted()
32483
+ );
32484
+ const nextAppState = { ...this.state };
32485
+ const [head, ...tail] = deltas;
32486
+ const mainDelta = StoreDelta2.load(head);
32487
+ for (const delta of tail) {
32488
+ mainDelta.squash(delta);
32489
+ }
32490
+ return StoreDelta2.applyTo(mainDelta, nextElements, nextAppState, options);
32491
+ });
32458
32492
  __publicField(this, "mutateElement", (element, updates, informMutation = true) => {
32459
32493
  return this.scene.mutateElement(element, updates, {
32460
32494
  informMutation,
@@ -33476,7 +33510,7 @@ var App = class _App extends React43.Component {
33476
33510
  __publicField(this, "getTopLayerFrameAtSceneCoords", (sceneCoords) => {
33477
33511
  const elementsMap = this.scene.getNonDeletedElementsMap();
33478
33512
  const frames = this.scene.getNonDeletedFramesLikes().filter(
33479
- (frame) => isCursorInFrame(sceneCoords, frame, elementsMap)
33513
+ (frame) => !frame.locked && isCursorInFrame(sceneCoords, frame, elementsMap)
33480
33514
  );
33481
33515
  return frames.length ? frames[frames.length - 1] : null;
33482
33516
  });
@@ -34875,7 +34909,7 @@ var App = class _App extends React43.Component {
34875
34909
  const elements = this.scene.getElementsIncludingDeleted().map((ele) => {
34876
34910
  if (this.elementsPendingErasure.has(ele.id) || ele.frameId && this.elementsPendingErasure.has(ele.frameId) || isBoundToContainer8(ele) && this.elementsPendingErasure.has(ele.containerId)) {
34877
34911
  didChange = true;
34878
- return newElementWith10(ele, { isDeleted: true });
34912
+ return newElementWith11(ele, { isDeleted: true });
34879
34913
  }
34880
34914
  return ele;
34881
34915
  });
@@ -34984,7 +35018,7 @@ var App = class _App extends React43.Component {
34984
35018
  */
34985
35019
  __publicField(this, "getLatestInitializedImageElement", (imagePlaceholder, fileId) => {
34986
35020
  const latestImageElement = this.scene.getElement(imagePlaceholder.id) ?? imagePlaceholder;
34987
- return newElementWith10(
35021
+ return newElementWith11(
34988
35022
  latestImageElement,
34989
35023
  {
34990
35024
  fileId
@@ -35105,7 +35139,7 @@ var App = class _App extends React43.Component {
35105
35139
  this.scene.replaceAllElements(
35106
35140
  elements.map((element) => {
35107
35141
  if (isInitializedImageElement3(element) && erroredFiles.has(element.fileId)) {
35108
- return newElementWith10(element, {
35142
+ return newElementWith11(element, {
35109
35143
  status: "error"
35110
35144
  });
35111
35145
  }
@@ -35849,6 +35883,7 @@ var App = class _App extends React43.Component {
35849
35883
  if (excalidrawAPI) {
35850
35884
  const api = {
35851
35885
  updateScene: this.updateScene,
35886
+ applyDeltas: this.applyDeltas,
35852
35887
  mutateElement: this.mutateElement,
35853
35888
  updateLibrary: this.library.updateLibrary,
35854
35889
  addFiles: this.addFiles,
@@ -37142,7 +37177,7 @@ var App = class _App extends React43.Component {
37142
37177
  // Not sure why we include deleted elements as well hence using deleted elements map
37143
37178
  ...this.scene.getElementsIncludingDeleted().map((_element) => {
37144
37179
  if (_element.id === element.id && isTextElement19(_element)) {
37145
- return newElementWith10(_element, {
37180
+ return newElementWith11(_element, {
37146
37181
  originalText: nextOriginalText,
37147
37182
  isDeleted: isDeleted ?? _element.isDeleted,
37148
37183
  // returns (wrapped) text and new dimensions
@@ -37954,7 +37989,7 @@ var App = class _App extends React43.Component {
37954
37989
  if (idsOfElementsToDuplicate.has(el.id)) {
37955
37990
  const origEl = pointerDownState.originalElements.get(el.id);
37956
37991
  if (origEl) {
37957
- return newElementWith10(el, {
37992
+ return newElementWith11(el, {
37958
37993
  x: origEl.x,
37959
37994
  y: origEl.y
37960
37995
  });
@@ -39405,7 +39440,7 @@ import {
39405
39440
  } from "@excalidraw/common";
39406
39441
  import {
39407
39442
  mutateElement as mutateElement2,
39408
- newElementWith as newElementWith11,
39443
+ newElementWith as newElementWith12,
39409
39444
  bumpVersion
39410
39445
  } from "@excalidraw/element";
39411
39446
  import { CaptureUpdateAction as CaptureUpdateAction38 } from "@excalidraw/element";
@@ -39656,7 +39691,7 @@ export {
39656
39691
  loadSceneOrLibraryFromBlob,
39657
39692
  mergeLibraryItems,
39658
39693
  mutateElement2 as mutateElement,
39659
- newElementWith11 as newElementWith,
39694
+ newElementWith12 as newElementWith,
39660
39695
  normalizeLink4 as normalizeLink,
39661
39696
  parseLibraryTokensFromUrl,
39662
39697
  reconcileElements,