mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 17:18:41 +00:00
9c74c97808
ve.dm.SurfaceFragment * Removed flawed implementation of word mode for expandRange method and made use of new getNearestWordBoundary method in the document model ve.dm.Surface * Got rid of useInsertionAnnotations, which allowed disabling and enabling of insertion annotations - this isn't needed anymore because it was just a dirty hack around the improper starting and stopping of surface observer that's now solved more elegantly by emitting lock and unlock before committing or rolling back transactions * Get annotations from the first character of the selection if the selection is not collapsed * Only emit annotationChange events if it really changed ve.dm.Document * Added getNearestWordBoundary method which performs the work behind the surface fragment expandRange word method ve.ce.SurfaceObserver * Allow using an initial selection to avoid the observer thinking the selection has changed just because it started out with null * Only emit selectionChange event if there was a meaningful change ve.ce.Surface * (bug 42279) Only annotate characters if insertion annotations are not empty * Remove manual locking and unlocking, this is now done inside the change method of surface model * Provide an initial selection to surface observer when we clear it * Remove enabling and disabling of insertionAnnotations, this isn't needed anymore * Stop/start observer on key presses that execute actions as well as those that have no special handling ve.ce.Document * Make getNodeFromOffsetand getSlugAtOffset return null when given -1 as an offset Change-Id: Ibf6b26de299e54ae8688a2653bf5d5538927f8c3
42 lines
1,001 B
JavaScript
42 lines
1,001 B
JavaScript
/**
|
|
* VisualEditor content editable Document class.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable document.
|
|
*
|
|
* @class
|
|
* @extends {ve.Document}
|
|
* @constructor
|
|
* @param {ve.dm.Document} model Model to observe
|
|
*/
|
|
ve.ce.Document = function VeCeDocument( model, surface ) {
|
|
// Parent constructor
|
|
ve.Document.call( this, new ve.ce.DocumentNode( model.getDocumentNode(), surface ) );
|
|
|
|
// Properties
|
|
this.model = model;
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ce.Document, ve.Document );
|
|
|
|
/* Methods */
|
|
|
|
ve.ce.Document.prototype.getNodeFromOffset = function ( offset ) {
|
|
var node = this.documentNode.getNodeFromOffset( offset );
|
|
if ( node && !node.canHaveChildren() ) {
|
|
node = node.getParent();
|
|
}
|
|
return node;
|
|
};
|
|
|
|
ve.ce.Document.prototype.getSlugAtOffset = function ( offset ) {
|
|
var node = this.getNodeFromOffset( offset );
|
|
return node ? node.getSlugAtOffset( offset ) : null;
|
|
};
|