slate-angular 1.8.0 → 1.9.2

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.
@@ -1432,15 +1432,15 @@
1432
1432
  }
1433
1433
  };
1434
1434
  e.apply = function (op) {
1435
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
1435
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
1436
1436
  var matches = [];
1437
1437
  switch (op.type) {
1438
1438
  case 'insert_text':
1439
1439
  case 'remove_text':
1440
1440
  case 'set_node': {
1441
1441
  try {
1442
- for (var _e = __values(slate.Editor.levels(e, { at: op.path })), _f = _e.next(); !_f.done; _f = _e.next()) {
1443
- var _g = __read(_f.value, 2), node = _g[0], path = _g[1];
1442
+ for (var _f = __values(slate.Editor.levels(e, { at: op.path })), _g = _f.next(); !_g.done; _g = _f.next()) {
1443
+ var _h = __read(_g.value, 2), node = _h[0], path = _h[1];
1444
1444
  var key = AngularEditor.findKey(e, node);
1445
1445
  matches.push([path, key]);
1446
1446
  }
@@ -1448,7 +1448,7 @@
1448
1448
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
1449
1449
  finally {
1450
1450
  try {
1451
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
1451
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
1452
1452
  }
1453
1453
  finally { if (e_1) throw e_1.error; }
1454
1454
  }
@@ -1459,10 +1459,10 @@
1459
1459
  case 'merge_node':
1460
1460
  case 'split_node': {
1461
1461
  try {
1462
- for (var _h = __values(slate.Editor.levels(e, {
1462
+ for (var _j = __values(slate.Editor.levels(e, {
1463
1463
  at: slate.Path.parent(op.path),
1464
- })), _j = _h.next(); !_j.done; _j = _h.next()) {
1465
- var _k = __read(_j.value, 2), node = _k[0], path = _k[1];
1464
+ })), _k = _j.next(); !_k.done; _k = _j.next()) {
1465
+ var _l = __read(_k.value, 2), node = _l[0], path = _l[1];
1466
1466
  var key = AngularEditor.findKey(e, node);
1467
1467
  matches.push([path, key]);
1468
1468
  }
@@ -1470,46 +1470,61 @@
1470
1470
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
1471
1471
  finally {
1472
1472
  try {
1473
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
1473
+ if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
1474
1474
  }
1475
1475
  finally { if (e_2) throw e_2.error; }
1476
1476
  }
1477
1477
  break;
1478
1478
  }
1479
1479
  case 'move_node': {
1480
+ var commonPath = slate.Path.common(slate.Path.parent(op.path), slate.Path.parent(op.newPath));
1480
1481
  try {
1481
- for (var _l = __values(slate.Editor.levels(e, {
1482
- at: slate.Path.common(slate.Path.parent(op.path), slate.Path.parent(op.newPath)),
1483
- })), _m = _l.next(); !_m.done; _m = _l.next()) {
1484
- var _o = __read(_m.value, 2), node = _o[0], path = _o[1];
1482
+ for (var _m = __values(slate.Editor.levels(e, { at: slate.Path.parent(op.path) })), _o = _m.next(); !_o.done; _o = _m.next()) {
1483
+ var _p = __read(_o.value, 2), node = _p[0], path = _p[1];
1485
1484
  var key = AngularEditor.findKey(e, node);
1486
- matches.push([path, key]);
1485
+ matches.push([slate.Editor.pathRef(editor, path), key]);
1487
1486
  }
1488
1487
  }
1489
1488
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
1490
1489
  finally {
1491
1490
  try {
1492
- if (_m && !_m.done && (_c = _l.return)) _c.call(_l);
1491
+ if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
1493
1492
  }
1494
1493
  finally { if (e_3) throw e_3.error; }
1495
1494
  }
1495
+ try {
1496
+ for (var _q = __values(slate.Editor.levels(e, { at: slate.Path.parent(op.newPath) })), _r = _q.next(); !_r.done; _r = _q.next()) {
1497
+ var _s = __read(_r.value, 2), node = _s[0], path = _s[1];
1498
+ if (path.length > commonPath.length) {
1499
+ var key = AngularEditor.findKey(e, node);
1500
+ matches.push([slate.Editor.pathRef(editor, path), key]);
1501
+ }
1502
+ }
1503
+ }
1504
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1505
+ finally {
1506
+ try {
1507
+ if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
1508
+ }
1509
+ finally { if (e_4) throw e_4.error; }
1510
+ }
1496
1511
  break;
1497
1512
  }
1498
1513
  }
1499
1514
  apply(op);
1500
1515
  try {
1501
1516
  for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1502
- var _p = __read(matches_1_1.value, 2), path = _p[0], key = _p[1];
1503
- var _q = __read(slate.Editor.node(e, path), 1), node = _q[0];
1517
+ var _t = __read(matches_1_1.value, 2), source = _t[0], key = _t[1];
1518
+ var _u = __read(slate.Editor.node(e, slate.Path.isPath(source) ? source : source.current), 1), node = _u[0];
1504
1519
  NODE_TO_KEY.set(node, key);
1505
1520
  }
1506
1521
  }
1507
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1522
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1508
1523
  finally {
1509
1524
  try {
1510
- if (matches_1_1 && !matches_1_1.done && (_d = matches_1.return)) _d.call(matches_1);
1525
+ if (matches_1_1 && !matches_1_1.done && (_e = matches_1.return)) _e.call(matches_1);
1511
1526
  }
1512
- finally { if (e_4) throw e_4.error; }
1527
+ finally { if (e_5) throw e_5.error; }
1513
1528
  }
1514
1529
  };
1515
1530
  e.onChange = function () {
@@ -1626,7 +1641,7 @@
1626
1641
  return false;
1627
1642
  };
1628
1643
  e.insertTextData = function (data) {
1629
- var e_5, _a;
1644
+ var e_6, _a;
1630
1645
  var text = data.getData('text/plain');
1631
1646
  if (text) {
1632
1647
  var lines = text.split(/\r\n|\r|\n/);
@@ -1641,12 +1656,12 @@
1641
1656
  split = true;
1642
1657
  }
1643
1658
  }
1644
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1659
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1645
1660
  finally {
1646
1661
  try {
1647
1662
  if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
1648
1663
  }
1649
- finally { if (e_5) throw e_5.error; }
1664
+ finally { if (e_6) throw e_6.error; }
1650
1665
  }
1651
1666
  return true;
1652
1667
  }
@@ -2028,12 +2043,21 @@
2028
2043
  enumerable: false,
2029
2044
  configurable: true
2030
2045
  });
2046
+ Object.defineProperty(SlateBlockCardComponent.prototype, "centerContainerElement", {
2047
+ get: function () {
2048
+ return this.centerContianer.nativeElement;
2049
+ },
2050
+ enumerable: false,
2051
+ configurable: true
2052
+ });
2031
2053
  SlateBlockCardComponent.prototype.ngOnInit = function () {
2032
- var fragment = document.createDocumentFragment();
2033
- fragment.append.apply(fragment, __spreadArray([], __read(this.centerRootNodes)));
2034
- this.centerContianer.nativeElement.appendChild(fragment);
2054
+ this.append();
2035
2055
  this.nativeElement.classList.add("slate-block-card");
2036
2056
  };
2057
+ SlateBlockCardComponent.prototype.append = function () {
2058
+ var _this = this;
2059
+ this.centerRootNodes.forEach(function (rootNode) { return !_this.centerContainerElement.contains(rootNode) && _this.centerContainerElement.appendChild(rootNode); });
2060
+ };
2037
2061
  SlateBlockCardComponent.prototype.initializeCenter = function (rootNodes) {
2038
2062
  this.centerRootNodes = rootNodes;
2039
2063
  };
@@ -2144,6 +2168,11 @@
2144
2168
  }
2145
2169
  }
2146
2170
  };
2171
+ ViewContainerItem.prototype.appendBlockCardElement = function () {
2172
+ if (this.blockCardComponentRef) {
2173
+ this.blockCardComponentRef.instance.append();
2174
+ }
2175
+ };
2147
2176
  return ViewContainerItem;
2148
2177
  }());
2149
2178
  ViewContainerItem.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: ViewContainerItem, deps: [{ token: i0__namespace.ViewContainerRef }, { token: i0__namespace.ComponentFactoryResolver }], target: i0__namespace.ɵɵFactoryTarget.Directive });
@@ -2506,6 +2535,8 @@
2506
2535
  });
2507
2536
  }
2508
2537
  }
2538
+ // Solve the block-card DOMElement loss when moving nodes
2539
+ record.item.appendBlockCardElement();
2509
2540
  };
2510
2541
  return ViewContainer;
2511
2542
  }());
@@ -3206,6 +3237,9 @@
3206
3237
  domSelection.setBaseAndExtent(newDomRange_1.startContainer, newDomRange_1.startOffset, newDomRange_1.endContainer, newDomRange_1.endOffset);
3207
3238
  }
3208
3239
  }
3240
+ else {
3241
+ domSelection.removeAllRanges();
3242
+ }
3209
3243
  setTimeout(function () {
3210
3244
  // COMPAT: In Firefox, it's not enough to create a range, you also need
3211
3245
  // to focus the contenteditable element too. (2016/11/16)