aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-html-editor-view.c
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-08-27 21:53:30 +0800
committerTomas Popela <tpopela@redhat.com>2014-08-27 22:12:02 +0800
commit94ac03022048a12b6a43c970ab6a95eef865e7b6 (patch)
tree4f97ca43a513d498f19f03a945ef77b4041edbb2 /e-util/e-html-editor-view.c
parentf382078b3478585c628cb6493214c9b57f32b66c (diff)
downloadgsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.tar
gsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.tar.gz
gsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.tar.bz2
gsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.tar.lz
gsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.tar.xz
gsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.tar.zst
gsoc2013-evolution-94ac03022048a12b6a43c970ab6a95eef865e7b6.zip
When changing the composer mode from HTML to Plain Text avoid reloading of the web view
Also preserve the selection (if it is possible) when changing the mode.
Diffstat (limited to 'e-util/e-html-editor-view.c')
-rw-r--r--e-util/e-html-editor-view.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index d5fcdc9b6a..90a75de3ff 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -5846,33 +5846,35 @@ process_elements (EHTMLEditorView *view,
}
/* Signature */
- if (WEBKIT_DOM_IS_HTML_DIV_ELEMENT (child)) {
+ if (WEBKIT_DOM_IS_HTML_DIV_ELEMENT (child) &&
+ element_has_class (WEBKIT_DOM_ELEMENT (child), "-x-evo-signature-wrapper")) {
WebKitDOMNode *first_child;
first_child = webkit_dom_node_get_first_child (child);
- if (WEBKIT_DOM_IS_ELEMENT (first_child)) {
- if (element_has_class (
- WEBKIT_DOM_ELEMENT (first_child),
- "-x-evo-signature")) {
-
- if (to_html) {
- remove_base_attributes (
- WEBKIT_DOM_ELEMENT (first_child));
- remove_evolution_attributes (
- WEBKIT_DOM_ELEMENT (first_child));
- }
- if (to_plain_text && !changing_mode) {
- g_string_append (buffer, "\n");
- content = webkit_dom_html_element_get_inner_text (
- WEBKIT_DOM_HTML_ELEMENT (first_child));
- g_string_append (buffer, content);
- g_free (content);
- skip_nl = TRUE;
- }
- skip_node = TRUE;
- goto next;
- }
+
+ if (to_html) {
+ remove_base_attributes (
+ WEBKIT_DOM_ELEMENT (first_child));
+ remove_evolution_attributes (
+ WEBKIT_DOM_ELEMENT (first_child));
+ }
+ if (to_plain_text && !changing_mode) {
+ g_string_append (buffer, "\n");
+ content = webkit_dom_html_element_get_inner_text (
+ WEBKIT_DOM_HTML_ELEMENT (first_child));
+ g_string_append (buffer, content);
+ g_free (content);
+ skip_nl = TRUE;
}
+ if (to_plain_text && changing_mode) {
+ content = webkit_dom_html_element_get_outer_html (
+ WEBKIT_DOM_HTML_ELEMENT (child));
+ g_string_append (buffer, content);
+ g_free (content);
+ skip_node = TRUE;
+ }
+ skip_node = TRUE;
+ goto next;
}
/* Replace smileys with their text representation */
@@ -6724,8 +6726,7 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
} else {
gchar *plain;
- /* Save caret position -> it will be restored in e-composer-private.c */
- e_html_editor_selection_save_caret_position (selection);
+ e_html_editor_selection_save (selection);
if (blockquote) {
e_html_editor_selection_wrap_paragraphs_in_document (
@@ -6739,9 +6740,15 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
plain = process_content_for_mode_change (view);
- if (*plain)
- webkit_web_view_load_string (
- WEBKIT_WEB_VIEW (view), plain, NULL, NULL, "file://");
+ if (*plain) {
+ webkit_dom_html_element_set_outer_html (
+ WEBKIT_DOM_HTML_ELEMENT (
+ webkit_dom_document_get_document_element (document)),
+ plain,
+ NULL);
+ e_html_editor_selection_restore (selection);
+ e_html_editor_view_force_spell_check (view);
+ }
g_free (plain);
}