[evolution] I#1536 - Allow to delete an inserted image/rule in HTML composer
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1536 - Allow to delete an inserted image/rule in HTML composer
- Date: Mon, 14 Jun 2021 17:25:34 +0000 (UTC)
commit 7bd2ce8a11cbcd851853b70d193043768b36c819
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 14 19:24:24 2021 +0200
I#1536 - Allow to delete an inserted image/rule in HTML composer
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1536
data/webkit/e-editor.js | 28 ++++++++++++++++--------
src/e-util/e-content-editor.c | 28 ++++++++++++++++++++++++
src/e-util/e-content-editor.h | 9 +++++++-
src/e-util/e-html-editor-actions.c | 34 +++++++++++++++++++++++++++++
src/e-util/e-html-editor-actions.h | 4 ++++
src/e-util/e-html-editor-manager.ui | 3 +++
src/e-util/e-html-editor.c | 2 ++
src/modules/webkit-editor/e-webkit-editor.c | 20 +++++++++++++++++
8 files changed, 118 insertions(+), 10 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index be77e8cc85..9c585c0241 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -4582,19 +4582,14 @@ EvoEditor.DialogUtilsTableDeleteRow = function()
EvoEditor.dialogUtilsForeachTableScope(EvoEditor.E_CONTENT_EDITOR_SCOPE_ROW, traversar,
"TableDeleteColumn");
}
-EvoEditor.DialogUtilsTableDelete = function()
+EvoEditor.elementDelete = function(element)
{
- var element = EvoEditor.getCurrentElement();
-
if (!element)
return;
- element = EvoEditor.getParentElement("TABLE", element, true);
-
- if (!element)
- return;
+ var undoName = element.tagName + "Delete";
- EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "TableDelete", element, element,
+ EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, undoName, element, element,
EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE | EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML);
try {
var parent = element.parentElement;
@@ -4605,12 +4600,27 @@ EvoEditor.DialogUtilsTableDelete = function()
parent.appendChild(document.createElement("BR"));
}
} finally {
- EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "TableDelete");
+ EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, undoName);
EvoEditor.maybeUpdateFormattingState(EvoEditor.FORCE_MAYBE);
EvoEditor.EmitContentChanged();
}
}
+EvoEditor.DialogUtilsTableDelete = function()
+{
+ var element = EvoEditor.getCurrentElement();
+
+ if (!element)
+ return;
+
+ EvoEditor.elementDelete(EvoEditor.getParentElement("TABLE", element, true));
+}
+
+EvoEditor.DialogUtilsContextElementDelete = function()
+{
+ EvoEditor.elementDelete(EvoEditor.contextMenuNode);
+}
+
// 'what' can be "column" or "row",
// 'where' can be lower than 0 for before/above, higher than 0 for after/below
EvoEditor.DialogUtilsTableInsert = function(what, where)
diff --git a/src/e-util/e-content-editor.c b/src/e-util/e-content-editor.c
index ed07be45b2..31317327d0 100644
--- a/src/e-util/e-content-editor.c
+++ b/src/e-util/e-content-editor.c
@@ -3887,3 +3887,31 @@ e_content_editor_emit_ref_mime_part (EContentEditor *editor,
return mime_part;
}
+
+void
+e_content_editor_delete_h_rule (EContentEditor *editor)
+{
+ EContentEditorInterface *iface;
+
+ g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
+
+ iface = E_CONTENT_EDITOR_GET_IFACE (editor);
+ g_return_if_fail (iface != NULL);
+ g_return_if_fail (iface->delete_h_rule != NULL);
+
+ iface->delete_h_rule (editor);
+}
+
+void
+e_content_editor_delete_image (EContentEditor *editor)
+{
+ EContentEditorInterface *iface;
+
+ g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
+
+ iface = E_CONTENT_EDITOR_GET_IFACE (editor);
+ g_return_if_fail (iface != NULL);
+ g_return_if_fail (iface->delete_image != NULL);
+
+ iface->delete_image (editor);
+}
diff --git a/src/e-util/e-content-editor.h b/src/e-util/e-content-editor.h
index eaa7aab44d..a377f5f1c0 100644
--- a/src/e-util/e-content-editor.h
+++ b/src/e-util/e-content-editor.h
@@ -422,6 +422,12 @@ struct _EContentEditorInterface {
void (*content_changed) (EContentEditor *editor);
CamelMimePart * (*ref_mime_part) (EContentEditor *editor,
const gchar *uri);
+
+ void (*delete_h_rule) (EContentEditor *editor);
+ void (*delete_image) (EContentEditor *editor);
+
+ /* padding for future expansion */
+ gpointer reserved[20];
};
/* Properties */
@@ -567,7 +573,6 @@ CamelMimePart * e_content_editor_util_create_data_mimepart
void e_content_editor_insert_image (EContentEditor *editor,
const gchar *uri);
-
void e_content_editor_insert_emoticon
(EContentEditor *editor,
EEmoticon *emoticon);
@@ -977,6 +982,8 @@ void e_content_editor_spell_check_replace_all
(EContentEditor *editor,
const gchar *word,
const gchar *replacement);
+void e_content_editor_delete_h_rule (EContentEditor *editor);
+void e_content_editor_delete_image (EContentEditor *editor);
/* Signal helpers */
diff --git a/src/e-util/e-html-editor-actions.c b/src/e-util/e-html-editor-actions.c
index 17869ff4f2..f6d78acb43 100644
--- a/src/e-util/e-html-editor-actions.c
+++ b/src/e-util/e-html-editor-actions.c
@@ -180,6 +180,26 @@ action_context_delete_table_cb (GtkAction *action,
e_content_editor_delete_table (cnt_editor);
}
+static void
+action_context_delete_hrule_cb (GtkAction *action,
+ EHTMLEditor *editor)
+{
+ EContentEditor *cnt_editor;
+
+ cnt_editor = e_html_editor_get_content_editor (editor);
+ e_content_editor_delete_h_rule (cnt_editor);
+}
+
+static void
+action_context_delete_image_cb (GtkAction *action,
+ EHTMLEditor *editor)
+{
+ EContentEditor *cnt_editor;
+
+ cnt_editor = e_html_editor_get_content_editor (editor);
+ e_content_editor_delete_image (cnt_editor);
+}
+
static void
action_context_insert_column_after_cb (GtkAction *action,
EHTMLEditor *editor)
@@ -1695,6 +1715,20 @@ static GtkActionEntry context_entries[] = {
static GtkActionEntry html_context_entries[] = {
+ { "context-delete-hrule",
+ NULL,
+ N_("Delete Rule"),
+ NULL,
+ NULL,
+ G_CALLBACK (action_context_delete_hrule_cb) },
+
+ { "context-delete-image",
+ NULL,
+ N_("Delete Image"),
+ NULL,
+ NULL,
+ G_CALLBACK (action_context_delete_image_cb) },
+
{ "context-insert-column-after",
NULL,
N_("Column After"),
diff --git a/src/e-util/e-html-editor-actions.h b/src/e-util/e-html-editor-actions.h
index a7898168bb..f66eb584aa 100644
--- a/src/e-util/e-html-editor-actions.h
+++ b/src/e-util/e-html-editor-actions.h
@@ -33,6 +33,10 @@
E_HTML_EDITOR_ACTION ((editor), "context-delete-cell")
#define E_HTML_EDITOR_ACTION_CONTEXT_DELETE_COLUMN(editor) \
E_HTML_EDITOR_ACTION ((editor), "context-delete-column")
+#define E_HTML_EDITOR_ACTION_CONTEXT_DELETE_HRULE(editor) \
+ E_HTML_EDITOR_ACTION ((editor), "context-delete-hrule")
+#define E_HTML_EDITOR_ACTION_CONTEXT_DELETE_IMAGE(editor) \
+ E_HTML_EDITOR_ACTION ((editor), "context-delete-image")
#define E_HTML_EDITOR_ACTION_CONTEXT_DELETE_ROW(editor) \
E_HTML_EDITOR_ACTION ((editor), "context-delete-row")
#define E_HTML_EDITOR_ACTION_CONTEXT_DELETE_TABLE(editor) \
diff --git a/src/e-util/e-html-editor-manager.ui b/src/e-util/e-html-editor-manager.ui
index f263c13ef0..3f7468d4de 100644
--- a/src/e-util/e-html-editor-manager.ui
+++ b/src/e-util/e-html-editor-manager.ui
@@ -158,6 +158,9 @@
<menuitem action='context-insert-link'/>
<menuitem action='context-remove-link'/>
<separator/>
+ <menuitem action='context-delete-hrule'/>
+ <menuitem action='context-delete-image'/>
+ <separator/>
<menu action='context-properties-menu'>
<menuitem action='context-properties-text'/>
<menuitem action='context-properties-link'/>
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 574fa01a66..e4cdd319b1 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -471,6 +471,7 @@ html_editor_update_actions (EHTMLEditor *editor,
visible = (flags & E_CONTENT_EDITOR_NODE_IS_IMAGE);
action_set_visible_and_sensitive (ACTION (CONTEXT_PROPERTIES_IMAGE), visible);
+ action_set_visible_and_sensitive (ACTION (CONTEXT_DELETE_IMAGE), visible);
visible = (flags & E_CONTENT_EDITOR_NODE_IS_ANCHOR);
if (visible)
@@ -479,6 +480,7 @@ html_editor_update_actions (EHTMLEditor *editor,
visible = (flags & E_CONTENT_EDITOR_NODE_IS_H_RULE);
action_set_visible_and_sensitive (ACTION (CONTEXT_PROPERTIES_RULE), visible);
+ action_set_visible_and_sensitive (ACTION (CONTEXT_DELETE_HRULE), visible);
visible = (flags & E_CONTENT_EDITOR_NODE_IS_TEXT);
/* Only display the text properties dialog when some text is selected. */
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index fcafeae2ee..4e0cdc02cb 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -2997,6 +2997,24 @@ webikt_editor_call_table_insert (EContentEditor *editor,
what, where);
}
+static void
+webkit_editor_delete_h_rule (EContentEditor *editor)
+{
+ EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
+
+ e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+ "EvoEditor.DialogUtilsContextElementDelete();");
+}
+
+static void
+webkit_editor_delete_image (EContentEditor *editor)
+{
+ EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
+
+ e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
+ "EvoEditor.DialogUtilsContextElementDelete();");
+}
+
static void
webkit_editor_insert_column_after (EContentEditor *editor)
{
@@ -5884,6 +5902,8 @@ e_webkit_editor_content_editor_init (EContentEditorInterface *iface)
iface->table_set_background_color = webkit_editor_table_set_background_color;
iface->spell_check_next_word = webkit_editor_spell_check_next_word;
iface->spell_check_prev_word = webkit_editor_spell_check_prev_word;
+ iface->delete_h_rule = webkit_editor_delete_h_rule;
+ iface->delete_image = webkit_editor_delete_image;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]