On Mon, Sep 7, 2009 at 6:38 PM, Eric Kidd<[email protected]> wrote:
> I have two questions about annotationBoundary: one involving cursors,
> and one involving deletion components. Assume I have a document
> containing a single italicized paragraph and a single link. In HTML,
> it would look like this:
>
>  <p><i>See <a href="http://example.com/";>this</a>.</i></p>
>
> In Wave, I think it would look something like this:
>
>  elementStart("p")
>  annotationBoundary([], ["style/fontStyle"], [null], ["italic"])
>  characters("See ")
>  annotationBoundary([], ["link/manual"], [null], ["http://
> example.com/"])
>  characters("this")
>  annotationBoundary(["link/manual"], [], [], [])
>  characters(".")
>  annotationBoundary(["style/fontStyle"], [], [], [])
>  elementEnd()
>
> Question #1: The Draft Protocol Spec says, "insertion components
> (characters, elementStart, elementEnd) generate items in the output
> document without moving the cursor". Does this mean I need to insert a
> "retain" component after each of the "elementStart" and "characters"
> components in the above document? Or is the document fine as it is?

Your document is fine as it is.  The cursor is just a position in the
input document; in your case, that's empty, so there is only one valid
position for the cursor, and you can't move it.


> Question #2: If I wanted to delete "<a href=...>this</a>" from the
> document, how would I do it? Would I do send this?
>
>  retain(5) // "<p>See "
>  deleteCharacters("this")
>  retain(2) // ".</p>"
>
> ...or would I send something reversible like this?
>
>  retain(5) // "<p>See "
>  annotationBoundary([], ["link/manual"], [null], ["http://
> example.com/"])
>  deleteCharacters("this")
>  annotationBoundary(["link/manual"], [], [], [])
>  retain(2) // ".</p>"

That's almost right.  You just need to swap old value and new value:
"For deletion components, the old values in the annotations update
match the annotations of each item in the input document [...], and
the new values match the annotations of the rightmost item generated
so far."

The "this" is annotated with link/manual=http://example.com/, so the
old value needs to be http://example.com/.  The rightmost item
generated so far is the space of "See ", which has the value null for
the key link/manual, so the new value needs to be null.

retain(5)
annotationBoundary([], ["link/manual"], ["http://example.com/";], [null])
deleteCharacters("this")
annotationBoundary(["link/manual"], [], [], [])
retain(2)

Hope this helps.
Christian.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Wave 
Protocol" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/wave-protocol?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to