222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
return xNode;
}
catch (e) {
showError(e);
}
},
sendTextToClipboard (sText) {
// recipe from https://github.com/mdn/webextensions-examples/blob/master/context-menu-copy-link-with-types/clipboard-helper.js
// It doesn’t seem to work anymore on Firefox. Still OK on Chrome.
//console.log(sText);
function setClipboardData (xEvent) {
document.removeEventListener("copy", setClipboardData, true);
xEvent.stopImmediatePropagation();
xEvent.preventDefault();
xEvent.clipboardData.setData("text/plain", sText);
}
document.addEventListener("copy", setClipboardData, true);
document.execCommand("copy");
},
getCaretPosition (xElement) {
// JS awfulness again.
// recepie from https://stackoverflow.com/questions/4811822/get-a-ranges-start-and-end-offsets-relative-to-its-parent-container
let nCaretOffsetStart = 0;
let nCaretOffsetEnd = 0;
let xSelection = window.getSelection();
if (xSelection.rangeCount > 0) {
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
return xNode;
}
catch (e) {
showError(e);
}
},
getCaretPosition (xElement) {
// JS awfulness again.
// recepie from https://stackoverflow.com/questions/4811822/get-a-ranges-start-and-end-offsets-relative-to-its-parent-container
let nCaretOffsetStart = 0;
let nCaretOffsetEnd = 0;
let xSelection = window.getSelection();
if (xSelection.rangeCount > 0) {
|