@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
|
@@ -18728,24 +18728,29 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18728
18728
|
: anchorNode.parentElement;
|
|
18729
18729
|
const sameSelection = container && container.innerText === selection.toString();
|
|
18730
18730
|
yield this.saveInlineSelection(container, true);
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
|
|
18735
|
-
else {
|
|
18736
|
-
if (sameSelection &&
|
|
18737
|
-
!this.isContainer(this.textContainers, container) &&
|
|
18738
|
-
this.hasStyle(container) &&
|
|
18739
|
-
selection.toString() === this.hasStyle(container).innerText) {
|
|
18740
|
-
yield this.updateSelection(selection, this.hasStyle(container), action, this.textContainers);
|
|
18731
|
+
try {
|
|
18732
|
+
// Link delete exception
|
|
18733
|
+
if (this.linkDeletion) {
|
|
18734
|
+
yield this.replaceLink(selection, this.hasStyle(container));
|
|
18741
18735
|
}
|
|
18742
18736
|
else {
|
|
18743
|
-
|
|
18737
|
+
if (sameSelection &&
|
|
18738
|
+
!this.isContainer(this.textContainers, container) &&
|
|
18739
|
+
this.hasStyle(container) &&
|
|
18740
|
+
selection.toString() === this.hasStyle(container).innerText) {
|
|
18741
|
+
yield this.updateSelection(selection, this.hasStyle(container), action, this.textContainers);
|
|
18742
|
+
}
|
|
18743
|
+
else {
|
|
18744
|
+
yield this.replaceSelection(this.getMostDescendantChild(container), action, selection, this.textContainers);
|
|
18745
|
+
}
|
|
18746
|
+
}
|
|
18747
|
+
yield this.cleanupContainer(selection, container, true);
|
|
18748
|
+
if (this.modifiedContent) {
|
|
18749
|
+
yield this.resetInlineSelection(container, true);
|
|
18744
18750
|
}
|
|
18745
18751
|
}
|
|
18746
|
-
|
|
18747
|
-
|
|
18748
|
-
yield this.resetInlineSelection(container, true);
|
|
18752
|
+
catch (error) {
|
|
18753
|
+
console.warn('Inline Tool Error : ' + error);
|
|
18749
18754
|
}
|
|
18750
18755
|
});
|
|
18751
18756
|
}
|
|
@@ -18753,7 +18758,13 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18753
18758
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18754
18759
|
if (this.modifies.style) {
|
|
18755
18760
|
const css = this.style.property;
|
|
18756
|
-
|
|
18761
|
+
let value = yield this.getStyleValue(container, action, containers);
|
|
18762
|
+
if (value !== this.style.default) {
|
|
18763
|
+
container.style[css] = value;
|
|
18764
|
+
}
|
|
18765
|
+
else {
|
|
18766
|
+
container.style.removeProperty(this.style.property);
|
|
18767
|
+
}
|
|
18757
18768
|
}
|
|
18758
18769
|
else {
|
|
18759
18770
|
const range = this.getRangeObject(selection);
|
|
@@ -18789,7 +18800,10 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18789
18800
|
? focusNode
|
|
18790
18801
|
: focusNode.parentElement;
|
|
18791
18802
|
let offsetParentContainer = this.hasStyle(offsetContainer);
|
|
18792
|
-
if (parentContainer &&
|
|
18803
|
+
if (parentContainer &&
|
|
18804
|
+
parentContainer === offsetParentContainer &&
|
|
18805
|
+
((parentContainer.children.length > 0 && parentContainer.innerText !== parentContainer.children[0].textContent) ||
|
|
18806
|
+
parentContainer.innerText !== selection.toString())) {
|
|
18793
18807
|
const range = this.getRangeObject(selection);
|
|
18794
18808
|
const currentFragment = range.extractContents();
|
|
18795
18809
|
const currentElement = document.createElement('span');
|
|
@@ -18810,12 +18824,14 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18810
18824
|
}
|
|
18811
18825
|
let currentElementToAppend = currentElement;
|
|
18812
18826
|
let currentParentElement = container;
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18827
|
+
if (parentContainer.contains(currentParentElement)) {
|
|
18828
|
+
while (currentParentElement !== parentContainer) {
|
|
18829
|
+
let tmpElement = document.createElement(currentParentElement.tagName);
|
|
18830
|
+
tmpElement = this.setInlineStyle(currentParentElement, tmpElement);
|
|
18831
|
+
tmpElement.appendChild(currentElementToAppend);
|
|
18832
|
+
currentElementToAppend = tmpElement;
|
|
18833
|
+
currentParentElement = currentParentElement.parentElement;
|
|
18834
|
+
}
|
|
18819
18835
|
}
|
|
18820
18836
|
const isLTR = this.isAnchorBeforeFocus(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
|
|
18821
18837
|
let selectionFocusOffset = isLTR ? selection.anchorOffset : selection.focusOffset;
|
|
@@ -18866,8 +18882,6 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18866
18882
|
}
|
|
18867
18883
|
replaceLink(selection, container) {
|
|
18868
18884
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18869
|
-
console.log('container');
|
|
18870
|
-
console.log(container);
|
|
18871
18885
|
let newElement = document.createElement('span');
|
|
18872
18886
|
newElement.innerHTML = container.innerHTML;
|
|
18873
18887
|
container.parentElement.replaceChild(newElement, container);
|
|
@@ -18887,17 +18901,13 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18887
18901
|
return false;
|
|
18888
18902
|
}
|
|
18889
18903
|
hasStyle(element, firstTimeCall = true) {
|
|
18890
|
-
var _a, _b
|
|
18904
|
+
var _a, _b;
|
|
18891
18905
|
if (firstTimeCall && element.children) {
|
|
18892
|
-
|
|
18893
|
-
element.innerText === ((_a = element.children[0]) === null || _a === void 0 ? void 0 : _a.innerText) &&
|
|
18894
|
-
element.children.length === 1) {
|
|
18895
|
-
element = element.children[0];
|
|
18896
|
-
}
|
|
18906
|
+
element = this.getMostDescendantChild(element);
|
|
18897
18907
|
}
|
|
18898
18908
|
// foundElement was added because of a return issue when a class is applied
|
|
18899
18909
|
let foundElement = null;
|
|
18900
|
-
if (!element || ((
|
|
18910
|
+
if (!element || ((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains('ce-paragraph'))) {
|
|
18901
18911
|
return null;
|
|
18902
18912
|
}
|
|
18903
18913
|
if (this.modifies.style) {
|
|
@@ -18918,7 +18928,7 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18918
18928
|
});
|
|
18919
18929
|
}
|
|
18920
18930
|
else if (this.modifies.tag) {
|
|
18921
|
-
if (((
|
|
18931
|
+
if (((_b = element.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === this.tag.toLowerCase()) {
|
|
18922
18932
|
return element;
|
|
18923
18933
|
}
|
|
18924
18934
|
}
|
|
@@ -18979,7 +18989,13 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
18979
18989
|
let newElement = document.createElement(this.tag);
|
|
18980
18990
|
if (this.modifies.style) {
|
|
18981
18991
|
const property = this.style.property;
|
|
18982
|
-
|
|
18992
|
+
let value = yield this.getStyleValue(container, action, containers);
|
|
18993
|
+
if (value !== this.style.default) {
|
|
18994
|
+
newElement.style[property] = value;
|
|
18995
|
+
}
|
|
18996
|
+
else {
|
|
18997
|
+
newElement.style.removeProperty(property);
|
|
18998
|
+
}
|
|
18983
18999
|
}
|
|
18984
19000
|
return newElement;
|
|
18985
19001
|
});
|
|
@@ -19009,7 +19025,7 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
19009
19025
|
});
|
|
19010
19026
|
}
|
|
19011
19027
|
cleanupContainer(selection, container, firstTimeCall) {
|
|
19012
|
-
var _a;
|
|
19028
|
+
var _a, _b;
|
|
19013
19029
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19014
19030
|
let parentContainer;
|
|
19015
19031
|
let parentFound = false;
|
|
@@ -19034,47 +19050,66 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
19034
19050
|
const children = Array.from(parentContainer.childNodes);
|
|
19035
19051
|
if ((children === null || children === void 0 ? void 0 : children.length) > 0) {
|
|
19036
19052
|
for (var currentNode = children[0]; currentNode; currentNode = currentNode.nextSibling) {
|
|
19037
|
-
|
|
19038
|
-
|
|
19053
|
+
console.log('currentNode');
|
|
19054
|
+
console.log(currentNode);
|
|
19055
|
+
console.log(currentNode.textContent);
|
|
19056
|
+
console.log((_b = currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length);
|
|
19057
|
+
if (!currentNode.textContent || currentNode.textContent.length === 0) {
|
|
19058
|
+
parentContainer.removeChild(currentNode);
|
|
19039
19059
|
}
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
currentNode.nodeType === Node.ELEMENT_NODE &&
|
|
19044
|
-
currentNode.nextSibling.nodeType === Node.ELEMENT_NODE) {
|
|
19045
|
-
let currentElement = currentNode;
|
|
19046
|
-
let nextElement = currentNode.nextSibling;
|
|
19047
|
-
if (this.identicalInlineStyle(currentElement, nextElement) &&
|
|
19048
|
-
currentElement.tagName.toLowerCase() === nextElement.tagName.toLowerCase() &&
|
|
19049
|
-
this.identicalClassList(currentElement, nextElement) &&
|
|
19050
|
-
!currentElement.hasAttributes() &&
|
|
19051
|
-
!nextElement.hasAttributes()) {
|
|
19052
|
-
currentElement.innerHTML += nextElement.innerHTML;
|
|
19053
|
-
nextElement.remove();
|
|
19054
|
-
this.modifiedContent = true;
|
|
19060
|
+
else {
|
|
19061
|
+
if (currentNode.childNodes.length > 0) {
|
|
19062
|
+
yield this.cleanupContainer(selection, currentNode, false);
|
|
19055
19063
|
}
|
|
19056
|
-
|
|
19057
|
-
|
|
19064
|
+
let identicalElements = true;
|
|
19065
|
+
while (identicalElements &&
|
|
19066
|
+
currentNode.nextSibling &&
|
|
19067
|
+
currentNode.nodeType === Node.ELEMENT_NODE &&
|
|
19068
|
+
currentNode.nextSibling.nodeType === Node.ELEMENT_NODE) {
|
|
19069
|
+
let currentElement = currentNode;
|
|
19070
|
+
let nextElement = currentNode.nextSibling;
|
|
19071
|
+
if (this.identicalInlineStyle(currentElement, nextElement) &&
|
|
19072
|
+
currentElement.tagName.toLowerCase() === nextElement.tagName.toLowerCase() &&
|
|
19073
|
+
this.identicalClassList(currentElement, nextElement) &&
|
|
19074
|
+
!currentElement.hasAttributes() &&
|
|
19075
|
+
!nextElement.hasAttributes()) {
|
|
19076
|
+
currentElement.innerHTML += nextElement.innerHTML;
|
|
19077
|
+
nextElement.remove();
|
|
19078
|
+
this.modifiedContent = true;
|
|
19079
|
+
}
|
|
19080
|
+
else {
|
|
19081
|
+
identicalElements = false;
|
|
19082
|
+
}
|
|
19058
19083
|
}
|
|
19059
|
-
|
|
19060
|
-
|
|
19061
|
-
|
|
19062
|
-
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19084
|
+
if (currentNode.nodeType === Node.ELEMENT_NODE &&
|
|
19085
|
+
currentNode.tagName.toLowerCase() === 'span' &&
|
|
19086
|
+
Object.keys(this.getInlineStyle(currentNode)).length === 0 &&
|
|
19087
|
+
(!currentNode.classList || currentNode.classList.length === 0) &&
|
|
19088
|
+
this.hasNoAttributes(currentNode)) {
|
|
19089
|
+
let currentNodeFirstChild = currentNode;
|
|
19090
|
+
while (currentNode.firstChild) {
|
|
19091
|
+
currentNodeFirstChild.parentElement.insertBefore(currentNode.firstChild, currentNodeFirstChild.nextSibling);
|
|
19092
|
+
currentNodeFirstChild = currentNodeFirstChild.nextSibling;
|
|
19093
|
+
}
|
|
19094
|
+
currentNode.remove();
|
|
19095
|
+
this.modifiedContent = true;
|
|
19069
19096
|
}
|
|
19070
|
-
currentNode.
|
|
19071
|
-
this.modifiedContent = true;
|
|
19097
|
+
currentNode.normalize();
|
|
19072
19098
|
}
|
|
19073
|
-
currentNode.normalize();
|
|
19074
19099
|
}
|
|
19075
19100
|
}
|
|
19076
19101
|
});
|
|
19077
19102
|
}
|
|
19103
|
+
hasNoAttributes(node) {
|
|
19104
|
+
let nodeStyle = Object.keys(this.getInlineStyle(node));
|
|
19105
|
+
let nodeAttributes = Object.keys(node.getAttributeNames().reduce((acc, name) => {
|
|
19106
|
+
return Object.assign(Object.assign({}, acc), { [name]: node.getAttribute(name) });
|
|
19107
|
+
}, {}));
|
|
19108
|
+
if (nodeAttributes.length === 0 || (nodeAttributes.length === 1 && nodeStyle.length === 0)) {
|
|
19109
|
+
return true;
|
|
19110
|
+
}
|
|
19111
|
+
return false;
|
|
19112
|
+
}
|
|
19078
19113
|
identicalClassList(currentElement, nextElement) {
|
|
19079
19114
|
return ([...currentElement.classList].every((classList) => nextElement.classList.contains(classList)) &&
|
|
19080
19115
|
[...nextElement.classList].every((classList) => currentElement.classList.contains(classList)));
|
|
@@ -19121,6 +19156,13 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
19121
19156
|
this.foundFocusNode = false;
|
|
19122
19157
|
this.foundAnchorOffset = 0;
|
|
19123
19158
|
this.foundFocusOffset = 0;
|
|
19159
|
+
if (this.getSelection().toString() === this.parentEditor.querySelector('.ce-paragraph').textContent) {
|
|
19160
|
+
this.foundAnchorOffset = 0;
|
|
19161
|
+
this.foundAnchorNode = true;
|
|
19162
|
+
this.foundFocusOffset = this.getSelection().toString().length;
|
|
19163
|
+
this.foundFocusNode = true;
|
|
19164
|
+
return;
|
|
19165
|
+
}
|
|
19124
19166
|
}
|
|
19125
19167
|
let nextNode = container.firstChild;
|
|
19126
19168
|
while (nextNode && (!this.foundAnchorNode || !this.foundFocusNode)) {
|
|
@@ -19159,6 +19201,15 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
19159
19201
|
this.foundAnchorNode = false;
|
|
19160
19202
|
this.foundFocusNode = false;
|
|
19161
19203
|
this.tmpOffset = 0;
|
|
19204
|
+
if (this.foundAnchorOffset === 0 &&
|
|
19205
|
+
this.parentEditor.querySelector('.ce-paragraph').textContent.length === this.foundFocusOffset) {
|
|
19206
|
+
this.selectedAnchorNode = this.parentEditor.querySelector('.ce-paragraph').firstElementChild;
|
|
19207
|
+
this.anchorOffset = 0;
|
|
19208
|
+
this.selectedFocusNode = this.parentEditor.querySelector('.ce-paragraph').firstElementChild;
|
|
19209
|
+
this.focusOffset = 1;
|
|
19210
|
+
this.resetUserSelection();
|
|
19211
|
+
return;
|
|
19212
|
+
}
|
|
19162
19213
|
}
|
|
19163
19214
|
let nextNode = container.firstChild;
|
|
19164
19215
|
while (nextNode && (!this.foundAnchorNode || !this.foundFocusNode)) {
|
|
@@ -19187,6 +19238,13 @@ class InlineStyleTool extends EditorJSTool {
|
|
|
19187
19238
|
}
|
|
19188
19239
|
});
|
|
19189
19240
|
}
|
|
19241
|
+
getMostDescendantChild(element) {
|
|
19242
|
+
var _a;
|
|
19243
|
+
while (element.children && element.innerText === ((_a = element.children[0]) === null || _a === void 0 ? void 0 : _a.innerText) && element.children.length === 1) {
|
|
19244
|
+
element = element.children[0];
|
|
19245
|
+
}
|
|
19246
|
+
return element;
|
|
19247
|
+
}
|
|
19190
19248
|
}
|
|
19191
19249
|
|
|
19192
19250
|
// @dynamic
|
|
@@ -20492,13 +20550,18 @@ class ParagraphStyleTool extends EditorJSTool {
|
|
|
20492
20550
|
return;
|
|
20493
20551
|
}
|
|
20494
20552
|
let parentModifier = this.findParentModifier(anchorNode.parentElement);
|
|
20495
|
-
|
|
20496
|
-
this.
|
|
20553
|
+
try {
|
|
20554
|
+
if (this.tag.toLowerCase() !== 'span') {
|
|
20555
|
+
this.changeContainerTag(parentModifier, selection);
|
|
20556
|
+
}
|
|
20557
|
+
if ((this.classToApply && this.classToApply.length > 0) || (this.classes && this.classes.length > 0)) {
|
|
20558
|
+
this.changeCurrentClass(parentModifier);
|
|
20559
|
+
}
|
|
20560
|
+
this.collapseSelection();
|
|
20497
20561
|
}
|
|
20498
|
-
|
|
20499
|
-
|
|
20562
|
+
catch (error) {
|
|
20563
|
+
console.warn('Paragraph Tool Error : ' + error);
|
|
20500
20564
|
}
|
|
20501
|
-
this.collapseSelection();
|
|
20502
20565
|
});
|
|
20503
20566
|
}
|
|
20504
20567
|
checkOrderedListValue() {
|
|
@@ -20914,6 +20977,7 @@ class TextTypeTool extends ParagraphTextTool {
|
|
|
20914
20977
|
let dropdownArrow = document.createElement('span');
|
|
20915
20978
|
dropdownArrow.classList.add(this.CSS.arrowButtonModifier);
|
|
20916
20979
|
this.nodes.button.appendChild(dropdownArrow);
|
|
20980
|
+
console.log('rendering paragraph tool');
|
|
20917
20981
|
return this.nodes.button;
|
|
20918
20982
|
}
|
|
20919
20983
|
surround(range, applyStyle = false) {
|
|
@@ -20941,6 +21005,7 @@ class TextTypeTool extends ParagraphTextTool {
|
|
|
20941
21005
|
this.nodes.button.classList.remove(textType.tag.toLowerCase());
|
|
20942
21006
|
});
|
|
20943
21007
|
this.nodes.button.classList.add(classToApply);
|
|
21008
|
+
console.log('checkState method on paragraph tool');
|
|
20944
21009
|
return true;
|
|
20945
21010
|
}
|
|
20946
21011
|
renderActions() {
|
|
@@ -22197,7 +22262,6 @@ class TextEditionTool extends ParagraphStyleTool {
|
|
|
22197
22262
|
language: 'html',
|
|
22198
22263
|
});
|
|
22199
22264
|
saveButton.addEventListener('click', () => {
|
|
22200
|
-
console.log("here");
|
|
22201
22265
|
let content = monacoEditor.getValue();
|
|
22202
22266
|
saveCodeEditModal(content);
|
|
22203
22267
|
}, true);
|