Class: Part
One OPC part. Holds the original bytes from the zip for its whole life; parses to a DOM only on demand; serializes back to the original bytes unless something mutated the DOM and called markDirty().
Untouched parts therefore round-trip byte-identically.
Constructors
Constructor
new Part(
partName,contentType,bytes):Part
Parameters
| Parameter | Type |
|---|---|
partName | string |
contentType | string |
bytes | Uint8Array |
Returns
Part
Properties
contentType
readonlycontentType:string
partName
readonlypartName:string
Accessors
dom
Get Signature
get dom():
Document
Lazily parsed DOM for XML parts. Parsing alone does not mark the part dirty; call markDirty() after mutating the tree.
Returns
Document
isDirty
Get Signature
get isDirty():
boolean
Returns
boolean
isParsed
Get Signature
get isParsed():
boolean
True once the body has been materialized as a DOM.
Returns
boolean
isXmlPart
Get Signature
get isXmlPart():
boolean
Whether this part's body is XML (by content type).
Returns
boolean
originalBytes
Get Signature
get originalBytes():
Uint8Array
The bytes the part was loaded or created with. Do not mutate.
Not the part's current body. An edit made through dom and markDirty is visible only through serialize. Anything that copies, compares or reads a part's content wants serialize(): every slide copy and import used to read this instead, and silently dropped each edit made earlier in the session. Named so a call site has to say which of the two it means.
Returns
Uint8Array
Methods
markDirty()
markDirty():
void
Call after mutating the DOM so serialize() reserializes this part.
Returns
void
serialize()
serialize():
Uint8Array
The part's current body, which is also what save() writes: the original bytes when clean (byte-identical), the serialized DOM when dirty (semantically equivalent, schema-valid). Copy a part through this, not originalBytes.
Returns
Uint8Array