summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2016-02-02 11:21:11 +0100
committerTomas Popela <tpopela@redhat.com>2016-02-02 11:46:59 +0100
commitc45c433d0d65497bffe1268023e729e62cb91b76 (patch)
tree49ea26dedfed7ffa06023db72082b75cb946ffd5
parentc2727d30d72b3dbbcfd6db5553a8fcdce38e1141 (diff)
downloadevolution-c45c433d0d65497bffe1268023e729e62cb91b76.tar.gz
EHTMLEditorView - It's not possible to change formatting from Blockquote to list
-rw-r--r--e-util/e-html-editor-selection.c6
-rw-r--r--e-util/e-html-editor-view.c102
-rw-r--r--e-util/e-html-editor-view.h4
3 files changed, 64 insertions, 48 deletions
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index d1c193366f..de82b8a044 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -2743,9 +2743,15 @@ format_change_block_to_list (EHTMLEditorSelection *selection,
g_object_unref (dom_selection);
g_object_unref (dom_window);
+ e_html_editor_view_remove_input_event_listener_from_body (view);
+ e_html_editor_selection_block_selection_changed (selection);
+
e_html_editor_view_exec_command (
view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT, NULL);
+ e_html_editor_view_register_input_event_listener_on_body (view);
+ e_html_editor_selection_unblock_selection_changed (selection);
+
element = webkit_dom_document_query_selector (
document, "body>br", NULL);
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 4ece012474..427a85f16e 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1077,9 +1077,15 @@ insert_new_line_into_citation (EHTMLEditorView *view,
return NULL;
} else {
+ e_html_editor_view_remove_input_event_listener_from_body (view);
+ block_selection_changed_callbacks (view);
+
ret_val = e_html_editor_view_exec_command (
view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT, NULL);
+ unblock_selection_changed_callbacks (view);
+ e_html_editor_view_register_input_event_listener_on_body (view);
+
if (!ret_val)
return NULL;
@@ -3107,45 +3113,6 @@ body_input_event_cb (WebKitDOMElement *element,
}
static void
-remove_input_event_listener_from_body (EHTMLEditorView *view)
-{
- if (!view->priv->body_input_event_removed) {
- WebKitDOMDocument *document;
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-
- webkit_dom_event_target_remove_event_listener (
- WEBKIT_DOM_EVENT_TARGET (
- webkit_dom_document_get_body (document)),
- "input",
- G_CALLBACK (body_input_event_cb),
- FALSE);
-
- view->priv->body_input_event_removed = TRUE;
- }
-}
-
-static void
-register_input_event_listener_on_body (EHTMLEditorView *view)
-{
- if (view->priv->body_input_event_removed) {
- WebKitDOMDocument *document;
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-
- webkit_dom_event_target_add_event_listener (
- WEBKIT_DOM_EVENT_TARGET (
- webkit_dom_document_get_body (document)),
- "input",
- G_CALLBACK (body_input_event_cb),
- FALSE,
- view);
-
- view->priv->body_input_event_removed = FALSE;
- }
-}
-
-static void
remove_empty_blocks (WebKitDOMDocument *document)
{
gint ii, length;
@@ -3509,7 +3476,7 @@ body_keyup_event_cb (WebKitDOMElement *element,
glong key_code;
if (!view->priv->composition_in_progress)
- register_input_event_listener_on_body (view);
+ e_html_editor_view_register_input_event_listener_on_body (view);
selection = e_html_editor_view_get_selection (view);
if (!e_html_editor_selection_is_collapsed (selection))
@@ -5671,7 +5638,7 @@ key_press_event_process_return_key (EHTMLEditorView *view)
* not break the citation automatically, so we need to use
* the special command to do it. */
if (e_html_editor_selection_is_citation (selection)) {
- remove_input_event_listener_from_body (view);
+ e_html_editor_view_remove_input_event_listener_from_body (view);
if (split_citation (view)) {
WebKitDOMRange *range;
@@ -7923,7 +7890,7 @@ body_compositionstart_event_cb (WebKitDOMElement *element,
EHTMLEditorView *view)
{
view->priv->composition_in_progress = TRUE;
- remove_input_event_listener_from_body (view);
+ e_html_editor_view_remove_input_event_listener_from_body (view);
}
static void
@@ -7932,7 +7899,7 @@ body_compositionend_event_cb (WebKitDOMElement *element,
EHTMLEditorView *view)
{
view->priv->composition_in_progress = FALSE;
- register_input_event_listener_on_body (view);
+ e_html_editor_view_register_input_event_listener_on_body (view);
}
static void
@@ -8166,7 +8133,7 @@ html_editor_convert_view_content (EHTMLEditorView *view,
g_object_unref (list);
repair_gmail_blockquotes (document);
- create_text_markers_for_citations_in_document (document);
+ create_text_markers_for_citations_in_element (WEBKIT_DOM_ELEMENT (body));
if (preferred_text && *preferred_text)
webkit_dom_html_element_set_inner_text (
@@ -8337,7 +8304,7 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
WebKitDOMNode *node;
WebKitDOMNode *current_block;
- remove_input_event_listener_from_body (view);
+ e_html_editor_view_remove_input_event_listener_from_body (view);
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
@@ -8738,7 +8705,7 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
e_html_editor_view_force_spell_check_in_viewport (view);
e_html_editor_selection_scroll_to_caret (selection);
- register_input_event_listener_on_body (view);
+ e_html_editor_view_register_input_event_listener_on_body (view);
}
static void
@@ -10834,7 +10801,7 @@ html_editor_view_load_status_changed (EHTMLEditorView *view)
style_updated_cb (view);
view->priv->convert_in_situ = FALSE;
- register_input_event_listener_on_body (view);
+ e_html_editor_view_register_input_event_listener_on_body (view);
register_html_events_handlers (view, body);
return;
@@ -10872,7 +10839,7 @@ html_editor_view_load_status_changed (EHTMLEditorView *view)
}
/* Register on input event that is called when the content (body) is modified */
- register_input_event_listener_on_body (view);
+ e_html_editor_view_register_input_event_listener_on_body (view);
register_html_events_handlers (view, body);
if (view->priv->html_mode)
@@ -14907,3 +14874,42 @@ e_html_editor_view_is_pasting_content_from_itself (EHTMLEditorView *view)
else
return view->priv->copy_paste_clipboard_in_view;
}
+
+void
+e_html_editor_view_remove_input_event_listener_from_body (EHTMLEditorView *view)
+{
+ if (!view->priv->body_input_event_removed) {
+ WebKitDOMDocument *document;
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+
+ webkit_dom_event_target_remove_event_listener (
+ WEBKIT_DOM_EVENT_TARGET (
+ webkit_dom_document_get_body (document)),
+ "input",
+ G_CALLBACK (body_input_event_cb),
+ FALSE);
+
+ view->priv->body_input_event_removed = TRUE;
+ }
+}
+
+void
+e_html_editor_view_register_input_event_listener_on_body (EHTMLEditorView *view)
+{
+ if (view->priv->body_input_event_removed) {
+ WebKitDOMDocument *document;
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+
+ webkit_dom_event_target_add_event_listener (
+ WEBKIT_DOM_EVENT_TARGET (
+ webkit_dom_document_get_body (document)),
+ "input",
+ G_CALLBACK (body_input_event_cb),
+ FALSE,
+ view);
+
+ view->priv->body_input_event_removed = FALSE;
+ }
+}
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index 83813dc537..93d3ce7f5c 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -307,6 +307,10 @@ void e_html_editor_view_unblock_style_updated_callbacks
(EHTMLEditorView *view);
gboolean e_html_editor_view_is_pasting_content_from_itself
(EHTMLEditorView *view);
+void e_html_editor_view_remove_input_event_listener_from_body
+ (EHTMLEditorView *view);
+void e_html_editor_view_register_input_event_listener_on_body
+ (EHTMLEditorView *view);
G_END_DECLS
#endif /* E_HTML_EDITOR_VIEW_H */