How to use getSelection method in wpt

Best JavaScript code snippet using wpt

text.js

Source:text.js Github

copy

Full Screen

1let params = (new URL(document.location)).searchParams;2let book = params.get("book");3let part = params.get("part");4window.addEventListener('click', () => {5 let focusElem = window.getSelection();6 if((focusElem.anchorNode && focusElem.anchorNode.nodeName == "#text") && (window.getSelection().getRangeAt(0).commonAncestorContainer.parentElement.localName == 'td')) {7 8 let range = window.getSelection().getRangeAt(0);9 function topNavTable() {10 11 // Отображение панели убравления "Таблицей"12 headerNav.innerHTML = '<div class="notEdit allTopNav">'+13 '<div class="notEdit">'+14 '<div>'+15 '<img src="public/img/delete.svg" onclick="deletedCell();" class="notEdit elementTopNavImg">'+16 '</div>'+17 '<div>'+18 '<img src="public/img/column.svg" onclick="colsCell();" class="notEdit elementTopNavImg">'+19 '</div>'+20 '<div>'+21 '<img src="public/img/row.svg" onclick="rowsCell();" class="notEdit elementTopNavImg">'+22 '</div>'+23 '<div>'+24 '<img src="public/img/plus.svg" onclick="appendCell();" class="notEdit elementTopNavImg">'+25 '</div>'+26 '</div>';27 28 29 }30 topNavTable();31 //range.commonAncestorContainer.parentNode.setAttribute('colspan', '3');32 }33});34function deletedCell() {35 let range = window.getSelection().getRangeAt(0);36 range.commonAncestorContainer.parentNode.remove();37}38function colsCell() {39 let range = window.getSelection().getRangeAt(0);40 let ans = prompt('Введите колличество колонок которое будет занимать ячейка');41 range.commonAncestorContainer.parentNode.setAttribute('colspan', ans);42}43function rowsCell() {44 let range = window.getSelection().getRangeAt(0);45 let ans = prompt('Введите колличество строк которое будет занимать ячейка');46 range.commonAncestorContainer.parentNode.setAttribute('rowspan', ans);47}48function appendCell() {49 let range = window.getSelection().getRangeAt(0);50 let newCell = document.createElement('td');51 newCell.innerText = 'Новая ячейка';52 range.commonAncestorContainer.parentNode.parentNode.appendChild(newCell);53}54function changeColorText(color) {55 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {56 let range = window.getSelection().getRangeAt(0);57 let newNode = document.createElement("span");58 newNode.style.color = color;59 range.surroundContents(newNode);60 //document.getSelection().removeAllRanges();61 // function highlight(range) {62 // var inputText = document.getElementById("inputText");63 // var innerHTML = inputText.innerHTML;64 // var index = innerHTML.indexOf(text);65 // if (index >= 0) { 66 // innerHTML = innerHTML.substring(0,index) + "<span style='color:"+color+"'>" + innerHTML.substring(index,index+text.length) + "</span>" + innerHTML.substring(index + text.length);67 // inputText.innerHTML = innerHTML;68 // }69 // }70 return false;71 } else {72 return false;73 }74}75function lockText() {76 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {77 let range = window.getSelection().getRangeAt(0);78 let newNode = document.createElement("span");79 newNode.classList.add('lockText');80 range.surroundContents(newNode);81 //document.getSelection().removeAllRanges();82 return false;83 } else {84 return false;85 }86}87function changeBgColorText(color) {88 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {89 let range = window.getSelection().getRangeAt(0);90 let newNode = document.createElement("span");91 newNode.style.background = color;92 range.surroundContents(newNode);93 //document.getSelection().removeAllRanges();94 return false;95 } else {96 return false;97 }98}99function changeFontSize(size) {100 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {101 let range = window.getSelection().getRangeAt(0);102 let newNode = document.createElement("span");103 newNode.style.fontSize = size;104 range.surroundContents(newNode);105 //document.getSelection().removeAllRanges();106 return false;107 } else {108 return false;109 }110}111function changeFontLine(lineStyle) {112 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {113 let range = window.getSelection().getRangeAt(0);114 let newNode = document.createElement("span");115 if(lineStyle == 'obst') {116 newNode.classList.add('obst');117 range.surroundContents(newNode);118 return false;119 }120 newNode.classList.add('lineColor');121 newNode.classList.add(lineStyle);122 range.surroundContents(newNode);123 //document.getSelection().removeAllRanges();124 return false;125 } else {126 return false;127 }128}129function changeFontMorf(style) {130 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {131 let range = window.getSelection().getRangeAt(0);132 let newNode = document.createElement("span");133 newNode.classList.add(style);134 range.surroundContents(newNode);135 //document.getSelection().removeAllRanges();136 return false;137 } else {138 return false;139 }140}141function appendMorf(style) {142 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {143 let range = window.getSelection().getRangeAt(0);144 let newNode = document.createElement("span");145 console.log(range);146 alert();147 newNode.setAttribute('data-morfana-markup', 'ko:'+range.startOffset+'-'+range.endOffset);148 range.surroundContents(newNode);149 //document.getSelection().removeAllRanges();150 return false;151 } else {152 return false;153 }154}155// Добавление формулы156function appendFormulaCarret() {157 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {158 159 let range = window.getSelection().getRangeAt(0);160 let myValue = prompt('Введите формулу без тегов "<math> </math>"');161 if(myValue == null) {162 return false;163 }164 let span = document.createElement('math');165 span.setAttribute('contenteditable', 'false');166 span.classList.add('formula');167 span.innerHTML = myValue;168 169 range.insertNode(span);170 return false;171 }172}173function changeMarginText(size) {174 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {175 let range = window.getSelection().getRangeAt(0);176 let newNode = document.createElement("span");177 newNode.style.margin = size;178 range.surroundContents(newNode);179 //document.getSelection().removeAllRanges();180 return false;181 } else {182 return false;183 }184}185function sup() {186 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {187 let range = window.getSelection().getRangeAt(0);188 let newNode = document.createElement("sup");189 range.surroundContents(newNode);190 //document.getSelection().removeAllRanges();191 return false;192 } else {193 return false;194 }195}196function clearText() {197 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {198 range = window.getSelection().getRangeAt(0);199 range.commonAncestorContainer.innerHTML = range.toString();200 return false;201 } else {202 return false;203 }204}205function sub() {206 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {207 let range = window.getSelection().getRangeAt(0);208 let newNode = document.createElement("sub");209 range.surroundContents(newNode);210 //document.getSelection().removeAllRanges();211 return false;212 } else {213 return false;214 }215}216function textAlignCenter() {217 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {218 let range = window.getSelection().getRangeAt(0);219 let newNode = document.createElement("span");220 newNode.style.display = 'block';221 newNode.style.textAlign = 'center';222 range.surroundContents(newNode);223 //document.getSelection().removeAllRanges();224 return false;225 } else {226 return false;227 }228}229function textAlignCenter() {230 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {231 let range = window.getSelection().getRangeAt(0);232 let newNode = document.createElement("span");233 newNode.style.display = 'block';234 newNode.style.textAlign = 'center';235 range.surroundContents(newNode);236 //document.getSelection().removeAllRanges();237 return false;238 } else {239 return false;240 }241}242function textAlignLeft() {243 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {244 let range = window.getSelection().getRangeAt(0);245 let newNode = document.createElement("span");246 newNode.style.display = 'block';247 newNode.style.textAlign = 'left';248 range.surroundContents(newNode);249 //document.getSelection().removeAllRanges();250 return false;251 } else {252 return false;253 }254}255function textAlignRight() {256 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {257 let range = window.getSelection().getRangeAt(0);258 let newNode = document.createElement("span");259 newNode.style.display = 'block';260 newNode.style.textAlign = 'right';261 range.surroundContents(newNode);262 //document.getSelection().removeAllRanges();263 return false;264 } else {265 return false;266 }267}268function textTitle() {269 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {270 let range = window.getSelection().getRangeAt(0);271 let newNode = document.createElement("span");272 let titleText = prompt('Введите подсказку');273 if(titleText) {274 appendNewTitle(range, titleText, '/app/saveBook/saveTitle', book, part);275 newNode.title = titleText;276 range.surroundContents(newNode);277 return false;278 }279 return false;280 } else {281 return false;282 }283}284function bold() {285 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {286 let range = window.getSelection().getRangeAt(0);287 let newNode = document.createElement("b");288 289 range.surroundContents(newNode);290 //document.getSelection().removeAllRanges();291 return false;292 } else {293 return false;294 }295}296function italic() {297 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {298 let range = window.getSelection().getRangeAt(0);299 let newNode = document.createElement("span");300 newNode.style.fontStyle = 'italic';301 302 range.surroundContents(newNode);303 //document.getSelection().removeAllRanges();304 return false;305 } else {306 return false;307 }308}309function normal() {310 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {311 let range = window.getSelection().getRangeAt(0);312 let newNode = document.createElement("span");313 newNode.style.fontWeight = '100';314 newNode.style.fontStyle = 'normal';315 316 range.surroundContents(newNode);317 //document.getSelection().removeAllRanges();318 return false;319 } else {320 return false;321 }322}323function appendAnchor() {324 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {325 let range = window.getSelection().getRangeAt(0);326 let newNode = document.createElement("span");327 let newId = prompt('Введите якорь (на латинице, значение должно быть уникальным');328 if(newId) {329 newNode.id = newId;330 range.surroundContents(newNode);331 //document.getSelection().removeAllRanges();332 return false;333 }334 return false;335 } else {336 return false;337 }338}339function appendLinkText() {340 if(typeof window.getSelection() != "undefined" && window.getSelection().anchorNode != null) {341 let range = window.getSelection().getRangeAt(0);342 let newNode = document.createElement("a");343 let result = prompt('Введите ссылку');344 newNode.href = result;345 range.surroundContents(newNode);346 return false;347 } else {348 return false;349 }...

Full Screen

Full Screen

browser_graphs-07a.js

Source:browser_graphs-07a.js Github

copy

Full Screen

...47 info("Making a selection.");48 dragStart(graph, 300);49 ok(graph.hasSelectionInProgress(),50 "The selection should start (1).");51 is(graph.getSelection().start, 300,52 "The current selection start value is correct (1).");53 is(graph.getSelection().end, 300,54 "The current selection end value is correct (1).");55 hover(graph, 400);56 ok(graph.hasSelectionInProgress(),57 "The selection should still be in progress (2).");58 is(graph.getSelection().start, 300,59 "The current selection start value is correct (2).");60 is(graph.getSelection().end, 400,61 "The current selection end value is correct (2).");62 dragStop(graph, 500);63 ok(!graph.hasSelectionInProgress(),64 "The selection should have stopped (3).");65 is(graph.getSelection().start, 300,66 "The current selection start value is correct (3).");67 is(graph.getSelection().end, 500,68 "The current selection end value is correct (3).");69 info("Making a new selection.");70 dragStart(graph, 200);71 ok(graph.hasSelectionInProgress(),72 "The selection should start (4).");73 is(graph.getSelection().start, 200,74 "The current selection start value is correct (4).");75 is(graph.getSelection().end, 200,76 "The current selection end value is correct (4).");77 hover(graph, 300);78 ok(graph.hasSelectionInProgress(),79 "The selection should still be in progress (5).");80 is(graph.getSelection().start, 200,81 "The current selection start value is correct (5).");82 is(graph.getSelection().end, 300,83 "The current selection end value is correct (5).");84 dragStop(graph, 400);85 ok(!graph.hasSelectionInProgress(),86 "The selection should have stopped (6).");87 is(graph.getSelection().start, 200,88 "The current selection start value is correct (6).");89 is(graph.getSelection().end, 400,90 "The current selection end value is correct (6).");91 info("Resizing by dragging the end handlebar.");92 dragStart(graph, 400);93 is(graph.getSelection().start, 200,94 "The current selection start value is correct (7).");95 is(graph.getSelection().end, 400,96 "The current selection end value is correct (7).");97 dragStop(graph, 600);98 is(graph.getSelection().start, 200,99 "The current selection start value is correct (8).");100 is(graph.getSelection().end, 600,101 "The current selection end value is correct (8).");102 info("Resizing by dragging the start handlebar.");103 dragStart(graph, 200);104 is(graph.getSelection().start, 200,105 "The current selection start value is correct (9).");106 is(graph.getSelection().end, 600,107 "The current selection end value is correct (9).");108 dragStop(graph, 100);109 is(graph.getSelection().start, 100,110 "The current selection start value is correct (10).");111 is(graph.getSelection().end, 600,112 "The current selection end value is correct (10).");113 info("Moving by dragging the selection.");114 dragStart(graph, 300);115 hover(graph, 400);116 is(graph.getSelection().start, 200,117 "The current selection start value is correct (11).");118 is(graph.getSelection().end, 700,119 "The current selection end value is correct (11).");120 dragStop(graph, 500);121 is(graph.getSelection().start, 300,122 "The current selection start value is correct (12).");123 is(graph.getSelection().end, 800,124 "The current selection end value is correct (12).");125 info("Zooming in by scrolling inside the selection.");126 scroll(graph, -1000, 600);127 is(graph.getSelection().start, 525,128 "The current selection start value is correct (13).");129 is(graph.getSelection().end, 650,130 "The current selection end value is correct (13).");131 info("Zooming out by scrolling inside the selection.");132 scroll(graph, 1000, 600);133 is(graph.getSelection().start, 468.75,134 "The current selection start value is correct (14).");135 is(graph.getSelection().end, 687.5,136 "The current selection end value is correct (14).");137 info("Sliding left by scrolling outside the selection.");138 scroll(graph, 100, 900);139 is(graph.getSelection().start, 458.75,140 "The current selection start value is correct (15).");141 is(graph.getSelection().end, 677.5,142 "The current selection end value is correct (15).");143 info("Sliding right by scrolling outside the selection.");144 scroll(graph, -100, 900);145 is(graph.getSelection().start, 468.75,146 "The current selection start value is correct (16).");147 is(graph.getSelection().end, 687.5,148 "The current selection end value is correct (16).");149 info("Zooming out a lot.");150 scroll(graph, Number.MAX_SAFE_INTEGER, 500);151 is(graph.getSelection().start, 1,152 "The current selection start value is correct (17).");153 is(graph.getSelection().end, graph.width - 1,154 "The current selection end value is correct (17).");155}156// EventUtils just doesn't work!157function hover(graph, x, y = 1) {158 x /= window.devicePixelRatio;159 y /= window.devicePixelRatio;160 graph._onMouseMove({ testX: x, testY: y });161}162function dragStart(graph, x, y = 1) {163 x /= window.devicePixelRatio;164 y /= window.devicePixelRatio;165 graph._onMouseMove({ testX: x, testY: y });166 graph._onMouseDown({ testX: x, testY: y });167}...

Full Screen

Full Screen

browser_graphs-07.js

Source:browser_graphs-07.js Github

copy

Full Screen

...25 info("Making a selection.");26 dragStart(graph, 300);27 ok(graph.hasSelectionInProgress(),28 "The selection should start (1).");29 is(graph.getSelection().start, 300,30 "The current selection start value is correct (1).");31 is(graph.getSelection().end, 300,32 "The current selection end value is correct (1).");33 hover(graph, 400);34 ok(graph.hasSelectionInProgress(),35 "The selection should still be in progress (2).");36 is(graph.getSelection().start, 300,37 "The current selection start value is correct (2).");38 is(graph.getSelection().end, 400,39 "The current selection end value is correct (2).");40 dragStop(graph, 500);41 ok(!graph.hasSelectionInProgress(),42 "The selection should have stopped (3).");43 is(graph.getSelection().start, 300,44 "The current selection start value is correct (3).");45 is(graph.getSelection().end, 500,46 "The current selection end value is correct (3).");47 info("Making a new selection.");48 dragStart(graph, 200);49 ok(graph.hasSelectionInProgress(),50 "The selection should start (4).");51 is(graph.getSelection().start, 200,52 "The current selection start value is correct (4).");53 is(graph.getSelection().end, 200,54 "The current selection end value is correct (4).");55 hover(graph, 300);56 ok(graph.hasSelectionInProgress(),57 "The selection should still be in progress (5).");58 is(graph.getSelection().start, 200,59 "The current selection start value is correct (5).");60 is(graph.getSelection().end, 300,61 "The current selection end value is correct (5).");62 dragStop(graph, 400);63 ok(!graph.hasSelectionInProgress(),64 "The selection should have stopped (6).");65 is(graph.getSelection().start, 200,66 "The current selection start value is correct (6).");67 is(graph.getSelection().end, 400,68 "The current selection end value is correct (6).");69 info("Resizing by dragging the end handlebar.");70 dragStart(graph, 400);71 is(graph.getSelection().start, 200,72 "The current selection start value is correct (7).");73 is(graph.getSelection().end, 400,74 "The current selection end value is correct (7).");75 dragStop(graph, 600);76 is(graph.getSelection().start, 200,77 "The current selection start value is correct (8).");78 is(graph.getSelection().end, 600,79 "The current selection end value is correct (8).");80 info("Resizing by dragging the start handlebar.");81 dragStart(graph, 200);82 is(graph.getSelection().start, 200,83 "The current selection start value is correct (9).");84 is(graph.getSelection().end, 600,85 "The current selection end value is correct (9).");86 dragStop(graph, 100);87 is(graph.getSelection().start, 100,88 "The current selection start value is correct (10).");89 is(graph.getSelection().end, 600,90 "The current selection end value is correct (10).");91 info("Moving by dragging the selection.");92 dragStart(graph, 300);93 hover(graph, 400);94 is(graph.getSelection().start, 200,95 "The current selection start value is correct (11).");96 is(graph.getSelection().end, 700,97 "The current selection end value is correct (11).");98 dragStop(graph, 500);99 is(graph.getSelection().start, 300,100 "The current selection start value is correct (12).");101 is(graph.getSelection().end, 800,102 "The current selection end value is correct (12).");103 info("Zooming in by scrolling inside the selection.");104 scroll(graph, -1000, 600);105 is(graph.getSelection().start, 525,106 "The current selection start value is correct (13).");107 is(graph.getSelection().end, 650,108 "The current selection end value is correct (13).");109 info("Zooming out by scrolling inside the selection.");110 scroll(graph, 1000, 600);111 is(graph.getSelection().start, 468.75,112 "The current selection start value is correct (14).");113 is(graph.getSelection().end, 687.5,114 "The current selection end value is correct (14).");115 info("Sliding left by scrolling outside the selection.");116 scroll(graph, 100, 900);117 is(graph.getSelection().start, 458.75,118 "The current selection start value is correct (15).");119 is(graph.getSelection().end, 677.5,120 "The current selection end value is correct (15).");121 info("Sliding right by scrolling outside the selection.");122 scroll(graph, -100, 900);123 is(graph.getSelection().start, 468.75,124 "The current selection start value is correct (16).");125 is(graph.getSelection().end, 687.5,126 "The current selection end value is correct (16).");127 info("Zooming out a lot.");128 scroll(graph, Number.MAX_SAFE_INTEGER, 500);129 is(graph.getSelection().start, 1,130 "The current selection start value is correct (17).");131 is(graph.getSelection().end, graph.width - 1,132 "The current selection end value is correct (17).");133}134// EventUtils just doesn't work!135function hover(graph, x, y = 1) {136 x /= window.devicePixelRatio;137 y /= window.devicePixelRatio;138 graph._onMouseMove({ clientX: x, clientY: y });139}140function click(graph, x, y = 1) {141 x /= window.devicePixelRatio;142 y /= window.devicePixelRatio;143 graph._onMouseMove({ clientX: x, clientY: y });144 graph._onMouseDown({ clientX: x, clientY: y });145 graph._onMouseUp({ clientX: x, clientY: y });...

Full Screen

Full Screen

SingleSelection.js

Source:SingleSelection.js Github

copy

Full Screen

...24 return model;25 },26 testSelection : function()27 {28 var selection = this._list.getSelection();29 selection.push(this._model.getItem(1));30 this.flush();31 // check selection from list32 this.assertEquals(1, this._list.getSelection().getLength(), "On List");33 var expectedSelection = new qx.data.Array([this._model.getItem(1)]);34 this.assertDataArrayEquals(selection, expectedSelection, "On List");35 expectedSelection.dispose();36 // check selection from manager37 var item = this._list._manager.getSelectedItem();38 item = this._list._getDataFromRow(item);39 this.assertEquals(this._model.getItem(1), item);40 },41 testInvalidSelection : function()42 {43 var selection = this._list.getSelection();44 selection.push(this._model.getItem(1));45 selection.push(this._model.getItem(2));46 this.flush();47 // check selection from list48 this.assertEquals(1, this._list.getSelection().getLength(), "On List");49 var expectedSelection = new qx.data.Array([this._model.getItem(2)]);50 this.assertDataArrayEquals(selection, expectedSelection, "On List");51 expectedSelection.dispose();52 // check selection from manager53 var selection = this._list._manager.getSelection();54 this.assertEquals(1, selection.length);55 this.assertEquals(2, selection[0]);56 },57 testSelectionByUserInteraction : function()58 {59 var selection = this._list.getSelection();60 this._list._manager.selectItem(2);61 this.flush();62 this.assertEquals(1, selection.getLength());63 this.assertEquals(this._model.getItem(2), selection.getItem(0));64 this.assertEquals(2, this._list._manager.getSelectedItem());65 },66 testSelectionEventByUserInteraction : function()67 {68 var selection = this._list.getSelection();69 var self = this;70 this.assertEventFired(selection, "change",71 function()72 {73 self._list._manager.selectItem(2);74 self.flush();75 },76 function(e)77 {78 self.assertEquals(1, selection.getLength());79 self.assertEquals(self._model.getItem(2), selection.getItem(0));80 self.assertEquals(2, self._list._manager.getSelectedItem());81 }82 );83 },84 testSelectionWithSorter : function()85 {86 this._list.setDelegate({87 sorter : function(a, b) {88 return a < b ? 1 : a > b ? -1 : 0;89 }90 });91 this.testSelection();92 },93 testSelectionWithFilter : function() {94 this._list.setDelegate({95 filter : function(data) {96 // Filters all even items97 return ((parseInt(data.slice(5, data.length), 10)) % 2 == 1);98 }99 });100 var selection = this._list.getSelection();101 selection.push(this._model.getItem(1));102 this.flush();103 // check selection from list104 this.assertEquals(1, this._list.getSelection().getLength(), "On List");105 var expectedSelection = new qx.data.Array([this._model.getItem(1)]);106 this.assertDataArrayEquals(selection, expectedSelection, "On List");107 expectedSelection.dispose();108 // check selection from manager109 var selection = this._list._manager.getSelection();110 this.assertEquals(1, selection.length);111 this.assertEquals(0, selection[0]);112 },113 testInvalidSelectionWithFilter : function() {114 this._list.setDelegate({115 filter : function(data) {116 // Filters all even items117 return ((parseInt(data.slice(5, data.length), 10)) % 2 == 1);118 }119 });120 var selection = this._list.getSelection();121 selection.push(this._model.getItem(0));122 this.flush();123 // check selection from list124 this.assertEquals(0, this._list.getSelection().getLength(), "On List");125 // check selection from manager126 var selection = this._list._manager.getSelection();127 this.assertEquals(0, selection.length);128 },129 testApplyFilterAfterSelection : function() {130 var selection = this._list.getSelection();131 selection.push(this._model.getItem(0));132 this.flush();133 this._list.setDelegate({134 filter : function(data) {135 // Filters all even items136 return ((parseInt(data.slice(5, data.length), 10)) % 2 == 1);137 }138 });139 this.flush();140 // check selection from list141 this.assertEquals(0, this._list.getSelection().getLength(), "On List");142 // check selection from manager143 var selection = this._list._manager.getSelection();144 this.assertEquals(0, selection.length, "On Manager");145 },146 testApplySortingAfterSelection : function()147 {148 var selection = this._list.getSelection();149 selection.push(this._model.getItem(0));150 this.flush();151 // check selection from list152 this.assertEquals(1, this._list.getSelection().getLength(), "On List");153 // check selection from manager154 var selection = this._list._manager.getSelection();155 this.assertEquals(1, selection.length, "On Manager");156 this._list.setDelegate({157 sorter : function(a, b) {158 return a < b ? 1 : a > b ? -1 : 0;159 }160 });161 this.flush();162 // check selection from list163 var expectedSelection = new qx.data.Array([this._model.getItem(0)]);164 this.assertDataArrayEquals(expectedSelection, this._list.getSelection(), "On List");165 expectedSelection.dispose();166 // check selection from manager167 var selection = this._list._manager.getSelection();168 this.assertEquals(1, selection.length, "On Manager");169 // check row == last index170 this.assertEquals(this._model.getLength() - 1, this._list._manager.getSelection()[0], "Row is wrong on Manager");171 },172 testRemoveItem : function()173 {174 var selection = this._list.getSelection();175 selection.push(this._model.getItem(0));176 this.flush();177 this._model.removeAt(0);178 this.flush();179 // check selection from list180 this.assertEquals(0, this._list.getSelection().getLength(), "On List");181 // check selection from manager182 var selection = this._list._manager.getSelection();183 this.assertEquals(0, selection.length, "On Manager");184 },185 testRemoveItemWithGrouping : function()186 {187 this._list.setDelegate({188 group : function(data) {189 return data;190 }191 });192 var lastIndex = this._model.getLength() - 1;193 var selection = this._list.getSelection();194 selection.push(this._model.getItem(lastIndex));195 this.flush();196 this._model.removeAt(lastIndex);197 this.flush();198 // check selection from list199 this.assertEquals(0, this._list.getSelection().getLength(), "On List");200 // check selection from manager201 var selection = this._list._manager.getSelection();202 this.assertEquals(0, selection.length, "On Manager");203 }204 }...

Full Screen

Full Screen

testsuite.js

Source:testsuite.js Github

copy

Full Screen

...78 // selecting two characters79 a().setContent("123456");80 eq("123456", a().getContent());81 a().makeSelection(2,4);82 eq("34", a().getSelection(), "getpref/suf1");83 eq("12", s().getPrefix());84 eq("56", s().getSuffix());85 // no selection, just caret86 a().makeSelection(2,2);87 eq("", a().getSelection());88 eq("12", s().getPrefix());89 eq("3456", s().getSuffix());90 // selecting one character91 a().makeSelection(2,3);92 eq("3", a().getSelection());93 eq("12", s().getPrefix());94 eq("456", s().getSuffix());95 // have empty lines before and after96 a().setContent("\n\n123456\n\n");97 eq("\n\n123456\n\n", a().getContent());98 a().makeSelection(4,6);99 eq("34", a().getSelection(), "getpref/suf empty lines");100 eq("12", s().getPrefix());101 eq("56", s().getSuffix());102 // no selection, just caret103 a().makeSelection(4,4);104 eq("", a().getSelection());105 eq("12", s().getPrefix());106 eq("3456", s().getSuffix());107 // selecting one character108 a().makeSelection(4,5);109 eq("3", a().getSelection());110 eq("12", s().getPrefix());111 eq("456", s().getSuffix());112 // Selecting an empty row with rows above and below.113 a().setContent("12\n34\n56");114 a().makeSelection(3,5);115 eq("34", a().getSelection(), "empty row 1");116 eq("", s().getPrefix(), "prefix");117 eq("", s().getSuffix(), "suffix");118 })();119 // Test space().120 (function () {121 a().setContent("123456");122 a().makeSelection(2,4);123 eq("34", a().getSelection());124 s().space();125 eq("12 34 56", a().getContent());126 eq("34", a().getSelection(), "space 1");127 // Space just one character.128 a().setContent("123456");129 a().makeSelection(3,4);130 eq("4", a().getSelection());131 s().space();132 eq("4", a().getSelection());133 eq("123 4 56", a().getContent());134 // Selecting at the start of a row.135 a().setContent("123456");136 a().makeSelection(0,1);137 eq("1", a().getSelection());138 s().space();139 eq("1", a().getSelection());140 eq("1 23456", a().getContent());141 142 // Selecting at the start of a row (but not the first row).143 a().setContent("123\n456");144 a().makeSelection(4, 5);145 eq("123\n456", a().getContent());146 eq("4", a().getSelection());147 s().space();148 eq("4", a().getSelection());149 eq("123\n4 56", a().getContent());150 })();151 // Test Reference.152 // Test fromString.153 (function () {154 var R = markdownEditor.Reference;155 var r;156 r = R.fromString("[ABC]: DEF", "Foo");157 eq("[", r.prefix);158 eq("]: ", r.infix);159 eq("Foo", r.type);160 eq("ABC", r.identifier);161 eq("DEF", r.text);162 eq("[ABC]: DEF", r.toString());163 r = R.fromString("[',.]: !@#$%", "Bar");164 eq("[',.]: !@#$%", r.toString());165 var x = R.fromString("[^1aoeu]: ");166 eq("[^1aoeu]: ", x.toString());167 })();168 // Test lineBreak.169 (function () {170 a().setContent("123456");171 a().makeSelection(2,4);172 eq("34", a().getSelection(), "linebreak1");173 s().lineBreak();174 eq("34", a().getSelection(), "linebreak2");175 eq("12\n\n34\n\n56", a().getContent());176 // Test with a multi line selection.177 a().setContent("123\n456");178 a().makeSelection(2,5);179 eq("3\n4", a().getSelection());180 s().lineBreak();181 eq("3\n4", a().getSelection());182 eq("12\n\n3\n4\n\n56", a().getContent());183 // Test with line above and below, whole middle line selected.184 a().setContent("12\n34\n56");185 a().makeSelection(3,5);186 eq("34", a().getSelection());187 s().lineBreak();188 eq("34", a().getSelection());189 eq("12\n\n34\n\n56", a().getContent());190 a().setContent("* 1\n* 2\n* 3");191 a().makeSelection(0, 22);192 eq("* 1\n* 2\n* 3", a().getSelection());193 s().lineBreak();194 eq("* 1\n* 2\n* 3", a().getSelection());195 // Test removing prefixing spaces.196 a().setContent("foo bar");197 a().makeSelection(5,9);198 eq(" bar", a().getSelection());199 s().lineBreak();200 eq(" bar", a().getSelection());201 // Test removing suffixing spaces202 a().setContent("foo bar");203 a().makeSelection(0, 4);204 eq("foo ", a().getSelection());205 s().lineBreak();206 eq("foo ", a().getSelection());207 // Make sure extra line breaks aren't removed.208 a().setContent("\n\n\n\nfoo\n\n\n\n");209 a().makeSelection(4, 7);210 eq("foo", a().getSelection());211 s().lineBreak();212 eq("\n\n\n\nfoo\n\n\n\n", a().getContent());213 })();214 // Test Unordered list.215 (function () {216 a().setContent("a\nb\nc\nd");217 a().makeSelection(1, 6);218 eq("\nb\nc\n", a().getSelection());219 markdownEditor.unorderedList();220 eq("a\n\n* b\n* c\n\nd", a().getContent());221 })();222 a().setContent("Tests finished successfully");...

Full Screen

Full Screen

selection.js

Source:selection.js Github

copy

Full Screen

...6if(_9.getSelection){7var _a="text";8var _b;9try{10_b=_8.getSelection();11}12catch(e){13}14if(_b&&_b.rangeCount==1){15var _c=_b.getRangeAt(0);16if((_c.startContainer==_c.endContainer)&&((_c.endOffset-_c.startOffset)==1)&&(_c.startContainer.nodeType!=3)){17_a="control";18}19}20return _a;21}else{22return _9.selection.type.toLowerCase();23}24};25this.getSelectedText=function(){26if(_9.getSelection){27var _d=_8.getSelection();28return _d?_d.toString():"";29}else{30if(this.getType()=="control"){31return null;32}33return _9.selection.createRange().text;34}35};36this.getSelectedHtml=function(){37if(_9.getSelection){38var _e=_8.getSelection();39if(_e&&_e.rangeCount){40var i;41var _f="";42for(i=0;i<_e.rangeCount;i++){43var _10=_e.getRangeAt(i).cloneContents();44var div=_9.createElement("div");45div.appendChild(_10);46_f+=div.innerHTML;47}48return _f;49}50return null;51}else{52if(this.getType()=="control"){53return null;54}55return _9.selection.createRange().htmlText;56}57};58this.getSelectedElement=function(){59if(this.getType()=="control"){60if(_9.getSelection){61var _11=_8.getSelection();62return _11.anchorNode.childNodes[_11.anchorOffset];63}else{64var _12=_9.selection.createRange();65if(_12&&_12.item){66return _9.selection.createRange().item(0);67}68}69}70return null;71};72this.getParentElement=function(){73if(this.getType()=="control"){74var p=this.getSelectedElement();75if(p){76return p.parentNode;77}78}else{79if(_9.getSelection){80var _13=_9.getSelection();81if(_13){82var _14=_13.anchorNode;83while(_14&&(_14.nodeType!=1)){84_14=_14.parentNode;85}86return _14;87}88}else{89var r=_9.selection.createRange();90r.collapse(true);91return r.parentElement();92}93}94return null;95};96this.hasAncestorElement=function(_15){97return this.getAncestorElement.apply(this,arguments)!=null;98};99this.getAncestorElement=function(_16){100var _17=this.getSelectedElement()||this.getParentElement();101return this.getParentOfType(_17,arguments);102};103this.isTag=function(_18,_19){104if(_18&&_18.tagName){105var _1a=_18.tagName.toLowerCase();106for(var i=0;i<_19.length;i++){107var _1b=String(_19[i]).toLowerCase();108if(_1a==_1b){109return _1b;110}111}112}113return "";114};115this.getParentOfType=function(_1c,_1d){116while(_1c){117if(this.isTag(_1c,_1d).length){118return _1c;119}120_1c=_1c.parentNode;121}122return null;123};124this.collapse=function(_1e){125if(_9.getSelection){126var _1f=_8.getSelection();127if(_1f.removeAllRanges){128if(_1e){129_1f.collapseToStart();130}else{131_1f.collapseToEnd();132}133}else{134_1f.collapse(_1e);135}136}else{137var _20=_9.selection.createRange();138_20.collapse(_1e);139_20.select();140}141};142this.remove=function(){143var sel=_9.selection;144if(_9.getSelection){145sel=_8.getSelection();146sel.deleteFromDocument();147return sel;148}else{149if(sel.type.toLowerCase()!="none"){150sel.clear();151}152return sel;153}154};155this.selectElementChildren=function(_21,_22){156var _23;157_21=_2.byId(_21);158if(_9.getSelection){159var _24=_8.getSelection();160if(_4("opera")){161if(_24.rangeCount){162_23=_24.getRangeAt(0);163}else{164_23=_9.createRange();165}166_23.setStart(_21,0);167_23.setEnd(_21,(_21.nodeType==3)?_21.length:_21.childNodes.length);168_24.addRange(_23);169}else{170_24.selectAllChildren(_21);171}172}else{173_23=_21.ownerDocument.body.createTextRange();174_23.moveToElementText(_21);175if(!_22){176try{177_23.select();178}179catch(e){180}181}182}183};184this.selectElement=function(_25,_26){185var _27;186_25=_2.byId(_25);187if(_9.getSelection){188var _28=_9.getSelection();189_27=_9.createRange();190if(_28.removeAllRanges){191if(_4("opera")){192if(_28.getRangeAt(0)){193_27=_28.getRangeAt(0);194}195}196_27.selectNode(_25);197_28.removeAllRanges();198_28.addRange(_27);199}200}else{201try{202var tg=_25.tagName?_25.tagName.toLowerCase():"";203if(tg==="img"||tg==="table"){204_27=_5.body(_9).createControlRange();205}else{206_27=_5.body(_9).createRange();207}208_27.addElement(_25);209if(!_26){210_27.select();211}212}213catch(e){214this.selectElementChildren(_25,_26);215}216}217};218this.inSelection=function(_29){219if(_29){220var _2a;221var _2b;222if(_9.getSelection){223var sel=_8.getSelection();224if(sel&&sel.rangeCount>0){225_2b=sel.getRangeAt(0);226}227if(_2b&&_2b.compareBoundaryPoints&&_9.createRange){228try{229_2a=_9.createRange();230_2a.setStart(_29,0);231if(_2b.compareBoundaryPoints(_2b.START_TO_END,_2a)===1){232return true;233}234}235catch(e){236}237}238}else{239_2b=_9.selection.createRange();240try{241_2a=_29.ownerDocument.body.createTextRange();242_2a.moveToElementText(_29);243}244catch(e2){245}246if(_2b&&_2a){247if(_2b.compareEndPoints("EndToStart",_2a)===1){248return true;249}250}251}252}253return false;254},this.getBookmark=function(){255var bm,rg,tg,sel=_9.selection,cf=_6.curNode;256if(_9.getSelection){257sel=_8.getSelection();258if(sel){259if(sel.isCollapsed){260tg=cf?cf.tagName:"";261if(tg){262tg=tg.toLowerCase();263if(tg=="textarea"||(tg=="input"&&(!cf.type||cf.type.toLowerCase()=="text"))){264sel={start:cf.selectionStart,end:cf.selectionEnd,node:cf,pRange:true};265return {isCollapsed:(sel.end<=sel.start),mark:sel};266}267}268bm={isCollapsed:true};269if(sel.rangeCount){270bm.mark=sel.getRangeAt(0).cloneRange();271}272}else{273rg=sel.getRangeAt(0);274bm={isCollapsed:false,mark:rg.cloneRange()};275}276}277}else{278if(sel){279tg=cf?cf.tagName:"";280tg=tg.toLowerCase();281if(cf&&tg&&(tg=="button"||tg=="textarea"||tg=="input")){282if(sel.type&&sel.type.toLowerCase()=="none"){283return {isCollapsed:true,mark:null};284}else{285rg=sel.createRange();286return {isCollapsed:rg.text&&rg.text.length?false:true,mark:{range:rg,pRange:true}};287}288}289bm={};290try{291rg=sel.createRange();292bm.isCollapsed=!(sel.type=="Text"?rg.htmlText.length:rg.length);293}294catch(e){295bm.isCollapsed=true;296return bm;297}298if(sel.type.toUpperCase()=="CONTROL"){299if(rg.length){300bm.mark=[];301var i=0,len=rg.length;302while(i<len){303bm.mark.push(rg.item(i++));304}305}else{306bm.isCollapsed=true;307bm.mark=null;308}309}else{310bm.mark=rg.getBookmark();311}312}else{313console.warn("No idea how to store the current selection for this browser!");314}315}316return bm;317};318this.moveToBookmark=function(_2c){319var _2d=_2c.mark;320if(_2d){321if(_9.getSelection){322var sel=_8.getSelection();323if(sel&&sel.removeAllRanges){324if(_2d.pRange){325var n=_2d.node;326n.selectionStart=_2d.start;327n.selectionEnd=_2d.end;328}else{329sel.removeAllRanges();330sel.addRange(_2d);331}332}else{333console.warn("No idea how to restore selection for this browser!");334}335}else{336if(_9.selection&&_2d){...

Full Screen

Full Screen

browser_graphs-12.js

Source:browser_graphs-12.js Github

copy

Full Screen

...37 ok(graph1.hasSelectionInProgress(),38 "The selection should start (1.1).");39 ok(!graph2.hasSelectionInProgress(),40 "The selection should not start yet in the second graph (1.2).");41 is(graph1.getSelection().start, 300,42 "The current selection start value is correct (1.1).");43 is(graph2.getSelection().start, 300,44 "The current selection start value is correct (1.2).");45 is(graph1.getSelection().end, 300,46 "The current selection end value is correct (1.1).");47 is(graph2.getSelection().end, 300,48 "The current selection end value is correct (1.2).");49 hover(graph1, 400);50 ok(graph1.hasSelectionInProgress(),51 "The selection should still be in progress (2.1).");52 ok(!graph2.hasSelectionInProgress(),53 "The selection should not be in progress in the second graph (2.2).");54 is(graph1.getSelection().start, 300,55 "The current selection start value is correct (2.1).");56 is(graph2.getSelection().start, 300,57 "The current selection start value is correct (2.2).");58 is(graph1.getSelection().end, 400,59 "The current selection end value is correct (2.1).");60 is(graph2.getSelection().end, 400,61 "The current selection end value is correct (2.2).");62 dragStop(graph1, 500);63 ok(!graph1.hasSelectionInProgress(),64 "The selection should have stopped (3.1).");65 ok(!graph2.hasSelectionInProgress(),66 "The selection should have stopped (3.2).");67 is(graph1.getSelection().start, 300,68 "The current selection start value is correct (3.1).");69 is(graph2.getSelection().start, 300,70 "The current selection start value is correct (3.2).");71 is(graph1.getSelection().end, 500,72 "The current selection end value is correct (3.1).");73 is(graph2.getSelection().end, 500,74 "The current selection end value is correct (3.2).");75 info("Making a new selection in the second graph.");76 dragStart(graph2, 200);77 ok(!graph1.hasSelectionInProgress(),78 "The selection should not start yet in the first graph (4.1).");79 ok(graph2.hasSelectionInProgress(),80 "The selection should start (4.2).");81 is(graph1.getSelection().start, 200,82 "The current selection start value is correct (4.1).");83 is(graph2.getSelection().start, 200,84 "The current selection start value is correct (4.2).");85 is(graph1.getSelection().end, 200,86 "The current selection end value is correct (4.1).");87 is(graph2.getSelection().end, 200,88 "The current selection end value is correct (4.2).");89 hover(graph2, 300);90 ok(!graph1.hasSelectionInProgress(),91 "The selection should not be in progress in the first graph (2.2).");92 ok(graph2.hasSelectionInProgress(),93 "The selection should still be in progress (5.2).");94 is(graph1.getSelection().start, 200,95 "The current selection start value is correct (5.1).");96 is(graph2.getSelection().start, 200,97 "The current selection start value is correct (5.2).");98 is(graph1.getSelection().end, 300,99 "The current selection end value is correct (5.1).");100 is(graph2.getSelection().end, 300,101 "The current selection end value is correct (5.2).");102 dragStop(graph2, 400);103 ok(!graph1.hasSelectionInProgress(),104 "The selection should have stopped (6.1).");105 ok(!graph2.hasSelectionInProgress(),106 "The selection should have stopped (6.2).");107 is(graph1.getSelection().start, 200,108 "The current selection start value is correct (6.1).");109 is(graph2.getSelection().start, 200,110 "The current selection start value is correct (6.2).");111 is(graph1.getSelection().end, 400,112 "The current selection end value is correct (6.1).");113 is(graph2.getSelection().end, 400,114 "The current selection end value is correct (6.2).");115}116// EventUtils just doesn't work!117function hover(graph, x, y = 1) {118 x /= window.devicePixelRatio;119 y /= window.devicePixelRatio;120 graph._onMouseMove({ clientX: x, clientY: y });121}122function dragStart(graph, x, y = 1) {123 x /= window.devicePixelRatio;124 y /= window.devicePixelRatio;125 graph._onMouseMove({ clientX: x, clientY: y });126 graph._onMouseDown({ clientX: x, clientY: y });127}...

Full Screen

Full Screen

shadow-tree-exposure.js

Source:shadow-tree-exposure.js Github

copy

Full Screen

1description("Test to make sure shadow nodes are not exposed.");2var container = document.createElement("p");3document.body.appendChild(container);4container.appendChild(document.createTextNode("Some text: "));5shouldBe("getSelection().anchorNode", "null");6shouldBe("getSelection().anchorOffset", "0");7shouldBe("getSelection().focusNode", "null");8shouldBe("getSelection().focusOffset", "0");9shouldBe("getSelection().isCollapsed", "true");10shouldBe("getSelection().rangeCount", "0");11shouldBe("getSelection().baseNode", "null");12shouldBe("getSelection().baseOffset", "0");13shouldBe("getSelection().extentNode", "null");14shouldBe("getSelection().extentOffset", "0");15shouldBe("getSelection().type", "'None'");16debug("\nAdd an input element.\n");17var input = document.createElement("input");18container.appendChild(input);19input.value = "text";20input.focus();21input.select();22shouldBe("getSelection().anchorNode", "container");23shouldBe("getSelection().anchorOffset", "1");24shouldBe("getSelection().focusNode", "container");25shouldBe("getSelection().focusOffset", "1");26shouldBe("getSelection().isCollapsed", "true");27shouldBe("getSelection().rangeCount", "1");28shouldBe("getSelection().getRangeAt(0).startContainer", "container");29shouldBe("getSelection().getRangeAt(0).startOffset", "1");30shouldBe("getSelection().getRangeAt(0).endContainer", "container");31shouldBe("getSelection().getRangeAt(0).endOffset", "1");32shouldBe("getSelection().baseNode", "container");33shouldBe("getSelection().baseOffset", "1");34shouldBe("getSelection().extentNode", "container");35shouldBe("getSelection().extentOffset", "1");36shouldBe("getSelection().type", "'Range'");37debug("\nAdd a textarea element.\n");38var textarea = document.createElement("textarea");39container.appendChild(textarea);40textarea.value = "text";41textarea.focus();42textarea.select();43shouldBe("getSelection().anchorNode", "container");44shouldBe("getSelection().anchorOffset", "2");45shouldBe("getSelection().focusNode", "container");46shouldBe("getSelection().focusOffset", "2");47shouldBe("getSelection().isCollapsed", "true");48shouldBe("getSelection().rangeCount", "1");49shouldBe("getSelection().getRangeAt(0).startContainer", "container");50shouldBe("getSelection().getRangeAt(0).startOffset", "2");51shouldBe("getSelection().getRangeAt(0).endContainer", "container");52shouldBe("getSelection().getRangeAt(0).endOffset", "2");53shouldBe("getSelection().baseNode", "container");54shouldBe("getSelection().baseOffset", "2");55shouldBe("getSelection().extentNode", "container");56shouldBe("getSelection().extentOffset", "2");57shouldBe("getSelection().type", "'Range'");58document.body.removeChild(container);59debug("");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var page = require('webpage').create();2page.open(url, function (status) {3 var selection = page.evaluate(function () {4 return window.getSelection();5 });6 console.log(selection);7 phantom.exit();8});9var page = require('webpage').create();10var system = require('system');11var url = system.args[1];12page.viewportSize = {13};14page.paperSize = {15};16page.open(url, function (status) {17 if (status !== 'success') {18 console.log('Unable to load the address!');19 } else {20 window.setTimeout(function () {21 page.render('page.pdf');22 phantom.exit();23 }, 2000);24 }25});26Error: TypeError: 'undefined' is not a function (evaluating 'this.paperSize = paperSize')27var page = require('webpage').create();28var system = require('system');29var url = system.args[1];30page.viewportSize = {31};32page.paperSize = {33};34page.open(url, function (status) {35 if (status !== 'success') {36 console.log('Unable to load the address!');37 } else {38 window.setTimeout(function () {39 page.render('page.pdf');40 phantom.exit();41 }, 2000

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var driver = new wpt.chromeDriver();3driver.findElement(wpt.By.name('q')).sendKeys('webdriver');4driver.findElement(wpt.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.executeScript('return window.getSelection().toString()').then(function(selection) {11 console.log('Selection: ' + selection);12});13driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');2driver.findElement(webdriver.By.name('btnG')).click();3driver.wait(function() {4 return driver.getTitle().then(function(title) {5 return title === 'webdriver - Google Search';6 });7}, 1000);8driver.quit();9driver.executeScript("return document.getSelection();").then(function(selection) {10});11 (unknown error: DevToolsActivePort file doesn't exist)12 (The process started from chrome location /usr/bin/google-chrome is no longer ru

Full Screen

Using AI Code Generation

copy

Full Screen

1var selection = wptextpattern.getSelection();2var range = wptextpattern.getRange(selection);3var selectedText = wptextpattern.getSelectedText(selection);4var selectedHtml = wptextpattern.getSelectedHTML(selection);5var selectedNode = wptextpattern.getSelectedNode(selection);6var selectedNode = wptextpattern.getSelectedNode(selection);7var selectedNode = wptextpattern.getSelectedNode(selection);8var selectedNode = wptextpattern.getSelectedNode(selection);9var selectedNode = wptextpattern.getSelectedNode(selection);10var selectedNode = wptextpattern.getSelectedNode(selection);11var selectedNode = wptextpattern.getSelectedNode(selection);12var selectedNode = wptextpattern.getSelectedNode(selection);13var selectedNode = wptextpattern.getSelectedNode(selection);14var selectedNode = wptextpattern.getSelectedNode(selection);15var selectedNode = wptextpattern.getSelectedNode(selection);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.getSelection('en.wikipedia.org/wiki/Node.js', function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = document.querySelector('.wptb-table-editor');2test.getSelection();3getSelection() {4 return this.selection;5}6var test = document.querySelector('.wptb-table-editor');7test.getSelection();8getSelection() {9 return this.selection;10}11var test = document.querySelector('.wptb-table-editor');12test.getSelection();13getSelection() {14 return this.selection;15}

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