@innovastudio/contentbuilder 1.5.83 → 1.5.85

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.5.83",
4
+ "version": "1.5.85",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "types": "index.d.ts",
@@ -1208,7 +1208,7 @@ const renderQuickAdd = builder => {
1208
1208
  const util = builder.util;
1209
1209
  const builderStuff = builder.builderStuff;
1210
1210
  const dom = builder.dom;
1211
- let quickAddButtons = ['paragraph', 'headline', 'image', 'list', 'heading1', 'heading2', 'heading3', 'heading4', 'quote', 'preformatted', 'button', 'twobutton', 'map', 'youtube', 'video', 'icon', 'svg', 'table', 'social', 'code', 'spacer']; // default
1211
+ let quickAddButtons = ['paragraph', 'headline', 'image', 'list', 'heading1', 'heading2', 'heading3', 'heading4', 'quote', 'preformatted', 'button', 'twobutton', 'map', 'youtube', 'video', 'icon', 'svg', 'form', 'table', 'social', 'code', 'spacer']; // default 'svg',
1212
1212
 
1213
1213
  if (builder.quickAddButtons) {
1214
1214
  quickAddButtons = builder.quickAddButtons;
@@ -1236,6 +1236,9 @@ const renderQuickAdd = builder => {
1236
1236
  social: `<button title="${util.out('Social Links')}" class="add-social"><span style="display:block;margin:0 0 8px;"><svg class="is-icon-flex" style="width:13px;height:13px;"><use xlink:href="#ion-social-twitter"></use></svg></use></svg></svg></span>${util.out('Social Links')}</button>`,
1237
1237
  code: `<button title="${util.out('HTML/JS')}" class="add-code"><span style="display:block;margin:0 0 8px;"><svg class="is-icon-flex" style="width:13px;height:13px;"><use xlink:href="#icon-code"></use></svg></use></svg></svg></span>${util.out('HTML/JS')}</button>`,
1238
1238
  spacer: `<button title="${util.out('Spacer')}" class="add-spacer"><span style="display:block;margin:0 0 8px;"><span style="display:inline-block;background:#eee;width:30px;height:5px;"></span></span>${util.out('Spacer')}</button>`,
1239
+ form: `<button title="${util.out('Form')}" class="add-form"><span style="display:block;margin:0 0 8px;">
1240
+ <svg xmlns="http://www.w3.org/2000/svg" style="width:18px;height:18px;fill:none" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-forms"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3" /><path d="M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3" /><path d="M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7" /><path d="M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1" /><path d="M17 12h.01" /><path d="M13 12h.01" /></svg>
1241
+ </span>${util.out('Form')}</button>`,
1239
1242
  line: `<button title="${util.out('Line')}" class="add-line"><span style="display:block;margin:0 0 8px;"><span style="display:inline-block;background:#ddd;width:30px;height:2px;"></span></span>${util.out('Line')}</button>`
1240
1243
  };
1241
1244
 
@@ -1243,6 +1246,12 @@ const renderQuickAdd = builder => {
1243
1246
  const filteredButtons = quickAddButtons.filter(item => {
1244
1247
  if (builder.opts.emailMode && item === 'button') return false;
1245
1248
  if (builder.opts.emailMode && item === 'twobutton') return false;
1249
+ if (!builder.quickAddButtons) {
1250
+ // if not custom specified by user
1251
+ if (!builder.win.FormViewer && item === 'form') return false; // hide 'form' if FormViewer object not found
1252
+ if (builder.win.FormViewer && item === 'svg') return false; // hide 'svg' if 'form' enabled.
1253
+ }
1254
+
1246
1255
  return true;
1247
1256
  });
1248
1257
  let buttonsHtml = filteredButtons.map(item => buttonTemplates[item] || '').join('');
@@ -1440,6 +1449,284 @@ const renderQuickAdd = builder => {
1440
1449
  }
1441
1450
  builder.addSnippet(html, bSnippet, noedit);
1442
1451
  });
1452
+ elm = quickadd.querySelector('.add-form');
1453
+ dom.addEventListener(elm, 'click', () => {
1454
+ // const mode = quickadd.getAttribute('data-mode');
1455
+
1456
+ let html = `
1457
+ <div class="row">
1458
+ <div class="column" data-noedit
1459
+ data-dialog-width="1220px"
1460
+ data-dialog-height="85vh"
1461
+ data-module="form-builder"
1462
+ data-module-desc="Form Builder"
1463
+ data-html="
1464
+
1465
+ ${encodeURIComponent(`
1466
+
1467
+ <div id="_style_{id}" style="display:none">
1468
+ .animate-spin {
1469
+ animation: spin 1s linear infinite;
1470
+ }
1471
+ @keyframes spin {
1472
+ from {
1473
+ transform: rotate(0deg);
1474
+ }
1475
+ to {
1476
+ transform: rotate(360deg);
1477
+ }
1478
+ }
1479
+ </div>
1480
+ <form id="form_{id}" method="POST" action="/formsubmission" style="padding: 25px 0 20px">
1481
+ <div id="{id}"></div>
1482
+
1483
+ <button id="btn_send_{id}" type="submit" class="transition-all inline-flex items-center whitespace-nowrap cursor-pointer no-underline border-2 border-solid mr-2 mt-6 mb-1 py-2 size-18 px-8 text-black leading-relaxed rounded border-transparent hover:border-transparent font-normal tracking-wide" style="background-color: rgb(240, 240, 240);">Submit</button>
1484
+
1485
+ <div id="status_{id}"></div>
1486
+ </form>
1487
+
1488
+ <script>
1489
+ var css = document.querySelector('#_style_{id}').innerHTML;
1490
+ var head = document.getElementsByTagName('head')[0];
1491
+ var s = document.createElement('style');
1492
+ s.appendChild(document.createTextNode(css));
1493
+ head.appendChild(s);
1494
+
1495
+ var docReady = function(fn) {
1496
+ var stateCheck = setInterval(function() {
1497
+ if (document.readyState !== "complete") return;
1498
+ clearInterval(stateCheck);
1499
+ fn();
1500
+ }, 1);
1501
+ };
1502
+
1503
+ docReady(function() {
1504
+
1505
+ var elm = document.getElementById('{id}');
1506
+ var viewer = new FormViewer(elm, {
1507
+ onChange: (json) => {
1508
+ // console.log(json);
1509
+ },
1510
+ // formHeader: false,
1511
+ });
1512
+
1513
+ let json = {
1514
+ "title": "Register for the Tech Conference",
1515
+ "description": "Join us for an insightful and engaging experience.",
1516
+ "elements": [
1517
+ {
1518
+ "title": "Full Name:",
1519
+ "name": "full_name",
1520
+ "type": "short-text",
1521
+ "isRequired": true,
1522
+ "placeholder": "Enter your full name"
1523
+ },
1524
+ {
1525
+ "title": "Ticket Type:",
1526
+ "name": "ticket_type",
1527
+ "type": "select",
1528
+ "isRequired": true,
1529
+ "choices": [
1530
+ "Standard Admission",
1531
+ "VIP Admission",
1532
+ "Student Discount"
1533
+ ]
1534
+ },
1535
+ {
1536
+ "title": "Select the sessions you’re interested in:",
1537
+ "name": "select_the_sessions_youre_interested_in",
1538
+ "type": "multi-select",
1539
+ "choices": [
1540
+ "Keynote Speech",
1541
+ "AI Workshop",
1542
+ "Networking Session",
1543
+ "Panel Discussion"
1544
+ ]
1545
+ },
1546
+ {
1547
+ "title": "Are you attending the networking dinner?",
1548
+ "name": "are_you_attending_the_networking_dinner",
1549
+ "type": "switch"
1550
+ },
1551
+ {
1552
+ "title": "Email:",
1553
+ "name": "email",
1554
+ "type": "email",
1555
+ "isRequired": true,
1556
+ "placeholder": "Enter your email"
1557
+ }
1558
+ ]
1559
+ };
1560
+
1561
+ viewer.view(json); // Render form
1562
+
1563
+ const form = document.querySelector('#form_{id}');
1564
+
1565
+ var btnSend = document.querySelector('#btn_send_{id}');
1566
+
1567
+ var statusInfo = document.querySelector('#status_{id}');
1568
+
1569
+ /*
1570
+ form.addEventListener('submit', async (event) => {
1571
+
1572
+ event.preventDefault();
1573
+
1574
+ const form = event.target;
1575
+ const formData = new FormData(form);
1576
+
1577
+ fetch('/formsubmission', {
1578
+ method: 'POST',
1579
+ body: formData,
1580
+ })
1581
+ .then(response=>response.json())
1582
+ .then(response=>{
1583
+ console.log(response);
1584
+ });
1585
+ });
1586
+ */
1587
+
1588
+ async function handleSubmit(event) {
1589
+ event.preventDefault();
1590
+
1591
+ btnSend.innerHTML = '<span class="loading-icon"><svg class="animate-spin" style="margin-right:7px;width:20px;height:20px" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg></span>Submit';
1592
+
1593
+ var data = new FormData(event.target);
1594
+ fetch(event.target.action, {
1595
+ method: form.method,
1596
+ body: data,
1597
+ headers: {
1598
+ 'Accept': 'application/json'
1599
+ }
1600
+ }).then(response => {
1601
+ if (response.ok) {
1602
+ statusInfo.innerHTML = '<div class="text-center pt-4"><i class="bi bi-send-check size-64"></i>' +
1603
+ '</div><div class="leading-11 text-center size-38 pb-4">Thanks for your submission!</div>';
1604
+ form.reset();
1605
+ } else {
1606
+ response.json().then(data => {
1607
+ if (Object.hasOwn(data, 'errors')) {
1608
+ statusInfo.innerHTML = data['errors'].map(error => error['message']).join(', ');
1609
+ } else {
1610
+ statusInfo.innerHTML = '<div class="leading-11 text-center size-38 pt-4 pb-4">Oops! There was a problem submitting your form.</div>';
1611
+ }
1612
+ });
1613
+ }
1614
+
1615
+ btnSend.innerHTML = 'Submit';
1616
+ }).catch(error => {
1617
+ statusInfo.innerHTML = '<div class="leading-11 text-center size-38 pt-4 pb-4">Oops! There was a problem submitting your form.</div>';
1618
+
1619
+ btnSend.innerHTML = 'Submit';
1620
+ });
1621
+ }
1622
+ form.addEventListener('submit', handleSubmit);
1623
+
1624
+ });
1625
+ </script>
1626
+
1627
+ `)}
1628
+
1629
+ "
1630
+
1631
+ data-settings="
1632
+
1633
+ ${encodeURIComponent(`
1634
+ {
1635
+ "json": {
1636
+ "title": "Register for the Tech Conference",
1637
+ "description": "Join us for an insightful and engaging experience.",
1638
+ "elements": [
1639
+ {
1640
+ "title": "Full Name:",
1641
+ "name": "full_name",
1642
+ "type": "short-text",
1643
+ "isRequired": true,
1644
+ "placeholder": "Enter your full name"
1645
+ },
1646
+ {
1647
+ "title": "Ticket Type:",
1648
+ "name": "ticket_type",
1649
+ "type": "select",
1650
+ "isRequired": true,
1651
+ "choices": [
1652
+ "Standard Admission",
1653
+ "VIP Admission",
1654
+ "Student Discount"
1655
+ ]
1656
+ },
1657
+ {
1658
+ "title": "Select the sessions you’re interested in:",
1659
+ "name": "select_the_sessions_youre_interested_in",
1660
+ "type": "multi-select",
1661
+ "choices": [
1662
+ "Keynote Speech",
1663
+ "AI Workshop",
1664
+ "Networking Session",
1665
+ "Panel Discussion"
1666
+ ]
1667
+ },
1668
+ {
1669
+ "title": "Are you attending the networking dinner?",
1670
+ "name": "are_you_attending_the_networking_dinner",
1671
+ "type": "switch"
1672
+ },
1673
+ {
1674
+ "title": "Email:",
1675
+ "name": "email",
1676
+ "type": "email",
1677
+ "isRequired": true,
1678
+ "placeholder": "Enter your email"
1679
+ }
1680
+ ]
1681
+ },
1682
+ "thankYouMessage": "Thanks for your submission!",
1683
+ "errorMessage": "Oops! There was a problem submitting your form.",
1684
+ "buttonText": "Submit",
1685
+ "hideHeader": false,
1686
+ "formAction": "/formsubmission"
1687
+ }
1688
+ `)}
1689
+
1690
+ ">
1691
+
1692
+ </div>
1693
+ </div>
1694
+ `;
1695
+ let noedit = true;
1696
+ let bSnippet = false;
1697
+ let snippetPathReplace = builder.opts.snippetPathReplace;
1698
+
1699
+ // Convert snippet into your defined 12 columns grid
1700
+ let rowClass = builder.opts.row; //row
1701
+ let colClass = builder.opts.cols; //['col s1', 'col s2', 'col s3', 'col s4', 'col s5', 'col s6', 'col s7', 'col s8', 'col s9', 'col s10', 'col s11', 'col s12']
1702
+ if (rowClass !== '' && colClass.length === 12) {
1703
+ // html = html.replace(new RegExp('row clearfix', 'g'), rowClass);
1704
+ html = html.replace(new RegExp('row clearfix', 'g'), 'row'); // backward
1705
+ html = html.replace(new RegExp('"row', 'g'), '"' + rowClass);
1706
+ html = html.replace(new RegExp('column full', 'g'), colClass[11]);
1707
+ html = html.replace(new RegExp('column half', 'g'), colClass[5]);
1708
+ html = html.replace(new RegExp('column third', 'g'), colClass[3]);
1709
+ html = html.replace(new RegExp('column fourth', 'g'), colClass[2]);
1710
+ html = html.replace(new RegExp('column fifth', 'g'), colClass[1]);
1711
+ html = html.replace(new RegExp('column sixth', 'g'), colClass[1]);
1712
+ html = html.replace(new RegExp('column two-third', 'g'), colClass[7]);
1713
+ html = html.replace(new RegExp('column two-fourth', 'g'), colClass[8]);
1714
+ html = html.replace(new RegExp('column two-fifth', 'g'), colClass[9]);
1715
+ html = html.replace(new RegExp('column two-sixth', 'g'), colClass[9]);
1716
+ }
1717
+ html = html.replace(/{id}/g, util.makeId()); // Replace {id} with auto generated id (for custom code snippet)
1718
+
1719
+ if (builder.opts.onAdd) {
1720
+ html = builder.opts.onAdd(html);
1721
+ }
1722
+ if (snippetPathReplace.length > 0) {
1723
+ if (snippetPathReplace[0] !== '') {
1724
+ let regex = new RegExp(snippetPathReplace[0], 'g');
1725
+ html = html.replace(regex, snippetPathReplace[1]);
1726
+ }
1727
+ }
1728
+ builder.addSnippet(html, bSnippet, noedit);
1729
+ });
1443
1730
  elm = quickadd.querySelector('.add-table');
1444
1731
  dom.addEventListener(elm, 'click', () => {
1445
1732
  const mode = quickadd.getAttribute('data-mode');
@@ -4745,6 +5032,8 @@ class Util {
4745
5032
  const dom = this.dom;
4746
5033
  pop.style.display = '';
4747
5034
  dom.removeClass(pop, 'active');
5035
+ this.builder.doc.activeElement.blur();
5036
+ // this.builder.doc.body.focus();
4748
5037
  pop.setAttribute('aria-hidden', true);
4749
5038
 
4750
5039
  // pop.removeEventListener('keydown', this.handlePopKeyDown);
@@ -4939,6 +5228,8 @@ class Util {
4939
5228
  }
4940
5229
 
4941
5230
  hideModal(modal) {
5231
+ this.builder.doc.activeElement.blur();
5232
+ // this.builder.doc.body.focus();
4942
5233
  modal.setAttribute('aria-hidden', true);
4943
5234
 
4944
5235
  /* Disable Modal Animation */
@@ -17650,14 +17941,14 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17650
17941
  if (builder.opts.snippetModal) {
17651
17942
  builder.opts.snippetList = '#divSnippetWindow';
17652
17943
  let html = `
17653
- <div class="is-modal active is-modal-content snippetwindow scroll-darker" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
17944
+ <div class="is-modal active is-modal-content snippetwindow scroll-darker" tabindex="-1" role="dialog" aria-modal="true">
17654
17945
  <div class="is-modal-bar is-draggable">
17655
17946
  <button class="is-modal-close" tabindex="-1" title="${util.out('Close')}">&#10005;</button>
17656
17947
  </div>
17657
17948
  <div id="divSnippetWindow">
17658
17949
  </div>
17659
17950
  </div>
17660
- `;
17951
+ `; // aria-hidden="true"
17661
17952
  let snippetModal = builder.builderStuff.querySelector('.is-modal.snippetwindow');
17662
17953
  if (!snippetModal) {
17663
17954
  dom.appendHtml(builder.builderStuff, html);
@@ -17666,6 +17957,9 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17666
17957
  builder.draggable('.snippetwindow .is-draggable');
17667
17958
  const btnClose = snippetModal.querySelector('.is-modal-close');
17668
17959
  btnClose.addEventListener('click', () => {
17960
+ builder.doc.activeElement.blur();
17961
+ // builder.doc.body.focus();
17962
+ snippetModal.setAttribute('aria-hidden', true);
17669
17963
  snippetModal.classList.remove('active');
17670
17964
  });
17671
17965
  if (builder.snippetModalLeft) {
@@ -49575,7 +49869,7 @@ class Module {
49575
49869
  <input id="hidContentModuleCode" type="hidden" />
49576
49870
  <input id="hidContentModuleSettings" type="hidden" />
49577
49871
 
49578
- <div class="is-modal custommodule" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
49872
+ <div class="is-modal custommodule" tabindex="-1" role="dialog" aria-modal="true">
49579
49873
  <div class="is-modal-content">
49580
49874
  <div class="is-modal-bar is-draggable">
49581
49875
  ${util.out('Module Settings')}
@@ -49588,7 +49882,8 @@ class Module {
49588
49882
  </div>
49589
49883
  </div>
49590
49884
  </div>
49591
- `;
49885
+ `; // aria-hidden="true"
49886
+
49592
49887
  dom.appendHtml(builderStuff, html);
49593
49888
  moduleModal = builderStuff.querySelector('.is-modal.custommodule');
49594
49889
  this.moduleModal = moduleModal;
@@ -91596,7 +91891,7 @@ class PageSize {
91596
91891
  position: relative;
91597
91892
  flex:none;
91598
91893
  background: #fff;
91599
- /* overflow: hidden;*/
91894
+ overflow: hidden;
91600
91895
  box-shadow: none;
91601
91896
  }
91602
91897
  ${css}
@@ -95303,8 +95598,12 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
95303
95598
  toggleSnippetModal() {
95304
95599
  const snippetModal = this.builderStuff.querySelector('.is-modal.snippetwindow');
95305
95600
  if (snippetModal.classList.contains('active')) {
95601
+ snippetModal.setAttribute('aria-hidden', true);
95306
95602
  snippetModal.classList.remove('active');
95307
95603
  } else {
95604
+ this.doc.activeElement.blur();
95605
+ // builder.doc.body.focus();
95606
+ snippetModal.setAttribute('aria-hidden', false);
95308
95607
  snippetModal.classList.add('active');
95309
95608
  }
95310
95609
  }