Bartosz Dziewoński has uploaded a new change for review.

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

Change subject: Show non-breaking spaces in the editor
......................................................................

Show non-breaking spaces in the editor

MWEntityNode representing   is now displayed with a light
grey background and has a tooltip explaining that this is a
non-breaking space and not a random grey blotch.

This is not done for TextNode (in core VisualEditor), as that doesn't
actually work: Parsoid converts all   in input to regular spaces.

It's still not easily possible to insert a non-breaking space.

Bug: T96666
Change-Id: Icbdf7cc3e5d675b199d08777a3439dc5dedceac1
---
M extension.json
M modules/ve-mw/ce/nodes/ve.ce.MWEntityNode.js
A modules/ve-mw/ce/styles/nodes/ve.ce.MWEntityNode.css
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
5 files changed, 25 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/36/255936/1

diff --git a/extension.json b/extension.json
index 18fdfc1..f82ec22 100644
--- a/extension.json
+++ b/extension.json
@@ -1041,6 +1041,7 @@
                                
"modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js"
                        ],
                        "styles": [
+                               
"modules/ve-mw/ce/styles/nodes/ve.ce.MWEntityNode.css",
                                
"modules/ve-mw/ui/styles/inspectors/ve.ui.MWExtensionInspector.css",
                                
"modules/ve-mw/ui/styles/inspectors/ve.ui.MWLiveExtensionInspector.css",
                                
"modules/ve-mw/ui/styles/dialogs/ve.ui.MWWelcomeDialog.css",
@@ -1123,6 +1124,7 @@
                                "visualeditor-toolbar-cite-label",
                                "visualeditor-toolbar-savedialog",
                                "visualeditor-toolbar-savedialog-short",
+                               "visualeditor-tooltip-non-breaking-space",
                                "visualeditor-version-label",
                                "visualeditor-viewpage-savewarning",
                                "visualeditor-viewpage-savewarning-discard",
diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWEntityNode.js 
b/modules/ve-mw/ce/nodes/ve.ce.MWEntityNode.js
index a7cd225..8459cb9 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWEntityNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWEntityNode.js
@@ -50,6 +50,16 @@
                chr = this.model.getAttribute( 'character' ),
                whitespaceHtmlChars = ve.ce.TextNode.whitespaceHtmlCharacters,
                significantWhitespace = 
this.getModel().getParent().hasSignificantWhitespace();
+       if ( chr === '\u00a0' ) {
+               //   non-breaking space
+               this.$element
+                       .addClass( 've-ce-mwEntityNode-nbsp' )
+                       .attr( 'title', mw.msg( 
'visualeditor-tooltip-non-breaking-space' ) );
+       } else {
+               this.$element
+                       .removeClass( 've-ce-mwEntityNode-nbsp' )
+                       .removeAttr( 'title' );
+       }
        if ( !significantWhitespace && Object.prototype.hasOwnProperty.call( 
whitespaceHtmlChars, chr ) ) {
                chr = whitespaceHtmlChars[ chr ];
        }
diff --git a/modules/ve-mw/ce/styles/nodes/ve.ce.MWEntityNode.css 
b/modules/ve-mw/ce/styles/nodes/ve.ce.MWEntityNode.css
new file mode 100644
index 0000000..ad843d1
--- /dev/null
+++ b/modules/ve-mw/ce/styles/nodes/ve.ce.MWEntityNode.css
@@ -0,0 +1,11 @@
+/*!
+ * VisualEditor ContentEditable MediaWiki MWEntityNode styles.
+ *
+ * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+.ve-ce-mwEntityNode-nbsp {
+       background-color: #ccc;
+       cursor: help;
+}
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index 7937666..1e98283 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -332,6 +332,7 @@
        "visualeditor-toolbar-cite-label": "Cite",
        "visualeditor-toolbar-savedialog": "Save page",
        "visualeditor-toolbar-savedialog-short": "Save",
+       "visualeditor-tooltip-non-breaking-space": "Non-breaking space",
        "visualeditor-usernamespacepagelink": "Project:User namespace",
        "visualeditor-version-label": "Version",
        "visualeditor-viewpage-savewarning": "Are you sure you want to go back 
to view mode without saving first?",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index 946fa8e..dd69876 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -343,6 +343,7 @@
        "visualeditor-toolbar-savedialog": "Label text for button to open save 
dialog.\n\nUsed in:\n* 
{{msg-mw|Guidedtour-tour-gettingstartedtasktoolbarve-click-save-description}}.\n{{Identical|Save
 page}}",
        "visualeditor-toolbar-savedialog-short": "Short label text for button 
to open save dialog on width-restricted devices\n{{Identical|Save}}",
        "visualeditor-usernamespacepagelink": "Name of a page describing the 
user namespace (NS2) in this project.\n{{doc-important|Do not translate 
\"Project\"; it is automatically converted to the wiki's project namespace.}}",
+       "visualeditor-tooltip-non-breaking-space": "Tooltip shown on the 
editing surface when a non-breaking space (<nowiki>&nbsp;</nowiki>) is 
inserted.",
        "visualeditor-version-label": "Label text for version 
number\n{{Identical|Version}}",
        "visualeditor-viewpage-savewarning": "Text shown when the user tries to 
leave the editor without saving their changes.\n\nFollowed by the following 
buttons:\n* {{msg-mw|Visualeditor-viewpage-savewarning-discard}}\n* 
{{msg-mw|Visualeditor-viewpage-savewarning-keep}}",
        "visualeditor-viewpage-savewarning-discard": "Text shown on the button 
which closes VE and discards changes when the user confirms that they want to 
leave the editor.\n\nPreceded by the prompt 
{{msg-mw|Visualeditor-viewpage-savewarning}}.\n\nFollowed by the button 
{{msg-mw|Visualeditor-viewpage-savewarning-keep}}.",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbdf7cc3e5d675b199d08777a3439dc5dedceac1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to