Skip to content

Instantly share code, notes, and snippets.

@damondouglas
Forked from anonymous/index.html
Last active January 30, 2016 02:10
Show Gist options
  • Save damondouglas/fa63285d6152dd94fac8 to your computer and use it in GitHub Desktop.
Save damondouglas/fa63285d6152dd94fac8 to your computer and use it in GitHub Desktop.
selecting node dart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>noisy-cell-0803</title>
<script type="application/dart" src="main.dart"></script>
</head>
<body>
<div contenteditable id="d1">
<h1 id="h1"><span id="h1s">Lorem ipsum</span></h1>
<h2 id="h2"><span id="h2s">dolor sit amet</span></h2>
<span id="s4">Etiam nunc turpis</span>
<span id="s5">Nam imperdiet felis</span>
<p id="p1">
<span>Lorem ipsum dolor sit amet, <span id="s1" bold>consectetur adipiscing elit</span>. Vestibulum interdum viverra molestie. Pellentesque aliquet ligula at neque posuere, et condimentum tortor finibus. Aliquam volutpat nisl non tristique hendrerit. Maecenas mattis dolor lorem, eu hendrerit sem molestie sed. Donec est ipsum, cursus sit amet cursus id, lacinia sit amet justo. Donec at leo interdum, tristique libero eget, lobortis felis. Nulla egestas laoreet fringilla. Nulla ac turpis ac purus sagittis bibendum scelerisque id leo.</span>
</p>
<p id="p2">
<span bold italic underline>Etiam nunc turpis, feugiat id ultrices eget, <span id="s2">tempor non dui. Proin quis scelerisque est</span>. Praesent sit amet dolor accumsan, mollis sapien non, fringilla metus. Nullam aliquam, erat ut porttitor congue, nunc nisl vulputate mauris, vitae gravida nulla nisi a mi. Nunc quis purus at diam ultrices placerat eget nec nulla. Maecenas vitae vehicula tellus, et lacinia sem. Duis a turpis eros. Sed at tempor diam, ut pharetra est. Vivamus iaculis venenatis orci tincidunt fringilla. Nulla libero massa, hendrerit vel lectus eget, placerat consectetur ligula. Ut sagittis ornare consectetur. Curabitur non laoreet turpis. Proin vestibulum risus urna, at finibus dolor euismod ut. Nullam sodales vehicula sagittis. Donec sit amet neque finibus, ullamcorper urna vitae, volutpat lacus. Ut eu metus tellus.</span>
</p>
<p id="p3">
<span>Nam imperdiet felis ut sapien pharetra pellentesque nec eget ante. <span id="s3" bold italic underline>Sed eu nulla id neque tincidunt varius</span> quis vel tortor. Morbi id libero lacus. Fusce eget justo eget lacus gravida tristique id id lacus. Aliquam vulputate neque in convallis ultrices. Donec lectus nibh, accumsan ac consectetur quis, mollis non urna. Donec mattis mauris ut ante fringilla, non posuere urna venenatis. Pellentesque molestie hendrerit libero, eget placerat lectus tempus at. Praesent pellentesque, mauris ut auctor congue, erat turpis tempus lectus, non condimentum massa dui a nulla. Nulla non felis massa. Integer lacinia imperdiet fermentum. Nunc interdum efficitur tortor a lacinia. Nullam non quam purus. Suspendisse gravida commodo ultrices. Sed ornare elementum bibendum.</span>
</p>
</div>
<div id="toolbar" on-click="clickedInToolbar" noselect>
<paper-toggle-button disabled$={{selectionIsEmpty}} id="bold"><span bold>Bold</span></paper-toggle-button>
</div>
</body>
</html>
import 'dart:html';
void main() {
var range = document.createRange();
var selection = window.getSelection();
range.selectNode(querySelector('#s1'));
selection.removeAllRanges();
selection.addRange(range);
print(selection.rangeCount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment