Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/230397

Change subject: Provide a context item for table cells in mobile
......................................................................

Provide a context item for table cells in mobile

Mobile doesn't provide double click or an enter key, which
desktop uses for editing table cells, so provide a context
item intead so the user can tap 'edit'.

Bug: T108514
Change-Id: Iaec408d195de4975a275130ef6da3f2d7b0ec126
---
M build/modules.json
M demos/ve/mobile.html
M i18n/en.json
M i18n/qqq.json
M src/ui/actions/ve.ui.TableAction.js
M src/ui/ve.ui.CommandRegistry.js
6 files changed, 29 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/97/230397/1

diff --git a/build/modules.json b/build/modules.json
index bdf0329..ef31e26 100644
--- a/build/modules.json
+++ b/build/modules.json
@@ -649,6 +649,7 @@
                "scripts": [
                        "src/ui/ve.ui.MobileSurface.js",
                        "src/ui/contexts/ve.ui.MobileContext.js",
+                       
"src/ui/contextitems/ve.ui.MobileTableCellContextItem.js",
                        "src/ui/windowmanagers/ve.ui.MobileWindowManager.js"
                ],
                "styles": [
diff --git a/demos/ve/mobile.html b/demos/ve/mobile.html
index dec36cf..689fbe3 100644
--- a/demos/ve/mobile.html
+++ b/demos/ve/mobile.html
@@ -422,6 +422,7 @@
                <!-- visualEditor.mobile.build -->
                <script src="../../src/ui/ve.ui.MobileSurface.js"></script>
                <script 
src="../../src/ui/contexts/ve.ui.MobileContext.js"></script>
+               <script 
src="../../src/ui/contextitems/ve.ui.MobileTableCellContextItem.js"></script>
                <script 
src="../../src/ui/windowmanagers/ve.ui.MobileWindowManager.js"></script>
 
                <script>
diff --git a/i18n/en.json b/i18n/en.json
index 2b469be..fe5bede 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -125,6 +125,7 @@
        "visualeditor-table-insert-table": "Table",
        "visualeditor-table-merge-cells": "Merge cells",
        "visualeditor-tablecell-tooltip": "Double click to edit cell",
+       "visualeditor-tablecell-contextitem": "Table cell",
        "visualeditor-toolbar-format-tooltip": "Format paragraph",
        "visualeditor-toolbar-history": "History",
        "visualeditor-toolbar-insert": "Insert",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index bb2eb0a..2f24134 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -132,6 +132,7 @@
        "visualeditor-table-insert-table": "Label for table insertion menu in 
the toolbar, for inserting parts of a 
table\n{{Identical|Table}}\n{{related|Visualeditor-table-insert}}",
        "visualeditor-table-merge-cells": "Label for merge cells tool",
        "visualeditor-tablecell-tooltip": "Tooltip rendered while hovering a 
table cell",
+       "visualeditor-tablecell-contextitem": "Context item title for a table 
cell",
        "visualeditor-toolbar-format-tooltip": "Tooltip text for the paragraph 
formatting menu which contains the following items:\n* 
{{msg-mw|Visualeditor-formatdropdown-format-paragraph}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-mw-heading1}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-mw-heading2}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-mw-heading3}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-mw-heading4}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-mw-heading5}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-mw-heading6}}\n* 
{{msg-mw|Visualeditor-formatdropdown-format-preformatted}}",
        "visualeditor-toolbar-history": "Label text for the 'history' menu in 
the toolbar of the undo and redo tools.\n\nSee also:\n* 
{{msg-mw|visualeditor-toolbar-insert}}\n* 
{{msg-mw|visualeditor-toolbar-paragraph-format}}\n* 
{{msg-mw|visualeditor-toolbar-structure}}\n* 
{{msg-mw|visualeditor-toolbar-text-style}}\n{{Identical|History}}",
        "visualeditor-toolbar-insert": "Label text for the 'insert' menu in the 
toolbar of tools that let you add items, like images.\n\nSee also:\n* 
{{msg-mw|visualeditor-toolbar-history}}\n* 
{{msg-mw|visualeditor-toolbar-paragraph-format}}\n* 
{{msg-mw|visualeditor-toolbar-structure}}\n* 
{{msg-mw|visualeditor-toolbar-text-style}}\n{{Identical|Insert}}",
diff --git a/src/ui/actions/ve.ui.TableAction.js 
b/src/ui/actions/ve.ui.TableAction.js
index b437866..5ae455a 100644
--- a/src/ui/actions/ve.ui.TableAction.js
+++ b/src/ui/actions/ve.ui.TableAction.js
@@ -33,7 +33,7 @@
  * @static
  * @property
  */
-ve.ui.TableAction.static.methods = [ 'create', 'insert', 'delete', 
'changeCellStyle', 'mergeCells', 'caption' ];
+ve.ui.TableAction.static.methods = [ 'create', 'insert', 'delete', 
'changeCellStyle', 'mergeCells', 'caption', 'enterTableCell' ];
 
 /* Methods */
 
@@ -328,6 +328,24 @@
        return true;
 };
 
+/**
+ * Enter a table cell for editing
+ *
+ * @return {boolean} Action was executed
+ */
+ve.ui.TableAction.prototype.enterTableCell = function () {
+       var tableNode,
+               selection = this.surface.getModel().getSelection();
+
+       if ( !( selection instanceof ve.dm.TableSelection ) ) {
+               return false;
+       }
+       tableNode = 
this.surface.getView().documentView.getBranchNodeFromOffset( 
selection.tableRange.start + 1 );
+       tableNode.setEditing( true );
+       this.surface.getView().focus();
+       return true;
+};
+
 /* Low-level API */
 // TODO: This API does only depends on the model so it should possibly be moved
 
diff --git a/src/ui/ve.ui.CommandRegistry.js b/src/ui/ve.ui.CommandRegistry.js
index 8b551b1..38d5d37 100644
--- a/src/ui/ve.ui.CommandRegistry.js
+++ b/src/ui/ve.ui.CommandRegistry.js
@@ -298,3 +298,9 @@
                { args: [ 'data' ], supportedSelections: [ 'table' ] }
        )
 );
+ve.ui.commandRegistry.register(
+       new ve.ui.Command(
+               'enterTableCell', 'table', 'enterTableCell',
+               { supportedSelections: [ 'table' ] }
+       )
+);

-- 
To view, visit https://gerrit.wikimedia.org/r/230397
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaec408d195de4975a275130ef6da3f2d7b0ec126
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to