@innovastudio/contentbuilder 1.5.231 → 1.5.232
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
|
@@ -62792,6 +62792,7 @@ function filterStyle(el, allowedProps) {
|
|
|
62792
62792
|
for (const [p, v] of keep) el.style.setProperty(p, v);
|
|
62793
62793
|
if (!el.getAttribute('style')) el.removeAttribute('style');
|
|
62794
62794
|
}
|
|
62795
|
+
const MARKUP_DATA = /^data-(html(-\d+)?|settings|src|cb-original-content|cb-content|module-desc)$/;
|
|
62795
62796
|
function sanitizeHTML(html, config = {}) {
|
|
62796
62797
|
const conf = {
|
|
62797
62798
|
tags: config.tags || DEFAULTS$1.tags,
|
|
@@ -62824,7 +62825,13 @@ function sanitizeHTML(html, config = {}) {
|
|
|
62824
62825
|
if (attr.value !== 'false') el.removeAttribute(attr.name);
|
|
62825
62826
|
continue;
|
|
62826
62827
|
}
|
|
62827
|
-
if (name.indexOf('data-') === 0)
|
|
62828
|
+
if (name.indexOf('data-') === 0) {
|
|
62829
|
+
/* Widget state lives here, except the attributes the editor turns
|
|
62830
|
+
back into markup or code (a module's source, a plugin's original
|
|
62831
|
+
content): from outside content they would bring in script. */
|
|
62832
|
+
if (MARKUP_DATA.test(name)) el.removeAttribute(attr.name);
|
|
62833
|
+
continue;
|
|
62834
|
+
}
|
|
62828
62835
|
if (name === 'style') {
|
|
62829
62836
|
filterStyle(el, conf.styleProps);
|
|
62830
62837
|
continue;
|
|
@@ -68751,7 +68758,7 @@ class InscribeRegion {
|
|
|
68751
68758
|
// keeps them (registered after the editor's own blur handler).
|
|
68752
68759
|
this.ed.on('blur', () => {
|
|
68753
68760
|
const img = this.builder.activeImage;
|
|
68754
|
-
if (img && img.isConnected && this.el.contains(img) && !imageFillsBox(img)) imageUI._show(img);
|
|
68761
|
+
if (imageUI.enabled && img && img.isConnected && this.el.contains(img) && !imageFillsBox(img)) imageUI._show(img);
|
|
68755
68762
|
});
|
|
68756
68763
|
}
|
|
68757
68764
|
|
|
@@ -69441,7 +69448,7 @@ class InscribeEngine {
|
|
|
69441
69448
|
for (const r of this.regions.values()) {
|
|
69442
69449
|
const ui = r.ed && r.ed.imageUI;
|
|
69443
69450
|
if (!ui) continue;
|
|
69444
|
-
if (img && img.isConnected && r.el && r.el.contains(img) && !imageFillsBox(img)) ui._show(img);else ui._syncToSelection();
|
|
69451
|
+
if (ui.enabled && img && img.isConnected && r.el && r.el.contains(img) && !imageFillsBox(img)) ui._show(img);else ui._syncToSelection();
|
|
69445
69452
|
}
|
|
69446
69453
|
}
|
|
69447
69454
|
hideImageHandles() {
|
|
@@ -89150,6 +89157,13 @@ ${singleModel ? '' : `
|
|
|
89150
89157
|
// Block-level HTML is the answer itself — show it as code so
|
|
89151
89158
|
// its line breaks survive. Inline HTML stays in the sentence.
|
|
89152
89159
|
return token && token.block ? '<pre><code>' + esc.replace(/\n$/, '') + '</code></pre>' : esc;
|
|
89160
|
+
},
|
|
89161
|
+
// A javascript: (or data:) link in a reply would run in the
|
|
89162
|
+
// editor: shown as text. Every other link stays.
|
|
89163
|
+
link(token) {
|
|
89164
|
+
const href = Array.from(String(token.href || '')).filter(ch => ch.charCodeAt(0) > 32).join('');
|
|
89165
|
+
if (!/^(javascript|vbscript|data):/i.test(href)) return false;
|
|
89166
|
+
return this.parser.parseInline(token.tokens);
|
|
89153
89167
|
}
|
|
89154
89168
|
}
|
|
89155
89169
|
});
|
|
@@ -92743,13 +92757,16 @@ ${this.buildHistoryContext()}`;
|
|
|
92743
92757
|
<div class="message-header">${out('Generated Images')}</div>
|
|
92744
92758
|
<div class="message-content" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 12px;">
|
|
92745
92759
|
`;
|
|
92760
|
+
|
|
92761
|
+
// A caption can be written by the AI: escaped, quotes too.
|
|
92762
|
+
const esc = s => String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
92746
92763
|
images.forEach(img => {
|
|
92747
92764
|
previewHTML += `
|
|
92748
92765
|
<div style="border-radius: 6px; overflow: hidden; background: rgba(255,255,255,0.05);">
|
|
92749
|
-
<img src="${img.url}" alt="${img.context || 'Generated image'}" style="width: 100%;" />
|
|
92766
|
+
<img src="${esc(img.url)}" alt="${esc(img.context || 'Generated image')}" style="width: 100%;" />
|
|
92750
92767
|
<div style="padding: 8px; font-size: 11px; opacity: 0.8;">
|
|
92751
|
-
${img.context || ''}
|
|
92752
|
-
<a href="${img.url}" target="_blank" rel="noopener noreferrer" style="display: block; margin-top: 4px;">View</a>
|
|
92768
|
+
${esc(img.context || '')}
|
|
92769
|
+
<a href="${esc(img.url)}" target="_blank" rel="noopener noreferrer" style="display: block; margin-top: 4px;">View</a>
|
|
92753
92770
|
</div>
|
|
92754
92771
|
</div>
|
|
92755
92772
|
`; // height: 150px; object-fit: cover;
|
|
@@ -93786,9 +93803,11 @@ ${this.buildHistoryContext()}`;
|
|
|
93786
93803
|
<div class="message-header">${out('Assistant')}</div>
|
|
93787
93804
|
<div class="loading">
|
|
93788
93805
|
<div class="spinner"></div>
|
|
93789
|
-
<span
|
|
93806
|
+
<span></span>
|
|
93790
93807
|
</div>
|
|
93791
93808
|
`;
|
|
93809
|
+
// The step's text can be written by the AI: shown as text.
|
|
93810
|
+
loadingDiv.querySelector('.loading span').textContent = taskDescription || out('Processing...');
|
|
93792
93811
|
this.messagesContainer.appendChild(loadingDiv);
|
|
93793
93812
|
this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight;
|
|
93794
93813
|
return loadingId;
|
|
@@ -94746,8 +94765,10 @@ function createSectionTarget(engine) {
|
|
|
94746
94765
|
*/
|
|
94747
94766
|
function normalize(html) {
|
|
94748
94767
|
if (!html || typeof html !== 'string') return null;
|
|
94749
|
-
|
|
94750
|
-
|
|
94768
|
+
// An inert template: nothing in the AI's markup loads or runs here.
|
|
94769
|
+
const tpl = document.createElement('template');
|
|
94770
|
+
tpl.innerHTML = html.replace(/```html\n?/g, '').replace(/```\n?/g, '').trim();
|
|
94771
|
+
const holder = tpl.content;
|
|
94751
94772
|
const found = holder.querySelectorAll('.is-section');
|
|
94752
94773
|
if (found.length !== 1) return null;
|
|
94753
94774
|
const section = found[0];
|
|
@@ -95160,8 +95181,10 @@ function createRowTarget(engine) {
|
|
|
95160
95181
|
*/
|
|
95161
95182
|
function normalize(html) {
|
|
95162
95183
|
if (!html || typeof html !== 'string') return null;
|
|
95163
|
-
|
|
95164
|
-
|
|
95184
|
+
// An inert template: nothing in the AI's markup loads or runs here.
|
|
95185
|
+
const tpl = document.createElement('template');
|
|
95186
|
+
tpl.innerHTML = html.replace(/```html\n?/g, '').replace(/```\n?/g, '').trim();
|
|
95187
|
+
const holder = tpl.content;
|
|
95165
95188
|
const found = Array.from(holder.children).filter(el => el.classList.contains('row'));
|
|
95166
95189
|
if (found.length !== 1) return null;
|
|
95167
95190
|
repairButtons(found[0]);
|
|
@@ -95558,6 +95581,13 @@ const md = new B({
|
|
|
95558
95581
|
// Block-level HTML is the answer itself — show it as code so its
|
|
95559
95582
|
// line breaks survive. Inline HTML stays in the sentence.
|
|
95560
95583
|
return token && token.block ? '<pre><code>' + esc.replace(/\n$/, '') + '</code></pre>' : esc;
|
|
95584
|
+
},
|
|
95585
|
+
// A javascript: (or data:) link in a reply would run in the editor:
|
|
95586
|
+
// shown as text. Every other link stays.
|
|
95587
|
+
link(token) {
|
|
95588
|
+
const href = Array.from(String(token.href || '')).filter(ch => ch.charCodeAt(0) > 32).join('');
|
|
95589
|
+
if (!/^(javascript|vbscript|data):/i.test(href)) return false;
|
|
95590
|
+
return this.parser.parseInline(token.tokens);
|
|
95561
95591
|
}
|
|
95562
95592
|
}
|
|
95563
95593
|
});
|
|
@@ -100197,9 +100227,11 @@ class AddonHost {
|
|
|
100197
100227
|
// Images that arrive inside the HTML (a Word file's) go
|
|
100198
100228
|
// through the editor's upload, as pasted images do.
|
|
100199
100229
|
if (html.indexOf('data:image/') !== -1) {
|
|
100200
|
-
|
|
100230
|
+
// An inert template: nothing in it loads or runs
|
|
100231
|
+
// (the sanitizer only cleans it on insert).
|
|
100232
|
+
const tmp = document.createElement('template');
|
|
100201
100233
|
tmp.innerHTML = html;
|
|
100202
|
-
tmp.querySelectorAll('img[src^="data:image/"]').forEach(im => im.setAttribute('data-cb-paste-upload', ''));
|
|
100234
|
+
tmp.content.querySelectorAll('img[src^="data:image/"]').forEach(im => im.setAttribute('data-cb-paste-upload', ''));
|
|
100203
100235
|
html = tmp.innerHTML;
|
|
100204
100236
|
}
|
|
100205
100237
|
const sel = builder.doc.getSelection();
|
|
@@ -100368,9 +100400,9 @@ class AddonHost {
|
|
|
100368
100400
|
const r = range || this.selection();
|
|
100369
100401
|
const region = regionAt(r);
|
|
100370
100402
|
if (!region) return null;
|
|
100371
|
-
const tmp = document.createElement('
|
|
100403
|
+
const tmp = document.createElement('template');
|
|
100372
100404
|
tmp.innerHTML = String(svg);
|
|
100373
|
-
const el = tmp.querySelector('svg');
|
|
100405
|
+
const el = tmp.content.querySelector('svg');
|
|
100374
100406
|
if (!el) return null;
|
|
100375
100407
|
cleanSvg(el);
|
|
100376
100408
|
if (opts && opts.line) {
|
|
@@ -108974,7 +109006,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
108974
109006
|
// Auto-embed a pasted YouTube/Vimeo URL
|
|
108975
109007
|
if (!this.opts.disableAutoEmbedVideo) {
|
|
108976
109008
|
const src = contentword.innerText;
|
|
108977
|
-
const youRegex = /^http[s]?:\/\/(((www.youtube.com\/watch\?(feature=player_detailpage&)?)v=)|(youtu.be\/))([
|
|
109009
|
+
const youRegex = /^http[s]?:\/\/(((www.youtube.com\/watch\?(feature=player_detailpage&)?)v=)|(youtu.be\/))([\w-]+)/;
|
|
108978
109010
|
const vimeoRegex = /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/)|(video\/))?([0-9]+)\/?/;
|
|
108979
109011
|
const y = youRegex.exec(src),
|
|
108980
109012
|
v = vimeoRegex.exec(src);
|
|
@@ -108982,6 +109014,7 @@ Please obtain a license at: https://innovastudio.com/contentbox`);
|
|
|
108982
109014
|
let embedSrc = src;
|
|
108983
109015
|
if (y && y.length >= 7) embedSrc = 'https://www.youtube.com/embed/' + y[6] + '?rel=0';
|
|
108984
109016
|
if (v && v.length >= 7) embedSrc = 'https://player.vimeo.com/video/' + v[6];
|
|
109017
|
+
embedSrc = embedSrc.replace(/"/g, '%22').replace(/</g, '%3C').replace(/>/g, '%3E');
|
|
108985
109018
|
return '<div class="embed-responsive embed-responsive-16by9"><iframe tabindex="0" width="560" height="315" src="' + embedSrc + '" frameborder="0" allowfullscreen=""></iframe></div>';
|
|
108986
109019
|
}
|
|
108987
109020
|
}
|