@innovastudio/contentbuilder 1.4.53 → 1.4.54
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -70171,6 +70171,185 @@ class Rte {
|
|
70171
70171
|
}
|
70172
70172
|
this.getState();
|
70173
70173
|
}
|
70174
|
+
formatTextNonToggle(command) {
|
70175
|
+
const dom = this.builder.dom;
|
70176
|
+
let elm;
|
70177
|
+
try {
|
70178
|
+
let curr;
|
70179
|
+
if (this.builder.win.getSelection) {
|
70180
|
+
curr = this.builder.win.getSelection().getRangeAt(0).commonAncestorContainer;
|
70181
|
+
if (curr.nodeType === 3) {
|
70182
|
+
//text node
|
70183
|
+
elm = curr.parentNode;
|
70184
|
+
} else {
|
70185
|
+
elm = curr;
|
70186
|
+
}
|
70187
|
+
} else if (this.builder.doc.selection) {
|
70188
|
+
curr = this.builder.doc.selection.createRange();
|
70189
|
+
elm = this.builder.doc.selection.createRange().parentElement();
|
70190
|
+
}
|
70191
|
+
} catch (e) {
|
70192
|
+
return;
|
70193
|
+
}
|
70194
|
+
var text = dom.getSelected();
|
70195
|
+
if (command === 'bold') {
|
70196
|
+
dom.execCommand('text-weight', 'bold', (ok, container) => {
|
70197
|
+
if (this.builder.useCssClasses) {
|
70198
|
+
if (container) {
|
70199
|
+
const config = this.builder.cssClasses;
|
70200
|
+
container.classList.remove(config.fontWeight.thin);
|
70201
|
+
container.classList.remove(config.fontWeight.extralight);
|
70202
|
+
container.classList.remove(config.fontWeight.light);
|
70203
|
+
container.classList.remove(config.fontWeight.normal);
|
70204
|
+
container.classList.remove(config.fontWeight.semibold);
|
70205
|
+
container.classList.remove(config.fontWeight.bold);
|
70206
|
+
container.classList.remove(config.fontWeight.extrabold);
|
70207
|
+
container.classList.remove(config.fontWeight.black);
|
70208
|
+
container.classList.remove(config.fontWeight.defaultBold);
|
70209
|
+
container.classList.remove(config.fontWeight.defaultNormal);
|
70210
|
+
container.classList.add(config.fontWeight.semibold);
|
70211
|
+
dom.doFunction(container, function (theEl) {
|
70212
|
+
theEl.style.fontWeight = '';
|
70213
|
+
}, true);
|
70214
|
+
}
|
70215
|
+
}
|
70216
|
+
});
|
70217
|
+
}
|
70218
|
+
if (command === 'italic') {
|
70219
|
+
dom.execCommand('text-style', 'italic', (ok, container) => {
|
70220
|
+
if (this.builder.useCssClasses) {
|
70221
|
+
if (container) {
|
70222
|
+
const config = this.builder.cssClasses;
|
70223
|
+
container.classList.remove(config.fontStyle.italic);
|
70224
|
+
container.classList.remove(config.fontStyle.normal);
|
70225
|
+
container.classList.add(config.fontStyle.italic);
|
70226
|
+
dom.doFunction(container, function (theEl) {
|
70227
|
+
theEl.style.fontStyle = '';
|
70228
|
+
}, true);
|
70229
|
+
}
|
70230
|
+
}
|
70231
|
+
});
|
70232
|
+
}
|
70233
|
+
if (command === 'underline') {
|
70234
|
+
dom.execCommand('text-decoration', 'underline', (ok, container) => {
|
70235
|
+
if (this.builder.useCssClasses) {
|
70236
|
+
if (container) {
|
70237
|
+
const config = this.builder.cssClasses;
|
70238
|
+
container.classList.remove(config.textDecoration.underline);
|
70239
|
+
container.classList.remove(config.textDecoration.linethrough);
|
70240
|
+
container.classList.remove(config.textDecoration.normal);
|
70241
|
+
container.classList.add(config.textDecoration.underline);
|
70242
|
+
dom.doFunction(container, function (theEl) {
|
70243
|
+
theEl.style.textDecoration = '';
|
70244
|
+
}, true);
|
70245
|
+
}
|
70246
|
+
}
|
70247
|
+
});
|
70248
|
+
}
|
70249
|
+
if (command === 'strikethrough') {
|
70250
|
+
dom.execCommand('text-decoration', 'line-through', (ok, container) => {
|
70251
|
+
if (this.builder.useCssClasses) {
|
70252
|
+
if (container) {
|
70253
|
+
const config = this.builder.cssClasses;
|
70254
|
+
container.classList.remove(config.textDecoration.underline);
|
70255
|
+
container.classList.remove(config.textDecoration.linethrough);
|
70256
|
+
container.classList.remove(config.textDecoration.normal);
|
70257
|
+
container.classList.add(config.textDecoration.linethrough);
|
70258
|
+
dom.doFunction(container, function (theEl) {
|
70259
|
+
theEl.style.textDecoration = '';
|
70260
|
+
}, true);
|
70261
|
+
}
|
70262
|
+
}
|
70263
|
+
});
|
70264
|
+
}
|
70265
|
+
if (command === 'superscript') {
|
70266
|
+
if (this.builder.useCssClasses) {
|
70267
|
+
dom.execCommandToggle('extend', 'superscript', this.builder.cssClasses);
|
70268
|
+
} else {
|
70269
|
+
this.builder.doc.execCommand('superscript', false, null);
|
70270
|
+
}
|
70271
|
+
}
|
70272
|
+
if (command === 'subscript') {
|
70273
|
+
if (this.builder.useCssClasses) {
|
70274
|
+
dom.execCommandToggle('extend', 'subscript', this.builder.cssClasses);
|
70275
|
+
} else {
|
70276
|
+
this.builder.doc.execCommand('subscript', false, null);
|
70277
|
+
}
|
70278
|
+
}
|
70279
|
+
if (command === 'uppercase') {
|
70280
|
+
dom.execCommand('text-transform', 'uppercase', (ok, container) => {
|
70281
|
+
if (this.builder.useCssClasses) {
|
70282
|
+
if (container) {
|
70283
|
+
const config = this.builder.cssClasses;
|
70284
|
+
container.classList.remove(config.textTransform.uppercase);
|
70285
|
+
container.classList.remove(config.textTransform.lowercase);
|
70286
|
+
container.classList.remove(config.textTransform.capitalize);
|
70287
|
+
container.classList.remove(config.textTransform.normal);
|
70288
|
+
container.classList.add(config.textTransform.uppercase);
|
70289
|
+
dom.doFunction(container, function (theEl) {
|
70290
|
+
theEl.style.textTransform = '';
|
70291
|
+
}, true);
|
70292
|
+
}
|
70293
|
+
}
|
70294
|
+
});
|
70295
|
+
}
|
70296
|
+
if (command === 'lowercase') {
|
70297
|
+
dom.execCommand('text-transform', 'lowercase', (ok, container) => {
|
70298
|
+
if (this.builder.useCssClasses) {
|
70299
|
+
if (container) {
|
70300
|
+
const config = this.builder.cssClasses;
|
70301
|
+
container.classList.remove(config.textTransform.uppercase);
|
70302
|
+
container.classList.remove(config.textTransform.lowercase);
|
70303
|
+
container.classList.remove(config.textTransform.capitalize);
|
70304
|
+
container.classList.remove(config.textTransform.normal);
|
70305
|
+
container.classList.add(config.textTransform.lowercase);
|
70306
|
+
dom.doFunction(container, function (theEl) {
|
70307
|
+
theEl.style.textTransform = '';
|
70308
|
+
}, true);
|
70309
|
+
}
|
70310
|
+
}
|
70311
|
+
});
|
70312
|
+
}
|
70313
|
+
if (command === 'capitalize') {
|
70314
|
+
dom.execCommand('text-transform', 'capitalize', (ok, container) => {
|
70315
|
+
if (this.builder.useCssClasses) {
|
70316
|
+
if (container) {
|
70317
|
+
const config = this.builder.cssClasses;
|
70318
|
+
container.classList.remove(config.textTransform.uppercase);
|
70319
|
+
container.classList.remove(config.textTransform.lowercase);
|
70320
|
+
container.classList.remove(config.textTransform.capitalize);
|
70321
|
+
container.classList.remove(config.textTransform.normal);
|
70322
|
+
container.classList.add(config.textTransform.capitalize);
|
70323
|
+
dom.doFunction(container, function (theEl) {
|
70324
|
+
theEl.style.textTransform = '';
|
70325
|
+
}, true);
|
70326
|
+
}
|
70327
|
+
}
|
70328
|
+
});
|
70329
|
+
}
|
70330
|
+
if (command === 'clean') {
|
70331
|
+
if (this.builder.useCssClasses) {
|
70332
|
+
this.builder.doc.execCommand('removeFormat', false, null); // optional: backward compatible (for cleaning old b, i tags)
|
70333
|
+
dom.execCommandToggle('clean', '', this.builder.cssClasses);
|
70334
|
+
} else {
|
70335
|
+
if (text.trim() === '') {
|
70336
|
+
elm.style.cssText = '';
|
70337
|
+
elm.className = '';
|
70338
|
+
} else {
|
70339
|
+
if (elm.innerText.replace(/(\r\n|\n|\r)/gm, '') === text.trim().replace(/(\r\n|\n|\r)/gm, '')) {
|
70340
|
+
elm.style.cssText = '';
|
70341
|
+
elm.className = '';
|
70342
|
+
this.builder.doc.execCommand('removeFormat', false, null);
|
70343
|
+
this.builder.doc.execCommand('removeFormat', false, null);
|
70344
|
+
} else {
|
70345
|
+
this.builder.doc.execCommand('removeFormat', false, null);
|
70346
|
+
this.builder.doc.execCommand('removeFormat', false, null);
|
70347
|
+
}
|
70348
|
+
}
|
70349
|
+
}
|
70350
|
+
}
|
70351
|
+
this.getState();
|
70352
|
+
}
|
70174
70353
|
insertImage() {
|
70175
70354
|
const dom = this.dom;
|
70176
70355
|
const modalInsertImage = this.builderStuff.querySelector('.insertimage');
|
@@ -78191,6 +78370,9 @@ class ContentBuilder {
|
|
78191
78370
|
formatText(command) {
|
78192
78371
|
this.rte.formatText(command);
|
78193
78372
|
}
|
78373
|
+
formatTextNonToggle(command) {
|
78374
|
+
this.rte.formatTextNonToggle(command);
|
78375
|
+
}
|
78194
78376
|
LightenDarkenColor(col, amt) {
|
78195
78377
|
// Backward compatibility (used by: Button Editor plugin)
|
78196
78378
|
return this.util.LightenDarkenColor(col, amt);
|