Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1x 3309x 3309x 3309x 1x 1x 328x 1x 3324x 3324x 26x 3298x 295x 3x 3295x 1x 3018x | /*! * VisualEditor annotated text content state chunk class * * @copyright See AUTHORS.txt */ /** * Uniformly annotated chunk of text content * * @class * * @constructor * @param {string} text Plain text * @param {HTMLElement[]} elements Annotation elements in force * @param {string} type If this is a unicorn then 'unicorn', else 'text' */ ve.ce.TextStateChunk = function VeCeTextStateChunk( text, elements, type ) { /** * @property {string} text The plain text of this chunk */ this.text = text; /** * @property {HTMLElement[]} elements The annotation elements open at this chunk */ this.elements = elements; /** * @property {string} type The chunk type: 'text' or 'unicorn' */ this.type = type; }; /* Inheritance */ OO.initClass( ve.ce.TextStateChunk ); /* Static methods */ /** * Test whether two elements are equal as annotations. * TODO: Improve this test. Currently annotations are compared by tag name and * certain attributes, which results in a stricter test than that of * ve.dm.ModelRegistry#matchElement . That is, a element pair that tests unequal * here might still both match the same ve.dm.Annotation object. * * @static * @param {HTMLElement} element1 An annotation element * @param {HTMLElement} element2 Another annotation element * @return {boolean} True if the elements are equal as annotations */ ve.ce.TextStateChunk.static.compareElements = function ( element1, element2 ) { return element1 === element2 || ( element1.nodeName === element2.nodeName && element1.getAttribute( 'class' ) === element2.getAttribute( 'class' ) && element1.getAttribute( 'typeof' ) === element2.getAttribute( 'typeof' ) && element1.getAttribute( 'property' ) === element2.getAttribute( 'property' ) && element1.getAttribute( 'href' ) === element2.getAttribute( 'href' ) ); }; /* Methods */ /** * Test whether this chunk has the same annotations (in order) as another * * @param {ve.ce.TextStateChunk} other The other chunk * @return {boolean} True if the chunks have the same annotations */ ve.ce.TextStateChunk.prototype.hasEqualElements = function ( other ) { Iif ( this.elements === other.elements ) { return true; } if ( this.elements.length !== other.elements.length ) { return false; } for ( let i = 0, len = this.elements.length; i < len; i++ ) { if ( !this.constructor.static.compareElements( this.elements[ i ], other.elements[ i ] ) ) { return false; } } return true; }; /** * Test whether this chunk is equal to another chunk in both elements and text. * * @param {ve.ce.TextStateChunk} other The other chunk * @return {boolean} True if the chunks are equal */ ve.ce.TextStateChunk.prototype.isEqual = function ( other ) { return this.text === other.text && this.type === other.type && this.hasEqualElements( other ); }; |