@wizishop/wizi-block 4.2.26-beta → 4.2.27-beta
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.
- package/bundles/wizishop-wizi-block.umd.js +177 -114
- package/bundles/wizishop-wizi-block.umd.js.map +1 -1
- package/bundles/wizishop-wizi-block.umd.min.js +1 -1
- package/bundles/wizishop-wizi-block.umd.min.js.map +1 -1
- package/esm2015/lib/shared/components/editorjs/tools/inline/tool-type/inline-style-tool.component.js +125 -67
- package/esm2015/lib/shared/components/editorjs/tools/paragraph/text-type-tool.component.js +3 -1
- package/esm2015/lib/shared/components/editorjs/tools/paragraph/tool-type/paragraph-style-tool.component.js +11 -6
- package/esm2015/lib/shared/components/editorjs/tools/paragraph/tool-type/text-edition.component.js +1 -2
- package/fesm2015/wizishop-wizi-block.js +136 -72
- package/fesm2015/wizishop-wizi-block.js.map +1 -1
- package/lib/shared/components/editorjs/tools/inline/tool-type/inline-style-tool.component.d.ts +2 -0
- package/package.json +1 -1
|
@@ -20422,9 +20422,9 @@
|
|
|
20422
20422
|
}
|
|
20423
20423
|
InlineStyleTool.prototype.execCommandStyle = function (action) {
|
|
20424
20424
|
return __awaiter(this, void 0, void 0, function () {
|
|
20425
|
-
var selection, anchorNode, container, sameSelection;
|
|
20426
|
-
return __generator(this, function (
|
|
20427
|
-
switch (
|
|
20425
|
+
var selection, anchorNode, container, sameSelection, error_1;
|
|
20426
|
+
return __generator(this, function (_c) {
|
|
20427
|
+
switch (_c.label) {
|
|
20428
20428
|
case 0:
|
|
20429
20429
|
selection = this.currentSelection ? this.currentSelection : this.getSelection();
|
|
20430
20430
|
if (!selection) {
|
|
@@ -20443,51 +20443,63 @@
|
|
|
20443
20443
|
sameSelection = container && container.innerText === selection.toString();
|
|
20444
20444
|
return [4 /*yield*/, this.saveInlineSelection(container, true)];
|
|
20445
20445
|
case 1:
|
|
20446
|
-
|
|
20447
|
-
|
|
20448
|
-
return [4 /*yield*/, this.replaceLink(selection, this.hasStyle(container))];
|
|
20446
|
+
_c.sent();
|
|
20447
|
+
_c.label = 2;
|
|
20449
20448
|
case 2:
|
|
20450
|
-
|
|
20451
|
-
return [3 /*break*/,
|
|
20449
|
+
_c.trys.push([2, 12, , 13]);
|
|
20450
|
+
if (!this.linkDeletion) return [3 /*break*/, 4];
|
|
20451
|
+
return [4 /*yield*/, this.replaceLink(selection, this.hasStyle(container))];
|
|
20452
20452
|
case 3:
|
|
20453
|
+
_c.sent();
|
|
20454
|
+
return [3 /*break*/, 8];
|
|
20455
|
+
case 4:
|
|
20453
20456
|
if (!(sameSelection &&
|
|
20454
20457
|
!this.isContainer(this.textContainers, container) &&
|
|
20455
20458
|
this.hasStyle(container) &&
|
|
20456
|
-
selection.toString() === this.hasStyle(container).innerText)) return [3 /*break*/,
|
|
20459
|
+
selection.toString() === this.hasStyle(container).innerText)) return [3 /*break*/, 6];
|
|
20457
20460
|
return [4 /*yield*/, this.updateSelection(selection, this.hasStyle(container), action, this.textContainers)];
|
|
20458
|
-
case
|
|
20459
|
-
|
|
20460
|
-
return [3 /*break*/,
|
|
20461
|
-
case
|
|
20462
|
-
case
|
|
20463
|
-
|
|
20464
|
-
|
|
20465
|
-
case
|
|
20466
|
-
case 8:
|
|
20467
|
-
_d.sent();
|
|
20468
|
-
if (!this.modifiedContent) return [3 /*break*/, 10];
|
|
20469
|
-
return [4 /*yield*/, this.resetInlineSelection(container, true)];
|
|
20461
|
+
case 5:
|
|
20462
|
+
_c.sent();
|
|
20463
|
+
return [3 /*break*/, 8];
|
|
20464
|
+
case 6: return [4 /*yield*/, this.replaceSelection(this.getMostDescendantChild(container), action, selection, this.textContainers)];
|
|
20465
|
+
case 7:
|
|
20466
|
+
_c.sent();
|
|
20467
|
+
_c.label = 8;
|
|
20468
|
+
case 8: return [4 /*yield*/, this.cleanupContainer(selection, container, true)];
|
|
20470
20469
|
case 9:
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
|
|
20470
|
+
_c.sent();
|
|
20471
|
+
if (!this.modifiedContent) return [3 /*break*/, 11];
|
|
20472
|
+
return [4 /*yield*/, this.resetInlineSelection(container, true)];
|
|
20473
|
+
case 10:
|
|
20474
|
+
_c.sent();
|
|
20475
|
+
_c.label = 11;
|
|
20476
|
+
case 11: return [3 /*break*/, 13];
|
|
20477
|
+
case 12:
|
|
20478
|
+
error_1 = _c.sent();
|
|
20479
|
+
console.warn('Inline Tool Error : ' + error_1);
|
|
20480
|
+
return [3 /*break*/, 13];
|
|
20481
|
+
case 13: return [2 /*return*/];
|
|
20474
20482
|
}
|
|
20475
20483
|
});
|
|
20476
20484
|
});
|
|
20477
20485
|
};
|
|
20478
20486
|
InlineStyleTool.prototype.updateSelection = function (selection, container, action, containers) {
|
|
20479
20487
|
return __awaiter(this, void 0, void 0, function () {
|
|
20480
|
-
var css,
|
|
20481
|
-
return __generator(this, function (
|
|
20482
|
-
switch (
|
|
20488
|
+
var css, value, range, newElement_1, elementClone;
|
|
20489
|
+
return __generator(this, function (_c) {
|
|
20490
|
+
switch (_c.label) {
|
|
20483
20491
|
case 0:
|
|
20484
20492
|
if (!this.modifies.style) return [3 /*break*/, 2];
|
|
20485
20493
|
css = this.style.property;
|
|
20486
|
-
_d = container.style;
|
|
20487
|
-
_e = css;
|
|
20488
20494
|
return [4 /*yield*/, this.getStyleValue(container, action, containers)];
|
|
20489
20495
|
case 1:
|
|
20490
|
-
|
|
20496
|
+
value = _c.sent();
|
|
20497
|
+
if (value !== this.style.default) {
|
|
20498
|
+
container.style[css] = value;
|
|
20499
|
+
}
|
|
20500
|
+
else {
|
|
20501
|
+
container.style.removeProperty(this.style.property);
|
|
20502
|
+
}
|
|
20491
20503
|
return [3 /*break*/, 5];
|
|
20492
20504
|
case 2:
|
|
20493
20505
|
range = this.getRangeObject(selection);
|
|
@@ -20495,11 +20507,11 @@
|
|
|
20495
20507
|
if (!this.modifies.class) return [3 /*break*/, 4];
|
|
20496
20508
|
return [4 /*yield*/, this.removeChildrenClasses(newElement_1)];
|
|
20497
20509
|
case 3:
|
|
20498
|
-
|
|
20510
|
+
_c.sent();
|
|
20499
20511
|
if (this.classToApply !== '') {
|
|
20500
20512
|
newElement_1.classList.add(this.classToApply);
|
|
20501
20513
|
}
|
|
20502
|
-
|
|
20514
|
+
_c.label = 4;
|
|
20503
20515
|
case 4:
|
|
20504
20516
|
if (this.modifies.attribute) {
|
|
20505
20517
|
this.attributesToApply.forEach(function (attribute) {
|
|
@@ -20514,7 +20526,7 @@
|
|
|
20514
20526
|
}
|
|
20515
20527
|
container.parentElement.replaceChild(newElement_1, container);
|
|
20516
20528
|
range.insertNode(newElement_1);
|
|
20517
|
-
|
|
20529
|
+
_c.label = 5;
|
|
20518
20530
|
case 5: return [2 /*return*/];
|
|
20519
20531
|
}
|
|
20520
20532
|
});
|
|
@@ -20524,8 +20536,8 @@
|
|
|
20524
20536
|
var _a;
|
|
20525
20537
|
return __awaiter(this, void 0, void 0, function () {
|
|
20526
20538
|
var parentContainer, focusNode, offsetContainer, offsetParentContainer, range, currentFragment, currentElement_1, currentElementToAppend, currentParentElement, tmpElement, isLTR, selectionFocusOffset, selectionFocusNode, newSelection, preRange, preFragment, newElement, range, fragment, fragmentElement, newElement_2, elementToAppend;
|
|
20527
|
-
return __generator(this, function (
|
|
20528
|
-
switch (
|
|
20539
|
+
return __generator(this, function (_c) {
|
|
20540
|
+
switch (_c.label) {
|
|
20529
20541
|
case 0:
|
|
20530
20542
|
parentContainer = this.hasStyle(container);
|
|
20531
20543
|
focusNode = selection.focusNode;
|
|
@@ -20533,7 +20545,10 @@
|
|
|
20533
20545
|
? focusNode
|
|
20534
20546
|
: focusNode.parentElement;
|
|
20535
20547
|
offsetParentContainer = this.hasStyle(offsetContainer);
|
|
20536
|
-
if (!(parentContainer &&
|
|
20548
|
+
if (!(parentContainer &&
|
|
20549
|
+
parentContainer === offsetParentContainer &&
|
|
20550
|
+
((parentContainer.children.length > 0 && parentContainer.innerText !== parentContainer.children[0].textContent) ||
|
|
20551
|
+
parentContainer.innerText !== selection.toString()))) return [3 /*break*/, 3];
|
|
20537
20552
|
range = this.getRangeObject(selection);
|
|
20538
20553
|
currentFragment = range.extractContents();
|
|
20539
20554
|
currentElement_1 = document.createElement('span');
|
|
@@ -20544,11 +20559,11 @@
|
|
|
20544
20559
|
if (!this.modifies.class) return [3 /*break*/, 2];
|
|
20545
20560
|
return [4 /*yield*/, this.removeChildrenClasses(currentElement_1)];
|
|
20546
20561
|
case 1:
|
|
20547
|
-
|
|
20562
|
+
_c.sent();
|
|
20548
20563
|
if (this.classToApply !== '') {
|
|
20549
20564
|
currentElement_1.classList.add(this.classToApply);
|
|
20550
20565
|
}
|
|
20551
|
-
|
|
20566
|
+
_c.label = 2;
|
|
20552
20567
|
case 2:
|
|
20553
20568
|
if (this.modifies.attribute) {
|
|
20554
20569
|
this.attributesToApply.forEach(function (attribute) {
|
|
@@ -20557,12 +20572,14 @@
|
|
|
20557
20572
|
}
|
|
20558
20573
|
currentElementToAppend = currentElement_1;
|
|
20559
20574
|
currentParentElement = container;
|
|
20560
|
-
|
|
20561
|
-
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
|
|
20565
|
-
|
|
20575
|
+
if (parentContainer.contains(currentParentElement)) {
|
|
20576
|
+
while (currentParentElement !== parentContainer) {
|
|
20577
|
+
tmpElement = document.createElement(currentParentElement.tagName);
|
|
20578
|
+
tmpElement = this.setInlineStyle(currentParentElement, tmpElement);
|
|
20579
|
+
tmpElement.appendChild(currentElementToAppend);
|
|
20580
|
+
currentElementToAppend = tmpElement;
|
|
20581
|
+
currentParentElement = currentParentElement.parentElement;
|
|
20582
|
+
}
|
|
20566
20583
|
}
|
|
20567
20584
|
isLTR = this.isAnchorBeforeFocus(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
|
|
20568
20585
|
selectionFocusOffset = isLTR ? selection.anchorOffset : selection.focusOffset;
|
|
@@ -20584,7 +20601,7 @@
|
|
|
20584
20601
|
fragmentElement = document.createElement('div');
|
|
20585
20602
|
return [4 /*yield*/, this.createElement(container, action, containers)];
|
|
20586
20603
|
case 4:
|
|
20587
|
-
newElement_2 =
|
|
20604
|
+
newElement_2 = _c.sent();
|
|
20588
20605
|
elementToAppend = newElement_2;
|
|
20589
20606
|
fragmentElement.append(fragment);
|
|
20590
20607
|
if (((_a = fragmentElement.children) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
|
|
@@ -20600,11 +20617,11 @@
|
|
|
20600
20617
|
if (!this.modifies.class) return [3 /*break*/, 6];
|
|
20601
20618
|
return [4 /*yield*/, this.removeChildrenClasses(newElement_2)];
|
|
20602
20619
|
case 5:
|
|
20603
|
-
|
|
20620
|
+
_c.sent();
|
|
20604
20621
|
if (this.classToApply !== '') {
|
|
20605
20622
|
newElement_2.classList.add(this.classToApply);
|
|
20606
20623
|
}
|
|
20607
|
-
|
|
20624
|
+
_c.label = 6;
|
|
20608
20625
|
case 6:
|
|
20609
20626
|
if (this.modifies.attribute) {
|
|
20610
20627
|
this.attributesToApply.forEach(function (attribute) {
|
|
@@ -20613,7 +20630,7 @@
|
|
|
20613
20630
|
}
|
|
20614
20631
|
range.insertNode(elementToAppend);
|
|
20615
20632
|
selection.selectAllChildren(elementToAppend);
|
|
20616
|
-
|
|
20633
|
+
_c.label = 7;
|
|
20617
20634
|
case 7: return [2 /*return*/];
|
|
20618
20635
|
}
|
|
20619
20636
|
});
|
|
@@ -20622,9 +20639,7 @@
|
|
|
20622
20639
|
InlineStyleTool.prototype.replaceLink = function (selection, container) {
|
|
20623
20640
|
return __awaiter(this, void 0, void 0, function () {
|
|
20624
20641
|
var newElement;
|
|
20625
|
-
return __generator(this, function (
|
|
20626
|
-
console.log('container');
|
|
20627
|
-
console.log(container);
|
|
20642
|
+
return __generator(this, function (_c) {
|
|
20628
20643
|
newElement = document.createElement('span');
|
|
20629
20644
|
newElement.innerHTML = container.innerHTML;
|
|
20630
20645
|
container.parentElement.replaceChild(newElement, container);
|
|
@@ -20647,17 +20662,13 @@
|
|
|
20647
20662
|
};
|
|
20648
20663
|
InlineStyleTool.prototype.hasStyle = function (element, firstTimeCall) {
|
|
20649
20664
|
if (firstTimeCall === void 0) { firstTimeCall = true; }
|
|
20650
|
-
var _a, _b
|
|
20665
|
+
var _a, _b;
|
|
20651
20666
|
if (firstTimeCall && element.children) {
|
|
20652
|
-
|
|
20653
|
-
element.innerText === ((_a = element.children[0]) === null || _a === void 0 ? void 0 : _a.innerText) &&
|
|
20654
|
-
element.children.length === 1) {
|
|
20655
|
-
element = element.children[0];
|
|
20656
|
-
}
|
|
20667
|
+
element = this.getMostDescendantChild(element);
|
|
20657
20668
|
}
|
|
20658
20669
|
// foundElement was added because of a return issue when a class is applied
|
|
20659
20670
|
var foundElement = null;
|
|
20660
|
-
if (!element || ((
|
|
20671
|
+
if (!element || ((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains('ce-paragraph'))) {
|
|
20661
20672
|
return null;
|
|
20662
20673
|
}
|
|
20663
20674
|
if (this.modifies.style) {
|
|
@@ -20678,7 +20689,7 @@
|
|
|
20678
20689
|
});
|
|
20679
20690
|
}
|
|
20680
20691
|
else if (this.modifies.tag) {
|
|
20681
|
-
if (((
|
|
20692
|
+
if (((_b = element.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === this.tag.toLowerCase()) {
|
|
20682
20693
|
return element;
|
|
20683
20694
|
}
|
|
20684
20695
|
}
|
|
@@ -20702,8 +20713,8 @@
|
|
|
20702
20713
|
InlineStyleTool.prototype.getStyleValue = function (container, action, containers) {
|
|
20703
20714
|
return __awaiter(this, void 0, void 0, function () {
|
|
20704
20715
|
var style;
|
|
20705
|
-
return __generator(this, function (
|
|
20706
|
-
switch (
|
|
20716
|
+
return __generator(this, function (_c) {
|
|
20717
|
+
switch (_c.label) {
|
|
20707
20718
|
case 0:
|
|
20708
20719
|
if (!container) {
|
|
20709
20720
|
return [2 /*return*/, this.style.value.indexOf('$1') > -1 ? this.style.value.replace('$1', this.style.input) : this.style.value];
|
|
@@ -20713,7 +20724,7 @@
|
|
|
20713
20724
|
}
|
|
20714
20725
|
return [4 /*yield*/, this.findStyleNode(container, action, containers)];
|
|
20715
20726
|
case 1:
|
|
20716
|
-
style =
|
|
20727
|
+
style = _c.sent();
|
|
20717
20728
|
if (style && this.hasStyle(style) && this.style.value.indexOf('$1') === -1) {
|
|
20718
20729
|
return [2 /*return*/, this.style.default];
|
|
20719
20730
|
}
|
|
@@ -20725,8 +20736,8 @@
|
|
|
20725
20736
|
InlineStyleTool.prototype.findStyleNode = function (node, style, containers) {
|
|
20726
20737
|
return __awaiter(this, void 0, void 0, function () {
|
|
20727
20738
|
var hasStyle;
|
|
20728
|
-
return __generator(this, function (
|
|
20729
|
-
switch (
|
|
20739
|
+
return __generator(this, function (_c) {
|
|
20740
|
+
switch (_c.label) {
|
|
20730
20741
|
case 0:
|
|
20731
20742
|
if (node.nodeName.toUpperCase() === 'HTML' || node.nodeName.toUpperCase() === 'BODY') {
|
|
20732
20743
|
return [2 /*return*/, null];
|
|
@@ -20744,26 +20755,30 @@
|
|
|
20744
20755
|
return [2 /*return*/, node];
|
|
20745
20756
|
}
|
|
20746
20757
|
return [4 /*yield*/, this.findStyleNode(node.parentNode, style, containers)];
|
|
20747
|
-
case 1: return [2 /*return*/,
|
|
20758
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
20748
20759
|
}
|
|
20749
20760
|
});
|
|
20750
20761
|
});
|
|
20751
20762
|
};
|
|
20752
20763
|
InlineStyleTool.prototype.createElement = function (container, action, containers) {
|
|
20753
20764
|
return __awaiter(this, void 0, void 0, function () {
|
|
20754
|
-
var newElement, property,
|
|
20755
|
-
return __generator(this, function (
|
|
20756
|
-
switch (
|
|
20765
|
+
var newElement, property, value;
|
|
20766
|
+
return __generator(this, function (_c) {
|
|
20767
|
+
switch (_c.label) {
|
|
20757
20768
|
case 0:
|
|
20758
20769
|
newElement = document.createElement(this.tag);
|
|
20759
20770
|
if (!this.modifies.style) return [3 /*break*/, 2];
|
|
20760
20771
|
property = this.style.property;
|
|
20761
|
-
_d = newElement.style;
|
|
20762
|
-
_e = property;
|
|
20763
20772
|
return [4 /*yield*/, this.getStyleValue(container, action, containers)];
|
|
20764
20773
|
case 1:
|
|
20765
|
-
|
|
20766
|
-
|
|
20774
|
+
value = _c.sent();
|
|
20775
|
+
if (value !== this.style.default) {
|
|
20776
|
+
newElement.style[property] = value;
|
|
20777
|
+
}
|
|
20778
|
+
else {
|
|
20779
|
+
newElement.style.removeProperty(property);
|
|
20780
|
+
}
|
|
20781
|
+
_c.label = 2;
|
|
20767
20782
|
case 2: return [2 /*return*/, newElement];
|
|
20768
20783
|
}
|
|
20769
20784
|
});
|
|
@@ -20772,15 +20787,15 @@
|
|
|
20772
20787
|
InlineStyleTool.prototype.removeChildrenClasses = function (element) {
|
|
20773
20788
|
return __awaiter(this, void 0, void 0, function () {
|
|
20774
20789
|
var children, currentElement;
|
|
20775
|
-
return __generator(this, function (
|
|
20776
|
-
switch (
|
|
20790
|
+
return __generator(this, function (_c) {
|
|
20791
|
+
switch (_c.label) {
|
|
20777
20792
|
case 0:
|
|
20778
20793
|
if (!element) {
|
|
20779
20794
|
return [2 /*return*/];
|
|
20780
20795
|
}
|
|
20781
20796
|
children = element.children;
|
|
20782
20797
|
currentElement = children[0];
|
|
20783
|
-
|
|
20798
|
+
_c.label = 1;
|
|
20784
20799
|
case 1:
|
|
20785
20800
|
if (!currentElement) return [3 /*break*/, 4];
|
|
20786
20801
|
this.classes.split(',').forEach(function (className) {
|
|
@@ -20797,8 +20812,8 @@
|
|
|
20797
20812
|
if (!(currentElement.children.length > 0)) return [3 /*break*/, 3];
|
|
20798
20813
|
return [4 /*yield*/, this.removeChildrenClasses(currentElement)];
|
|
20799
20814
|
case 2:
|
|
20800
|
-
|
|
20801
|
-
|
|
20815
|
+
_c.sent();
|
|
20816
|
+
_c.label = 3;
|
|
20802
20817
|
case 3:
|
|
20803
20818
|
currentElement = currentElement.nextElementSibling;
|
|
20804
20819
|
return [3 /*break*/, 1];
|
|
@@ -20808,11 +20823,11 @@
|
|
|
20808
20823
|
});
|
|
20809
20824
|
};
|
|
20810
20825
|
InlineStyleTool.prototype.cleanupContainer = function (selection, container, firstTimeCall) {
|
|
20811
|
-
var _a;
|
|
20826
|
+
var _a, _b;
|
|
20812
20827
|
return __awaiter(this, void 0, void 0, function () {
|
|
20813
20828
|
var parentContainer, parentFound, children, currentNode, identicalElements, currentElement, nextElement, currentNodeFirstChild;
|
|
20814
|
-
return __generator(this, function (
|
|
20815
|
-
switch (
|
|
20829
|
+
return __generator(this, function (_c) {
|
|
20830
|
+
switch (_c.label) {
|
|
20816
20831
|
case 0:
|
|
20817
20832
|
parentFound = false;
|
|
20818
20833
|
if (firstTimeCall) {
|
|
@@ -20834,17 +20849,25 @@
|
|
|
20834
20849
|
}
|
|
20835
20850
|
parentContainer.normalize();
|
|
20836
20851
|
children = Array.from(parentContainer.childNodes);
|
|
20837
|
-
if (!((children === null || children === void 0 ? void 0 : children.length) > 0)) return [3 /*break*/,
|
|
20852
|
+
if (!((children === null || children === void 0 ? void 0 : children.length) > 0)) return [3 /*break*/, 6];
|
|
20838
20853
|
currentNode = children[0];
|
|
20839
|
-
|
|
20854
|
+
_c.label = 1;
|
|
20840
20855
|
case 1:
|
|
20841
|
-
if (!currentNode) return [3 /*break*/,
|
|
20842
|
-
|
|
20843
|
-
|
|
20856
|
+
if (!currentNode) return [3 /*break*/, 6];
|
|
20857
|
+
console.log('currentNode');
|
|
20858
|
+
console.log(currentNode);
|
|
20859
|
+
console.log(currentNode.textContent);
|
|
20860
|
+
console.log((_b = currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length);
|
|
20861
|
+
if (!(!currentNode.textContent || currentNode.textContent.length === 0)) return [3 /*break*/, 2];
|
|
20862
|
+
parentContainer.removeChild(currentNode);
|
|
20863
|
+
return [3 /*break*/, 5];
|
|
20844
20864
|
case 2:
|
|
20845
|
-
|
|
20846
|
-
|
|
20865
|
+
if (!(currentNode.childNodes.length > 0)) return [3 /*break*/, 4];
|
|
20866
|
+
return [4 /*yield*/, this.cleanupContainer(selection, currentNode, false)];
|
|
20847
20867
|
case 3:
|
|
20868
|
+
_c.sent();
|
|
20869
|
+
_c.label = 4;
|
|
20870
|
+
case 4:
|
|
20848
20871
|
identicalElements = true;
|
|
20849
20872
|
while (identicalElements &&
|
|
20850
20873
|
currentNode.nextSibling &&
|
|
@@ -20869,7 +20892,7 @@
|
|
|
20869
20892
|
currentNode.tagName.toLowerCase() === 'span' &&
|
|
20870
20893
|
Object.keys(this.getInlineStyle(currentNode)).length === 0 &&
|
|
20871
20894
|
(!currentNode.classList || currentNode.classList.length === 0) &&
|
|
20872
|
-
|
|
20895
|
+
this.hasNoAttributes(currentNode)) {
|
|
20873
20896
|
currentNodeFirstChild = currentNode;
|
|
20874
20897
|
while (currentNode.firstChild) {
|
|
20875
20898
|
currentNodeFirstChild.parentElement.insertBefore(currentNode.firstChild, currentNodeFirstChild.nextSibling);
|
|
@@ -20879,15 +20902,26 @@
|
|
|
20879
20902
|
this.modifiedContent = true;
|
|
20880
20903
|
}
|
|
20881
20904
|
currentNode.normalize();
|
|
20882
|
-
|
|
20883
|
-
case
|
|
20905
|
+
_c.label = 5;
|
|
20906
|
+
case 5:
|
|
20884
20907
|
currentNode = currentNode.nextSibling;
|
|
20885
20908
|
return [3 /*break*/, 1];
|
|
20886
|
-
case
|
|
20909
|
+
case 6: return [2 /*return*/];
|
|
20887
20910
|
}
|
|
20888
20911
|
});
|
|
20889
20912
|
});
|
|
20890
20913
|
};
|
|
20914
|
+
InlineStyleTool.prototype.hasNoAttributes = function (node) {
|
|
20915
|
+
var nodeStyle = Object.keys(this.getInlineStyle(node));
|
|
20916
|
+
var nodeAttributes = Object.keys(node.getAttributeNames().reduce(function (acc, name) {
|
|
20917
|
+
var _c;
|
|
20918
|
+
return Object.assign(Object.assign({}, acc), (_c = {}, _c[name] = node.getAttribute(name), _c));
|
|
20919
|
+
}, {}));
|
|
20920
|
+
if (nodeAttributes.length === 0 || (nodeAttributes.length === 1 && nodeStyle.length === 0)) {
|
|
20921
|
+
return true;
|
|
20922
|
+
}
|
|
20923
|
+
return false;
|
|
20924
|
+
};
|
|
20891
20925
|
InlineStyleTool.prototype.identicalClassList = function (currentElement, nextElement) {
|
|
20892
20926
|
return (__spread(currentElement.classList).every(function (classList) { return nextElement.classList.contains(classList); }) &&
|
|
20893
20927
|
__spread(nextElement.classList).every(function (classList) { return currentElement.classList.contains(classList); }));
|
|
@@ -20901,15 +20935,15 @@
|
|
|
20901
20935
|
};
|
|
20902
20936
|
InlineStyleTool.prototype.sortInlineStyle = function (currentElement) {
|
|
20903
20937
|
return Object.entries(currentElement)
|
|
20904
|
-
.sort(function (
|
|
20905
|
-
var
|
|
20906
|
-
var
|
|
20938
|
+
.sort(function (_c, _d) {
|
|
20939
|
+
var _e = __read(_c, 2), a = _e[1];
|
|
20940
|
+
var _f = __read(_d, 2), b = _f[1];
|
|
20907
20941
|
return a - b;
|
|
20908
20942
|
})
|
|
20909
|
-
.reduce(function (r,
|
|
20910
|
-
var
|
|
20911
|
-
var
|
|
20912
|
-
return (Object.assign(Object.assign({}, r), (
|
|
20943
|
+
.reduce(function (r, _c) {
|
|
20944
|
+
var _d;
|
|
20945
|
+
var _e = __read(_c, 2), k = _e[0], v = _e[1];
|
|
20946
|
+
return (Object.assign(Object.assign({}, r), (_d = {}, _d[k] = v, _d)));
|
|
20913
20947
|
}, {});
|
|
20914
20948
|
};
|
|
20915
20949
|
InlineStyleTool.prototype.getInlineStyle = function (currentElement) {
|
|
@@ -20938,8 +20972,8 @@
|
|
|
20938
20972
|
if (firstTimeCall === void 0) { firstTimeCall = false; }
|
|
20939
20973
|
return __awaiter(this, void 0, void 0, function () {
|
|
20940
20974
|
var nextNode, selection, range, currentFragment, currentElement;
|
|
20941
|
-
return __generator(this, function (
|
|
20942
|
-
switch (
|
|
20975
|
+
return __generator(this, function (_c) {
|
|
20976
|
+
switch (_c.label) {
|
|
20943
20977
|
case 0:
|
|
20944
20978
|
if (firstTimeCall) {
|
|
20945
20979
|
container = this.parentEditor.querySelector('.ce-paragraph').firstElementChild;
|
|
@@ -20947,9 +20981,16 @@
|
|
|
20947
20981
|
this.foundFocusNode = false;
|
|
20948
20982
|
this.foundAnchorOffset = 0;
|
|
20949
20983
|
this.foundFocusOffset = 0;
|
|
20984
|
+
if (this.getSelection().toString() === this.parentEditor.querySelector('.ce-paragraph').textContent) {
|
|
20985
|
+
this.foundAnchorOffset = 0;
|
|
20986
|
+
this.foundAnchorNode = true;
|
|
20987
|
+
this.foundFocusOffset = this.getSelection().toString().length;
|
|
20988
|
+
this.foundFocusNode = true;
|
|
20989
|
+
return [2 /*return*/];
|
|
20990
|
+
}
|
|
20950
20991
|
}
|
|
20951
20992
|
nextNode = container.firstChild;
|
|
20952
|
-
|
|
20993
|
+
_c.label = 1;
|
|
20953
20994
|
case 1:
|
|
20954
20995
|
if (!(nextNode && (!this.foundAnchorNode || !this.foundFocusNode))) return [3 /*break*/, 4];
|
|
20955
20996
|
if (nextNode === this.selectedAnchorNode) {
|
|
@@ -20976,8 +21017,8 @@
|
|
|
20976
21017
|
if (!nextNode.firstChild) return [3 /*break*/, 3];
|
|
20977
21018
|
return [4 /*yield*/, this.saveInlineSelection(nextNode)];
|
|
20978
21019
|
case 2:
|
|
20979
|
-
|
|
20980
|
-
|
|
21020
|
+
_c.sent();
|
|
21021
|
+
_c.label = 3;
|
|
20981
21022
|
case 3:
|
|
20982
21023
|
nextNode = nextNode.nextSibling;
|
|
20983
21024
|
return [3 /*break*/, 1];
|
|
@@ -20991,17 +21032,26 @@
|
|
|
20991
21032
|
if (firstTimeCall === void 0) { firstTimeCall = false; }
|
|
20992
21033
|
return __awaiter(this, void 0, void 0, function () {
|
|
20993
21034
|
var nextNode;
|
|
20994
|
-
return __generator(this, function (
|
|
20995
|
-
switch (
|
|
21035
|
+
return __generator(this, function (_c) {
|
|
21036
|
+
switch (_c.label) {
|
|
20996
21037
|
case 0:
|
|
20997
21038
|
if (firstTimeCall) {
|
|
20998
21039
|
container = this.parentEditor.querySelector('.ce-paragraph').firstElementChild;
|
|
20999
21040
|
this.foundAnchorNode = false;
|
|
21000
21041
|
this.foundFocusNode = false;
|
|
21001
21042
|
this.tmpOffset = 0;
|
|
21043
|
+
if (this.foundAnchorOffset === 0 &&
|
|
21044
|
+
this.parentEditor.querySelector('.ce-paragraph').textContent.length === this.foundFocusOffset) {
|
|
21045
|
+
this.selectedAnchorNode = this.parentEditor.querySelector('.ce-paragraph').firstElementChild;
|
|
21046
|
+
this.anchorOffset = 0;
|
|
21047
|
+
this.selectedFocusNode = this.parentEditor.querySelector('.ce-paragraph').firstElementChild;
|
|
21048
|
+
this.focusOffset = 1;
|
|
21049
|
+
this.resetUserSelection();
|
|
21050
|
+
return [2 /*return*/];
|
|
21051
|
+
}
|
|
21002
21052
|
}
|
|
21003
21053
|
nextNode = container.firstChild;
|
|
21004
|
-
|
|
21054
|
+
_c.label = 1;
|
|
21005
21055
|
case 1:
|
|
21006
21056
|
if (!(nextNode && (!this.foundAnchorNode || !this.foundFocusNode))) return [3 /*break*/, 4];
|
|
21007
21057
|
if (nextNode.nodeType === Node.TEXT_NODE) {
|
|
@@ -21022,8 +21072,8 @@
|
|
|
21022
21072
|
if (!nextNode.firstChild) return [3 /*break*/, 3];
|
|
21023
21073
|
return [4 /*yield*/, this.resetInlineSelection(nextNode)];
|
|
21024
21074
|
case 2:
|
|
21025
|
-
|
|
21026
|
-
|
|
21075
|
+
_c.sent();
|
|
21076
|
+
_c.label = 3;
|
|
21027
21077
|
case 3:
|
|
21028
21078
|
nextNode = nextNode.nextSibling;
|
|
21029
21079
|
return [3 /*break*/, 1];
|
|
@@ -21036,6 +21086,13 @@
|
|
|
21036
21086
|
});
|
|
21037
21087
|
});
|
|
21038
21088
|
};
|
|
21089
|
+
InlineStyleTool.prototype.getMostDescendantChild = function (element) {
|
|
21090
|
+
var _a;
|
|
21091
|
+
while (element.children && element.innerText === ((_a = element.children[0]) === null || _a === void 0 ? void 0 : _a.innerText) && element.children.length === 1) {
|
|
21092
|
+
element = element.children[0];
|
|
21093
|
+
}
|
|
21094
|
+
return element;
|
|
21095
|
+
};
|
|
21039
21096
|
return InlineStyleTool;
|
|
21040
21097
|
}(EditorJSTool));
|
|
21041
21098
|
|
|
@@ -22611,13 +22668,18 @@
|
|
|
22611
22668
|
return [2 /*return*/];
|
|
22612
22669
|
}
|
|
22613
22670
|
parentModifier = this.findParentModifier(anchorNode.parentElement);
|
|
22614
|
-
|
|
22615
|
-
this.
|
|
22671
|
+
try {
|
|
22672
|
+
if (this.tag.toLowerCase() !== 'span') {
|
|
22673
|
+
this.changeContainerTag(parentModifier, selection);
|
|
22674
|
+
}
|
|
22675
|
+
if ((this.classToApply && this.classToApply.length > 0) || (this.classes && this.classes.length > 0)) {
|
|
22676
|
+
this.changeCurrentClass(parentModifier);
|
|
22677
|
+
}
|
|
22678
|
+
this.collapseSelection();
|
|
22616
22679
|
}
|
|
22617
|
-
|
|
22618
|
-
|
|
22680
|
+
catch (error) {
|
|
22681
|
+
console.warn('Paragraph Tool Error : ' + error);
|
|
22619
22682
|
}
|
|
22620
|
-
this.collapseSelection();
|
|
22621
22683
|
return [2 /*return*/];
|
|
22622
22684
|
});
|
|
22623
22685
|
});
|
|
@@ -23067,6 +23129,7 @@
|
|
|
23067
23129
|
var dropdownArrow = document.createElement('span');
|
|
23068
23130
|
dropdownArrow.classList.add(this.CSS.arrowButtonModifier);
|
|
23069
23131
|
this.nodes.button.appendChild(dropdownArrow);
|
|
23132
|
+
console.log('rendering paragraph tool');
|
|
23070
23133
|
return this.nodes.button;
|
|
23071
23134
|
};
|
|
23072
23135
|
TextTypeTool.prototype.surround = function (range, applyStyle) {
|
|
@@ -23104,6 +23167,7 @@
|
|
|
23104
23167
|
_this.nodes.button.classList.remove(textType.tag.toLowerCase());
|
|
23105
23168
|
});
|
|
23106
23169
|
this.nodes.button.classList.add(classToApply);
|
|
23170
|
+
console.log('checkState method on paragraph tool');
|
|
23107
23171
|
return true;
|
|
23108
23172
|
};
|
|
23109
23173
|
TextTypeTool.prototype.renderActions = function () {
|
|
@@ -24616,7 +24680,6 @@
|
|
|
24616
24680
|
language: 'html',
|
|
24617
24681
|
});
|
|
24618
24682
|
saveButton.addEventListener('click', function () {
|
|
24619
|
-
console.log("here");
|
|
24620
24683
|
var content = monacoEditor.getValue();
|
|
24621
24684
|
saveCodeEditModal(content);
|
|
24622
24685
|
}, true);
|