From 0113d2e9c9ff34a6ffb10707cc76d34b67a0c367 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 19 Jan 2026 16:29:41 +0000
Subject: [PATCH] =Refactored window.getTemplate into a full templating class window.jvbTemplates. Refactored CRUD.js, UploadManager.js, FormController.js, PopulateForm.js with that in mind
---
assets/js/concise/quill.js | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/assets/js/concise/quill.js b/assets/js/concise/quill.js
index 847f8eb..cab9cf5 100644
--- a/assets/js/concise/quill.js
+++ b/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,18 +195,13 @@
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/`,
{
method: 'POST',
headers: {
- 'X-WP-Nonce': jvbSettings.nonce
+ 'X-WP-Nonce': window.auth.getNonce()
},
body: formData
}
@@ -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;
};
--
Gitblit v1.10.0