https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113095
Revision: 113095
Author: rmoen
Date: 2012-03-05 22:08:35 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
enable CE demo toolbar, added annnotation and renderDomNode methods
Modified Paths:
--------------
trunk/extensions/VisualEditor/demos/ce/main.js
trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
trunk/extensions/VisualEditor/modules/ve/ui/tools/ve.ui.FormatDropdownTool.js
Modified: trunk/extensions/VisualEditor/demos/ce/main.js
===================================================================
--- trunk/extensions/VisualEditor/demos/ce/main.js 2012-03-05 21:58:10 UTC
(rev 113094)
+++ trunk/extensions/VisualEditor/demos/ce/main.js 2012-03-05 22:08:35 UTC
(rev 113095)
@@ -473,7 +473,7 @@
window.documentModel = ve.dm.DocumentNode.newFromPlainObject(
wikidoms['Wikipedia article'] );
window.surfaceModel = new ve.dm.Surface( window.documentModel );
window.surfaceView = new ve.es.Surface( $( '#es-editor' ),
window.surfaceModel );
- window.toolbarView = new ve.ui.Toolbar( $( '#es-toolbar' ),
window.surfaceView, [] );
+ window.toolbarView = new ve.ui.Toolbar( $( '#es-toolbar' ),
window.surfaceView );
window.contextView = new ve.ui.Context( window.surfaceView );
window.surfaceModel.select( new ve.Range( 1, 1 ) );
Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
2012-03-05 21:58:10 UTC (rev 113094)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
2012-03-05 22:08:35 UTC (rev 113095)
@@ -81,6 +81,36 @@
/* Methods */
+ve.es.Surface.prototype.annotate = function( method, annotation ) {
+ var range = this.getSelection();
+ if ( method === 'toggle' ) {
+ var annotations = this.getAnnotations();
+ if ( ve.dm.DocumentNode.getIndexOfAnnotation( annotations.full,
annotation ) !== -1 ) {
+ method = 'clear';
+ } else {
+ method = 'set';
+ }
+ }
+ if ( range.getLength() ) {
+ var tx = this.model.getDocument().prepareContentAnnotation(
+ range, method, annotation
+ );
+ this.model.transact( tx );
+ // re-render Node
+ this.renderDomNode ( rangy.getSelection().anchorNode );
+ } else {
+ if ( method === 'set' ) {
+ this.addInsertionAnnotation( annotation );
+ } else if ( method === 'clear' ) {
+ this.removeInsertionAnnotation( annotation );
+ }
+ }
+};
+
+ve.es.Surface.prototype.renderDomNode = function ( node ) {
+ this.getLeafNode( node ).data( 'view' ).renderContent();
+};
+
ve.es.Surface.prototype.onCutCopy = function( e ) {
var _this = this,
rangySel = rangy.getSelection(),
Modified:
trunk/extensions/VisualEditor/modules/ve/ui/tools/ve.ui.FormatDropdownTool.js
===================================================================
---
trunk/extensions/VisualEditor/modules/ve/ui/tools/ve.ui.FormatDropdownTool.js
2012-03-05 21:58:10 UTC (rev 113094)
+++
trunk/extensions/VisualEditor/modules/ve/ui/tools/ve.ui.FormatDropdownTool.js
2012-03-05 22:08:35 UTC (rev 113095)
@@ -11,7 +11,7 @@
ve.FormatDropdownTool = function( toolbar, name, title ) {
// Inheritance
ve.ui.DropdownTool.call( this, toolbar, name, title, [
- {
+ {
'name': 'paragraph',
'label': 'Paragraph',
'type' : 'paragraph'
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs