+
\ No newline at end of file
diff --git a/client_document_edit_modal.php b/client_document_edit_modal.php
index 3ba73644..0a313042 100644
--- a/client_document_edit_modal.php
+++ b/client_document_edit_modal.php
@@ -18,9 +18,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/js/ai_reword.js b/js/ai_reword.js
index 43ab587e..515869a8 100644
--- a/js/ai_reword.js
+++ b/js/ai_reword.js
@@ -33,4 +33,4 @@ document.getElementById('rewordButton').addEventListener('click', function() {
rewordButton.disabled = false;
rewordButton.innerText = 'Reword'; // Reset button text
});
-});
+});
\ No newline at end of file
diff --git a/js/app.js b/js/app.js
index 1fdea279..23f49db6 100644
--- a/js/app.js
+++ b/js/app.js
@@ -42,6 +42,67 @@ tinymce.init({
plugins: 'link image lists table code codesample fullscreen autoresize',
});
+// Initialize TinyMCE AI
+tinymce.init({
+ selector: '.tinymceai',
+ browser_spellcheck: true,
+ contextmenu: false,
+ resize: true,
+ min_height: 300,
+ max_height: 600,
+ promotion: false,
+ branding: false,
+ menubar: false,
+ statusbar: false,
+ toolbar: [
+ 'styles bold italic forecolor bullist numlist alignleft aligncenter alignright alignjustify outdent indent table code fullscreen'
+ ],
+ mobile: {
+ menubar: false,
+ toolbar: 'bold italic styles'
+ },
+ 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');
+
+ // Disable the Reword button and show loading state
+ rewordButton.disabled = true;
+ rewordButton.innerText = 'Processing...';
+
+ 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
+ });
+
+ // 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
+ };
+ });
+ }
+});
+
// Initialize TinyMCE
tinymce.init({
selector: '.tinymcePreview',
diff --git a/ticket.php b/ticket.php
index bf2965e9..da185ed0 100644
--- a/ticket.php
+++ b/ticket.php
@@ -303,7 +303,21 @@ if (isset($_GET['ticket_id'])) {