Jake Vanderwerf
2026-01-19 0113d2e9c9ff34a6ffb10707cc76d34b67a0c367
assets/js/concise/quill.js
@@ -1,5 +1,6 @@
window.jvbQuill = function(form) {
   const textareas = form.querySelectorAll('textarea[data-editor=true]');
   const instances = [];
   textareas.forEach(textarea => {
      let container, editor, toolbar;
@@ -12,7 +13,7 @@
         editor.className = 'editor';
         toolbar = document.createElement('div');
         toolbar.className = 'toolbar';
         const image = textarea.dataset.allowimage === true ? `<button type="button" class="ql-jvb_image">\n                    ${dashboardSettings.icons.image}\n                </button>` : '';
         const image = textarea.dataset.allowimage === true ? `<button type="button" class="ql-jvb_image">\n                    ${window.getIcon('image')}\n                </button>` : '';
         toolbar.id = `toolbar-${textarea.id}`;
         toolbar.innerHTML = `
                <span class="ql-formats">
@@ -93,10 +94,10 @@
                  h1: function() { this.quill.format('header', 1); },
                  h2: function() { this.quill.format('header', 2); },
                  h3: function() { this.quill.format('header', 3); },
                  jvb_bold: function() {this.quill.format('bold', true)},
                  jvb_italic: function() {this.quill.format('italic', true)},
                  jvb_strike: function() {this.quill.format('strike', true)},
                  jvb_underline: function() {this.quill.format('underline', true)},
                  'jvb_bold': function() {this.quill.format('bold', true)},
                  'jvb_italic': function() {this.quill.format('italic', true)},
                  'jvb_strike': function() {this.quill.format('strike', true)},
                  'jvb_underline': function() {this.quill.format('underline', true)},
                  'jvb_align': function(value) {
                     this.quill.format('align', value === this.quill.getFormat().list ? false : value);
                  },
@@ -107,8 +108,6 @@
                     if (value) {
                        const range = this.quill.getSelection();
                        if (range == null || range.length === 0) return;
                        // Get the existing link if any
                        const preview = this.quill.getText(range.index, range.length);
                        const existingLink = this.quill.getFormat(range).link;
                        // Create modal for link input
@@ -196,11 +195,6 @@
                           formData.append('post_id', objectID);
                        }
                        // Show loading state
                        if (window.jvbLoading) {
                           window.jvbLoading.showLoading('Uploading image...', 'Processing Upload');
                        }
                        try {
                           const response = await fetch(
                              `${jvbSettings.api}uploads/`,
@@ -229,9 +223,6 @@
                              'italic': true
                           }, true);
                        } finally {
                           if (window.jvbLoading) {
                              window.jvbLoading.hide();
                           }
                           input.remove();
                        }
                     };
@@ -250,6 +241,8 @@
         }
      });
      instances.push(quill);
      quill.on('selection-change', function(range) {
         const alignmentTools = toolbar.querySelector('.ql-align');
         if (alignmentTools) {
@@ -270,4 +263,5 @@
         textarea.dispatchEvent(new Event('change', { bubbles: true }));
      });
   });
   return instances;
};