@innovastudio/contentbuilder 1.4.56 → 1.4.57

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.56",
4
+ "version": "1.4.57",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -5444,6 +5444,9 @@ class Util {
5444
5444
  localStorage.removeItem('_htmlview');
5445
5445
  localStorage.removeItem('_pasteresult'); //DON'T HAVE PROP
5446
5446
  localStorage.removeItem('_livepreview');
5447
+ localStorage.removeItem('_dictation');
5448
+ localStorage.removeItem('_mic');
5449
+ localStorage.removeItem('_autosendcommand');
5447
5450
 
5448
5451
  //NOT USED
5449
5452
  localStorage.removeItem('_scrollableeditor');
@@ -76369,12 +76372,39 @@ class Lib {
76369
76372
 
76370
76373
  // Run functions based on short command
76371
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;
76392
+ const getMatchingCommand = command => {
76393
+ for (const key in shortCommandList) {
76394
+ if (shortCommandList[key].includes(command)) {
76395
+ return key;
76396
+ }
76397
+ }
76398
+ return false;
76399
+ };
76400
+ const intent = getMatchingCommand(command);
76401
+
76372
76402
  // Undo/Redo
76373
- if (command === 'undo') {
76403
+ if (intent === 'undo') {
76374
76404
  this.builder.undo();
76375
76405
  return false;
76376
76406
  }
76377
- if (command === 'redo') {
76407
+ if (intent === 'redo') {
76378
76408
  this.builder.redo();
76379
76409
  return false;
76380
76410
  }
@@ -76389,7 +76419,7 @@ class Lib {
76389
76419
  const tagName = element.tagName.toUpperCase();
76390
76420
  return textBlockTags.includes(tagName);
76391
76421
  };
76392
- if (command === 'bigger' || command === 'larger' || command === 'enlarge' || command === 'increase') {
76422
+ if (intent === 'increase') {
76393
76423
  if (elm.classList.contains('spacer')) {
76394
76424
  this.builder.saveForUndo();
76395
76425
  this.builder.lib.increaseElementHeight(elm);
@@ -76400,7 +76430,7 @@ class Lib {
76400
76430
  return false;
76401
76431
  }
76402
76432
  }
76403
- if (command === 'smaller' || command === 'decrease') {
76433
+ if (intent === 'decrease') {
76404
76434
  if (elm.classList.contains('spacer')) {
76405
76435
  this.builder.saveForUndo();
76406
76436
  this.builder.lib.decreaseElementHeight(elm);
@@ -76419,43 +76449,43 @@ class Lib {
76419
76449
  this.builder.formatTextNonToggle(s);
76420
76450
  this.builder.util.saveSelection();
76421
76451
  };
76422
- if (command === 'bold') {
76452
+ if (intent === 'bold') {
76423
76453
  formatText('bold');
76424
76454
  return false;
76425
76455
  }
76426
- if (command === 'italic') {
76456
+ if (intent === 'italic') {
76427
76457
  formatText('italic');
76428
76458
  return false;
76429
76459
  }
76430
- if (command === 'underline') {
76460
+ if (intent === 'underline') {
76431
76461
  formatText('underline');
76432
76462
  return false;
76433
76463
  }
76434
- if (command === 'strikethrough') {
76464
+ if (intent === 'strikethrough') {
76435
76465
  formatText('strikethrough');
76436
76466
  return false;
76437
76467
  }
76438
- if (command === 'superscript') {
76468
+ if (intent === 'superscript') {
76439
76469
  formatText('superscript');
76440
76470
  return false;
76441
76471
  }
76442
- if (command === 'subscript') {
76472
+ if (intent === 'subscript') {
76443
76473
  formatText('subscript');
76444
76474
  return false;
76445
76475
  }
76446
- if (command === 'uppercase') {
76476
+ if (intent === 'uppercase') {
76447
76477
  formatText('uppercase');
76448
76478
  return false;
76449
76479
  }
76450
- if (command === 'lowercase') {
76480
+ if (intent === 'lowercase') {
76451
76481
  formatText('lowercase');
76452
76482
  return false;
76453
76483
  }
76454
- if (command === 'capitalize') {
76484
+ if (intent === 'capitalize') {
76455
76485
  formatText('capitalize');
76456
76486
  return false;
76457
76487
  }
76458
- if (command === 'clean') {
76488
+ if (intent === 'clean') {
76459
76489
  formatText('clean');
76460
76490
  return false;
76461
76491
  }
@@ -77170,12 +77200,8 @@ const dom = new Dom();
77170
77200
  class Dictation {
77171
77201
  constructor(opts = {}, builder) {
77172
77202
  let defaults = {
77173
- send: command => {
77174
- console.log('send: ' + command);
77175
- },
77176
- abort: () => {
77177
- console.log('abort');
77178
- }
77203
+ send: () => {},
77204
+ abort: () => {}
77179
77205
  };
77180
77206
  this.opts = Object.assign(this, defaults, opts);
77181
77207
  this.builder = builder;
@@ -77298,15 +77324,35 @@ class Dictation {
77298
77324
  this.modalCommand = modalCommand;
77299
77325
  this.builder.commandText = '';
77300
77326
  this.builder.autoSendCommand = false;
77301
-
77302
- // this.modalCommand.classList.add('active');
77303
- // this.startDictation();
77304
-
77327
+ this.aborted = true;
77328
+ if (localStorage.getItem('_dictation') !== null) {
77329
+ if (localStorage.getItem('_dictation') === '1') {
77330
+ this.modalCommand.classList.add('active');
77331
+ if (localStorage.getItem('_mic') !== null) {
77332
+ if (localStorage.getItem('_mic') === '1') {
77333
+ this.startDictation();
77334
+ }
77335
+ } else {
77336
+ this.startDictation();
77337
+ }
77338
+ }
77339
+ }
77340
+ const btnDictation = builderStuff.querySelector('.cmd-enable-dictation');
77341
+ if (localStorage.getItem('_mic') !== null) {
77342
+ if (localStorage.getItem('_mic') === '0') {
77343
+ btnDictation.innerHTML = '<svg class="is-icon-flex" style="width:18px; height:18px;"><use xlink:href="#icon-microphone-off"></use></svg>';
77344
+ }
77345
+ }
77346
+ const chkAutoSend = builderStuff.querySelector('#chkAutoSendCommand');
77347
+ if (localStorage.getItem('_autosendcommand') !== null) {
77348
+ if (localStorage.getItem('_autosendcommand') === '1') {
77349
+ chkAutoSend.checked = true;
77350
+ }
77351
+ }
77305
77352
  this.modalCommand.addEventListener('focus', () => {
77306
77353
  util.saveSelection(); // must be called in case used by formatText()
77307
77354
  });
77308
77355
 
77309
- const btnDictation = builderStuff.querySelector('.cmd-enable-dictation');
77310
77356
  btnDictation.addEventListener('click', () => {
77311
77357
  if (this.aborted) {
77312
77358
  this.startDictation();
@@ -77316,12 +77362,13 @@ class Dictation {
77316
77362
  btnDictation.innerHTML = '<svg class="is-icon-flex" style="width:18px; height:18px;"><use xlink:href="#icon-microphone-off"></use></svg>';
77317
77363
  }
77318
77364
  });
77319
- const chkAutoSend = builderStuff.querySelector('#chkAutoSendCommand');
77320
77365
  chkAutoSend.addEventListener('change', () => {
77321
77366
  if (chkAutoSend.checked) {
77322
77367
  this.builder.autoSendCommand = true;
77368
+ localStorage.setItem('_autosendcommand', '1');
77323
77369
  } else {
77324
77370
  this.builder.autoSendCommand = false;
77371
+ localStorage.setItem('_autosendcommand', '0');
77325
77372
  }
77326
77373
  });
77327
77374
  const btnClear = builderStuff.querySelector('.cmd-clear-command');
@@ -77351,9 +77398,17 @@ class Dictation {
77351
77398
  this.opts.send(question);
77352
77399
  });
77353
77400
  const inpCommand = this.builderStuff.querySelector('.inp-command');
77401
+ inpCommand.addEventListener('keydown', e => {
77402
+ if (e.keyCode === 13 && !e.shiftKey) {
77403
+ e.preventDefault();
77404
+ return;
77405
+ }
77406
+ });
77354
77407
  inpCommand.addEventListener('keyup', e => {
77355
77408
  if (e.keyCode === 13 && !e.shiftKey) {
77356
77409
  btnSend.click();
77410
+ e.preventDefault();
77411
+ return;
77357
77412
  }
77358
77413
  this.builder.commandText = inpCommand.value;
77359
77414
  });
@@ -77361,15 +77416,18 @@ class Dictation {
77361
77416
  btnClose.addEventListener('click', () => {
77362
77417
  this.modalCommand.classList.remove('active');
77363
77418
  this.stopDictation();
77419
+ localStorage.setItem('_dictation', '0');
77364
77420
  });
77365
77421
  }
77366
77422
  openDictation() {
77367
77423
  this.modalCommand.classList.add('active');
77368
77424
  this.startDictation();
77425
+ localStorage.setItem('_dictation', '1');
77369
77426
  }
77370
77427
  stopDictation() {
77371
77428
  this.recognition.abort();
77372
77429
  this.aborted = true;
77430
+ localStorage.setItem('_mic', '0');
77373
77431
  }
77374
77432
  startDictation() {
77375
77433
  this.aborted = false;
@@ -77415,6 +77473,9 @@ class Dictation {
77415
77473
  this.recognition.onend = () => {
77416
77474
  if (!this.aborted) this.startDictation();
77417
77475
  };
77476
+ this.recognition.onstart = () => {
77477
+ localStorage.setItem('_mic', '1');
77478
+ };
77418
77479
  this.recognition.onerror = () => {
77419
77480
  // console.log(e.error);
77420
77481
  };
@@ -77713,7 +77774,7 @@ class Command {
77713
77774
 
77714
77775
  processPrompt(question) {
77715
77776
  const activeBox = this.builder.activeBox;
77716
- let intent = this.cp.check(question);
77777
+ let intent = this.builder.similarity.check(question);
77717
77778
  // console.log(intent);
77718
77779
 
77719
77780
  if (!intent) return question;
@@ -78764,6 +78825,13 @@ class ContentBuilder {
78764
78825
  // Prompt Stuff
78765
78826
  this.dictation = new Dictation({}, this); // Dictation Panel
78766
78827
  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
+ }
78767
78835
  if (!this.opts.isContentBox) {
78768
78836
  this.command = new Command(this);
78769
78837
  }