-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ms2/property-panel
- Loading branch information
Showing
10 changed files
with
475 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/management-system-v2/lib/process-export/copy-process-image.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { toBpmnObject, toBpmnXml } from '@proceed/bpmn-helper'; | ||
|
||
import { getSVGFromBPMN } from './util'; | ||
import { getPNGFromSVG } from './image-export'; | ||
|
||
/** | ||
* Adds an image of a process or selected parts of a process to the clipboard | ||
* | ||
* @param modeler the modeler to copy the process image from | ||
*/ | ||
export async function copyProcessImage(modeler: any) { | ||
let { xml } = await modeler.saveXML({ format: true }); | ||
|
||
// get the currently visible layer | ||
const rootElement = (modeler.get('canvas') as any).getRootElement().businessObject; | ||
const subprocessId = | ||
rootElement.$type === 'bpmn:Process' || rootElement.$type === 'bpmn:Collaboration' | ||
? undefined | ||
: rootElement.id; | ||
|
||
// get the selected elements | ||
let selection: any[] = (modeler.get('selection') as any).get(); | ||
// get the png and copy it to the clipboard | ||
const svg = await getSVGFromBPMN( | ||
xml!, | ||
subprocessId, | ||
selection.map((el) => el.id), | ||
); | ||
const blob = await getPNGFromSVG(svg, 3); | ||
const data = [new ClipboardItem({ 'image/png': blob })]; | ||
navigator.clipboard.write(data).then(() => { | ||
console.log('Copied to clipboard'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.