Files
evolution/e-util/e-html-editor-utils.h
Tomas Popela a60e6be8f1 EHTMLEditorView - Improve how the content is processed
Split the process_elements function to:
 * process_node_to_plain_text_for_exporting
 * process_node_to_plain_text_changing_composer_mode
 * process_node_to_html_changing_composer_mode
 * process_node_to_html_for_exporting

that process the given nodes (usually just BODY) for purposes described by the
function names - i.e. the first function will process the BODY and will transform
the lists to their plain text version, fill the indentation or alignment with
spaces and so on; the process_node_to_html_for_exporting will remove all the
classes, ids and other attributes from the DOM.

Also in the process_node_to_plain_text_for_exporting correctly process the block
elements to avoid situations when an extra new line could be added on the end of
the block or not added at all. Always look if the new line is indeed there, if
not add it there explicitly. This fixes the bug 767681. Also avoid working with
the innerHTML of the BODY (that was previously leaked), but instead copy the
nodes. Also remove images from the BODY if they are presented to avoid unneeded
line break.

After this change the indented elements will be preserved when switching between
composer modes.

When removing an image also remove its wrappers and the block where the image
was, if the block is empty after the image was removed, otherwise an extra line
will be added to the output.
2016-06-29 15:19:13 +02:00

116 lines
3.3 KiB
C

/*
* e-html-editor-utils.h
*
* Copyright (C) 2012 Dan Vrátil <dvratil@redhat.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
#error "Only <e-util/e-util.h> should be included directly."
#endif
#ifndef E_HTML_EDITOR_UTILS_H
#define E_HTML_EDITOR_UTILS_H
#include <e-util/e-util-enums.h>
#include <webkit/webkitdom.h>
G_BEGIN_DECLS
WebKitDOMElement *
e_html_editor_dom_node_find_parent_element
(WebKitDOMNode *node,
const gchar *tagname);
WebKitDOMElement *
e_html_editor_dom_node_find_child_element
(WebKitDOMNode *node,
const gchar *tagname);
gboolean e_html_editor_node_is_selection_position_node
(WebKitDOMNode *node);
WebKitDOMNode * e_html_editor_get_parent_block_node_from_child
(WebKitDOMNode *node);
gboolean element_has_id (WebKitDOMElement *element,
const gchar* id);
gboolean element_has_tag (WebKitDOMElement *element,
const gchar* tag);
gboolean element_has_class (WebKitDOMElement *element,
const gchar* class);
void element_add_class (WebKitDOMElement *element,
const gchar* class);
void element_remove_class (WebKitDOMElement *element,
const gchar* class);
void remove_node (WebKitDOMNode *node);
void remove_node_if_empty (WebKitDOMNode *node);
WebKitDOMNode * split_node_into_two (WebKitDOMNode *item,
gint level);
WebKitDOMElement *
create_selection_marker (WebKitDOMDocument *document,
gboolean start);
void add_selection_markers_into_element_start
(WebKitDOMDocument *document,
WebKitDOMElement *element,
WebKitDOMElement **selection_start_marker,
WebKitDOMElement **selection_end_marker);
void add_selection_markers_into_element_end
(WebKitDOMDocument *document,
WebKitDOMElement *element,
WebKitDOMElement **selection_start_marker,
WebKitDOMElement **selection_end_marker);
void remove_selection_markers (WebKitDOMDocument *document);
gboolean node_is_list (WebKitDOMNode *node);
gboolean node_is_list_or_item (WebKitDOMNode *node);
EHTMLEditorSelectionBlockFormat
get_list_format_from_node (WebKitDOMNode *node);
void merge_list_into_list (WebKitDOMNode *from,
WebKitDOMNode *to,
gboolean insert_before);
void merge_lists_if_possible (WebKitDOMNode *list);
WebKitDOMElement *
get_parent_block_element (WebKitDOMNode *node);
void dom_element_rename_attribute (WebKitDOMElement *element,
const gchar *from,
const gchar *to);
void dom_element_swap_attributes (WebKitDOMElement *element,
const gchar *from,
const gchar *to);
G_END_DECLS
#endif /* E_HTML_EDITOR_UTILS_H */