docx
    Preparing search index...

    Class Endnotes

    Base class for all XML components in WordprocessingML documents.

    XmlComponent provides the infrastructure for building XML element trees that are serialized into document.xml and other parts of the DOCX package. It manages a collection of child components and handles the conversion to the intermediate object format used by the xml serialization library.

    // Creating a custom XML component
    class MyElement extends XmlComponent {
    constructor(text: string) {
    super("w:myElement");
    this.root.push(new Attributes({ val: text }));
    }
    }

    const element = new MyElement("Hello");
    // When serialized: <w:myElement w:val="Hello"/>

    Hierarchy (View Summary)

    Index
    • get writtenAs(): readonly BaseXmlComponent[] | undefined
      Internal

      The components written in this one's place, one after another, when it can't be written as a single element, such as a run with another run in its children. Undefined when it is written as itself.

      Returns readonly BaseXmlComponent[] | undefined

    • Internal

      The id of the endnote that a reference run brings with it, which is added to the endnotes the first time the run is written, with an id no other endnote has. Word has endnotes only in a document's body, so a run written anywhere else, such as in a header, has none, and its endnote isn't added.

      Parameters

      • reference: object

        The run, which has the same endnote each time it is written

      • endnote: NoteContent

        The endnote's content

      • context: IContext

        The context the run is written in

      Returns number | undefined

      The endnote's id, or undefined outside the document's body