r103211 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103210‎ | r103211 | r103212 >
Date:19:01, 15 November 2011
Author:tparscal
Status:resolved (Comments)
Tags:
Comment:
Added a "droppable" bit to each model so that prepareRemoval can avoid dropping table cells (for instance) when removing nodes that are completely covered (which it can't do yet)
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.HeadingModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.ListItemModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.ListModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.ParagraphModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.PreModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.TableCellModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.TableModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.TableRowModel.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js
@@ -36,26 +36,37 @@
3737 /**
3838 * Mapping of symbolic names and nesting rules.
3939 *
40 - * Each rule is an object with a parents and children property. Each of these properties may contain
41 - * one of two possible values:
42 - * Array - List of allowed element types (if empty, no elements will be allowed)
43 - * Null - Any element type is allowed (as long as the other element also allows it)
 40+ * Each rule is an object with the follwing properties:
 41+ * parents and children properties may contain one of two possible values:
 42+ * {Array} List symbolic names of allowed element types (if empty, none will be allowed)
 43+ * {Null} Any element type is allowed (as long as the other element also allows it)
 44+ * droppable:
 45+ * {Boolean} Whether the node can be dropped from it's parent (false for table cells)
4446 *
4547 * @example Paragraph rules
4648 * {
4749 * 'parents': null,
48 - * 'children': []
 50+ * 'children': [],
 51+ * 'droppable': true
4952 * }
5053 * @example List rules
5154 * {
5255 * 'parents': null,
53 - * 'children': ['listItem']
 56+ * 'children': ['listItem'],
 57+ * 'droppable': true
5458 * }
5559 * @example ListItem rules
5660 * {
5761 * 'parents': ['list'],
58 - * 'children': []
 62+ * 'children': null,
 63+ * 'droppable': true
5964 * }
 65+ * @example TableCell rules
 66+ * {
 67+ * 'parents': ['tableRow'],
 68+ * 'children': null,
 69+ * 'droppable': false
 70+ * }
6071 */
6172 es.DocumentModel.nodeRules = {};
6273
@@ -862,7 +873,8 @@
863874 /**
864875 * Remove content data only, retaining structure
865876 *
866 - * TODO: Nodes that are completely covered should be dropped, not stripped
 877+ * TODO: Nodes that are completely covered and are droppable should be dropped, not stripped
 878+ * @see {es.DocumentModel.nodeRules} for obtaining the 'droppable' bit for a given node
867879 *
868880 * @param {es.Range} range Range of data to delete
869881 * @param {es.Transaction} tx Transaction to push to
Index: trunk/extensions/VisualEditor/modules/es/models/es.HeadingModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.heading = {
3333 'parents': null,
34 - 'children': []
 34+ 'children': [],
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.TableRowModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.listItem = {
3333 'parents': ['table'],
34 - 'children': ['tableCell']
 34+ 'children': ['tableCell'],
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.ParagraphModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.paragraph = {
3333 'parents': null,
34 - 'children': []
 34+ 'children': [],
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.PreModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.pre = {
3333 'parents': null,
34 - 'children': []
 34+ 'children': [],
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.TableCellModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.listItem = {
3333 'parents': ['tableRow'],
34 - 'children': null
 34+ 'children': null,
 35+ 'droppable': false
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.TableModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.table = {
3333 'parents': null,
34 - 'children': ['tableRow']
 34+ 'children': ['tableRow'],
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.ListItemModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.listItem = {
3333 'parents': ['list'],
34 - 'children': ['paragraph', 'table']
 34+ 'children': null,
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */
Index: trunk/extensions/VisualEditor/modules/es/models/es.ListModel.js
@@ -30,7 +30,8 @@
3131
3232 es.DocumentModel.nodeRules.list = {
3333 'parents': null,
34 - 'children': ['listItem']
 34+ 'children': ['listItem'],
 35+ 'droppable': true
3536 };
3637
3738 /* Inheritance */

Follow-up revisions

RevisionCommit summaryAuthorDate
r103345Fixed incorrect symbolic name being used for nodeRules registration on tableC...tparscal18:17, 16 November 2011
r103359Drop droppable (oh, how meta!) attribute introduced in r103211. Will convert ...catrope19:28, 16 November 2011

Comments

#Comment by Catrope (talk | contribs)   12:01, 16 November 2011
Index: trunk/extensions/VisualEditor/modules/es/models/es.TableCellModel.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/models/es.TableCellModel.js	(revision 103210)
+++ trunk/extensions/VisualEditor/modules/es/models/es.TableCellModel.js	(revision 103211)
@@ -30,7 +30,8 @@

 es.DocumentModel.nodeRules.listItem = {
 	'parents': ['tableRow'],
-	'children': null
+	'children': null,
+	'droppable': false
 };

listItem?!?!?!?!?

Status & tagging log