[Rt-commit] rt branch, 4.6/update-ckeditor, updated. rt-4.4.4-429-gfe2e4367c

? sunnavy sunnavy at bestpractical.com
Thu Oct 17 18:27:15 EDT 2019


The branch, 4.6/update-ckeditor has been updated
       via  fe2e4367cb5ea51fd98a3e3e5136a19470422cfc (commit)
       via  58893eaeb5383bc7adb07036cdd06e6360643925 (commit)
       via  9fcb586953b4b35b087bc18eddaa73799cc587aa (commit)
       via  30ad482fc0984f0da2dd2c0595a9646c93af973f (commit)
      from  3cd775e3fa73bc30455bc1bfd96e2e4842aa52db (commit)

Summary of changes:
 share/html/Elements/AttachmentWarning |  2 +-
 share/html/Elements/MessageBox        |  2 +-
 share/html/Ticket/Update.html         | 11 --------
 share/static/js/util.js               | 51 ++++++-----------------------------
 4 files changed, 10 insertions(+), 56 deletions(-)

- Log -----------------------------------------------------------------
commit 30ad482fc0984f0da2dd2c0595a9646c93af973f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 18 05:21:18 2019 +0800

    Stop updating recipients for message content change
    
    It's really rare that different message content could cause different
    recipients.

diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 71fef3bc9..b3084bce1 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -219,10 +219,6 @@
 <script type="text/javascript">
 jQuery( function() {
    var updateScrips = function() {
-       if ( RichTextEditor ) {
-           // Should confirm we still need this call with CKEditor 5
-           RichTextEditor.updateSourceElement();
-       }
        var syncCheckboxes = function(ev) {
            var target = ev.target;
            jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == target.value; } ).prop("checked",jQuery(target).prop('checked'));
@@ -263,13 +259,6 @@ jQuery( function() {
    };
    updateScrips();
 
-   if ( RichTextEditor ) {
-       RichTextEditor.on('blur', updateScrips );
-   }
-   else {
-       jQuery('#UpdateContent').on('blur', updateScrips );
-   }
-
    jQuery("#ticket-update-metadata :input, #UpdateCc, #UpdateBcc").change( updateScrips );
 
 });

commit 9fcb586953b4b35b087bc18eddaa73799cc587aa
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 18 05:42:36 2019 +0800

    Switch to "div" to vertically align the attachment warning text
    
    "p" has "margin-bottom: 1rem", so the text wasn't vertically centered

diff --git a/share/html/Elements/AttachmentWarning b/share/html/Elements/AttachmentWarning
index 885402460..7cc7839f2 100644
--- a/share/html/Elements/AttachmentWarning
+++ b/share/html/Elements/AttachmentWarning
@@ -51,7 +51,7 @@
         <% $Signature %>
     </div>
 
-    <p><&|/l&>It looks like you may have forgotten to add an attachment.</&></p>
+    <div><&|/l&>It looks like you may have forgotten to add an attachment.</&></div>
 </div>
 <%ARGS>
 $QuotedMessage => ''

commit 58893eaeb5383bc7adb07036cdd06e6360643925
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 18 05:45:39 2019 +0800

    Migrate height set for CKEditor 5

diff --git a/share/static/js/util.js b/share/static/js/util.js
index 4c26dfc64..675916ec3 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -311,12 +311,10 @@ function ReplaceAllTextareas() {
             // Set the type
             type.val("text/html");
 
-//            CKEDITOR.replace(textArea.name,{ width: '100%', height: RT.Config.MessageBoxRichTextHeight });
-
         ClassicEditor
             .create( document.querySelector( '.richtext' ) )
             .then(editor => {
-                RichTextEditor = editor; // Save the editor so we can get it later
+                jQuery(editor.ui.view.editable.element).css('height', RT.Config.MessageBoxRichTextHeight);
             })
             .catch( error => {
                 console.error( error );

commit fe2e4367cb5ea51fd98a3e3e5136a19470422cfc
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 18 05:55:55 2019 +0800

    Make attachment warning work for CKEditor 5
    
    The new version has 'change:data' event, which simplifes code a lot.
    
    As we are gonna reuse MessageBox in more places like articles, I added
    suppress-attachment-warning class to not trigger attachment warning
    easily for future code.

diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 42b1b1d13..873ff8299 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<textarea autocomplete="off" class="form-control messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>" placeholder="<% $Placeholder %>">
+<textarea autocomplete="off" class="form-control messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $SuppressAttachmentWarning ? 'suppress-attachment-warning' : '' %> <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>" placeholder="<% $Placeholder %>">
 % $m->comp('/Articles/Elements/IncludeArticle', %ARGS, IncludeArticleId => $article_id, QueueObj => $QueueObj) if $IncludeArticle;
 % $m->callback( %ARGS, SignatureRef => \$signature, DefaultRef => \$Default, MessageRef => \$message );
 % if (RT->Config->Get("SignatureAboveQuote", $session{'CurrentUser'})) {
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 675916ec3..856744211 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -293,8 +293,6 @@ function textToHTML(value) {
                 .replace(/\n/g,   "\n<br />");
 };
 
-// Save the CKEditor instance for use after initializing
-var RichTextEditor;
 
 function ReplaceAllTextareas() {
     // replace all content and signature message boxes
@@ -315,6 +313,7 @@ function ReplaceAllTextareas() {
             .create( document.querySelector( '.richtext' ) )
             .then(editor => {
                 jQuery(editor.ui.view.editable.element).css('height', RT.Config.MessageBoxRichTextHeight);
+                AddAttachmentWarning(editor);
             })
             .catch( error => {
                 console.error( error );
@@ -323,23 +322,18 @@ function ReplaceAllTextareas() {
     }
 };
 
-/*
 
-function AddAttachmentWarning() {
+function AddAttachmentWarning(richTextEditor) {
     var plainMessageBox  = jQuery('.messagebox');
+    if (plainMessageBox.hasClass('suppress-attachment-warning')) return;
+
     var warningMessage   = jQuery('.messagebox-attachment-warning');
     var ignoreMessage    = warningMessage.find('.ignore');
     var dropzoneElement  = jQuery('#attach-dropzone');
     var fallbackElement  = jQuery('.old-attach');
     var reuseElements    = jQuery('#reuse-attachments');
 
-    // there won't be a ckeditor when using the plain <textarea>
-    var richTextEditor;
     var messageBoxId = plainMessageBox.attr('id');
-    if (CKEDITOR.instances && CKEDITOR.instances[messageBoxId]) {
-        richTextEditor = CKEDITOR.instances[messageBoxId];
-    }
-
     var regex = new RegExp(loc_key("attachment_warning_regex"), "i");
 
     // if the quoted text or signature contains the magic word
@@ -397,34 +391,8 @@ function AddAttachmentWarning() {
 
     var listenForAttachmentEvents = function () {
         if (richTextEditor) {
-            richTextEditor.on('instanceReady', function () {
-                // this set of events is imperfect. what I really want is:
-                //     this.on('change', ...)
-                // but ckeditor doesn't seem to provide that out of the box
-
-                this.on('blur', function () {
-                    toggleAttachmentWarning();
-                });
-
-                // we want to capture ~every keystroke type event; we only do the
-                // full checking periodically to avoid overloading the browser
-                this.document.on("keyup", function () {
-                    delayedAttachmentWarning();
-                });
-                this.document.on("keydown", function () {
-                    delayedAttachmentWarning();
-                });
-                this.document.on("keypress", function () {
-                    delayedAttachmentWarning();
-                });
-
-                // hook into the undo/redo buttons in the ckeditor UI
-                this.getCommand('undo').on('afterUndo', function () {
-                    toggleAttachmentWarning();
-                });
-                this.getCommand('redo').on('afterRedo', function () {
-                    toggleAttachmentWarning();
-                });
+            richTextEditor.model.document.on( 'change:data', () => {
+                delayedAttachmentWarning();
             });
         }
         else {
@@ -470,7 +438,6 @@ function AddAttachmentWarning() {
     }
 }
 
-*/
 
 function toggle_addprincipal_validity(input, good, title) {
     if (good) {
@@ -555,7 +522,7 @@ jQuery(function() {
     });
     ReplaceAllTextareas();
     jQuery('select.chosen.CF-Edit').chosen({ width: '20em', placeholder_text_multiple: ' ', no_results_text: ' ', search_contains: true });
-//    AddAttachmentWarning();
+    AddAttachmentWarning();
     jQuery('a.delete-attach').click( function() {
         var parent = jQuery(this).closest('div');
         var name = jQuery(this).attr('data-name');

-----------------------------------------------------------------------


More information about the rt-commit mailing list