@yorkie-js/react 0.6.42 → 0.6.44

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.
@@ -6302,9 +6302,10 @@
6302
6302
  return this.root ? this.root.getWeight() : 0;
6303
6303
  }
6304
6304
  /**
6305
- * `find` returns the Node and offset of the given index.
6305
+ * `findForText` returns the Node and offset of the given position (cursor).
6306
+ * Used for Text where cursor placed between characters.
6306
6307
  */
6307
- find(pos) {
6308
+ findForText(pos) {
6308
6309
  if (!this.root || pos < 0) {
6309
6310
  return [void 0, 0];
6310
6311
  }
@@ -6329,6 +6330,34 @@
6329
6330
  this.splayNode(node);
6330
6331
  return [node, pos];
6331
6332
  }
6333
+ /**
6334
+ * `findForArray` returns the Node of the given position (index).
6335
+ * Used for Array where index points to the element.
6336
+ */
6337
+ findForArray(idx) {
6338
+ if (!this.root) {
6339
+ return void 0;
6340
+ }
6341
+ if (idx < 0 || idx >= this.length) {
6342
+ throw new YorkieError(
6343
+ Code.ErrInvalidArgument,
6344
+ `out of index range: idx: ${idx}, length: ${this.length}`
6345
+ );
6346
+ }
6347
+ let node = this.root;
6348
+ for (; ; ) {
6349
+ if (node.hasLeft() && idx < node.getLeftWeight()) {
6350
+ node = node.getLeft();
6351
+ } else if (node.hasRight() && node.getLeftWeight() + node.getLength() <= idx) {
6352
+ idx -= node.getLeftWeight() + node.getLength();
6353
+ node = node.getRight();
6354
+ } else {
6355
+ break;
6356
+ }
6357
+ }
6358
+ this.splayNode(node);
6359
+ return node;
6360
+ }
6332
6361
  /**
6333
6362
  * Find the index of the given node in BST.
6334
6363
  *
@@ -8011,15 +8040,8 @@
8011
8040
  if (idx >= this.length) {
8012
8041
  return;
8013
8042
  }
8014
- const [node, offset] = this.nodeMapByIndex.find(idx);
8015
- let rgaNode = node;
8016
- if (idx === 0 && node === this.dummyHead || offset > 0) {
8017
- do {
8018
- if (rgaNode) {
8019
- rgaNode = rgaNode.getNext();
8020
- }
8021
- } while (rgaNode && rgaNode.isRemoved());
8022
- }
8043
+ const node = this.nodeMapByIndex.findForArray(idx);
8044
+ const rgaNode = node;
8023
8045
  return rgaNode;
8024
8046
  }
8025
8047
  /**
@@ -9486,7 +9508,7 @@
9486
9508
  * `indexToPos` finds RGATreeSplitPos of given offset.
9487
9509
  */
9488
9510
  indexToPos(idx) {
9489
- const [node, offset] = this.treeByIndex.find(idx);
9511
+ const [node, offset] = this.treeByIndex.findForText(idx);
9490
9512
  const splitNode = node;
9491
9513
  return RGATreeSplitPos.of(splitNode.getID(), offset);
9492
9514
  }
@@ -19246,7 +19268,7 @@
19246
19268
  };
19247
19269
  }
19248
19270
  const name$1 = "@yorkie-js/sdk";
19249
- const version$1 = "0.6.42";
19271
+ const version$1 = "0.6.44";
19250
19272
  const pkg$1 = {
19251
19273
  name: name$1,
19252
19274
  version: version$1
@@ -19779,8 +19801,7 @@
19779
19801
  {
19780
19802
  clientId: this.id,
19781
19803
  documentId: attachment.resourceID,
19782
- changePack: converter.toChangePack(doc.createChangePack()),
19783
- removeIfNotAttached: opts.removeIfNotAttached ?? false
19804
+ changePack: converter.toChangePack(doc.createChangePack())
19784
19805
  },
19785
19806
  { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
19786
19807
  );
@@ -21033,7 +21054,7 @@
21033
21054
  };
21034
21055
  }
21035
21056
  const name = "@yorkie-js/react";
21036
- const version = "0.6.42";
21057
+ const version = "0.6.44";
21037
21058
  const pkg = {
21038
21059
  name,
21039
21060
  version