@innovastudio/contentbuilder 1.5.213 → 1.5.214
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
|
@@ -8888,11 +8888,13 @@ class Dom {
|
|
|
8888
8888
|
// source: https://stackoverflow.com/questions/2871081/jquery-setting-cursor-position-in-contenteditable-div
|
|
8889
8889
|
moveCursorToElement(element) {
|
|
8890
8890
|
var sel, range;
|
|
8891
|
-
if (
|
|
8891
|
+
if (this.builder.win.getSelection && this.builder.doc.createRange) {
|
|
8892
8892
|
range = this.builder.doc.createRange();
|
|
8893
8893
|
range.selectNodeContents(element);
|
|
8894
8894
|
range.collapse(false);
|
|
8895
|
-
|
|
8895
|
+
// The CONTENT window's selection — with the editor in an iframe the
|
|
8896
|
+
// global one belongs to the host page, so the caret never moved.
|
|
8897
|
+
sel = this.builder.win.getSelection();
|
|
8896
8898
|
sel.removeAllRanges();
|
|
8897
8899
|
sel.addRange(range);
|
|
8898
8900
|
} else if (this.builder.doc.body.createTextRange) {
|
|
@@ -84958,20 +84960,6 @@ class ContentBuilder {
|
|
|
84958
84960
|
// force (and the option itself) disappears at the final step.
|
|
84959
84961
|
this.opts.engine = 'inscribe';
|
|
84960
84962
|
this.engine = 'inscribe';
|
|
84961
|
-
if (!this.opts.uploadFile && !this.opts.upload) {
|
|
84962
|
-
this.opts.uploadFile = async e => {
|
|
84963
|
-
const selectedFile = e.target.files[0];
|
|
84964
|
-
const reader = new FileReader();
|
|
84965
|
-
const result = await new Promise((resolve, reject) => {
|
|
84966
|
-
reader.onload = () => resolve(reader.result);
|
|
84967
|
-
reader.onerror = reject;
|
|
84968
|
-
reader.readAsDataURL(selectedFile);
|
|
84969
|
-
});
|
|
84970
|
-
return {
|
|
84971
|
-
url: result
|
|
84972
|
-
};
|
|
84973
|
-
};
|
|
84974
|
-
}
|
|
84975
84963
|
if (this.opts.uploadFile) {
|
|
84976
84964
|
const uploadHandler = async e => {
|
|
84977
84965
|
const data = await this.opts.uploadFile(e);
|
|
@@ -85172,6 +85160,26 @@ class ContentBuilder {
|
|
|
85172
85160
|
this.opts.onLargerImageUpload = this.opts.onImageUpload;
|
|
85173
85161
|
}
|
|
85174
85162
|
|
|
85163
|
+
// Last-resort uploader for a builder configured without one (the demo
|
|
85164
|
+
// and no-backend setups): embed the picked file as a data URL. Filled
|
|
85165
|
+
// in per upload type, and only where nothing else provided a handler,
|
|
85166
|
+
// so it can never overwrite `upload`, `uploadFile`, or a legacy
|
|
85167
|
+
// per-type callback — overwriting those turned every upload into a
|
|
85168
|
+
// silent base64 embed instead of calling the host app's uploader.
|
|
85169
|
+
const embedAsDataUrl = async e => {
|
|
85170
|
+
const selectedFile = e.target.files[0];
|
|
85171
|
+
const reader = new FileReader();
|
|
85172
|
+
const result = await new Promise((resolve, reject) => {
|
|
85173
|
+
reader.onload = () => resolve(reader.result);
|
|
85174
|
+
reader.onerror = reject;
|
|
85175
|
+
reader.readAsDataURL(selectedFile);
|
|
85176
|
+
});
|
|
85177
|
+
this.returnUrl(result);
|
|
85178
|
+
};
|
|
85179
|
+
['onImageUpload', 'onLargerImageUpload', 'onVideoUpload', 'onAudioUpload', 'onMediaUpload', 'onFileUpload'].forEach(name => {
|
|
85180
|
+
if (!this.opts[name]) this.opts[name] = embedAsDataUrl;
|
|
85181
|
+
});
|
|
85182
|
+
|
|
85175
85183
|
// useButtonPlugin
|
|
85176
85184
|
if (this.opts.emailMode) {
|
|
85177
85185
|
this.useButtonPlugin = true;
|
|
@@ -90674,7 +90682,11 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90674
90682
|
handleCellKeydown(col, e) {
|
|
90675
90683
|
if (e.which === 46 || e.which === 8) {
|
|
90676
90684
|
//delete or backspace
|
|
90677
|
-
|
|
90685
|
+
// Only when the selected icon is still live AND belongs to THIS
|
|
90686
|
+
// column: a stale activeIcon (already deleted, or left over from
|
|
90687
|
+
// another column) would otherwise swallow the key — cancelling the
|
|
90688
|
+
// delete without removing anything, or throwing on a detached node.
|
|
90689
|
+
if (this.activeIcon && this.activeIcon.isConnected && col.contains(this.activeIcon)) {
|
|
90678
90690
|
// Delete icon
|
|
90679
90691
|
if (this.activeIcon.parentNode.tagName.toLowerCase() === 'a' && this.activeIcon.parentNode.innerText.trim() === '') {
|
|
90680
90692
|
let link = this.activeIcon.parentNode;
|
|
@@ -90762,46 +90774,56 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90762
90774
|
}
|
|
90763
90775
|
}
|
|
90764
90776
|
}
|
|
90765
|
-
|
|
90766
|
-
|
|
90767
|
-
|
|
90777
|
+
|
|
90778
|
+
// LEGACY empty-block guards for Delete/Backspace (module/custom-code
|
|
90779
|
+
// columns only). Inscribe owns block joining in its regions
|
|
90780
|
+
// (_joinBack/_joinFwd + ensureBlocks), so running these there is both
|
|
90781
|
+
// unnecessary and harmful: the Delete branch mutates the DOM behind
|
|
90782
|
+
// Inscribe's back (bypassing its history) and the Backspace branch
|
|
90783
|
+
// cancels the key outright.
|
|
90784
|
+
//
|
|
90785
|
+
// Both read the caret from `this.win` — the CONTENT window — not the
|
|
90786
|
+
// global `window`, and only act when the caret really is inside this
|
|
90787
|
+
// column. Reading the global selection was the cause of "Backspace
|
|
90788
|
+
// stopped working": with the editor in an iframe (or after a click
|
|
90789
|
+
// landed a caret in the editor UI), the global selection points at
|
|
90790
|
+
// some unrelated node whose textContent is '' and which has no
|
|
90791
|
+
// previousElementSibling, so EVERY Backspace was preventDefault()ed —
|
|
90792
|
+
// typing kept working, and only a page reload cleared it.
|
|
90793
|
+
const legacyDeleteGuard = !this.inscribeRegionAt(col, e.target);
|
|
90794
|
+
if (legacyDeleteGuard && (e.keyCode === 46 || e.keyCode === 8)) {
|
|
90795
|
+
let curr = null;
|
|
90768
90796
|
try {
|
|
90769
|
-
|
|
90770
|
-
|
|
90771
|
-
|
|
90772
|
-
|
|
90773
|
-
|
|
90774
|
-
|
|
90775
|
-
|
|
90776
|
-
if (
|
|
90777
|
-
curr.
|
|
90778
|
-
|
|
90779
|
-
|
|
90797
|
+
const sel = this.win.getSelection ? this.win.getSelection() : null;
|
|
90798
|
+
if (sel && sel.rangeCount) curr = sel.getRangeAt(0).commonAncestorContainer;
|
|
90799
|
+
} catch (err) {
|
|
90800
|
+
curr = null;
|
|
90801
|
+
}
|
|
90802
|
+
if (curr && col.contains(curr)) {
|
|
90803
|
+
if (e.keyCode === 46) {
|
|
90804
|
+
if (curr.innerHTML === '<br>') {
|
|
90805
|
+
let next = curr.nextElementSibling;
|
|
90806
|
+
if (next) {
|
|
90807
|
+
curr.parentNode.removeChild(curr); //without this, empty P, H1, H2 (contains only <br />) cannot be deleted (when there is another P below)
|
|
90808
|
+
// Of course, we can backspace from the P below, but the formatting will change.
|
|
90809
|
+
e.preventDefault();
|
|
90810
|
+
}
|
|
90780
90811
|
}
|
|
90781
90812
|
}
|
|
90782
|
-
|
|
90783
|
-
|
|
90784
|
-
|
|
90785
|
-
|
|
90786
|
-
|
|
90787
|
-
|
|
90788
|
-
|
|
90789
|
-
|
|
90790
|
-
|
|
90791
|
-
curr = window.getSelection().getRangeAt(0).commonAncestorContainer;
|
|
90792
|
-
} else if (document.selection) {
|
|
90793
|
-
curr = document.selection.createRange();
|
|
90794
|
-
}
|
|
90795
|
-
if (curr.textContent === '') {
|
|
90796
|
-
let prev = curr.previousElementSibling;
|
|
90797
|
-
if (!prev) {
|
|
90798
|
-
e.preventDefault(); //Without this, empty P, H1, H2 (that doesn't have prev element) will be lost => can make empty column.
|
|
90813
|
+
if (e.keyCode === 8) {
|
|
90814
|
+
// delete on Mac
|
|
90815
|
+
// Element nodes only: a text node has no previousElementSibling,
|
|
90816
|
+
// so an empty text node under the caret would always cancel the key.
|
|
90817
|
+
if (curr.nodeType === 1 && curr.textContent === '') {
|
|
90818
|
+
let prev = curr.previousElementSibling;
|
|
90819
|
+
if (!prev) {
|
|
90820
|
+
e.preventDefault(); //Without this, empty P, H1, H2 (that doesn't have prev element) will be lost => can make empty column.
|
|
90821
|
+
}
|
|
90799
90822
|
}
|
|
90800
90823
|
}
|
|
90801
|
-
} catch (e) {
|
|
90802
|
-
// Do Nothing
|
|
90803
90824
|
}
|
|
90804
90825
|
}
|
|
90826
|
+
|
|
90805
90827
|
if (e.which === 9 && !e.shiftKey) {
|
|
90806
90828
|
// tab key pressed
|
|
90807
90829
|
const activeCol = this.activeCol;
|
|
@@ -90812,7 +90834,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90812
90834
|
if (target) target.click();
|
|
90813
90835
|
// if(target.firstElementChild) target.firstElementChild.click();
|
|
90814
90836
|
|
|
90815
|
-
let selection =
|
|
90837
|
+
let selection = this.win.getSelection();
|
|
90816
90838
|
let range = this.createRange(target, {
|
|
90817
90839
|
count: 0
|
|
90818
90840
|
});
|
|
@@ -90836,7 +90858,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90836
90858
|
if (firstCol) firstCol.click();
|
|
90837
90859
|
// if(firstCol.firstElementChild) firstCol.firstElementChild.click();
|
|
90838
90860
|
|
|
90839
|
-
let selection =
|
|
90861
|
+
let selection = this.win.getSelection();
|
|
90840
90862
|
let range = this.createRange(firstCol, {
|
|
90841
90863
|
count: 0
|
|
90842
90864
|
});
|
|
@@ -90865,7 +90887,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90865
90887
|
const target = activeCol.previousElementSibling;
|
|
90866
90888
|
if (target) target.click();
|
|
90867
90889
|
if (target.firstElementChild) target.firstElementChild.click();
|
|
90868
|
-
let selection =
|
|
90890
|
+
let selection = this.win.getSelection();
|
|
90869
90891
|
let range = this.createRange(target, {
|
|
90870
90892
|
count: 0
|
|
90871
90893
|
});
|
|
@@ -90888,7 +90910,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90888
90910
|
const target = divs[divs.length - 1];
|
|
90889
90911
|
if (target) target.click();
|
|
90890
90912
|
if (target.firstElementChild) target.firstElementChild.click();
|
|
90891
|
-
let selection =
|
|
90913
|
+
let selection = this.win.getSelection();
|
|
90892
90914
|
let range = this.createRange(target, {
|
|
90893
90915
|
count: 0
|
|
90894
90916
|
});
|
|
@@ -90957,7 +90979,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
90957
90979
|
}
|
|
90958
90980
|
createRange(node, chars, range) {
|
|
90959
90981
|
if (!range) {
|
|
90960
|
-
range =
|
|
90982
|
+
range = this.doc.createRange();
|
|
90961
90983
|
range.selectNode(node);
|
|
90962
90984
|
range.setStart(node, 0);
|
|
90963
90985
|
}
|