loleaflet/src/control/Control.ContextMenu.js |   27 +++++++++++++++++++++++++--
 loleaflet/src/unocommands.js                 |    5 +----
 2 files changed, 26 insertions(+), 6 deletions(-)

New commits:
commit 5460aa108c10f044a20863b5fe82efa921a51291
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Tue Feb 11 15:34:41 2020 +0530
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Feb 12 11:18:40 2020 +0100

    Add 'Delete' to context menu on non-text selection
    
    The context menu items are obtained from core. Add a 'Delete'
    entry to the context-menu json data just after 'Paste' only if
    the selection is graphic and online is in Mobile mode.
    
    Change-Id: Ie5810038bbca5d8ace01b236508b2dd4d31ca2a7
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88510
    Tested-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/loleaflet/src/control/Control.ContextMenu.js 
b/loleaflet/src/control/Control.ContextMenu.js
index 83a57730c..9912729ce 100644
--- a/loleaflet/src/control/Control.ContextMenu.js
+++ b/loleaflet/src/control/Control.ContextMenu.js
@@ -20,7 +20,7 @@ L.Control.ContextMenu = L.Control.extend({
                         * in following list is just for reference and ease of 
locating uno command
                         * from context menu structure.
                         */
-                       general: ['Cut', 'Copy', 'Paste',
+                       general: ['Cut', 'Copy', 'Paste', 'Delete',
                                          'NumberingStart', 
'ContinueNumbering', 'IncrementLevel', 'DecrementLevel',
                                          'OpenHyperlinkOnCursor', 
'CopyHyperlinkLocation', 'RemoveHyperlink',
                                          'AnchorMenu', 'SetAnchorToPage', 
'SetAnchorToPara', 'SetAnchorAtChar',
@@ -104,6 +104,8 @@ L.Control.ContextMenu = L.Control.extend({
                        this._onClosePopup();
                }
 
+               this._amendContextMenuData(obj);
+
                var contextMenu = this._createContextMenuStructure(obj);
                var spellingContextMenu = false;
                for (var menuItem in contextMenu) {
@@ -154,6 +156,27 @@ L.Control.ContextMenu = L.Control.extend({
                }
        },
 
+       _amendContextMenuData: function(obj) {
+
+               // Add a 'delete' entry for mobile when selection is 
ole/image/shape
+               if (this._map._clip && this._map._clip._selectionType === 
'complex' &&
+                       window.mode.isMobile()) {
+
+                       var insertIndex = -1;
+                       obj.menu.forEach(function(item, index) {
+                               if (item.command === '.uno:Paste') {
+                                       insertIndex = index + 1;
+                               }
+                       });
+
+                       if (insertIndex != -1) {
+                               obj.menu.splice(insertIndex, 0,
+                                       { text: _('Delete'), type: 'command', 
command: '.uno:Delete', enabled: true });
+                       }
+               }
+
+       },
+
        _createContextMenuStructure: function(obj) {
                var docType = this._map.getDocType();
                var contextMenu = {};
@@ -205,7 +228,7 @@ L.Control.ContextMenu = L.Control.extend({
                                                item.command = '.uno:HideNote';
                                }
 
-                               if (hasParam || commandName === 'None' || 
commandName === 'FontDialogForParagraph') {
+                               if (hasParam || commandName === 'None' || 
commandName === 'FontDialogForParagraph' || commandName === 'Delete') {
                                        itemName = 
window.removeAccessKey(item.text);
                                        itemName = itemName.replace(' ', 
'\u00a0');
                                } else {
diff --git a/loleaflet/src/unocommands.js b/loleaflet/src/unocommands.js
index 08335e9f1..82a07e0a9 100644
--- a/loleaflet/src/unocommands.js
+++ b/loleaflet/src/unocommands.js
@@ -57,6 +57,7 @@ var unoCommandsArray = {
        DefaultBullet:{global:{context:_('Toggle Bulleted 
List'),menu:_('~Bulleted List'),},},
        DefaultNumbering:{global:{context:_('Toggle Numbered 
List'),menu:_('~Numbered List'),},},
        DelBreakMenu:{spreadsheet:{menu:_('Delete Page ~Break'),},},
+       Delete:{global:{menu:_('Delete 
C~ontents...'),},spreadsheet:{context:_('Cl~ear Contents...'),menu:_('Cle~ar 
Cells...'),},},
        DeleteAllNotes:{global:{menu:_('Delete All 
Comments'),},spreadsheet:{menu:_('Delete All Comments'),},},
        DeleteAuthor:{global:{menu:_('Delete All Comments by This Author'),},},
        DeleteAxis:{global:{menu:_('Delete Axis'),},},
@@ -117,7 +118,6 @@ var unoCommandsArray = {
        FormatYErrorBars:{global:{menu:_('Format Y Error Bars...'),},},
        FormattingMarkMenu:{global:{menu:_('Formatting Mark'),},},
        FullScreen:{global:{menu:_('F~ull Screen'),},},
-       FunctionDialog:{spreadsheet:{menu:_('~Function...'),},},
        GoalSeekDialog:{spreadsheet:{menu:_('~Goal Seek...'),},},
        Group:{global:{menu:_('~Group...'),},},
        GroupOutlineMenu:{spreadsheet:{menu:_('~Group and Outline'),},},
@@ -152,9 +152,6 @@ var unoCommandsArray = {
        InsertDateFieldVar:{presentation:{menu:_('Dat~e (variable)'),},},
        InsertEndnote:{text:{menu:_('~Endnote'),},},
        InsertField:{text:{menu:_('~More Fields...'),},},
-       InsertFieldDateVariable:{spreadsheet:{menu:_('Date'),},},
-       InsertFieldDocTitle:{spreadsheet:{menu:_('Document Title'),},},
-       InsertFieldSheet:{spreadsheet:{menu:_('Sheet Name'),},},
        InsertFileField:{presentation:{menu:_('~File Name'),},},
        InsertFootnote:{text:{menu:_('~Footnote'),},},
        InsertGraphic:{global:{context:_('Insert 
Image...'),menu:_('~Image...'),},},
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to