diff --git a/js/app.js b/js/app.js
index d45bb760..ca1e78a3 100644
--- a/js/app.js
+++ b/js/app.js
@@ -42,9 +42,9 @@ tinymce.init({
plugins: 'link image lists table code codesample fullscreen autoresize',
});
-// Initialize TinyMCE AI
+// Initialize TinyMCE
tinymce.init({
- selector: '.tinymceai',
+ selector: '.tinymceAI',
browser_spellcheck: true,
contextmenu: false,
resize: true,
@@ -55,7 +55,140 @@ tinymce.init({
menubar: false,
statusbar: false,
toolbar: [
- 'styles bold italic forecolor bullist numlist alignleft aligncenter alignright alignjustify outdent indent table code fullscreen'
+ { name: 'styles', items: [ 'styles' ] },
+ { name: 'formatting', items: [ 'bold', 'italic', 'forecolor' ] },
+ { name: 'lists', items: [ 'bullist', 'numlist' ] },
+ { name: 'alignment', items: [ 'alignleft', 'aligncenter', 'alignright', 'alignjustify' ] },
+ { name: 'indentation', items: [ 'outdent', 'indent' ] },
+ { name: 'table', items: [ 'table' ] },
+ { name: 'extra', items: [ 'code', 'fullscreen' ] },
+ { name: 'ai', items: [ 'reword', 'undo', 'redo' ] }
+ ],
+ mobile: {
+ menubar: false,
+ plugins: 'autosave lists autolink',
+ toolbar: 'bold italic styles'
+ },
+ plugins: 'link image lists table code codesample fullscreen autoresize',
+ setup: function(editor) {
+ var rewordButtonApi;
+
+ editor.ui.registry.addButton('reword', {
+ icon: 'ai',
+ tooltip: 'Reword Text',
+ onAction: function() {
+ var content = editor.getContent();
+
+ // Disable the Reword button
+ rewordButtonApi.setEnabled(false);
+
+ // Show the progress indicator
+ editor.setProgressState(true);
+
+ fetch('post.php?ai_reword', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ text: content }),
+ })
+ .then(response => {
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ return response.json();
+ })
+ .then(data => {
+ editor.undoManager.transact(function() {
+ editor.setContent(data.rewordedText || 'Error: Could not reword the text.');
+ });
+
+ // Hide the progress indicator
+ editor.setProgressState(false);
+
+ // Re-enable the Reword button
+ rewordButtonApi.setEnabled(true);
+
+ // Optional: Show a success notification
+ editor.notificationManager.open({
+ text: 'Text reworded successfully!',
+ type: 'success',
+ timeout: 3000
+ });
+ })
+ .catch(error => {
+ console.error('Error:', error);
+
+ // Hide the progress indicator
+ editor.setProgressState(false);
+
+ // Re-enable the Reword button
+ rewordButtonApi.setEnabled(true);
+
+ // Show an error notification
+ editor.notificationManager.open({
+ text: 'An error occurred while rewording the text.',
+ type: 'error',
+ timeout: 5000
+ });
+ });
+ },
+ onSetup: function(buttonApi) {
+ rewordButtonApi = buttonApi;
+ return function() {
+ // Cleanup when the editor is destroyed (if necessary)
+ };
+ }
+ });
+ }
+});
+
+tinymce.init({
+ selector: '.tinymceTicket',
+ browser_spellcheck: true,
+ contextmenu: false,
+ resize: true,
+ min_height: 300,
+ max_height: 600,
+ promotion: false,
+ branding: false,
+ menubar: false,
+ statusbar: false,
+ toolbar: [
+ { name: 'styles', items: [ 'styles' ] },
+ { name: 'formatting', items: [ 'bold', 'italic', 'forecolor'] },
+ { name: 'link', items: [ 'link'] },
+ { name: 'lists', items: [ 'bullist', 'numlist' ] },
+ { name: 'indentation', items: [ 'outdent', 'indent' ] }
+ ],
+ mobile: {
+ menubar: false,
+ plugins: 'autosave lists autolink',
+ toolbar: 'bold italic styles'
+ },
+ plugins: 'link image lists table code fullscreen autoresize',
+
+});
+
+// Initialize TinyMCE AI
+tinymce.init({
+ selector: '.tinymceTicketAI',
+ browser_spellcheck: true,
+ contextmenu: false,
+ resize: true,
+ min_height: 300,
+ max_height: 600,
+ promotion: false,
+ branding: false,
+ menubar: false,
+ statusbar: false,
+ toolbar: [
+ { name: 'styles', items: [ 'styles' ] },
+ { name: 'formatting', items: [ 'bold', 'italic', 'forecolor'] },
+ { name: 'link', items: [ 'link'] },
+ { name: 'lists', items: [ 'bullist', 'numlist' ] },
+ { name: 'indentation', items: [ 'outdent', 'indent' ] },
+ { name: 'ai', items: [ 'reword', 'undo', 'redo' ] }
],
mobile: {
menubar: false,
@@ -63,42 +196,74 @@ tinymce.init({
},
plugins: 'link image lists table code codesample fullscreen autoresize',
setup: function(editor) {
- var previousContent = ''; // Initialize previousContent outside the event listener
- document.getElementById('rewordButton').addEventListener('click', function() {
- var content = editor.getContent();
- previousContent = content; // Store the current content before rewording
- var rewordButton = document.getElementById('rewordButton');
- var undoButton = document.getElementById('undoButton');
+ var rewordButtonApi;
- // Disable the Reword button and show loading state
- rewordButton.disabled = true;
- rewordButton.innerText = 'Processing...';
+ editor.ui.registry.addButton('reword', {
+ icon: 'ai',
+ tooltip: 'Reword Text',
+ onAction: function() {
+ var content = editor.getContent();
- fetch('post.php?ai_reword', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ text: content }),
- })
- .then(response => response.json())
- .then(data => {
- editor.setContent(data.rewordedText || 'Error: Could not reword the text.');
- rewordButton.disabled = false;
- rewordButton.innerText = 'Reword'; // Reset button text
- undoButton.style.display = 'inline'; // Show the Undo button
- })
- .catch(error => {
- console.error('Error:', error);
- rewordButton.disabled = false;
- rewordButton.innerText = 'Reword'; // Reset button text
- });
+ // Disable the Reword button
+ rewordButtonApi.setEnabled(false);
- // Setup the Undo button click event only once, not every time the reword button is clicked
- undoButton.onclick = function() {
- editor.setContent(previousContent);
- this.style.display = 'none'; // Hide the Undo button again
- };
+ // Show the progress indicator
+ editor.setProgressState(true);
+
+ fetch('post.php?ai_reword', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ text: content }),
+ })
+ .then(response => {
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ return response.json();
+ })
+ .then(data => {
+ editor.undoManager.transact(function() {
+ editor.setContent(data.rewordedText || 'Error: Could not reword the text.');
+ });
+
+ // Hide the progress indicator
+ editor.setProgressState(false);
+
+ // Re-enable the Reword button
+ rewordButtonApi.setEnabled(true);
+
+ // Optional: Show a success notification
+ editor.notificationManager.open({
+ text: 'Text reworded successfully!',
+ type: 'success',
+ timeout: 3000
+ });
+ })
+ .catch(error => {
+ console.error('Error:', error);
+
+ // Hide the progress indicator
+ editor.setProgressState(false);
+
+ // Re-enable the Reword button
+ rewordButtonApi.setEnabled(true);
+
+ // Show an error notification
+ editor.notificationManager.open({
+ text: 'An error occurred while rewording the text.',
+ type: 'error',
+ timeout: 5000
+ });
+ });
+ },
+ onSetup: function(buttonApi) {
+ rewordButtonApi = buttonApi;
+ return function() {
+ // Cleanup when the editor is destroyed (if necessary)
+ };
+ }
});
}
});
diff --git a/recurring_ticket_add_modal.php b/recurring_ticket_add_modal.php
index 5605b1be..8413d940 100644
--- a/recurring_ticket_add_modal.php
+++ b/recurring_ticket_add_modal.php
@@ -45,7 +45,7 @@
-
+
diff --git a/ticket.php b/ticket.php
index dffe0a99..90527662 100644
--- a/ticket.php
+++ b/ticket.php
@@ -624,7 +624,7 @@ if (isset($_GET['ticket_id'])) {
-
+