[evolution/wip/mcrha/webkit-jsc-api] webkit-editor: Skip unneeded (and unimplemented) EvoEditor.ConvertContent()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/webkit-jsc-api] webkit-editor: Skip unneeded (and unimplemented) EvoEditor.ConvertContent()
- Date: Wed, 22 Apr 2020 14:14:45 +0000 (UTC)
commit 40acdb73e84f6199d939c960af2d206339918e01
Author: Milan Crha <mcrha redhat com>
Date: Wed Apr 22 16:17:40 2020 +0200
webkit-editor: Skip unneeded (and unimplemented) EvoEditor.ConvertContent()
data/webkit/e-editor.js | 7 -------
src/modules/webkit-editor/e-webkit-editor.c | 32 +++++++++++++++++++++++++----
2 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index bc1e945806..b749f35a52 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -4872,13 +4872,6 @@ EvoEditor.isEmptyParagraph = function(node)
return !node.children.length || (node.children.length == 1 && node.children[0].tagName == "BR");
}
-// the body contains data, which should be converted into editable content;
-// preferredPlainText can be empty, if not, then it replaces body content
-EvoEditor.ConvertContent = function(preferredPlainText, startBottom, topSignature)
-{
- throw "EvoEditor.ConvertContent: startBottom:" + startBottom + " topSignature:" + topSignature + "
plainText:---" + preferredPlainText + "---";
-}
-
// replaces current selection with the plain text or HTML, quoted or normal DIV
EvoEditor.InsertContent = function(text, isHTML, quote)
{
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 51267f5333..ecc63c17da 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -2043,11 +2043,35 @@ webkit_editor_insert_content (EContentEditor *editor,
"EvoEditor.LoadHTML(%s);", content);
} else if ((flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
(flags & E_CONTENT_EDITOR_INSERT_TEXT_PLAIN)) {
+ gchar *html, **lines;
+ gint ii;
+
+ lines = g_strsplit (content ? content : "", "\n", -1);
+
+ for (ii = 0; lines && lines[ii]; ii++) {
+ gchar *line = lines[ii];
+ gint len = strlen (line);
+
+ if (len > 0 && line[len - 1] == '\r') {
+ line[len - 1] = 0;
+ len--;
+ }
+
+ if (len)
+ lines[ii] = g_markup_printf_escaped ("<div>%s</div>", line);
+ else
+ lines[ii] = g_strdup ("<div><br></div>");
+
+ g_free (line);
+ }
+
+ html = g_strjoinv ("", lines);
+
e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
- "EvoEditor.ConvertContent(%s, %x, %x);",
- content,
- e_webkit_editor_three_state_to_bool (e_content_editor_get_start_bottom (editor),
"composer-reply-start-bottom"),
- e_webkit_editor_three_state_to_bool (e_content_editor_get_top_signature (editor),
"composer-top-signature"));
+ "EvoEditor.LoadHTML(%s);", html);
+
+ g_strfreev (lines);
+ g_free (html);
} else if ((flags & E_CONTENT_EDITOR_INSERT_CONVERT) &&
!(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
!(flags & E_CONTENT_EDITOR_INSERT_QUOTE_CONTENT)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]