@innovastudio/contentbox 1.4.12 → 1.4.13
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/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@innovastudio/contentbox",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.4.
|
4
|
+
"version": "1.4.13",
|
5
5
|
"description": "",
|
6
6
|
"main": "public/contentbox/contentbox.esm.js",
|
7
7
|
"files": [
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"webpack-dev-server": "^4.0.0"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
-
"@innovastudio/contentbuilder": "^1.3.
|
49
|
+
"@innovastudio/contentbuilder": "^1.3.11",
|
50
50
|
"js-beautify": "^1.14.0"
|
51
51
|
}
|
52
52
|
}
|
@@ -12125,7 +12125,11 @@ class EditBox {
|
|
12125
12125
|
dom$j.removeClass(elm, 'center');
|
12126
12126
|
let elms = activeBox.querySelectorAll('.is-builder > div > div, .is-builder > div > div > *');
|
12127
12127
|
elms.forEach(elm => {
|
12128
|
+
if (elm.closest('.is-section-tool') || elm.closest('.is-box-tool') || elm.closest('.is-tool') || elm.closest('.is-rowadd-tool')) return;
|
12128
12129
|
elm.style.textAlign = '';
|
12130
|
+
dom$j.removeClass(elm, 'left');
|
12131
|
+
dom$j.removeClass(elm, 'right');
|
12132
|
+
dom$j.removeClass(elm, 'center');
|
12129
12133
|
dom$j.removeClass(elm, this.builder.cssClasses.textAlign.left);
|
12130
12134
|
dom$j.removeClass(elm, this.builder.cssClasses.textAlign.center);
|
12131
12135
|
dom$j.removeClass(elm, this.builder.cssClasses.textAlign.right);
|
@@ -12133,6 +12137,9 @@ class EditBox {
|
|
12133
12137
|
this.builder.editor.dom.doFunction(elm, theEl => {
|
12134
12138
|
if (theEl.closest('.is-section-tool') || theEl.closest('.is-box-tool') || theEl.closest('.is-tool') || theEl.closest('.is-rowadd-tool')) return;
|
12135
12139
|
theEl.style.textAlign = '';
|
12140
|
+
dom$j.removeClass(theEl, 'left');
|
12141
|
+
dom$j.removeClass(theEl, 'right');
|
12142
|
+
dom$j.removeClass(theEl, 'center');
|
12136
12143
|
dom$j.removeClass(theEl, this.builder.cssClasses.textAlign.left);
|
12137
12144
|
dom$j.removeClass(theEl, this.builder.cssClasses.textAlign.center);
|
12138
12145
|
dom$j.removeClass(theEl, this.builder.cssClasses.textAlign.right);
|
@@ -78935,26 +78942,61 @@ class Rte {
|
|
78935
78942
|
|
78936
78943
|
const command = item.getAttribute('data-block'); //h1, h2, h3, h4, p, pre
|
78937
78944
|
|
78945
|
+
/*
|
78938
78946
|
let block = this.builder.doc.queryCommandValue('FormatBlock');
|
78939
78947
|
block = block.toLowerCase();
|
78940
|
-
|
78941
78948
|
if (block === 'pre') {
|
78942
|
-
|
78949
|
+
let elm = dom.textSelection();
|
78950
|
+
if(elm) {
|
78951
|
+
let pre = elm.closest('pre');
|
78952
|
+
if(pre) {
|
78953
|
+
let newnode = pre.cloneNode(true);
|
78954
|
+
let s = newnode.outerHTML.replace('<pre', '<' + command);
|
78955
|
+
s = s.replace('</pre>', '</' + command + '>');
|
78956
|
+
pre.outerHTML = s;
|
78957
|
+
}
|
78958
|
+
pre.focus();
|
78959
|
+
}
|
78960
|
+
} else {
|
78961
|
+
this.builder.doc.execCommand('formatBlock', false, '<' + command + '>'); //Needs contenteditable.
|
78962
|
+
}
|
78963
|
+
*/
|
78943
78964
|
|
78944
|
-
|
78945
|
-
|
78965
|
+
const selection = dom.getSelection();
|
78966
|
+
if (!selection) return;
|
78967
|
+
const anchorNode = selection.anchorNode;
|
78968
|
+
let container;
|
78946
78969
|
|
78947
|
-
|
78948
|
-
|
78949
|
-
|
78950
|
-
s = s.replace('</pre>', '</' + command + '>');
|
78951
|
-
pre.outerHTML = s;
|
78952
|
-
}
|
78970
|
+
if (anchorNode) {
|
78971
|
+
container = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.COMMENT_NODE ? anchorNode : anchorNode.parentElement;
|
78972
|
+
}
|
78953
78973
|
|
78954
|
-
|
78974
|
+
if (!container) return;
|
78975
|
+
let element = container.closest('h1') || container.closest('h2') || container.closest('h3') || container.closest('h4') || container.closest('h5') || container.closest('h6') || container.closest('pre') || container.closest('p');
|
78976
|
+
|
78977
|
+
if (element) {
|
78978
|
+
// const tagName = element.tagName.toLowerCase();
|
78979
|
+
element.setAttribute('data-replacetagname', '1');
|
78980
|
+
const newElement = document.createElement(command); // Copy the attributes
|
78981
|
+
|
78982
|
+
for (var i = 0, l = element.attributes.length; i < l; ++i) {
|
78983
|
+
var nodeName = element.attributes.item(i).nodeName;
|
78984
|
+
var nodeValue = element.attributes.item(i).nodeValue;
|
78985
|
+
newElement.setAttribute(nodeName, nodeValue);
|
78986
|
+
} // move all elements in the other container.
|
78987
|
+
|
78988
|
+
|
78989
|
+
while (element.firstChild) {
|
78990
|
+
newElement.appendChild(element.firstChild);
|
78991
|
+
}
|
78992
|
+
|
78993
|
+
element.parentNode.replaceChild(newElement, element);
|
78994
|
+
const result = document.querySelector('[data-replacetagname="1"]');
|
78995
|
+
|
78996
|
+
if (result) {
|
78997
|
+
result.removeAttribute('data-replacetagname');
|
78998
|
+
dom.selectElementContents(result);
|
78955
78999
|
}
|
78956
|
-
} else {
|
78957
|
-
this.builder.doc.execCommand('formatBlock', false, '<' + command + '>'); //Needs contenteditable.
|
78958
79000
|
} //save selection
|
78959
79001
|
|
78960
79002
|
|
@@ -80594,7 +80636,7 @@ class Rte {
|
|
80594
80636
|
for (let i = 0; i < Object.keys(classes).length; i++) {
|
80595
80637
|
let className = Object.values(classes)[i];
|
80596
80638
|
|
80597
|
-
if (
|
80639
|
+
if (container.closest(`.${className}`)) {
|
80598
80640
|
if (num === '+') {
|
80599
80641
|
if (i + 1 === Object.keys(classes).length) return;
|
80600
80642
|
newClassName = Object.values(classes)[i + 1];
|