Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60940
Change subject: Add TableCaptionNode
......................................................................
Add TableCaptionNode
Because we have a node for <table>, we also need one for <caption>,
otherwise we'll try to alienate it and fail.
Change-Id: I3a917db58e6c0eb97899b214b07d01fc8d86b56d
---
M VisualEditor.php
M demos/ve/index.php
A modules/ve/dm/nodes/ve.dm.TableCaptionNode.js
M modules/ve/test/dm/ve.dm.example.js
M modules/ve/test/index.php
5 files changed, 97 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/40/60940/1
diff --git a/VisualEditor.php b/VisualEditor.php
index df34f48..d95f0ff 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -270,6 +270,7 @@
've/dm/nodes/ve.dm.ListNode.js',
've/dm/nodes/ve.dm.ParagraphNode.js',
've/dm/nodes/ve.dm.PreformattedNode.js',
+ 've/dm/nodes/ve.dm.TableCaptionNode.js',
've/dm/nodes/ve.dm.TableCellNode.js',
've/dm/nodes/ve.dm.TableNode.js',
've/dm/nodes/ve.dm.TableRowNode.js',
diff --git a/demos/ve/index.php b/demos/ve/index.php
index 712a94b..9c2c606 100644
--- a/demos/ve/index.php
+++ b/demos/ve/index.php
@@ -155,6 +155,7 @@
<script
src="../../modules/ve/dm/nodes/ve.dm.ListNode.js"></script>
<script
src="../../modules/ve/dm/nodes/ve.dm.ParagraphNode.js"></script>
<script
src="../../modules/ve/dm/nodes/ve.dm.PreformattedNode.js"></script>
+ <script
src="../../modules/ve/dm/nodes/ve.dm.TableCaptionNode.js"></script>
<script
src="../../modules/ve/dm/nodes/ve.dm.TableCellNode.js"></script>
<script
src="../../modules/ve/dm/nodes/ve.dm.TableNode.js"></script>
<script
src="../../modules/ve/dm/nodes/ve.dm.TableRowNode.js"></script>
diff --git a/modules/ve/dm/nodes/ve.dm.TableCaptionNode.js
b/modules/ve/dm/nodes/ve.dm.TableCaptionNode.js
new file mode 100644
index 0000000..0ec55a2
--- /dev/null
+++ b/modules/ve/dm/nodes/ve.dm.TableCaptionNode.js
@@ -0,0 +1,44 @@
+/*!
+ * VisualEditor DataModel TableCaptionNode class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * DataModel table caption node.
+ *
+ * @class
+ * @extends ve.dm.BranchNode
+ * @constructor
+ * @param {ve.dm.BranchNode[]} [children] Child nodes to attach
+ * @param {Object} [element] Reference to element in linear model
+ */
+ve.dm.TableCaptionNode = function VeDmTableCaptionNode( children, element ) {
+ // Parent constructor
+ ve.dm.BranchNode.call( this, children, element );
+};
+
+/* Inheritance */
+
+ve.inheritClass( ve.dm.TableCaptionNode, ve.dm.BranchNode );
+
+/* Static Properties */
+
+ve.dm.TableCaptionNode.static.name = 'tableCaption';
+
+ve.dm.TableCaptionNode.static.parentNodeTypes = [ 'table' ];
+
+ve.dm.TableCaptionNode.static.matchTagNames = [ 'caption' ];
+
+ve.dm.TableCaptionNode.static.toDataElement = function () {
+ return { 'type': 'tableCaption' };
+};
+
+ve.dm.TableCaptionNode.static.toDomElements = function ( dataElement, doc ) {
+ return [ doc.createElement( 'caption' ) ];
+};
+
+/* Registration */
+
+ve.dm.modelRegistry.register( ve.dm.TableCaptionNode );
diff --git a/modules/ve/test/dm/ve.dm.example.js
b/modules/ve/test/dm/ve.dm.example.js
index 987a253..1377351 100644
--- a/modules/ve/test/dm/ve.dm.example.js
+++ b/modules/ve/test/dm/ve.dm.example.js
@@ -2409,6 +2409,56 @@
{ 'type': '/tableSection' },
{ 'type': '/table' }
]
+ },
+ 'table with caption, head, foot and body': {
+ 'html':
'<table><caption>Foo</caption><thead><tr><th>Bar</th></tr></thead><tfoot><tr><td>Quux</td></tr></tfoot>'
+
+ '<tbody><tr><td>Whee</td></tr></tbody></table>',
+ 'data': [
+ { 'type': 'table' },
+ { 'type': 'tableCaption' },
+ { 'type': 'paragraph', 'internal': { 'generated':
'wrapper' } },
+ 'F',
+ 'o',
+ 'o',
+ { 'type': '/paragraph' },
+ { 'type': '/tableCaption' },
+ { 'type': 'tableSection', 'attributes': { 'style':
'header' } },
+ { 'type': 'tableRow' },
+ { 'type': 'tableCell', 'attributes': { 'style':
'header' } },
+ { 'type': 'paragraph', 'internal': { 'generated':
'wrapper' } },
+ 'B',
+ 'a',
+ 'r',
+ { 'type': '/paragraph' },
+ { 'type': '/tableCell' },
+ { 'type': '/tableRow' },
+ { 'type': '/tableSection' },
+ { 'type': 'tableSection', 'attributes': { 'style':
'footer' } },
+ { 'type': 'tableRow' },
+ { 'type': 'tableCell', 'attributes': { 'style': 'data'
} },
+ { 'type': 'paragraph', 'internal': { 'generated':
'wrapper' } },
+ 'Q',
+ 'u',
+ 'u',
+ 'x',
+ { 'type': '/paragraph' },
+ { 'type': '/tableCell' },
+ { 'type': '/tableRow' },
+ { 'type': '/tableSection' },
+ { 'type': 'tableSection', 'attributes': { 'style':
'body' } },
+ { 'type': 'tableRow' },
+ { 'type': 'tableCell', 'attributes': { 'style': 'data'
} },
+ { 'type': 'paragraph', 'internal': { 'generated':
'wrapper' } },
+ 'W',
+ 'h',
+ 'e',
+ 'e',
+ { 'type': '/paragraph' },
+ { 'type': '/tableCell' },
+ { 'type': '/tableRow' },
+ { 'type': '/tableSection' },
+ { 'type': '/table' }
+ ]
}
};
diff --git a/modules/ve/test/index.php b/modules/ve/test/index.php
index 84eb40b..d755d9f 100644
--- a/modules/ve/test/index.php
+++ b/modules/ve/test/index.php
@@ -98,6 +98,7 @@
<script src="../../ve/dm/nodes/ve.dm.ListNode.js"></script>
<script src="../../ve/dm/nodes/ve.dm.ParagraphNode.js"></script>
<script
src="../../ve/dm/nodes/ve.dm.PreformattedNode.js"></script>
+ <script
src="../../ve/dm/nodes/ve.dm.TableCaptionNode.js"></script>
<script src="../../ve/dm/nodes/ve.dm.TableCellNode.js"></script>
<script src="../../ve/dm/nodes/ve.dm.TableNode.js"></script>
<script src="../../ve/dm/nodes/ve.dm.TableRowNode.js"></script>
--
To view, visit https://gerrit.wikimedia.org/r/60940
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a917db58e6c0eb97899b214b07d01fc8d86b56d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits