Index: trunk/extensions/VisualEditor/demo/es.js |
— | — | @@ -3,6 +3,10 @@ |
4 | 4 | 'type': 'document', |
5 | 5 | 'children': [ |
6 | 6 | { |
| 7 | + 'type': 'pre', |
| 8 | + 'content': { 'text': 'A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps..' } |
| 9 | + }, |
| 10 | + { |
7 | 11 | 'type': 'heading', |
8 | 12 | 'attributes': { 'level': 1 }, |
9 | 13 | 'content': { |
Index: trunk/extensions/VisualEditor/demo/index.html |
— | — | @@ -81,6 +81,7 @@ |
82 | 82 | <script src="../modules/es/models/es.SurfaceModel.js"></script> |
83 | 83 | <script src="../modules/es/models/es.DocumentModel.js"></script> |
84 | 84 | <script src="../modules/es/models/es.ParagraphModel.js"></script> |
| 85 | + <script src="../modules/es/models/es.PreModel.js"></script> |
85 | 86 | <script src="../modules/es/models/es.ListModel.js"></script> |
86 | 87 | <script src="../modules/es/models/es.ListItemModel.js"></script> |
87 | 88 | <script src="../modules/es/models/es.TableModel.js"></script> |
— | — | @@ -93,6 +94,7 @@ |
94 | 95 | <script src="../modules/es/views/es.ContentView.js"></script> |
95 | 96 | <script src="../modules/es/views/es.DocumentView.js"></script> |
96 | 97 | <script src="../modules/es/views/es.ParagraphView.js"></script> |
| 98 | + <script src="../modules/es/views/es.PreView.js"></script> |
97 | 99 | <script src="../modules/es/views/es.ListView.js"></script> |
98 | 100 | <script src="../modules/es/views/es.ListItemView.js"></script> |
99 | 101 | <script src="../modules/es/views/es.TableView.js"></script> |
Index: trunk/extensions/VisualEditor/modules/es/models/es.PreModel.js |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +/**
|
| 3 | + * Creates an es.PreModel object.
|
| 4 | + *
|
| 5 | + * @class
|
| 6 | + * @constructor
|
| 7 | + * @extends {es.DocumentModelLeafNode}
|
| 8 | + * @param {Object} element Document data element of this node
|
| 9 | + * @param {Integer} length Length of document data element
|
| 10 | + */
|
| 11 | +es.PreModel = function( element, length ) {
|
| 12 | + // Inheritance
|
| 13 | + es.DocumentModelLeafNode.call( this, 'pre', element, length );
|
| 14 | +};
|
| 15 | +
|
| 16 | +/* Methods */
|
| 17 | +
|
| 18 | +/**
|
| 19 | + * Creates a pre view for this model.
|
| 20 | + *
|
| 21 | + * @method
|
| 22 | + * @returns {es.PreView}
|
| 23 | + */
|
| 24 | +es.PreModel.prototype.createView = function() {
|
| 25 | + return new es.PreView( this );
|
| 26 | +};
|
| 27 | +
|
| 28 | +/* Registration */
|
| 29 | +
|
| 30 | +es.DocumentModel.nodeModels.pre = es.PreModel;
|
| 31 | +
|
| 32 | +es.DocumentModel.nodeRules.pre = {
|
| 33 | + 'parents': null,
|
| 34 | + 'children': []
|
| 35 | +};
|
| 36 | +
|
| 37 | +/* Inheritance */
|
| 38 | +
|
| 39 | +es.extendClass( es.PreModel, es.DocumentModelLeafNode );
|
Index: trunk/extensions/VisualEditor/modules/es/es.Surface.css |
— | — | @@ -41,6 +41,7 @@ |
42 | 42 | .es-headingView, |
43 | 43 | .es-tableView, |
44 | 44 | .es-listView, |
| 45 | +.es-preView, |
45 | 46 | .es-paragraphView { |
46 | 47 | margin: 1em; |
47 | 48 | margin-top: 0; |
— | — | @@ -57,6 +58,14 @@ |
58 | 59 | margin: 0; |
59 | 60 | } |
60 | 61 | |
| 62 | +.es-preView { |
| 63 | + padding: 1em; |
| 64 | + border: 1px dashed #2F6FAB; |
| 65 | +} |
| 66 | +.es-preView > * { |
| 67 | + font-family: monospace,"Courier New"; |
| 68 | +} |
| 69 | + |
61 | 70 | .es-headingView-level1, |
62 | 71 | .es-headingView-level2 { |
63 | 72 | border-bottom: 1px solid #AAA; |
Index: trunk/extensions/VisualEditor/modules/es/views/es.PreView.js |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +/**
|
| 3 | + * Creates an es.PreView object.
|
| 4 | + *
|
| 5 | + * @class
|
| 6 | + * @constructor
|
| 7 | + * @extends {es.DocumentViewLeafNode}
|
| 8 | + * @param {es.PreModel} model Pre model to view
|
| 9 | + */
|
| 10 | +es.PreView = function( model ) {
|
| 11 | + // Inheritance
|
| 12 | + es.DocumentViewLeafNode.call( this, model );
|
| 13 | +
|
| 14 | + // DOM Changes
|
| 15 | + this.$.addClass( 'es-preView' );
|
| 16 | +};
|
| 17 | +
|
| 18 | +/* Inheritance */
|
| 19 | +
|
| 20 | +es.extendClass( es.PreView, es.DocumentViewLeafNode );
|