Skip to main content
1-Visitor
August 26, 2011
Question

surroundContents() and losing track changes

  • August 26, 2011
  • 2 replies
  • 837 views

Hello Adepters,


I wrote a function to wrap/unwrap a range in a special element. To wrap the range I use the range function range.surroundContents(element). To unwrap an element I replace the wrapped range by the actual range. Now in the function if I don’t turn track changes off the whole range is marked as added which I don’t want. If in the wrap/unwrap function I turn track changes off I lose all track changes I had in the actual range.



How do I wrap/unwrap a range in anew element without losing track changes?



Thanks,


-Samah

    2 replies

    18-Opal
    August 26, 2011
    Hi Samah-



    The AOM functions for modifying a range do seem to spread the change
    tracking markup around more than one might like. To get around this, you
    can try "cheating" and using the Acl object to apply ACL functions,
    which give simpler change tracking markup. For example, instead of using
    range.surroundContents(), make the range selected and then call
    Acl.execute("insert_tag {tagname}"). This will leave the existing
    content alone, and will only mark the tag insertion as a change. For
    removing a wrapper, position the caret at the beginning of the element
    (just inside the start tag) and use Acl.execute("delete_tag").



    --Clay



    Clay Helberg

    Senior Consultant

    TerraXML


    samah1-VisitorAuthor
    1-Visitor
    August 29, 2011
    Hi Clay,

    Thanks for your reply. The insert_tag() & delete_tag() worked perfectly.

    -Samah