mirror of
https://github.com/servo/servo
synced 2026-04-28 10:27:40 +02:00
32 lines
843 B
JavaScript
32 lines
843 B
JavaScript
document.addEventListener("DOMContentLoaded", function() {
|
|
// Mare sure we're styling with CSS
|
|
document.execCommand("styleWithCss", true, null);
|
|
});
|
|
|
|
function insertText(selector, newText) {
|
|
var selection = window.getSelection(),
|
|
insertionPoint = document.querySelector(selector),
|
|
range = document.createRange();
|
|
|
|
range.selectNode(insertionPoint);
|
|
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
|
|
document.execCommand("insertText", true, newText);
|
|
}
|
|
|
|
function duplicate(selector) {
|
|
var selection = window.getSelection(),
|
|
insertionPoint = document.querySelector(selector),
|
|
range = document.createRange();
|
|
|
|
range.selectNode(insertionPoint);
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
|
|
document.execCommand("copy", true, null);
|
|
|
|
selection.removeAllRanges();
|
|
document.execCommand("paste", true, null);
|
|
} |