[geary/wip/728002-webkit2: 51/96] Re-enable rich/plain text editing toggke for WK2.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2: 51/96] Re-enable rich/plain text editing toggke for WK2.
- Date: Sat, 14 Jan 2017 12:16:07 +0000 (UTC)
commit 9e14671f5afa14ec21d9d692cc557f27a24cfbe5
Author: Michael James Gratton <mike vee net>
Date: Fri Dec 2 19:49:35 2016 +1100
Re-enable rich/plain text editing toggke for WK2.
src/client/composer/composer-web-view.vala | 6 ++++--
src/client/composer/composer-widget.vala | 2 +-
src/client/web-process/util-composer.vala | 12 ------------
ui/composer-web-view.js | 7 +++++++
4 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala
index 821ff0b..f5a1494 100644
--- a/src/client/composer/composer-web-view.vala
+++ b/src/client/composer/composer-web-view.vala
@@ -173,8 +173,10 @@ public class ComposerWebView : ClientWebView {
/**
* Sets whether the editor is in rich text or plain text mode.
*/
- public void enable_rich_text(bool enabled) {
- // XXX
+ public void set_rich_text(bool enabled) {
+ this.run_javascript.begin(
+ "geary.setRichText(%s);".printf(enabled ? "true" : "false"), null
+ );
}
/**
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index b2d213f..f851ec5 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -1679,7 +1679,7 @@ public class ComposerWidget : Gtk.EventBox {
this.menu_button.menu_model = (compose_as_html) ? this.html_menu : this.plain_menu;
- this.editor.enable_rich_text(compose_as_html);
+ this.editor.set_rich_text(compose_as_html);
GearyApplication.instance.config.compose_as_html = compose_as_html;
}
diff --git a/src/client/web-process/util-composer.vala b/src/client/web-process/util-composer.vala
index 15c4195..6a3ea38 100644
--- a/src/client/web-process/util-composer.vala
+++ b/src/client/web-process/util-composer.vala
@@ -92,18 +92,6 @@ namespace Util.Composer {
// return offset > 0 ? document.create_text_node(node_value[0:index]) : null;
// }
- public void enable_rich_text(WebKit.WebPage page, bool is_enabled) {
- // WebKit.DOM.DOMTokenList body_classes = this.editor.get_dom_document().body.get_class_list();
- // try {
- // if (is_enabled)
- // body_classes.remove("plain");
- // else
- // body_classes.add("plain");
- // } catch (Error error) {
- // debug("Error setting composer style: %s", error.message);
- // }
- }
-
public void undo_blockquote_style(WebKit.WebPage page) {
try {
WebKit.DOM.NodeList node_list = page.get_dom_document().query_selector_all(
diff --git a/ui/composer-web-view.js b/ui/composer-web-view.js
index db238ad..5e28f98 100644
--- a/ui/composer-web-view.js
+++ b/ui/composer-web-view.js
@@ -59,6 +59,13 @@ ComposerPageState.prototype = {
},
getText: function() {
return document.getElementById(ComposerPageState.BODY_ID).innerText;
+ },
+ setRichText: function(enabled) {
+ if (enabled) {
+ document.body.classList.remove("plain");
+ } else {
+ document.body.classList.add("plain");
+ }
}
// private static void on_link_clicked(WebKit.DOM.Element element, WebKit.DOM.Event event,
// ComposerWidget composer) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]