diff --git a/lib/BaseViewer.d.ts b/lib/BaseViewer.d.ts index d6663aa2ef..0c6c1e14de 100644 --- a/lib/BaseViewer.d.ts +++ b/lib/BaseViewer.d.ts @@ -82,7 +82,7 @@ declare namespace Events { * A `import.parse.start` event. */ export type ImportParseStart = { - + /** * The XML that is to be parsed. */ @@ -93,7 +93,7 @@ declare namespace Events { * A `import.parse.complete` event. */ export type ImportParseComplete = { - + /** * An error thrown when parsing the XML. */ @@ -151,7 +151,7 @@ declare namespace Events { * A `saveXML.done` event. */ export type SaveXMLDone = SaveXMLResult & Event; - + /** * A `saveSVG.done` event. */ @@ -268,11 +268,11 @@ export default class BaseViewer extends Diagram { * * @throws An error thrown during export. * - * @param options The options. + * @param [options] The options. * * @return A promise resolving with the XML. */ - saveXML(options: SaveXMLOptions): Promise; + saveXML(options?: SaveXMLOptions): Promise; /** * Export the currently displayed BPMN 2.0 diagram as @@ -363,4 +363,4 @@ export default class BaseViewer extends Diagram { * Detach the viewer. */ detach(): void; -} \ No newline at end of file +} diff --git a/lib/features/modeling/Modeling.d.ts b/lib/features/modeling/Modeling.d.ts new file mode 100644 index 0000000000..a4a1b5d867 --- /dev/null +++ b/lib/features/modeling/Modeling.d.ts @@ -0,0 +1,60 @@ +import BaseModeling, { ModelingHints } from 'diagram-js/lib/features/modeling/Modeling'; +import EventBus from 'diagram-js/lib/core/EventBus'; +import ElementFactory from 'diagram-js/lib/core/ElementFactory'; +import CommandStack, { CommandHandlerConstructor } from 'diagram-js/lib/command/CommandStack'; +import { Base, ModelAttrsConnection, Root, Shape } from 'diagram-js/lib/model'; +import { DirectionTRBL, Rect } from 'diagram-js/lib/util/Types'; +import { ModdleElement } from '../../BaseViewer'; + +export type ModelingUpdateLabelHints = { + removeShape?: boolean +} & ModelingHints + +export type ModelingColorsHints = { + fill?: string + stroke?: string +} & ModelingHints + +/** + * BPMN 2.0 modeling features activator + * + * @param {EventBus} eventBus + * @param {ElementFactory} elementFactory + * @param {CommandStack} commandStack + * @param {BpmnRules} bpmnRules + */ +export default class Modeling extends BaseModeling { + constructor(eventBus: EventBus, elementFactory: ElementFactory, commandStack: CommandStack, bpmnRules: Object); + + getHandlers(): Map; + + updateLabel(element: Base, newLabel: string, newBounds?: Rect, hints?: ModelingUpdateLabelHints): void; + + connect(source: Base, target: Base, attrs?: ModelAttrsConnection, hints?: ModelingHints): typeof BaseModeling.prototype.createConnection; + + updateModdleProperties(source: Base, target: ModdleElement, properties: Record): void; + + updateProperties(source: Base, properties: Record): void; + + resizeLane(laneShape: Base, newBounds: Rect, balanced?: boolean): void; + + addLane(targetLaneShape: Shape, location?: DirectionTRBL): Shape; + + splitLane(targetLane: Shape, count: number): void; + + makeCollaboration(): Root; + + updateLaneRefs(flowNodeShapes: Shape[], laneShapes: Shape[]): void; + + /** + * Transform the current diagram into a process. + */ + makeProcess(): void; + + claimId(id: string, moddleElement: ModdleElement): void; + + unclaimId(id: string, moddleElement: ModdleElement): void; + + setColor(elements: Base, colors?: ModelingColorsHints): void; + setColor(elements: Base[], colors?: ModelingColorsHints): void; +} diff --git a/lib/features/modeling/Modeling.js b/lib/features/modeling/Modeling.js index c2888d738b..bb08320b37 100644 --- a/lib/features/modeling/Modeling.js +++ b/lib/features/modeling/Modeling.js @@ -72,7 +72,7 @@ Modeling.prototype.updateLabel = function(element, newLabel, newBounds, hints) { Modeling.prototype.connect = function(source, target, attrs, hints) { - var bpmnRules = this._bpmnRules; + const bpmnRules = this._bpmnRules; if (!attrs) { attrs = bpmnRules.canConnect(source, target); @@ -110,7 +110,7 @@ Modeling.prototype.resizeLane = function(laneShape, newBounds, balanced) { }; Modeling.prototype.addLane = function(targetLaneShape, location) { - var context = { + const context = { shape: targetLaneShape, location: location }; @@ -134,11 +134,11 @@ Modeling.prototype.splitLane = function(targetLane, count) { */ Modeling.prototype.makeCollaboration = function() { - var collaborationElement = this._create('root', { + const collaborationElement = this._create('root', { type: 'bpmn:Collaboration' }); - var context = { + const context = { newRoot: collaborationElement }; @@ -157,16 +157,14 @@ Modeling.prototype.updateLaneRefs = function(flowNodeShapes, laneShapes) { /** * Transform the current diagram into a process. - * - * @return {djs.model.Root} the new root element */ Modeling.prototype.makeProcess = function() { - var processElement = this._create('root', { + const processElement = this._create('root', { type: 'bpmn:Process' }); - var context = { + const context = { newRoot: processElement };