@innovastudio/contentbuilder 1.4.57 → 1.4.58

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.57",
4
+ "version": "1.4.58",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -76372,23 +76372,7 @@ class Lib {
76372
76372
 
76373
76373
  // Run functions based on short command
76374
76374
  processShortCommand(command) {
76375
- let shortCommandList = {
76376
- undo: ['undo'],
76377
- redo: ['undo'],
76378
- increase: ['increase', 'bigger', 'larger', 'enlarge'],
76379
- decrease: ['decrease', 'smaller'],
76380
- bold: ['bold'],
76381
- italic: ['italic'],
76382
- underline: ['underline'],
76383
- strikethrough: ['strikethrough'],
76384
- superscript: ['superscript'],
76385
- subscript: ['subscript'],
76386
- uppercase: ['uppercase'],
76387
- lowercase: ['lowercase'],
76388
- capitalize: ['capitalize'],
76389
- clean: ['clean']
76390
- };
76391
- if (this.builder.shortCommandList) shortCommandList = this.builder.shortCommandList;
76375
+ let shortCommandList = this.builder.shortCommandList;
76392
76376
  const getMatchingCommand = command => {
76393
76377
  for (const key in shortCommandList) {
76394
76378
  if (shortCommandList[key].includes(command)) {
@@ -76679,8 +76663,7 @@ class Lib {
76679
76663
  }
76680
76664
  }
76681
76665
  chooseHeadline() {
76682
- let list = ['We create simple and effective designs.', 'Ultimate Experiences With Story, Emotion, And Purpose.', 'Build Anything Beautifully', 'With Less Stuff and More Compassion', 'We\'re [CompanyName]. Full stack development with a spark of creativity.', 'Transforming your digital experience with [CompanyName]. Achieve your online goals with our customized solutions.', 'Revolutionizing web development with [CompanyName]. Unleash your digital potential with our high-performance solutions.', 'Creative and Inspiring'];
76683
- if (this.builder.headlineList) list = this.builder.headlineList;
76666
+ let list = this.builder.headlineList;
76684
76667
  let randomIndex = Math.floor(Math.random() * list.length);
76685
76668
  return list[randomIndex];
76686
76669
  }
@@ -77322,9 +77305,11 @@ class Dictation {
77322
77305
  dom.appendHtml(builderStuff, html);
77323
77306
  const modalCommand = builderStuff.querySelector('.page-command');
77324
77307
  this.modalCommand = modalCommand;
77308
+ const btnDictation = builderStuff.querySelector('.cmd-enable-dictation');
77309
+ const btnClear = builderStuff.querySelector('.cmd-clear-command');
77310
+ const chkAutoSend = builderStuff.querySelector('#chkAutoSendCommand');
77325
77311
  this.builder.commandText = '';
77326
77312
  this.builder.autoSendCommand = false;
77327
- this.aborted = true;
77328
77313
  if (localStorage.getItem('_dictation') !== null) {
77329
77314
  if (localStorage.getItem('_dictation') === '1') {
77330
77315
  this.modalCommand.classList.add('active');
@@ -77337,13 +77322,13 @@ class Dictation {
77337
77322
  }
77338
77323
  }
77339
77324
  }
77340
- const btnDictation = builderStuff.querySelector('.cmd-enable-dictation');
77341
77325
  if (localStorage.getItem('_mic') !== null) {
77342
77326
  if (localStorage.getItem('_mic') === '0') {
77343
77327
  btnDictation.innerHTML = '<svg class="is-icon-flex" style="width:18px; height:18px;"><use xlink:href="#icon-microphone-off"></use></svg>';
77328
+ chkAutoSend.parentNode.style.display = 'none';
77329
+ btnClear.style.marginRight = '6px';
77344
77330
  }
77345
77331
  }
77346
- const chkAutoSend = builderStuff.querySelector('#chkAutoSendCommand');
77347
77332
  if (localStorage.getItem('_autosendcommand') !== null) {
77348
77333
  if (localStorage.getItem('_autosendcommand') === '1') {
77349
77334
  chkAutoSend.checked = true;
@@ -77354,12 +77339,18 @@ class Dictation {
77354
77339
  });
77355
77340
 
77356
77341
  btnDictation.addEventListener('click', () => {
77357
- if (this.aborted) {
77342
+ if (!this.checkMic()) {
77358
77343
  this.startDictation();
77359
77344
  btnDictation.innerHTML = '<svg class="is-icon-flex" style="width:18px; height:18px;"><use xlink:href="#icon-microphone"></use></svg>';
77345
+ localStorage.setItem('_mic', '1');
77346
+ chkAutoSend.parentNode.style.display = 'flex';
77347
+ btnClear.style.marginRight = '';
77360
77348
  } else {
77361
77349
  this.stopDictation();
77362
77350
  btnDictation.innerHTML = '<svg class="is-icon-flex" style="width:18px; height:18px;"><use xlink:href="#icon-microphone-off"></use></svg>';
77351
+ localStorage.setItem('_mic', '0');
77352
+ chkAutoSend.parentNode.style.display = 'none';
77353
+ btnClear.style.marginRight = '6px';
77363
77354
  }
77364
77355
  });
77365
77356
  chkAutoSend.addEventListener('change', () => {
@@ -77371,7 +77362,6 @@ class Dictation {
77371
77362
  localStorage.setItem('_autosendcommand', '0');
77372
77363
  }
77373
77364
  });
77374
- const btnClear = builderStuff.querySelector('.cmd-clear-command');
77375
77365
  btnClear.addEventListener('click', () => {
77376
77366
  const inpCommand = this.builderStuff.querySelector('.inp-command');
77377
77367
  this.builder.commandText = '';
@@ -77419,25 +77409,46 @@ class Dictation {
77419
77409
  localStorage.setItem('_dictation', '0');
77420
77410
  });
77421
77411
  }
77412
+ checkMic() {
77413
+ if (localStorage.getItem('_mic') !== null) {
77414
+ if (localStorage.getItem('_mic') === '0') {
77415
+ return false;
77416
+ } else {
77417
+ return true;
77418
+ }
77419
+ } else {
77420
+ return true;
77421
+ }
77422
+ }
77422
77423
  openDictation() {
77423
77424
  this.modalCommand.classList.add('active');
77424
- this.startDictation();
77425
77425
  localStorage.setItem('_dictation', '1');
77426
+ const chkAutoSend = this.builderStuff.querySelector('#chkAutoSendCommand');
77427
+ const btnClear = this.builderStuff.querySelector('.cmd-clear-command');
77428
+ if (this.checkMic()) {
77429
+ // Do Nothing
77430
+ chkAutoSend.parentNode.style.display = 'flex';
77431
+ btnClear.style.marginRight = '';
77432
+ } else {
77433
+ const btnDictation = this.builderStuff.querySelector('.cmd-enable-dictation');
77434
+ btnDictation.innerHTML = '<svg class="is-icon-flex" style="width:18px; height:18px;"><use xlink:href="#icon-microphone-off"></use></svg>';
77435
+ chkAutoSend.parentNode.style.display = 'none';
77436
+ btnClear.style.marginRight = '6px';
77437
+ return;
77438
+ }
77439
+ this.startDictation();
77426
77440
  }
77427
77441
  stopDictation() {
77428
- this.recognition.abort();
77442
+ if (this.recognition) this.recognition.abort();
77429
77443
  this.aborted = true;
77430
- localStorage.setItem('_mic', '0');
77431
77444
  }
77432
77445
  startDictation() {
77433
- this.aborted = false;
77434
77446
  if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
77435
77447
  var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
77436
77448
  this.recognition = new SpeechRecognition();
77437
77449
  this.recognition.continuous = true;
77438
77450
  this.recognition.interimResults = true;
77439
- let lang = 'en-US';
77440
- if (this.builder.speechRecognitionLang) lang = this.builder.speechRecognitionLang;
77451
+ let lang = this.builder.speechRecognitionLang;
77441
77452
  this.recognition.lang = lang;
77442
77453
  this.recognition.start();
77443
77454
  let speechTimeout;
@@ -77474,13 +77485,12 @@ class Dictation {
77474
77485
  if (!this.aborted) this.startDictation();
77475
77486
  };
77476
77487
  this.recognition.onstart = () => {
77477
- localStorage.setItem('_mic', '1');
77488
+ this.aborted = false;
77478
77489
  };
77479
77490
  this.recognition.onerror = () => {
77480
77491
  // console.log(e.error);
77481
77492
  };
77482
77493
  } else {
77483
- // this.aborted = true;
77484
77494
  alert(this.util.out('Speech recognition not supported in this browser.'));
77485
77495
  }
77486
77496
  }
@@ -77513,188 +77523,6 @@ class Dictation {
77513
77523
  }
77514
77524
  }
77515
77525
 
77516
- var src = {
77517
- compareTwoStrings:compareTwoStrings,
77518
- findBestMatch:findBestMatch
77519
- };
77520
-
77521
- function compareTwoStrings(first, second) {
77522
- first = first.replace(/\s+/g, '');
77523
- second = second.replace(/\s+/g, '');
77524
-
77525
- if (first === second) return 1; // identical or empty
77526
- if (first.length < 2 || second.length < 2) return 0; // if either is a 0-letter or 1-letter string
77527
-
77528
- let firstBigrams = new Map();
77529
- for (let i = 0; i < first.length - 1; i++) {
77530
- const bigram = first.substring(i, i + 2);
77531
- const count = firstBigrams.has(bigram)
77532
- ? firstBigrams.get(bigram) + 1
77533
- : 1;
77534
-
77535
- firstBigrams.set(bigram, count);
77536
- }
77537
- let intersectionSize = 0;
77538
- for (let i = 0; i < second.length - 1; i++) {
77539
- const bigram = second.substring(i, i + 2);
77540
- const count = firstBigrams.has(bigram)
77541
- ? firstBigrams.get(bigram)
77542
- : 0;
77543
-
77544
- if (count > 0) {
77545
- firstBigrams.set(bigram, count - 1);
77546
- intersectionSize++;
77547
- }
77548
- }
77549
-
77550
- return (2.0 * intersectionSize) / (first.length + second.length - 2);
77551
- }
77552
-
77553
- function findBestMatch(mainString, targetStrings) {
77554
- if (!areArgsValid(mainString, targetStrings)) throw new Error('Bad arguments: First argument should be a string, second should be an array of strings');
77555
-
77556
- const ratings = [];
77557
- let bestMatchIndex = 0;
77558
-
77559
- for (let i = 0; i < targetStrings.length; i++) {
77560
- const currentTargetString = targetStrings[i];
77561
- const currentRating = compareTwoStrings(mainString, currentTargetString);
77562
- ratings.push({target: currentTargetString, rating: currentRating});
77563
- if (currentRating > ratings[bestMatchIndex].rating) {
77564
- bestMatchIndex = i;
77565
- }
77566
- }
77567
-
77568
-
77569
- const bestMatch = ratings[bestMatchIndex];
77570
-
77571
- return { ratings: ratings, bestMatch: bestMatch, bestMatchIndex: bestMatchIndex };
77572
- }
77573
-
77574
- function areArgsValid(mainString, targetStrings) {
77575
- if (typeof mainString !== 'string') return false;
77576
- if (!Array.isArray(targetStrings)) return false;
77577
- if (!targetStrings.length) return false;
77578
- if (targetStrings.find( function (s) { return typeof s !== 'string'})) return false;
77579
- return true;
77580
- }
77581
-
77582
- class Similarity {
77583
- constructor(settings = {}) {
77584
- const defaults = {
77585
- commandList: {
77586
- add_bg_color: ['add a background color', 'add background color'],
77587
- add_bg_image: ['add a background image', 'add background image', 'add a background', 'add background'],
77588
- change_bg_color: ['change the background color', 'change background color'],
77589
- change_bg_image: ['change the background image', 'change background image', 'change the background', 'change background'],
77590
- remove_bg_color: ['remove background color', 'remove the background color', 'clear background color', 'clear the background color'],
77591
- remove_bg: ['remove background', 'remove background image', 'remove the background', 'remove the background image', 'clear background', 'clear background image', 'clear the background', 'clear the background image'],
77592
- increase_content_width: ['increase content width', 'enlarge content width'],
77593
- decrease_content_width: ['decrease content width', 'reduce content width'],
77594
- clear_content_width: ['clear content width', 'remove content width', 'make content full', 'full width content'],
77595
- make_content_light: ['make the content white', 'make the content light', 'make the text white', 'make the text light', 'make content white', 'make content light', 'make text white', 'make text light', 'change the content white', 'change the content light', 'change the text white', 'change the text light', 'change to white content', 'change to light content', 'change to white text', 'change to light text'],
77596
- make_content_dark: ['make the content black', 'make the content dark', 'make the text black', 'make the text dark', 'make content black', 'make content dark', 'make text black', 'make text dark', 'change the content black', 'change the content dark', 'change the text black', 'change the text dark', 'change to black content', 'change to dark content', 'change to black text', 'change to dark text'],
77597
- make_section_height_10: ['make section height 10'],
77598
- make_section_height_15: ['make section height 15'],
77599
- make_section_height_20: ['make section height 20'],
77600
- make_section_height_25: ['make section height 25'],
77601
- make_section_height_30: ['make section height 30'],
77602
- make_section_height_40: ['make section height 40'],
77603
- make_section_height_50: ['make section height 50'],
77604
- make_section_height_60: ['make section height 60'],
77605
- make_section_height_70: ['make section height 70'],
77606
- make_section_height_75: ['make section height 75'],
77607
- make_section_height_80: ['make section height 80'],
77608
- make_section_height_85: ['make section height 85'],
77609
- make_section_height_90: ['make section height 90'],
77610
- make_section_height_100: ['make section height 100'],
77611
- make_section_height_auto: ['make section height auto'],
77612
- suggest_headline: ['suggest a headline', 'suggest headline', 'suggest a header', 'suggest header', 'suggest a title', 'suggest title', 'write a headline', 'write headline', 'write a header', 'write header', 'write a title', 'write title'],
77613
- add_headline: ['add a headline', 'add headline', 'add a header', 'add header', 'add a title', 'add title'],
77614
- add_paragraph: ['add a paragraph', 'add paragraph'],
77615
- add_image: ['add an image', 'add image'],
77616
- add_youtube: ['add a youtube', 'add youtube'],
77617
- add_video: ['add a video', 'add video', 'add an HTML5 video', 'add HTML5 video', 'add an mp4 video', 'add mp4 video'],
77618
- add_audio: ['add an audio', 'add audio', 'add a music', 'add music', 'add an mp3', 'add mp3'],
77619
- add_map: ['add a map', 'add map', 'add a google map', 'add google map'],
77620
- add_table: ['add a table', 'add table'],
77621
- add_social: ['add a social', 'add social'],
77622
- add_icon: ['add an icon', 'add icon'],
77623
- add_button: ['add a button', 'add button'],
77624
- add_2buttons: ['add 2 button', 'add 2 button', 'add 2 buttons', 'add 2 buttons'],
77625
- add_space: ['add a space', 'add space'],
77626
- position_before: ['above', 'before'],
77627
- increase_line_height: ['increase line height', 'increase line spacing', 'increase text spacing', 'increase the line height', 'increase the line spacing', 'increase the text spacing', 'enlarge line height', 'enlarge line spacing', 'enlarge text spacing', 'enlarge the line height', 'enlarge the line spacing', 'enlarge the text spacing', 'bigger line height', 'bigger line spacing', 'bigger text spacing', 'bigger the line height', 'bigger the line spacing', 'bigger the text spacing', 'make line height bigger', 'make line spacing bigger', 'make text spacing bigger', 'make the line height bigger', 'make the line spacing bigger', 'make the text spacing bigger'],
77628
- increase_default_line_height: ['increase default line height', 'increase default line spacing', 'increase default text spacing', 'increase the default line height', 'increase the default line spacing', 'increase the default text spacing', 'enlarge default line height', 'enlarge default line spacing', 'enlarge default text spacing', 'enlarge the default line height', 'enlarge the default line spacing', 'enlarge the default text spacing', 'bigger default line height', 'bigger default line spacing', 'bigger default text spacing', 'bigger the default line height', 'bigger the default line spacing', 'bigger the default text spacing', 'make default line height bigger', 'make default line spacing bigger', 'make default text spacing bigger', 'make the default line height bigger', 'make the default line spacing bigger', 'make the default text spacing bigger'],
77629
- decrease_line_height: ['decrease line height', 'decrease line spacing', 'decrease text spacing', 'decrease the line height', 'decrease the line spacing', 'decrease the text spacing', 'reduce line height', 'reduce line spacing', 'reduce text spacing', 'reduce the line height', 'reduce the line spacing', 'reduce the text spacing', 'smaller line height', 'smaller line spacing', 'smaller text spacing', 'smaller the line height', 'smaller the line spacing', 'smaller the text spacing', 'make line height smaller', 'make line spacing smaller', 'make text spacing smaller', 'make the line height smaller', 'make the line spacing smaller', 'make the text spacing smaller'],
77630
- decrease_default_line_height: ['decrease default line height', 'decrease default line spacing', 'decrease default text spacing', 'decrease the default line height', 'decrease the default line spacing', 'decrease the default text spacing', 'reduce default line height', 'reduce default line spacing', 'reduce default text spacing', 'reduce the default line height', 'reduce the default line spacing', 'reduce the default text spacing', 'smaller default line height', 'smaller default line spacing', 'smaller default text spacing', 'smaller the default line height', 'smaller the default line spacing', 'smaller the default text spacing', 'make default line height smaller', 'make default line spacing smaller', 'make default text spacing smaller', 'make the default line height smaller', 'make the default line spacing smaller', 'make the default text spacing smaller'],
77631
- increase_font_size: ['increase font', 'increase size', 'increase font size', 'increase the font', 'increase the size', 'increase the font size', 'increase text', 'increase size', 'increase text size', 'increase the text', 'increase the text size', 'enlarge font', 'enlarge size', 'enlarge font size', 'enlarge the font', 'enlarge the size', 'enlarge the font size', 'enlarge text', 'enlarge size', 'enlarge text size', 'enlarge the text', 'enlarge the text size', 'text bigger', 'font bigger', 'size bigger'],
77632
- decrease_font_size: ['decrease font', 'decrease size', 'decrease font size', 'decrease the font', 'decrease the size', 'decrease the font size', 'decrease text', 'decrease size', 'decrease text size', 'decrease the text', 'decrease the text size', 'reduce font', 'reduce size', 'reduce font size', 'reduce the font', 'reduce the size', 'reduce the font size', 'reduce text', 'reduce size', 'reduce text size', 'reduce the text', 'reduce the text size', 'text smaller', 'font smaller', 'size smaller'],
77633
- increase_default_font_size: ['increase default font', 'increase default size', 'increase default font size', 'increase the default font', 'increase the default size', 'increase the default font size', 'increase default text', 'increase default size', 'increase default text size', 'increase the default text', 'increase the default text size', 'enlarge default font', 'enlarge default size', 'enlarge default font size', 'enlarge the default font', 'enlarge the default size', 'enlarge the default font size', 'enlarge default text', 'enlarge default text size', 'enlarge the default text', 'enlarge the default text size', 'default text bigger', 'default font bigger', 'default size bigger', 'increase default content', 'increase default content size', 'increase the default content', 'increase the default content size', 'enlarge default content', 'enlarge default content size', 'enlarge the default content', 'enlarge the default content size'],
77634
- decrease_default_font_size: ['decrease default font', 'decrease default size', 'decrease default font size', 'decrease the default font', 'decrease the default size', 'decrease the default font size', 'decrease default text', 'decrease default size', 'decrease default text size', 'decrease the default text', 'decrease the default text size', 'reduce default font', 'reduce default size', 'reduce default font size', 'reduce the default font', 'reduce the default size', 'reduce the default font size', 'reduce default text', 'reduce default text size', 'reduce the default text', 'reduce the default text size', 'default text smaller', 'default font smaller', 'default size smaller', 'decrease default content', 'decrease default content size', 'decrease the default content', 'decrease the default content size', 'reduce default content', 'reduce default content size', 'reduce the default content', 'reduce the default content size'],
77635
- clear_font_size: ['clear font size', 'remove font size', 'clear text size', 'remove text size', 'use default font size', 'ude the default font size'],
77636
- align_left: ['align left', 'align the text left', 'align text left', 'left aligned'],
77637
- align_center: ['align center', 'align the text center', 'align text center', 'center aligned'],
77638
- align_right: ['align right', 'align the text right', 'align text right', 'right aligned'],
77639
- align_full: ['align full', 'align justify', 'justify', 'justify text', 'justify the text', 'justify full'],
77640
- clear_alignment: ['clear alignment', 'remove alignment', 'clear the text alignment', 'remove the text alignment', 'clear text alignment', 'remove text alignment'],
77641
- make_content_centered: ['make the content center', 'make the content centered'],
77642
- move_content_left: ['move content left', 'move content to left', 'move the content left', 'move content to the left', 'move content to the left', 'place content on the left', 'move the content to the left', 'move the content to the left', 'place the content on the left'],
77643
- move_content_center: ['move content center', 'move content to center', 'move the content center', 'move content to the center', 'move content to the center', 'place content on the center', 'move the content to the center', 'move the content to the center', 'place the content on the center'],
77644
- move_content_right: ['move content right', 'move content to right', 'move the content right', 'move content to the right', 'move content to the right', 'place content on the right', 'move the content to the right', 'move the content to the right', 'place the content on the right'],
77645
- move_content_top: ['move content top', 'move content to top', 'move the content top', 'move content to the top', 'move content to the top', 'place content on the top', 'move the content to the top', 'move the content to the top', 'place the content on the top'],
77646
- move_content_middle: ['move content middle', 'move content to middle', 'move the content middle', 'move content to the middle', 'move content to the middle', 'place content on the middle', 'move the content to the middle', 'move the content to the middle', 'place the content on the middle'],
77647
- move_content_bottom: ['move content bottom', 'move content to bottom', 'move the content bottom', 'move content to the bottom', 'move content to the bottom', 'place content on the bottom', 'move the content to the bottom', 'move the content to the bottom', 'place the content on the bottom'],
77648
- increase_space: ['more space', 'increase space', 'increase the space', 'enlarge the space'],
77649
- decrease_space: ['less space', 'decrease space', 'decrease the space', 'reduce the space'],
77650
- move_row_up: ['move up', 'move row up'],
77651
- move_row_down: ['move down', 'move row down'],
77652
- duplicate_row: ['duplicate row', 'copy row'],
77653
- remove_row: ['remove row', 'delete row'],
77654
- move_col_left: ['move left', 'move column left'],
77655
- move_col_right: ['move right', 'move column right'],
77656
- duplicate_col: ['duplicate column', 'copy column'],
77657
- remove_col: ['remove column', 'delete column'],
77658
- move_column_up: ['move column up'],
77659
- move_column_down: ['move column down']
77660
- }
77661
- };
77662
- this.settings = Object.assign(this, defaults, settings);
77663
- }
77664
- check(command) {
77665
- const {
77666
- commandList
77667
- } = this.settings;
77668
- let maxSimilarity = 0;
77669
- let maxKey = '';
77670
- for (const [key, value] of Object.entries(commandList)) {
77671
- const similarity = this.calculate(command, value);
77672
- if (similarity > maxSimilarity) {
77673
- maxSimilarity = similarity;
77674
- maxKey = key;
77675
- }
77676
- }
77677
- const similarityThreshold = 0.5;
77678
- if (maxSimilarity >= similarityThreshold) {
77679
- return maxKey;
77680
- }
77681
- return false;
77682
- }
77683
- calculate(command, list) {
77684
- const normalizedCommand = command.toLowerCase();
77685
- let maxSimilarity = 0;
77686
- for (const cmd of list) {
77687
- const similarity = src.compareTwoStrings(normalizedCommand, cmd);
77688
- if (similarity > maxSimilarity) {
77689
- // console.log(list)
77690
- // console.log(similarity)
77691
- maxSimilarity = similarity;
77692
- }
77693
- }
77694
- return maxSimilarity;
77695
- }
77696
- }
77697
-
77698
77526
  class Command {
77699
77527
  constructor(builder) {
77700
77528
  this.builder = builder;
@@ -77702,13 +77530,6 @@ class Command {
77702
77530
  this.builderStuff = builderStuff;
77703
77531
  const controller = new AbortController(); // Abort
77704
77532
  let signal = controller.signal;
77705
- if (this.builder.commandList) {
77706
- this.cp = new Similarity({
77707
- commandList: this.builder.commandList
77708
- });
77709
- } else {
77710
- this.cp = new Similarity();
77711
- }
77712
77533
 
77713
77534
  // Dictation Panel
77714
77535
  this.dictation = this.builder.dictation;
@@ -77922,6 +77743,110 @@ class Command {
77922
77743
  }
77923
77744
  }
77924
77745
 
77746
+ var src = {
77747
+ compareTwoStrings:compareTwoStrings,
77748
+ findBestMatch:findBestMatch
77749
+ };
77750
+
77751
+ function compareTwoStrings(first, second) {
77752
+ first = first.replace(/\s+/g, '');
77753
+ second = second.replace(/\s+/g, '');
77754
+
77755
+ if (first === second) return 1; // identical or empty
77756
+ if (first.length < 2 || second.length < 2) return 0; // if either is a 0-letter or 1-letter string
77757
+
77758
+ let firstBigrams = new Map();
77759
+ for (let i = 0; i < first.length - 1; i++) {
77760
+ const bigram = first.substring(i, i + 2);
77761
+ const count = firstBigrams.has(bigram)
77762
+ ? firstBigrams.get(bigram) + 1
77763
+ : 1;
77764
+
77765
+ firstBigrams.set(bigram, count);
77766
+ }
77767
+ let intersectionSize = 0;
77768
+ for (let i = 0; i < second.length - 1; i++) {
77769
+ const bigram = second.substring(i, i + 2);
77770
+ const count = firstBigrams.has(bigram)
77771
+ ? firstBigrams.get(bigram)
77772
+ : 0;
77773
+
77774
+ if (count > 0) {
77775
+ firstBigrams.set(bigram, count - 1);
77776
+ intersectionSize++;
77777
+ }
77778
+ }
77779
+
77780
+ return (2.0 * intersectionSize) / (first.length + second.length - 2);
77781
+ }
77782
+
77783
+ function findBestMatch(mainString, targetStrings) {
77784
+ if (!areArgsValid(mainString, targetStrings)) throw new Error('Bad arguments: First argument should be a string, second should be an array of strings');
77785
+
77786
+ const ratings = [];
77787
+ let bestMatchIndex = 0;
77788
+
77789
+ for (let i = 0; i < targetStrings.length; i++) {
77790
+ const currentTargetString = targetStrings[i];
77791
+ const currentRating = compareTwoStrings(mainString, currentTargetString);
77792
+ ratings.push({target: currentTargetString, rating: currentRating});
77793
+ if (currentRating > ratings[bestMatchIndex].rating) {
77794
+ bestMatchIndex = i;
77795
+ }
77796
+ }
77797
+
77798
+
77799
+ const bestMatch = ratings[bestMatchIndex];
77800
+
77801
+ return { ratings: ratings, bestMatch: bestMatch, bestMatchIndex: bestMatchIndex };
77802
+ }
77803
+
77804
+ function areArgsValid(mainString, targetStrings) {
77805
+ if (typeof mainString !== 'string') return false;
77806
+ if (!Array.isArray(targetStrings)) return false;
77807
+ if (!targetStrings.length) return false;
77808
+ if (targetStrings.find( function (s) { return typeof s !== 'string'})) return false;
77809
+ return true;
77810
+ }
77811
+
77812
+ class Similarity {
77813
+ constructor(builder) {
77814
+ this.builder = builder;
77815
+ }
77816
+ check(command) {
77817
+ const {
77818
+ commandList
77819
+ } = this.builder.settings;
77820
+ let maxSimilarity = 0;
77821
+ let maxKey = '';
77822
+ for (const [key, value] of Object.entries(commandList)) {
77823
+ const similarity = this.calculate(command, value);
77824
+ if (similarity > maxSimilarity) {
77825
+ maxSimilarity = similarity;
77826
+ maxKey = key;
77827
+ }
77828
+ }
77829
+ const similarityThreshold = 0.5;
77830
+ if (maxSimilarity >= similarityThreshold) {
77831
+ return maxKey;
77832
+ }
77833
+ return false;
77834
+ }
77835
+ calculate(command, list) {
77836
+ const normalizedCommand = command.toLowerCase();
77837
+ let maxSimilarity = 0;
77838
+ for (const cmd of list) {
77839
+ const similarity = src.compareTwoStrings(normalizedCommand, cmd);
77840
+ if (similarity > maxSimilarity) {
77841
+ // console.log(list)
77842
+ // console.log(similarity)
77843
+ maxSimilarity = similarity;
77844
+ }
77845
+ }
77846
+ return maxSimilarity;
77847
+ }
77848
+ }
77849
+
77925
77850
  class ContentBuilder {
77926
77851
  constructor(opts = {}) {
77927
77852
  let defaults = {
@@ -78165,7 +78090,6 @@ class ContentBuilder {
78165
78090
  imageRenameOnEdit: true,
78166
78091
  disableAutoEmbedVideo: false,
78167
78092
  deleteConfirm: false,
78168
- isContentBox: false,
78169
78093
  sectionTemplate: `
78170
78094
  <div class="is-section is-box is-section-100 type-opensans">
78171
78095
  <div class="is-overlay"></div>
@@ -78536,7 +78460,102 @@ class ContentBuilder {
78536
78460
  useButtonPlugin: false,
78537
78461
  enableDragResize: true,
78538
78462
  simpleTextSettings: false,
78539
- enableColumnsPerLine: true
78463
+ enableColumnsPerLine: true,
78464
+ isContentBox: false,
78465
+ speechRecognitionLang: 'en-US',
78466
+ headlineList: ['We create simple and effective designs.', 'Ultimate Experiences With Story, Emotion, And Purpose.', 'Build Anything Beautifully', 'With Less Stuff and More Compassion', 'We\'re [CompanyName]. Full stack development with a spark of creativity.', 'Transforming your digital experience with [CompanyName]. Achieve your online goals with our customized solutions.', 'Revolutionizing web development with [CompanyName]. Unleash your digital potential with our high-performance solutions.', 'Creative and Inspiring'],
78467
+ shortCommandList: {
78468
+ undo: ['undo'],
78469
+ redo: ['undo'],
78470
+ increase: ['increase', 'bigger', 'larger', 'enlarge'],
78471
+ decrease: ['decrease', 'smaller'],
78472
+ bold: ['bold'],
78473
+ italic: ['italic'],
78474
+ underline: ['underline'],
78475
+ strikethrough: ['strikethrough'],
78476
+ superscript: ['superscript'],
78477
+ subscript: ['subscript'],
78478
+ uppercase: ['uppercase'],
78479
+ lowercase: ['lowercase'],
78480
+ capitalize: ['capitalize'],
78481
+ clean: ['clean']
78482
+ },
78483
+ commandList: {
78484
+ add_bg_color: ['add a background color', 'add background color'],
78485
+ add_bg_image: ['add a background image', 'add background image', 'add a background', 'add background'],
78486
+ change_bg_color: ['change the background color', 'change background color'],
78487
+ change_bg_image: ['change the background image', 'change background image', 'change the background', 'change background'],
78488
+ remove_bg_color: ['remove background color', 'remove the background color', 'clear background color', 'clear the background color'],
78489
+ remove_bg: ['remove background', 'remove background image', 'remove the background', 'remove the background image', 'clear background', 'clear background image', 'clear the background', 'clear the background image'],
78490
+ increase_content_width: ['increase content width', 'enlarge content width'],
78491
+ decrease_content_width: ['decrease content width', 'reduce content width'],
78492
+ clear_content_width: ['clear content width', 'remove content width', 'make content full', 'full width content'],
78493
+ make_content_light: ['make the content white', 'make the content light', 'make the text white', 'make the text light', 'make content white', 'make content light', 'make text white', 'make text light', 'change the content white', 'change the content light', 'change the text white', 'change the text light', 'change to white content', 'change to light content', 'change to white text', 'change to light text'],
78494
+ make_content_dark: ['make the content black', 'make the content dark', 'make the text black', 'make the text dark', 'make content black', 'make content dark', 'make text black', 'make text dark', 'change the content black', 'change the content dark', 'change the text black', 'change the text dark', 'change to black content', 'change to dark content', 'change to black text', 'change to dark text'],
78495
+ make_section_height_10: ['make section height 10'],
78496
+ make_section_height_15: ['make section height 15'],
78497
+ make_section_height_20: ['make section height 20'],
78498
+ make_section_height_25: ['make section height 25'],
78499
+ make_section_height_30: ['make section height 30'],
78500
+ make_section_height_40: ['make section height 40'],
78501
+ make_section_height_50: ['make section height 50'],
78502
+ make_section_height_60: ['make section height 60'],
78503
+ make_section_height_70: ['make section height 70'],
78504
+ make_section_height_75: ['make section height 75'],
78505
+ make_section_height_80: ['make section height 80'],
78506
+ make_section_height_85: ['make section height 85'],
78507
+ make_section_height_90: ['make section height 90'],
78508
+ make_section_height_100: ['make section height 100'],
78509
+ make_section_height_auto: ['make section height auto'],
78510
+ suggest_headline: ['suggest a headline', 'suggest headline', 'suggest a header', 'suggest header', 'suggest a title', 'suggest title', 'write a headline', 'write headline', 'write a header', 'write header', 'write a title', 'write title'],
78511
+ add_headline: ['add a headline', 'add headline', 'add a header', 'add header', 'add a title', 'add title'],
78512
+ add_paragraph: ['add a paragraph', 'add paragraph'],
78513
+ add_image: ['add an image', 'add image'],
78514
+ add_youtube: ['add a youtube', 'add youtube'],
78515
+ add_video: ['add a video', 'add video', 'add an HTML5 video', 'add HTML5 video', 'add an mp4 video', 'add mp4 video'],
78516
+ add_audio: ['add an audio', 'add audio', 'add a music', 'add music', 'add an mp3', 'add mp3'],
78517
+ add_map: ['add a map', 'add map', 'add a google map', 'add google map'],
78518
+ add_table: ['add a table', 'add table'],
78519
+ add_social: ['add a social', 'add social'],
78520
+ add_icon: ['add an icon', 'add icon'],
78521
+ add_button: ['add a button', 'add button'],
78522
+ add_2buttons: ['add 2 button', 'add 2 button', 'add 2 buttons', 'add 2 buttons'],
78523
+ add_space: ['add a space', 'add space'],
78524
+ position_before: ['above', 'before'],
78525
+ increase_line_height: ['increase line height', 'increase line spacing', 'increase text spacing', 'increase the line height', 'increase the line spacing', 'increase the text spacing', 'enlarge line height', 'enlarge line spacing', 'enlarge text spacing', 'enlarge the line height', 'enlarge the line spacing', 'enlarge the text spacing', 'bigger line height', 'bigger line spacing', 'bigger text spacing', 'bigger the line height', 'bigger the line spacing', 'bigger the text spacing', 'make line height bigger', 'make line spacing bigger', 'make text spacing bigger', 'make the line height bigger', 'make the line spacing bigger', 'make the text spacing bigger'],
78526
+ increase_default_line_height: ['increase default line height', 'increase default line spacing', 'increase default text spacing', 'increase the default line height', 'increase the default line spacing', 'increase the default text spacing', 'enlarge default line height', 'enlarge default line spacing', 'enlarge default text spacing', 'enlarge the default line height', 'enlarge the default line spacing', 'enlarge the default text spacing', 'bigger default line height', 'bigger default line spacing', 'bigger default text spacing', 'bigger the default line height', 'bigger the default line spacing', 'bigger the default text spacing', 'make default line height bigger', 'make default line spacing bigger', 'make default text spacing bigger', 'make the default line height bigger', 'make the default line spacing bigger', 'make the default text spacing bigger'],
78527
+ decrease_line_height: ['decrease line height', 'decrease line spacing', 'decrease text spacing', 'decrease the line height', 'decrease the line spacing', 'decrease the text spacing', 'reduce line height', 'reduce line spacing', 'reduce text spacing', 'reduce the line height', 'reduce the line spacing', 'reduce the text spacing', 'smaller line height', 'smaller line spacing', 'smaller text spacing', 'smaller the line height', 'smaller the line spacing', 'smaller the text spacing', 'make line height smaller', 'make line spacing smaller', 'make text spacing smaller', 'make the line height smaller', 'make the line spacing smaller', 'make the text spacing smaller'],
78528
+ decrease_default_line_height: ['decrease default line height', 'decrease default line spacing', 'decrease default text spacing', 'decrease the default line height', 'decrease the default line spacing', 'decrease the default text spacing', 'reduce default line height', 'reduce default line spacing', 'reduce default text spacing', 'reduce the default line height', 'reduce the default line spacing', 'reduce the default text spacing', 'smaller default line height', 'smaller default line spacing', 'smaller default text spacing', 'smaller the default line height', 'smaller the default line spacing', 'smaller the default text spacing', 'make default line height smaller', 'make default line spacing smaller', 'make default text spacing smaller', 'make the default line height smaller', 'make the default line spacing smaller', 'make the default text spacing smaller'],
78529
+ increase_font_size: ['increase font', 'increase size', 'increase font size', 'increase the font', 'increase the size', 'increase the font size', 'increase text', 'increase size', 'increase text size', 'increase the text', 'increase the text size', 'enlarge font', 'enlarge size', 'enlarge font size', 'enlarge the font', 'enlarge the size', 'enlarge the font size', 'enlarge text', 'enlarge size', 'enlarge text size', 'enlarge the text', 'enlarge the text size', 'text bigger', 'font bigger', 'size bigger'],
78530
+ decrease_font_size: ['decrease font', 'decrease size', 'decrease font size', 'decrease the font', 'decrease the size', 'decrease the font size', 'decrease text', 'decrease size', 'decrease text size', 'decrease the text', 'decrease the text size', 'reduce font', 'reduce size', 'reduce font size', 'reduce the font', 'reduce the size', 'reduce the font size', 'reduce text', 'reduce size', 'reduce text size', 'reduce the text', 'reduce the text size', 'text smaller', 'font smaller', 'size smaller'],
78531
+ increase_default_font_size: ['increase default font', 'increase default size', 'increase default font size', 'increase the default font', 'increase the default size', 'increase the default font size', 'increase default text', 'increase default size', 'increase default text size', 'increase the default text', 'increase the default text size', 'enlarge default font', 'enlarge default size', 'enlarge default font size', 'enlarge the default font', 'enlarge the default size', 'enlarge the default font size', 'enlarge default text', 'enlarge default text size', 'enlarge the default text', 'enlarge the default text size', 'default text bigger', 'default font bigger', 'default size bigger', 'increase default content', 'increase default content size', 'increase the default content', 'increase the default content size', 'enlarge default content', 'enlarge default content size', 'enlarge the default content', 'enlarge the default content size'],
78532
+ decrease_default_font_size: ['decrease default font', 'decrease default size', 'decrease default font size', 'decrease the default font', 'decrease the default size', 'decrease the default font size', 'decrease default text', 'decrease default size', 'decrease default text size', 'decrease the default text', 'decrease the default text size', 'reduce default font', 'reduce default size', 'reduce default font size', 'reduce the default font', 'reduce the default size', 'reduce the default font size', 'reduce default text', 'reduce default text size', 'reduce the default text', 'reduce the default text size', 'default text smaller', 'default font smaller', 'default size smaller', 'decrease default content', 'decrease default content size', 'decrease the default content', 'decrease the default content size', 'reduce default content', 'reduce default content size', 'reduce the default content', 'reduce the default content size'],
78533
+ clear_font_size: ['clear font size', 'remove font size', 'clear text size', 'remove text size', 'use default font size', 'ude the default font size'],
78534
+ align_left: ['align left', 'align the text left', 'align text left', 'left aligned'],
78535
+ align_center: ['align center', 'align the text center', 'align text center', 'center aligned'],
78536
+ align_right: ['align right', 'align the text right', 'align text right', 'right aligned'],
78537
+ align_full: ['align full', 'align justify', 'justify', 'justify text', 'justify the text', 'justify full'],
78538
+ clear_alignment: ['clear alignment', 'remove alignment', 'clear the text alignment', 'remove the text alignment', 'clear text alignment', 'remove text alignment'],
78539
+ make_content_centered: ['make the content center', 'make the content centered'],
78540
+ move_content_left: ['move content left', 'move content to left', 'move the content left', 'move content to the left', 'move content to the left', 'place content on the left', 'move the content to the left', 'move the content to the left', 'place the content on the left'],
78541
+ move_content_center: ['move content center', 'move content to center', 'move the content center', 'move content to the center', 'move content to the center', 'place content on the center', 'move the content to the center', 'move the content to the center', 'place the content on the center'],
78542
+ move_content_right: ['move content right', 'move content to right', 'move the content right', 'move content to the right', 'move content to the right', 'place content on the right', 'move the content to the right', 'move the content to the right', 'place the content on the right'],
78543
+ move_content_top: ['move content top', 'move content to top', 'move the content top', 'move content to the top', 'move content to the top', 'place content on the top', 'move the content to the top', 'move the content to the top', 'place the content on the top'],
78544
+ move_content_middle: ['move content middle', 'move content to middle', 'move the content middle', 'move content to the middle', 'move content to the middle', 'place content on the middle', 'move the content to the middle', 'move the content to the middle', 'place the content on the middle'],
78545
+ move_content_bottom: ['move content bottom', 'move content to bottom', 'move the content bottom', 'move content to the bottom', 'move content to the bottom', 'place content on the bottom', 'move the content to the bottom', 'move the content to the bottom', 'place the content on the bottom'],
78546
+ increase_space: ['more space', 'increase space', 'increase the space', 'enlarge the space'],
78547
+ decrease_space: ['less space', 'decrease space', 'decrease the space', 'reduce the space'],
78548
+ move_row_up: ['move up', 'move row up'],
78549
+ move_row_down: ['move down', 'move row down'],
78550
+ duplicate_row: ['duplicate row', 'copy row'],
78551
+ remove_row: ['remove row', 'delete row'],
78552
+ move_col_left: ['move left', 'move column left'],
78553
+ move_col_right: ['move right', 'move column right'],
78554
+ duplicate_col: ['duplicate column', 'copy column'],
78555
+ remove_col: ['remove column', 'delete column'],
78556
+ move_column_up: ['move column up'],
78557
+ move_column_down: ['move column down']
78558
+ }
78540
78559
  };
78541
78560
 
78542
78561
  // obj.preserveSelection = true; (can be set programmatically) to prevent click that clears selection on external custom modal.
@@ -78825,13 +78844,7 @@ class ContentBuilder {
78825
78844
  // Prompt Stuff
78826
78845
  this.dictation = new Dictation({}, this); // Dictation Panel
78827
78846
  this.lib = new Lib(this); // Libraries of common editing functions
78828
- if (this.commandList) {
78829
- this.similarity = new Similarity({
78830
- commandList: this.commandList
78831
- });
78832
- } else {
78833
- this.similarity = new Similarity();
78834
- }
78847
+ this.similarity = new Similarity(this);
78835
78848
  if (!this.opts.isContentBox) {
78836
78849
  this.command = new Command(this);
78837
78850
  }