Interface CanvasBuilder

  • public interface CanvasBuilder
    Defines contract for building a canvas from a raw HTML document stream.

    The CanvasBuilder is responsible for building a canvas component tree, along with the top level canvas component script as well as the design and clientlibs. A CanvasBuilder builds canvas artifacts for one html document. If a design package contains multiple importable html documents, multiple CanvasBuilders hook in to accomplish import.

    The CanvasBuilder should dispatch appropriate events during major events of its lifetime. These events, listed as they appear in order, are tabulated as follows:

    EVENT_STARTINGDispatched before the CanvasBuilder begins building. May be used for any pre-processing
    EVENT_PARSE_COMPLETEDispatched when the html document stream has been successfully parsed.
    EVENT_COMPONENT_TREE_BUILTDispatched after the canvas component tree has been persisted to the repository
    EVENT_CANVAS_SCRIPT_BUILTDispatched after the canvas component script has been generated and persisted successfully
    EVENT_COMPLETEMarks the completion of canvas building.

    The bundled implementation of the CanvasBuilder also attaches contextual information to the above events. This information comes handy to find various state parameters and process accordingly.

    The contextual information is sent in form of event payload, accessible via Event.getProperty(String). The below table enlists various event properties along with their type, description and the events the payload is available with.

    Property Type Description Available
    designImporterContext DesignImporterContext The design importer context associated with the canvas build operation ALL
    parseResult ParseResult Encapsulates the result of html document parsing. Can be used to access the markup formed and/or cq components culled EVENT_PARSE_COMPLETE and all events onward
    canvas Resource The resource representing the root of the canvas component tree built EVENT_COMPONENT_TREE_BUILT and all events onward