[evolution/wip/mcrha/webkit-jsc-api] e-editor.js: 'Start typing at bottom' option doesn't work



commit f199cdb844d7752fdcef5144bc2b599eb64844d4
Author: Milan Crha <mcrha redhat com>
Date:   Tue Apr 21 17:54:00 2020 +0200

    e-editor.js: 'Start typing at bottom' option doesn't work

 data/webkit/e-editor.js                     | 16 ++++++++++++++--
 src/modules/webkit-editor/e-webkit-editor.c | 14 ++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 4ba4536573..05872b3d17 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -78,6 +78,8 @@ var EvoEditor = {
        MAGIC_SMILEYS : false,
        UNICODE_SMILEYS : false,
        WRAP_QUOTED_TEXT_IN_REPLIES : true,
+       START_BOTTOM : false,
+       TOP_SIGNATURE : false,
 
        FORCE_NO : 0,
        FORCE_YES : 1,
@@ -4742,8 +4744,7 @@ EvoEditor.InsertSignature = function(content, isHTML, uid, fromMessage, checkCha
                                useWrapper.className = "-x-evo-signature-wrapper";
                                useWrapper.appendChild(sigSpan);
 
-                               if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT)
-                                       useWrapper.style.width = EvoEditor.NORMAL_PARAGRAPH_WIDTH + "ch";
+                               EvoEditor.maybeUpdateParagraphWidth(useWrapper);
 
                                EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, 
"InsertSignature::new-changes", document.body, document.body, EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML);
                                try {
@@ -5313,6 +5314,7 @@ EvoEditor.processLoadedContent = function()
                        elem.innerText = credits;
 
                        document.body.insertAdjacentElement("afterbegin", elem);
+                       EvoEditor.maybeUpdateParagraphWidth(elem);
                }
 
                node.remove();
@@ -5394,6 +5396,16 @@ EvoEditor.processLoadedContent = function()
 
                document.getSelection().setPosition(node, 0);
        }
+
+       if (EvoEditor.START_BOTTOM) {
+               var node = document.createElement("DIV");
+
+               node.appendChild(document.createElement("BR"));
+               document.body.appendChild(node);
+               EvoEditor.maybeUpdateParagraphWidth(node);
+
+               document.getSelection().setPosition(node, 0);
+       }
 }
 
 EvoEditor.LoadHTML = function(html)
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index af1da34344..7ba13e7a00 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -2415,6 +2415,10 @@ webkit_editor_set_start_bottom (EWebKitEditor *wk_editor,
 
        wk_editor->priv->start_bottom = value;
 
+       e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+               "EvoEditor.START_BOTTOM = %x;",
+               e_webkit_editor_three_state_to_bool (value, "composer-reply-start-bottom"));
+
        g_object_notify (G_OBJECT (wk_editor), "start-bottom");
 }
 
@@ -2437,6 +2441,10 @@ webkit_editor_set_top_signature (EWebKitEditor *wk_editor,
 
        wk_editor->priv->top_signature = value;
 
+       e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+               "EvoEditor.TOP_SIGNATURE = %x;",
+               e_webkit_editor_three_state_to_bool (value, "composer-top-signature"));
+
        g_object_notify (G_OBJECT (wk_editor), "top-signature");
 }
 
@@ -4755,6 +4763,12 @@ webkit_editor_load_changed_cb (EWebKitEditor *wk_editor,
            !webkit_editor_is_ready (E_CONTENT_EDITOR (wk_editor)))
                return;
 
+       e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+               "EvoEditor.START_BOTTOM = %x;\n"
+               "EvoEditor.TOP_SIGNATURE = %x;",
+               e_webkit_editor_three_state_to_bool (wk_editor->priv->start_bottom, 
"composer-reply-start-bottom"),
+               e_webkit_editor_three_state_to_bool (wk_editor->priv->top_signature, 
"composer-top-signature"));
+
        /* Dispatch queued operations - as we are using this just for load
         * operations load just the latest request and throw away the rest. */
        if (wk_editor->priv->post_reload_operations &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]