The dom.edit module¶
The Edit base class, to perform operations on a DOM document and/or a related parce Document in different ways.
-
class
Edit[source]¶ Bases:
objectBase class to perform operations on a DOM document via a
Range, anelement.Elementnode, aparce.Documentor a selection of a parce document in aparce.Cursor.You must implement at least
Edit.edit_range()to make it work. You can choose to reimplement other methods to alter behaviour or functionality.Then you create an instance, and you can call one of the
edit_xxx()methods.-
range_from_root= False¶ If True, when there is a selection, a Range is created from the root node, otherwise from the younghest common ancestor.
-
range_from_cursor= False¶ If True, a Range is created from the cursor’s position to the end, instead of the full document in case there is no selection.
-
readonly= False¶ If True, does not write back changes to the parce Document
-
document()[source]¶ Return the parce Document, if available.
This is the document that was used when
edit_cursor()oredit_document()was called. The document is only available during that edit call.
-
edit(music)[source]¶ Convenience method calling one of the other edit_xxx methods depending on the type.
-
edit_cursor(cursor)[source]¶ Edit the range pointed to by the
parce.Cursor.The default implementation calls
edit_range()with a Range, that by default encompasses the full DOM tree when there is no selection. Setrange_from_cursorto True if you want the edited range to be from the cursor’s position to the document end when there is no selection.If the cursor has a selection, the Range encompasses only the child nodes that are within the cursor’s selection. The ancestor of the range is by default the younghest common ancestor of the start and end nodes of the range. Set
range_from_rootto True if you want the ancestor of the range to be the DOM tree root anyway.
-
edit_document(document)[source]¶ Edit the full
parce.Document.The default implementation calls
edit_cursor()with aparce.Cursorpointing to the beginning of the document, without selection.
-
edit_node(node)[source]¶ Edit the full
element.Elementnode.The default implementation calls
edit_range()with a Range encompassing the full element node.
-