How to use Annotation method in wpt

Best JavaScript code snippet using wpt

ve.ui.AnnotationTool.js

Source:ve.ui.AnnotationTool.js Github

copy

Full Screen

1/*!2 * VisualEditor UserInterface AnnotationTool classes.3 *4 * @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org5 */6/**7 * UserInterface annotation tool.8 *9 * @class10 * @abstract11 * @extends ve.ui.Tool12 * @constructor13 * @param {OO.ui.ToolGroup} toolGroup14 * @param {Object} [config] Configuration options15 */16ve.ui.AnnotationTool = function VeUiAnnotationTool() {17 // Parent constructor18 ve.ui.AnnotationTool.super.apply( this, arguments );19};20/* Inheritance */21OO.inheritClass( ve.ui.AnnotationTool, ve.ui.Tool );22/* Static Properties */23/**24 * Annotation name and data the tool applies.25 *26 * @abstract27 * @static28 * @property {Object}29 * @inheritable30 */31ve.ui.AnnotationTool.static.annotation = { name: '' };32ve.ui.AnnotationTool.static.deactivateOnSelect = false;33/* Methods */34/**35 * @inheritdoc36 */37ve.ui.AnnotationTool.prototype.onUpdateState = function ( fragment ) {38 // Parent method39 ve.ui.AnnotationTool.super.prototype.onUpdateState.apply( this, arguments );40 this.setActive(41 fragment && fragment.getAnnotations().hasAnnotationWithName( this.constructor.static.annotation.name )42 );43};44/**45 * UserInterface bold tool.46 *47 * @class48 * @extends ve.ui.AnnotationTool49 * @constructor50 * @param {OO.ui.ToolGroup} toolGroup51 * @param {Object} [config] Configuration options52 */53ve.ui.BoldAnnotationTool = function VeUiBoldAnnotationTool() {54 ve.ui.BoldAnnotationTool.super.apply( this, arguments );55};56OO.inheritClass( ve.ui.BoldAnnotationTool, ve.ui.AnnotationTool );57ve.ui.BoldAnnotationTool.static.name = 'bold';58ve.ui.BoldAnnotationTool.static.group = 'textStyle';59ve.ui.BoldAnnotationTool.static.icon = 'bold';60ve.ui.BoldAnnotationTool.static.title =61 OO.ui.deferMsg( 'visualeditor-annotationbutton-bold-tooltip' );62ve.ui.BoldAnnotationTool.static.annotation = { name: 'textStyle/bold' };63ve.ui.BoldAnnotationTool.static.commandName = 'bold';64ve.ui.toolFactory.register( ve.ui.BoldAnnotationTool );65/**66 * UserInterface italic tool.67 *68 * @class69 * @extends ve.ui.AnnotationTool70 * @constructor71 * @param {OO.ui.ToolGroup} toolGroup72 * @param {Object} [config] Configuration options73 */74ve.ui.ItalicAnnotationTool = function VeUiItalicAnnotationTool() {75 ve.ui.ItalicAnnotationTool.super.apply( this, arguments );76};77OO.inheritClass( ve.ui.ItalicAnnotationTool, ve.ui.AnnotationTool );78ve.ui.ItalicAnnotationTool.static.name = 'italic';79ve.ui.ItalicAnnotationTool.static.group = 'textStyle';80ve.ui.ItalicAnnotationTool.static.icon = 'italic';81ve.ui.ItalicAnnotationTool.static.title =82 OO.ui.deferMsg( 'visualeditor-annotationbutton-italic-tooltip' );83ve.ui.ItalicAnnotationTool.static.annotation = { name: 'textStyle/italic' };84ve.ui.ItalicAnnotationTool.static.commandName = 'italic';85ve.ui.toolFactory.register( ve.ui.ItalicAnnotationTool );86/**87 * UserInterface code tool.88 *89 * @class90 * @extends ve.ui.AnnotationTool91 * @constructor92 * @param {OO.ui.ToolGroup} toolGroup93 * @param {Object} [config] Configuration options94 */95ve.ui.CodeAnnotationTool = function VeUiCodeAnnotationTool() {96 ve.ui.CodeAnnotationTool.super.apply( this, arguments );97};98OO.inheritClass( ve.ui.CodeAnnotationTool, ve.ui.AnnotationTool );99ve.ui.CodeAnnotationTool.static.name = 'code';100ve.ui.CodeAnnotationTool.static.group = 'textStyle';101ve.ui.CodeAnnotationTool.static.icon = 'code';102ve.ui.CodeAnnotationTool.static.title =103 OO.ui.deferMsg( 'visualeditor-annotationbutton-code-tooltip' );104ve.ui.CodeAnnotationTool.static.annotation = { name: 'textStyle/code' };105ve.ui.CodeAnnotationTool.static.commandName = 'code';106ve.ui.toolFactory.register( ve.ui.CodeAnnotationTool );107/**108 * UserInterface strikethrough tool.109 *110 * @class111 * @extends ve.ui.AnnotationTool112 * @constructor113 * @param {OO.ui.ToolGroup} toolGroup114 * @param {Object} [config] Configuration options115 */116ve.ui.StrikethroughAnnotationTool = function VeUiStrikethroughAnnotationTool() {117 ve.ui.StrikethroughAnnotationTool.super.apply( this, arguments );118};119OO.inheritClass( ve.ui.StrikethroughAnnotationTool, ve.ui.AnnotationTool );120ve.ui.StrikethroughAnnotationTool.static.name = 'strikethrough';121ve.ui.StrikethroughAnnotationTool.static.group = 'textStyle';122ve.ui.StrikethroughAnnotationTool.static.icon = 'strikethrough';123ve.ui.StrikethroughAnnotationTool.static.title =124 OO.ui.deferMsg( 'visualeditor-annotationbutton-strikethrough-tooltip' );125ve.ui.StrikethroughAnnotationTool.static.annotation = { name: 'textStyle/strikethrough' };126ve.ui.StrikethroughAnnotationTool.static.commandName = 'strikethrough';127ve.ui.toolFactory.register( ve.ui.StrikethroughAnnotationTool );128/**129 * UserInterface underline tool.130 *131 * @class132 * @extends ve.ui.AnnotationTool133 * @constructor134 * @param {OO.ui.ToolGroup} toolGroup135 * @param {Object} [config] Configuration options136 */137ve.ui.UnderlineAnnotationTool = function VeUiUnderlineAnnotationTool() {138 ve.ui.UnderlineAnnotationTool.super.apply( this, arguments );139};140OO.inheritClass( ve.ui.UnderlineAnnotationTool, ve.ui.AnnotationTool );141ve.ui.UnderlineAnnotationTool.static.name = 'underline';142ve.ui.UnderlineAnnotationTool.static.group = 'textStyle';143ve.ui.UnderlineAnnotationTool.static.icon = 'underline';144ve.ui.UnderlineAnnotationTool.static.title =145 OO.ui.deferMsg( 'visualeditor-annotationbutton-underline-tooltip' );146ve.ui.UnderlineAnnotationTool.static.annotation = { name: 'textStyle/underline' };147ve.ui.UnderlineAnnotationTool.static.commandName = 'underline';148ve.ui.toolFactory.register( ve.ui.UnderlineAnnotationTool );149/**150 * UserInterface superscript tool.151 *152 * @class153 * @extends ve.ui.AnnotationTool154 * @constructor155 * @param {OO.ui.ToolGroup} toolGroup156 * @param {Object} [config] Configuration options157 */158ve.ui.SuperscriptAnnotationTool = function VeUiSuperscriptAnnotationTool() {159 ve.ui.SuperscriptAnnotationTool.super.apply( this, arguments );160};161OO.inheritClass( ve.ui.SuperscriptAnnotationTool, ve.ui.AnnotationTool );162ve.ui.SuperscriptAnnotationTool.static.name = 'superscript';163ve.ui.SuperscriptAnnotationTool.static.group = 'textStyle';164ve.ui.SuperscriptAnnotationTool.static.icon = 'superscript';165ve.ui.SuperscriptAnnotationTool.static.title =166 OO.ui.deferMsg( 'visualeditor-annotationbutton-superscript-tooltip' );167ve.ui.SuperscriptAnnotationTool.static.annotation = { name: 'textStyle/superscript' };168ve.ui.SuperscriptAnnotationTool.static.commandName = 'superscript';169ve.ui.toolFactory.register( ve.ui.SuperscriptAnnotationTool );170/**171 * UserInterface subscript tool.172 *173 * @class174 * @extends ve.ui.AnnotationTool175 * @constructor176 * @param {OO.ui.ToolGroup} toolGroup177 * @param {Object} [config] Configuration options178 */179ve.ui.SubscriptAnnotationTool = function VeUiSubscriptAnnotationTool() {180 ve.ui.SubscriptAnnotationTool.super.apply( this, arguments );181};182OO.inheritClass( ve.ui.SubscriptAnnotationTool, ve.ui.AnnotationTool );183ve.ui.SubscriptAnnotationTool.static.name = 'subscript';184ve.ui.SubscriptAnnotationTool.static.group = 'textStyle';185ve.ui.SubscriptAnnotationTool.static.icon = 'subscript';186ve.ui.SubscriptAnnotationTool.static.title =187 OO.ui.deferMsg( 'visualeditor-annotationbutton-subscript-tooltip' );188ve.ui.SubscriptAnnotationTool.static.annotation = { name: 'textStyle/subscript' };189ve.ui.SubscriptAnnotationTool.static.commandName = 'subscript';190ve.ui.toolFactory.register( ve.ui.SubscriptAnnotationTool );191/**192 * UserInterface big tool.193 *194 * @class195 * @extends ve.ui.AnnotationTool196 * @constructor197 * @param {OO.ui.ToolGroup} toolGroup198 * @param {Object} [config] Configuration options199 */200ve.ui.BigAnnotationTool = function VeUiBigAnnotationTool() {201 ve.ui.BigAnnotationTool.super.apply( this, arguments );202};203OO.inheritClass( ve.ui.BigAnnotationTool, ve.ui.AnnotationTool );204ve.ui.BigAnnotationTool.static.name = 'big';205ve.ui.BigAnnotationTool.static.group = 'textStyle';206ve.ui.BigAnnotationTool.static.icon = 'bigger';207ve.ui.BigAnnotationTool.static.title =208 OO.ui.deferMsg( 'visualeditor-annotationbutton-big-tooltip' );209ve.ui.BigAnnotationTool.static.annotation = { name: 'textStyle/big' };210ve.ui.BigAnnotationTool.static.commandName = 'big';211ve.ui.toolFactory.register( ve.ui.BigAnnotationTool );212/**213 * UserInterface small tool.214 *215 * @class216 * @extends ve.ui.AnnotationTool217 * @constructor218 * @param {OO.ui.ToolGroup} toolGroup219 * @param {Object} [config] Configuration options220 */221ve.ui.SmallAnnotationTool = function VeUiSmallAnnotationTool() {222 ve.ui.SmallAnnotationTool.super.apply( this, arguments );223};224OO.inheritClass( ve.ui.SmallAnnotationTool, ve.ui.AnnotationTool );225ve.ui.SmallAnnotationTool.static.name = 'small';226ve.ui.SmallAnnotationTool.static.group = 'textStyle';227ve.ui.SmallAnnotationTool.static.icon = 'smaller';228ve.ui.SmallAnnotationTool.static.title =229 OO.ui.deferMsg( 'visualeditor-annotationbutton-small-tooltip' );230ve.ui.SmallAnnotationTool.static.annotation = { name: 'textStyle/small' };231ve.ui.SmallAnnotationTool.static.commandName = 'small';232ve.ui.toolFactory.register( ve.ui.SmallAnnotationTool );233/**234 * UserInterface more text styles tool.235 *236 * @class237 * @extends OO.ui.ToolGroupTool238 * @constructor239 * @param {OO.ui.ToolGroup} toolGroup240 * @param {Object} [config] Configuration options241 */242ve.ui.MoreTextStyleTool = function VeUiMoreTextStyleTool() {243 ve.ui.MoreTextStyleTool.super.apply( this, arguments );244};245OO.inheritClass( ve.ui.MoreTextStyleTool, OO.ui.ToolGroupTool );246ve.ui.MoreTextStyleTool.static.autoAddToCatchall = false;247ve.ui.MoreTextStyleTool.static.name = 'moreTextStyle';248ve.ui.MoreTextStyleTool.static.group = 'textStyleExpansion';249ve.ui.MoreTextStyleTool.static.title =250 OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' );251ve.ui.MoreTextStyleTool.static.groupConfig = {252 header: OO.ui.deferMsg( 'visualeditor-toolbar-text-style' ),253 icon: 'textStyle',254 indicator: 'down',255 title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),256 label: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),257 invisibleLabel: true,258 include: [ { group: 'textStyle' }, 'language', 'clear' ],259 demote: [ 'strikethrough', 'code', 'underline', 'language', 'big', 'small', 'clear' ]260};...

Full Screen

Full Screen

ve.dm.AnnotationSet.test.js

Source:ve.dm.AnnotationSet.test.js Github

copy

Full Screen

...7/* Tests */8QUnit.test( 'Basic usage', function ( assert ) {9 var annotationSet3,10 store = new ve.dm.HashValueStore(),11 bold = new ve.dm.BoldAnnotation(),12 italic = new ve.dm.ItalicAnnotation(),13 underline = new ve.dm.UnderlineAnnotation(),14 annotationSet = new ve.dm.AnnotationSet( store, store.hashAll( [ bold, italic ] ) ),15 annotationSet2 = new ve.dm.AnnotationSet( store, store.hashAll( [ italic, underline ] ) ),16 emptySet = new ve.dm.AnnotationSet( store );17 assert.strictEqual( annotationSet.getLength(), 2, 'getLength is 2' );18 assert.strictEqual( annotationSet.isEmpty(), false, 'isEmpty is false' );19 assert.deepEqual( annotationSet.get( 0 ), bold, 'get(0) is bold' );20 assert.strictEqual( annotationSet.contains( italic ), true, 'contains italic' );21 assert.strictEqual( annotationSet.contains( underline ), false, 'doesn\'t contain underline' );22 assert.strictEqual( annotationSet.containsHash( store.hashOfValue( italic ) ), true, 'contains italic by hash' );23 assert.strictEqual( annotationSet.containsHash( store.hashOfValue( underline ) ), false, 'doesn\'t contain underline by hash' );24 assert.strictEqual( annotationSet.containsAnyOf( annotationSet2 ), true, 'containsAnyOf set2 is true' );25 assert.strictEqual( annotationSet.containsAnyOf( emptySet ), false, 'containsAnyOf empty set is false' );26 assert.strictEqual( annotationSet.containsAllOf( annotationSet2 ), false, 'containsAllOf set2 set is false' );27 assert.strictEqual( annotationSet.containsAllOf( annotationSet ), true, 'containsAllOf self is true' );28 assert.strictEqual( annotationSet.offsetOf( italic ), 1, 'offsetOf italic is 1' );29 assert.strictEqual( annotationSet.offsetOf( underline ), -1, 'offsetOf underline is -1' );30 assert.deepEqual(31 annotationSet.filter( function ( annotation ) { return annotation.name === 'textStyle/bold'; } ).get(),32 [ bold ], 'filter for name=textStyle/bold returns just bold annotation'33 );34 assert.strictEqual( annotationSet.hasAnnotationWithName( 'textStyle/bold' ), true, 'hasAnnotationWithName textStyle/bold is true' );35 assert.strictEqual( annotationSet.hasAnnotationWithName( 'textStyle/underline' ), false, 'hasAnnotationWithName underline is false' );36 annotationSet2.add( bold, 1 );37 assert.strictEqual( annotationSet2.offsetOf( bold ), 1, 'set2 contains bold at 1 after add at 1' );38 annotationSet2.remove( bold );39 assert.strictEqual( annotationSet2.contains( bold ), false, 'set2 doesn\'t contain bold after remove' );40 annotationSet2.add( bold, 0 );41 assert.strictEqual( annotationSet2.offsetOf( bold ), 0, 'set2 contains bold at 0 after add at 0' );42 annotationSet2.add( bold, 0 );43 assert.strictEqual( annotationSet2.getLength(), 3, 'adding existing annotation doesn\'t change length' );44 // Set is now [ bold, italic, underline ]45 annotationSet2.removeAt( 2 );46 assert.strictEqual( annotationSet2.contains( underline ), false, 'set2 doesn\'t contain underline after removeAt 2' );47 annotationSet2.removeAll();48 assert.strictEqual( annotationSet2.isEmpty(), true, 'set2 is empty after removeAll' );49 annotationSet2.addSet( annotationSet );50 assert.strictEqual( annotationSet.getLength(), 2, 'set2 has length 2 after addSet' );51 annotationSet2.removeSet( annotationSet );52 assert.strictEqual( annotationSet2.isEmpty(), true, 'set2 is empty after removeSet' );53 annotationSet2.push( bold );54 annotationSet2.push( italic );55 assert.deepEqual( annotationSet2.get(), [ bold, italic ], 'set2 contains bold then italic after two pushes' );56 annotationSet2 = new ve.dm.AnnotationSet( store, store.hashAll( [ italic, underline ] ) );57 annotationSet2.removeNotInSet( annotationSet );58 assert.strictEqual( annotationSet.contains( italic ) && !annotationSet.contains( underline ), true, 'contains italic not underline after removeNotInSet' );59 annotationSet2.add( underline, 1 );60 annotationSet3 = annotationSet2.reversed();61 assert.strictEqual( annotationSet3.offsetOf( underline ), 0, 'underline has offsetOf 0 after reverse' );62 annotationSet3 = annotationSet.mergeWith( annotationSet2 );63 assert.strictEqual( annotationSet3.getLength(), 3, 'set merged with set2 has length 3' );64 annotationSet3 = annotationSet.diffWith( annotationSet2 );65 assert.strictEqual( annotationSet3.getLength(), 1, 'set diffed with set2 has length 1' );66 assert.strictEqual( annotationSet3.contains( bold ), true, 'set diffed with set2 contains bold' );67 annotationSet3 = annotationSet.intersectWith( annotationSet2 );68 assert.strictEqual( annotationSet3.getLength(), 1, 'set intersected with set2 has length 1' );69 assert.strictEqual( annotationSet3.contains( italic ), true, 'set intersected with set2 contains italic' );70} );71QUnit.test( 'Comparable', function ( assert ) {72 var annotationSet3,73 store = new ve.dm.HashValueStore(),74 bold = new ve.dm.BoldAnnotation(),75 italic = new ve.dm.ItalicAnnotation(),76 strong = new ve.dm.BoldAnnotation( { type: 'textStyle/bold', attributes: { nodeName: 'strong' } } ),77 underline = new ve.dm.UnderlineAnnotation(),78 annotationSet = new ve.dm.AnnotationSet( store, store.hashAll( [ bold, italic ] ) ),79 annotationSet2 = new ve.dm.AnnotationSet( store, store.hashAll( [ strong, underline ] ) ),80 emptySet = new ve.dm.AnnotationSet( store );81 assert.strictEqual( annotationSet.containsComparable( strong ), true, '[b,i] contains comparable strong' );82 assert.strictEqual( annotationSet.containsComparable( bold ), true, '[b,i] contains comparable b' );83 assert.strictEqual( annotationSet.containsComparable( underline ), false, '[b,i] doesn\'t contain comparable u' );84 annotationSet3 = new ve.dm.AnnotationSet( store, store.hashAll( [ bold ] ) );85 assert.deepEqual( annotationSet.getComparableAnnotations( strong ), annotationSet3, '[b,i] get comparable strong returns [b]' );86 assert.deepEqual( annotationSet.getComparableAnnotations( underline ), emptySet, '[b,i] get comparable underline returns []' );87 annotationSet3 = new ve.dm.AnnotationSet( store, store.hashAll( [ bold ] ) );88 assert.deepEqual( annotationSet.getComparableAnnotationsFromSet( annotationSet2 ), annotationSet3, '[b,i] get comparable from set [strong,u] returns just [b]' );89 annotationSet3 = new ve.dm.AnnotationSet( store, store.hashAll( [ italic, strong ] ) );90 assert.strictEqual( annotationSet.compareTo( annotationSet3 ), true, '[b,i] compares to [i,strong]' );91} );

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var wpt = new WebPageTest('www.webpagetest.org');4wpt.runTest(testURL, {5}, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPageTest for %s', testURL);8 console.log('Test ID: %s', data.data.testId);9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test completed for %s', testURL);12 console.log('View the test at: %s', data.data.summary);13 });14});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = wptools.page('Barack Obama');3wp.get(function(err, resp) {4 console.log(resp);5});6var wptools = require('wptools');7var wp = wptools.page('Barack Obama');8wp.get(function(err, resp) {9 console.log(resp);10});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptoolkit = require('wptoolkit');2const fs = require('fs');3let text = fs.readFileSync('test.txt').toString('utf-8');4let annotatedText = wptoolkit.Annotation.annotate(text);5console.log(annotatedText);6#### 1.1. `annotate(text, options)`7let text = "Hello World. This is a test.";8let annotatedText = wptoolkit.Annotation.annotate(text);9let text = "Hello World. This is a test.";10let options = {11};12let annotatedText = wptoolkit.Annotation.annotate(text, options);13let text = "Hello World. This is a test.";14let options = {15};16let annotatedText = wptoolkit.Annotation.annotate(text, options);17let text = "Hello World. This is a test.";18let options = {19};20let annotatedText = wptoolkit.Annotation.annotate(text, options);21let text = "Hello World. This is a test.";22let options = {23 attributes: {24 }25};26let annotatedText = wptoolkit.Annotation.annotate(text, options);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webpagetest = wpt(options);5webpagetest.runTest(testUrl, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPagetest for %s', testUrl);8 console.log('View your test at %s', data.data.userUrl);9 webpagetest.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test completed for %s', testUrl);12 console.log('View your test at %s', data.data.userUrl);13 console.log('First View (loadTime): %d', data.data.average.firstView.loadTime);14 console.log('Repeat View (loadTime): %d', data.data.average.repeatView.loadTime);15 });16});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful