diff --git a/src/main/html/Integration.html b/src/main/html/Integration.html new file mode 100644 index 0000000..0dc0c1c --- /dev/null +++ b/src/main/html/Integration.html @@ -0,0 +1,112 @@ + + +
+Hello world
"); + editor.setContent("Hello world
Hello again
And some bolded content
const paragraph = Traverse.child(contentBody, 1).getOrDie('Unable to find second child of editor body'); - // And then get the bolded (child 0 would be the text node "And some ") + // And then get the bolded (child 0 would be the text node 'And some ') const strong = Traverse.child(paragraph, 1).getOrDie('Unable to find second child of paragraph'); - // And finally let's get the text node "bolded" + // And finally let's get the text node 'bolded' const text = Traverse.child(strong, 0).getOrDie('Unable to find text inside strong element'); range.setStart(text.dom, 0); @@ -72,9 +72,9 @@ describe('Part3Ex3Test', () => { const contentBody = TinyDom.body(editor); // Let's get theAnd some bolded content
const paragraph = Traverse.child(contentBody, 1).getOrDie('Unable to find second child of editor body'); - // And then get the bolded (child 0 would be the text node "And some ") + // And then get the bolded (child 0 would be the text node 'And some ') const strong = Traverse.child(paragraph, 1).getOrDie('Unable to find second child of paragraph'); - // And finally let's get the text node "bolded" + // And finally let's get the text node 'bolded' const text = Traverse.child(strong, 0).getOrDie('Unable to find text inside strong element'); And here's how you'd do all of this with an agar API. @@ -84,7 +84,7 @@ describe('Part3Ex3Test', () => { // Note that Cursors.follow only deals with DOM nodes, not offsets, and it uses the same node // for both the selection start and end node /* - Each number in this array represents a call to "Traverse.child(...,Here is a bit of content
', @@ -112,5 +114,9 @@ describe('Part3Ex3Test', () => { ].join('\n')); // TODO: Write an assertion to test your changes (hint: TinyAssertions) + // TinySelections.setSelection(editor, [0, 0], 5, [0], 3); + // selection includes span with text decoration style + TinyAssertions.assertSelection(editor, [0, 1, 0], 0, [0], 2) + assert.equal(editor.selection.getContent(), 'a bit of'); }); });