[geary/wip/728002-webkit2] Ensure basic rich text editing controls work under WK2.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2] Ensure basic rich text editing controls work under WK2.
- Date: Sun, 4 Dec 2016 23:09:51 +0000 (UTC)
commit 9863d931539b922a15329fa26f7568c7ef2b1a14
Author: Michael James Gratton <mike vee net>
Date: Mon Dec 5 10:05:15 2016 +1100
Ensure basic rich text editing controls work under WK2.
src/client/composer/composer-web-view.vala | 10 +---------
src/client/composer/composer-widget.vala | 6 +++---
src/client/web-process/util-composer.vala | 14 --------------
ui/composer-web-view.js | 10 ++++++++++
4 files changed, 14 insertions(+), 26 deletions(-)
---
diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala
index f5a1494..deaabbc 100644
--- a/src/client/composer/composer-web-view.vala
+++ b/src/client/composer/composer-web-view.vala
@@ -70,17 +70,9 @@ public class ComposerWebView : ClientWebView {
private bool is_shift_down = false;
- public signal void text_attributes_changed(uint wk_typing_attrs);
-
-
public ComposerWebView() {
base();
this.user_content_manager.add_script(ComposerWebView.app_script);
-
- get_editor_state().notify["typing-attributes"].connect(() => {
- text_attributes_changed(get_editor_state().typing_attributes);
- });
-
// this.should_insert_text.connect(on_should_insert_text);
this.key_press_event.connect(on_key_press_event);
}
@@ -197,7 +189,7 @@ public class ComposerWebView : ClientWebView {
* ???
*/
public void undo_blockquote_style() {
- // XXX
+ this.run_javascript.begin("geary.undoBlockquoteStyle();", null);
}
/**
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 7b030f5..e30d8ba 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -449,10 +449,9 @@ public class ComposerWidget : Gtk.EventBox {
this.bcc_entry.changed.connect(validate_send_button);
this.reply_to_entry.changed.connect(validate_send_button);
this.editor.context_menu.connect(on_context_menu);
- this.editor.link_activated.connect(on_link_activated);
this.editor.load_changed.connect(on_load_changed);
this.editor.mouse_target_changed.connect(on_mouse_target_changed);
- this.editor.text_attributes_changed.connect(on_text_attributes_changed);
+ this.editor.get_editor_state().notify["typing-attributes"].connect(on_typing_attributes_changed);
// this.editor.move_focus.connect(update_actions);
// this.editor.copy_clipboard.connect(update_actions);
// this.editor.cut_clipboard.connect(update_actions);
@@ -2177,7 +2176,8 @@ public class ComposerWidget : Gtk.EventBox {
this.signature_html = account_sig;
}
- private void on_text_attributes_changed(uint mask) {
+ private void on_typing_attributes_changed() {
+ uint mask = this.editor.get_editor_state().get_typing_attributes();
this.actions.change_action_state(
ACTION_BOLD,
(mask & WebKit.EditorTypingAttributes.BOLD) == WebKit.EditorTypingAttributes.BOLD
diff --git a/src/client/web-process/util-composer.vala b/src/client/web-process/util-composer.vala
index 6a3ea38..4d87eaf 100644
--- a/src/client/web-process/util-composer.vala
+++ b/src/client/web-process/util-composer.vala
@@ -92,20 +92,6 @@ namespace Util.Composer {
// return offset > 0 ? document.create_text_node(node_value[0:index]) : null;
// }
- public void undo_blockquote_style(WebKit.WebPage page) {
- try {
- WebKit.DOM.NodeList node_list = page.get_dom_document().query_selector_all(
- "blockquote[style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"]");
- for (int i = 0; i < node_list.length; ++i) {
- WebKit.DOM.Element element = (WebKit.DOM.Element) node_list.item(i);
- element.remove_attribute("style");
- element.set_attribute("type", "cite");
- }
- } catch (Error error) {
- debug("Error removing blockquote style: %s", error.message);
- }
- }
-
public bool handle_key_press(WebKit.WebPage page, Gdk.EventKey event) {
WebKit.DOM.Document document = page.get_dom_document();
if (event.keyval == Gdk.Key.Tab) {
diff --git a/ui/composer-web-view.js b/ui/composer-web-view.js
index 12543a9..0089132 100644
--- a/ui/composer-web-view.js
+++ b/ui/composer-web-view.js
@@ -72,6 +72,16 @@ ComposerPageState.prototype = {
document.body.classList.add("plain");
}
},
+ undoBlockquoteStyle: function() {
+ let nodeList = document.querySelectorAll(
+ "blockquote[style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"]"
+ );
+ for (let i = 0; i < nodeList.length; ++i) {
+ let element = nodeList.item(i);
+ element.removeAttribute("style");
+ element.setAttribute("type", "cite");
+ }
+ },
linkClicked: function(element) {
window.getSelection().selectAllChildren(element);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]