@innovastudio/contentbuilder 1.3.10 → 1.3.11
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
|
@@ -66274,26 +66274,61 @@ class Rte {
|
|
|
66274
66274
|
|
|
66275
66275
|
const command = item.getAttribute('data-block'); //h1, h2, h3, h4, p, pre
|
|
66276
66276
|
|
|
66277
|
+
/*
|
|
66277
66278
|
let block = this.builder.doc.queryCommandValue('FormatBlock');
|
|
66278
66279
|
block = block.toLowerCase();
|
|
66279
|
-
|
|
66280
66280
|
if (block === 'pre') {
|
|
66281
|
-
|
|
66281
|
+
let elm = dom.textSelection();
|
|
66282
|
+
if(elm) {
|
|
66283
|
+
let pre = elm.closest('pre');
|
|
66284
|
+
if(pre) {
|
|
66285
|
+
let newnode = pre.cloneNode(true);
|
|
66286
|
+
let s = newnode.outerHTML.replace('<pre', '<' + command);
|
|
66287
|
+
s = s.replace('</pre>', '</' + command + '>');
|
|
66288
|
+
pre.outerHTML = s;
|
|
66289
|
+
}
|
|
66290
|
+
pre.focus();
|
|
66291
|
+
}
|
|
66292
|
+
} else {
|
|
66293
|
+
this.builder.doc.execCommand('formatBlock', false, '<' + command + '>'); //Needs contenteditable.
|
|
66294
|
+
}
|
|
66295
|
+
*/
|
|
66282
66296
|
|
|
66283
|
-
|
|
66284
|
-
|
|
66297
|
+
const selection = dom.getSelection();
|
|
66298
|
+
if (!selection) return;
|
|
66299
|
+
const anchorNode = selection.anchorNode;
|
|
66300
|
+
let container;
|
|
66285
66301
|
|
|
66286
|
-
|
|
66287
|
-
|
|
66288
|
-
|
|
66289
|
-
s = s.replace('</pre>', '</' + command + '>');
|
|
66290
|
-
pre.outerHTML = s;
|
|
66291
|
-
}
|
|
66302
|
+
if (anchorNode) {
|
|
66303
|
+
container = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.COMMENT_NODE ? anchorNode : anchorNode.parentElement;
|
|
66304
|
+
}
|
|
66292
66305
|
|
|
66293
|
-
|
|
66306
|
+
if (!container) return;
|
|
66307
|
+
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');
|
|
66308
|
+
|
|
66309
|
+
if (element) {
|
|
66310
|
+
// const tagName = element.tagName.toLowerCase();
|
|
66311
|
+
element.setAttribute('data-replacetagname', '1');
|
|
66312
|
+
const newElement = document.createElement(command); // Copy the attributes
|
|
66313
|
+
|
|
66314
|
+
for (var i = 0, l = element.attributes.length; i < l; ++i) {
|
|
66315
|
+
var nodeName = element.attributes.item(i).nodeName;
|
|
66316
|
+
var nodeValue = element.attributes.item(i).nodeValue;
|
|
66317
|
+
newElement.setAttribute(nodeName, nodeValue);
|
|
66318
|
+
} // move all elements in the other container.
|
|
66319
|
+
|
|
66320
|
+
|
|
66321
|
+
while (element.firstChild) {
|
|
66322
|
+
newElement.appendChild(element.firstChild);
|
|
66323
|
+
}
|
|
66324
|
+
|
|
66325
|
+
element.parentNode.replaceChild(newElement, element);
|
|
66326
|
+
const result = document.querySelector('[data-replacetagname="1"]');
|
|
66327
|
+
|
|
66328
|
+
if (result) {
|
|
66329
|
+
result.removeAttribute('data-replacetagname');
|
|
66330
|
+
dom.selectElementContents(result);
|
|
66294
66331
|
}
|
|
66295
|
-
} else {
|
|
66296
|
-
this.builder.doc.execCommand('formatBlock', false, '<' + command + '>'); //Needs contenteditable.
|
|
66297
66332
|
} //save selection
|
|
66298
66333
|
|
|
66299
66334
|
|
|
@@ -67933,7 +67968,7 @@ class Rte {
|
|
|
67933
67968
|
for (let i = 0; i < Object.keys(classes).length; i++) {
|
|
67934
67969
|
let className = Object.values(classes)[i];
|
|
67935
67970
|
|
|
67936
|
-
if (
|
|
67971
|
+
if (container.closest(`.${className}`)) {
|
|
67937
67972
|
if (num === '+') {
|
|
67938
67973
|
if (i + 1 === Object.keys(classes).length) return;
|
|
67939
67974
|
newClassName = Object.values(classes)[i + 1];
|