@upmade/core 0.6.2 → 0.6.3

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.
@@ -5762,16 +5762,23 @@ function dropPoint(doc3, pos, slice) {
5762
5762
  for (let pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {
5763
5763
  for (let d2 = $pos.depth; d2 >= 0; d2--) {
5764
5764
  let bias = d2 == $pos.depth ? 0 : $pos.pos <= ($pos.start(d2 + 1) + $pos.end(d2 + 1)) / 2 ? -1 : 1;
5765
- let insertPos = $pos.index(d2) + (bias > 0 ? 1 : 0);
5766
- let parent = $pos.node(d2), fits = false;
5767
- if (pass == 1) {
5768
- fits = parent.canReplace(insertPos, insertPos, content);
5769
- } else {
5770
- let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
5771
- fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
5765
+ for (let attempt = 0; attempt < 2; attempt++) {
5766
+ if (attempt) {
5767
+ if (!bias)
5768
+ break;
5769
+ bias = -bias;
5770
+ }
5771
+ let insertPos = $pos.index(d2) + (bias > 0 ? 1 : 0);
5772
+ let parent = $pos.node(d2), fits = false;
5773
+ if (pass == 1) {
5774
+ fits = parent.canReplace(insertPos, insertPos, content);
5775
+ } else {
5776
+ let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
5777
+ fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
5778
+ }
5779
+ if (fits)
5780
+ return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d2 + 1) : $pos.after(d2 + 1);
5772
5781
  }
5773
- if (fits)
5774
- return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d2 + 1) : $pos.after(d2 + 1);
5775
5782
  }
5776
5783
  }
5777
5784
  return null;
@@ -14338,9 +14345,10 @@ var lightTheme = {
14338
14345
  separatorColor: "hsl(0, 0%, 0%, 8%)"
14339
14346
  },
14340
14347
  watermark: {
14341
- background: "rgba(255, 255, 255, 0.6)",
14342
- boxShadow: "0 1px 2px rgba(0, 0, 0, 0.12)",
14343
- color: "rgba(60, 60, 60, 0.75)"
14348
+ background: "rgba(255, 255, 255, 0.9)",
14349
+ boxShadow: "0 1px 3px rgba(0, 0, 0, 0.12)",
14350
+ color: "#52525b",
14351
+ logoColor: "#000000"
14344
14352
  },
14345
14353
  chatBox: {
14346
14354
  backgroundColor: "#ffffff",
@@ -14764,9 +14772,10 @@ var darkTheme = {
14764
14772
  separatorColor: "hsl(0, 0%, 100%, 12%)"
14765
14773
  },
14766
14774
  watermark: {
14767
- background: "rgba(40, 40, 40, 0.6)",
14768
- boxShadow: "0 1px 2px rgba(0, 0, 0, 0.35)",
14769
- color: "rgba(220, 220, 220, 0.8)"
14775
+ background: "rgba(40, 40, 40, 0.9)",
14776
+ boxShadow: "0 1px 3px rgba(0, 0, 0, 0.35)",
14777
+ color: "#d4d4d8",
14778
+ logoColor: "#ffffff"
14770
14779
  },
14771
14780
  chatBox: {
14772
14781
  backgroundColor: "#2a2a2a",
@@ -43634,7 +43643,7 @@ var CURRENT_APP_STATE_SCHEMA_VERSION = 2;
43634
43643
  var CURRENT_WORKSPACE_SCHEMA_VERSION = 3;
43635
43644
 
43636
43645
  // src/constants/version.ts
43637
- var UPMADE_VERSION = "0.6.2";
43646
+ var UPMADE_VERSION = "0.6.3";
43638
43647
 
43639
43648
  // src/configs/default-engine-config.ts
43640
43649
  var DEFAULT_ENGINE_CONFIG = {
@@ -45238,6 +45247,40 @@ var UpmadeObjectMap = class _UpmadeObjectMap {
45238
45247
  }
45239
45248
  }
45240
45249
  }
45250
+ /**
45251
+ * Removes an object the local user started but did not finish, as if it had never been made,
45252
+ * e.g. a brush stroke whose first finger turned out to be the start of a pinch-zoom.
45253
+ *
45254
+ * Unlike `remove()`, which records the removal as an undo step of its own (so undo would bring
45255
+ * the half-made object back), the deletion joins the still open undo step that recorded the
45256
+ * object's insertion. Yjs never restores what was created and deleted in the same step. If that
45257
+ * step holds nothing else, it is dropped, so the next undo reverts the user's previous action.
45258
+ *
45259
+ * @param objectId - The ID of the object to discard
45260
+ */
45261
+ discard(objectId) {
45262
+ if (!this._idMap.has(objectId)) {
45263
+ return;
45264
+ }
45265
+ this.quadtree.remove((o3) => o3.id === objectId);
45266
+ this._idMap.delete(objectId);
45267
+ if (this._localActiveDrawingObjectId === objectId) {
45268
+ this._localActiveDrawingObjectId = null;
45269
+ }
45270
+ if (this._objectsMap?.has(objectId)) {
45271
+ const undoManager = this._undoManager;
45272
+ const stackLength = undoManager?.undoStack.length ?? 0;
45273
+ const origin = this.writeOrigin;
45274
+ this._ydoc?.transact(() => {
45275
+ this._objectsMap?.delete(objectId);
45276
+ }, origin);
45277
+ const top = undoManager?.undoStack[stackLength - 1];
45278
+ if (undoManager && top && origin === "local" && this._transactionDepth === 0 && this._temporaryItemsCount === 0 && undoManager.undoStack.length === stackLength && Y5.equalDeleteSets(top.insertions, top.deletions)) {
45279
+ undoManager.undoStack.pop();
45280
+ }
45281
+ }
45282
+ this.markUndoBoundary();
45283
+ }
45241
45284
  /**
45242
45285
  * Filters objects in the quadtree based on a predicate function.
45243
45286
  *
@@ -50921,9 +50964,10 @@ var UpmadeViewport = class _UpmadeViewport {
50921
50964
  }
50922
50965
  if (activePointers.length === 2) {
50923
50966
  this._core.store.objects?.clearCursorPosition();
50924
- const currentPath = this._core.store.currentPath;
50925
- if (currentPath) {
50926
- this._core.store.objects.remove((obj) => obj.id === currentPath.id);
50967
+ const drawingObjectId = this._core.store.objects?.localActiveDrawingObjectId;
50968
+ const drawingObject = drawingObjectId ? this._core.store.objects.findById(drawingObjectId) : void 0;
50969
+ if (drawingObject instanceof UpmadePath) {
50970
+ this._core.store.objects.discard(drawingObject.id);
50927
50971
  }
50928
50972
  if (this._core.store.state.isSelecting) {
50929
50973
  this._core.store.state.isSelecting = false;