From 6a0592918ac4bf109d67b619cdf3835239b700d4 Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Wed, 27 Aug 2014 16:06:07 +0200 Subject: Fix handling of the selection in the composer when saving the message draft When saving the draft don't lose the active selection in the web view. Also restore the selection when the draft is again opened. Also fix the situations when the spell check was not activated when the composer was opened. --- e-util/e-html-editor-view.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'e-util/e-html-editor-view.c') diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index 90a75de3ff..e0028ffa15 100644 --- a/e-util/e-html-editor-view.c +++ b/e-util/e-html-editor-view.c @@ -1202,6 +1202,14 @@ html_editor_view_load_status_changed (EHTMLEditorView *view) move_elements_to_body (document); repair_gmail_blockquotes (document); + if (webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (body), "data-evo-draft")) { + /* Restore the selection how it was when the draft was saved */ + e_html_editor_selection_move_caret_into_element ( + document, WEBKIT_DOM_ELEMENT (body)); + e_html_editor_selection_restore ( + e_html_editor_view_get_selection (view)); + } + /* Register on input event that is called when the content (body) is modified */ register_input_event_listener_on_body (view); @@ -6185,17 +6193,11 @@ process_content_for_saving_as_draft (EHTMLEditorView *view) { WebKitDOMDocument *document; WebKitDOMHTMLElement *body; - WebKitDOMElement *element, *document_element; + WebKitDOMElement *document_element; gchar *content; document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view)); body = webkit_dom_document_get_body (document); - element = webkit_dom_document_get_element_by_id ( - document, "-x-evo-caret-position"); - - if (element) - webkit_dom_element_set_attribute ( - element, "style", "display: none; color: red;", NULL); webkit_dom_element_set_attribute ( WEBKIT_DOM_ELEMENT (body), "data-evo-draft", "", NULL); @@ -6207,10 +6209,6 @@ process_content_for_saving_as_draft (EHTMLEditorView *view) webkit_dom_element_remove_attribute ( WEBKIT_DOM_ELEMENT (body), "data-evo-draft"); - if (element) - webkit_dom_element_set_attribute ( - element, "style", "color: red;", NULL); - return content; } -- cgit v1.2.3