| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- /**
- * A base viewer for BPMN 2.0 diagrams.
- *
- * Have a look at {@link Viewer}, {@link NavigatedViewer} or {@link Modeler} for
- * bundles that include actual features.
- *
- */
- export default class BaseViewer extends Diagram {
- /**
- * @param options The options to configure the viewer.
- */
- constructor(options?: BaseViewerOptions);
- /**
- * Parse and render a BPMN 2.0 diagram.
- *
- * Once finished the viewer reports back the result to the
- * provided callback function with (err, warnings).
- *
- * ## Life-Cycle Events
- *
- * During import the viewer will fire life-cycle events:
- *
- * * import.parse.start (about to read model from XML)
- * * import.parse.complete (model read; may have worked or not)
- * * import.render.start (graphical import start)
- * * import.render.complete (graphical import finished)
- * * import.done (everything done)
- *
- * You can use these events to hook into the life-cycle.
- *
- * @throws {ImportXMLError} An error thrown during the import of the XML.
- *
- * @fires BaseViewer#ImportParseStartEvent
- * @fires BaseViewer#ImportParseCompleteEvent
- * @fires Importer#ImportRenderStartEvent
- * @fires Importer#ImportRenderCompleteEvent
- * @fires BaseViewer#ImportDoneEvent
- *
- * @param xml The BPMN 2.0 XML to be imported.
- * @param bpmnDiagram The optional diagram or Id of the BPMN diagram to open.
- *
- * @return A promise resolving with warnings that were produced during the import.
- */
- importXML(xml: string, bpmnDiagram?: ModdleElement | string): Promise<ImportXMLResult>;
- /**
- * Import parsed definitions and render a BPMN 2.0 diagram.
- *
- * Once finished the viewer reports back the result to the
- * provided callback function with (err, warnings).
- *
- * ## Life-Cycle Events
- *
- * During import the viewer will fire life-cycle events:
- *
- * * import.render.start (graphical import start)
- * * import.render.complete (graphical import finished)
- *
- * You can use these events to hook into the life-cycle.
- *
- * @throws {ImportDefinitionsError} An error thrown during the import of the definitions.
- *
- * @param definitions The definitions.
- * @param bpmnDiagram The optional diagram or ID of the BPMN diagram to open.
- *
- * @return A promise resolving with warnings that were produced during the import.
- */
- importDefinitions(definitions: ModdleElement, bpmnDiagram?: ModdleElement | string): Promise<ImportDefinitionsResult>;
- /**
- * Open diagram of previously imported XML.
- *
- * Once finished the viewer reports back the result to the
- * provided callback function with (err, warnings).
- *
- * ## Life-Cycle Events
- *
- * During switch the viewer will fire life-cycle events:
- *
- * * import.render.start (graphical import start)
- * * import.render.complete (graphical import finished)
- *
- * You can use these events to hook into the life-cycle.
- *
- * @throws {OpenError} An error thrown during opening.
- *
- * @param bpmnDiagramOrId The diagram or Id of the BPMN diagram to open.
- *
- * @return A promise resolving with warnings that were produced during opening.
- */
- open(bpmnDiagramOrId: ModdleElement | string): Promise<OpenResult>;
- /**
- * Export the currently displayed BPMN 2.0 diagram as
- * a BPMN 2.0 XML document.
- *
- * ## Life-Cycle Events
- *
- * During XML saving the viewer will fire life-cycle events:
- *
- * * saveXML.start (before serialization)
- * * saveXML.serialized (after xml generation)
- * * saveXML.done (everything done)
- *
- * You can use these events to hook into the life-cycle.
- *
- * @throws {Error} An error thrown during export.
- *
- * @fires BaseViewer#SaveXMLStart
- * @fires BaseViewer#SaveXMLDone
- *
- * @param options The options.
- *
- * @return A promise resolving with the XML.
- */
- saveXML(options?: SaveXMLOptions): Promise<SaveXMLResult>;
- /**
- * Export the currently displayed BPMN 2.0 diagram as
- * an SVG image.
- *
- * ## Life-Cycle Events
- *
- * During SVG saving the viewer will fire life-cycle events:
- *
- * * saveSVG.start (before serialization)
- * * saveSVG.done (everything done)
- *
- * You can use these events to hook into the life-cycle.
- *
- * @throws {Error} An error thrown during export.
- *
- * @fires BaseViewer#SaveSVGDone
- *
- * @return A promise resolving with the SVG.
- */
- saveSVG(): Promise<SaveSVGResult>;
- /**
- * Return modules to instantiate with.
- *
- * @return The modules.
- */
- getModules(): ModuleDeclaration[];
- /**
- * Register an event listener.
- *
- * Remove an event listener via {@link BaseViewer#off}.
- *
- *
- * @param events The event(s) to listen to.
- * @param callback The callback.
- * @param that Value of `this` the callback will be called with.
- */
- on<T>(events: string | string[], callback: EventBusEventCallback<T>, that?: any): any;
- /**
- * Register an event listener.
- *
- * Remove an event listener via {@link BaseViewer#off}.
- *
- *
- * @param events The event(s) to listen to.
- * @param priority The priority with which to listen.
- * @param callback The callback.
- * @param that Value of `this` the callback will be called with.
- */
- on<T>(
- events: string | string[],
- priority: number,
- callback: EventBusEventCallback<T>,
- that?: any
- ): any;
- /**
- * Remove an event listener.
- *
- * @param events The event(s).
- * @param callback The callback.
- */
- off(events: string | string[], callback?: Function): void;
- /**
- * Attach the viewer to an HTML element.
- *
- * @param parentNode The parent node to attach to.
- */
- attachTo(parentNode: HTMLElement): void;
- /**
- * Get the definitions model element.
- *
- * @return The definitions model element.
- */
- getDefinitions(): ModdleElement;
- /**
- * Detach the viewer.
- *
- * @fires BaseViewer#DetachEvent
- */
- detach(): void;
- }
- type EventBusEventCallback<T> = import('diagram-js/lib/core/EventBus').EventBusEventCallback<T>;
- type ModuleDeclaration = import('didi').ModuleDeclaration;
- type Moddle = import('./model/Types').Moddle;
- type ModdleElement = import('./model/Types').ModdleElement;
- type ModdleExtension = import('./model/Types').ModdleExtension;
- export type BaseViewerOptions = {
- width?: number | string;
- height?: number | string;
- position?: string;
- container?: string | HTMLElement;
- moddleExtensions?: ModdleExtensions;
- additionalModules?: ModuleDeclaration[];
- } & Record<string, any>;
- export type ModdleElementsById = Record<string, ModdleElement>;
- export type ModdleExtensions = {
- [key: string]: import("./model/Types").ModdleExtension;
- };
- export type ImportXMLResult = {
- warnings: string[];
- };
- export type ImportXMLError = ImportXMLResult & Error;
- export type ImportDefinitionsResult = ImportXMLResult;
- export type ImportDefinitionsError = ImportXMLError;
- export type OpenResult = ImportXMLResult;
- export type OpenError = ImportXMLError;
- export type SaveXMLOptions = {
- format?: boolean;
- preamble?: boolean;
- };
- export type SaveXMLResult = {
- xml?: string;
- error?: Error;
- };
- export type SaveSVGResult = {
- svg: string;
- };
- export type ImportParseStartEvent = {
- xml: string;
- };
- export type ImportParseCompleteEvent = {
- error?: ImportXMLError;
- definitions?: ModdleElement;
- elementsById?: ModdleElementsById;
- references?: ModdleElement[];
- warnings: string[];
- };
- export type ImportDoneEvent = {
- error?: ImportXMLError;
- warnings: string[];
- };
- export type SaveXMLStartEvent = {
- definitions: ModdleElement;
- };
- export type SaveXMLDoneEvent = SaveXMLResult;
- export type SaveSVGDoneEvent = {
- error?: Error;
- svg: string;
- };
- import Diagram from 'diagram-js';
|