Used to define an action for lassoed diagram areas. Note that a lassoed area action can only be defined when the property lassoedAreasEnabled is set to true.
.defineLassoedAreaAction( /*String*/ actionCaption, /*Function*/ actionFunction)
A string that will be used as the lassoed area action's UI caption. This is the caption users will see in the UI for the action.
A function that accepts one parameter, an object that defines a diagram rectangle by its top, left, bottom, and right coordinates. I.E., an object with the numeric properties, top, bottom, left, right.
This function will be called whenever the user invokes the lassoed area action.
editor = new ESDWeb(null, 'editorNode'); ... // Startup the editor with lassoed areas enabled. editor.startup({ requestTimeout: 10 * 1000, // Set the request timeout (10 seconds) lassoedAreasEnabled: true, // Enable lassoed areas beginZIndex: 50 // Set the z-index }); ... // Define a lassoed area action that will export a lassoed area as an image. var exportAction = this.editor.defineLassoedAreaAction('Export', function (rect) { // summary: // Download a base64 encoded image of the portion of the diagram defined by rect. // rec: Object // A rectangular diagram area defined by top, bottom, left, and right coordinates. var rectWidth = Math.abs(rect.right - rect.left), rectHeight = Math.abs(rect.top - rect.bottom), aspectRatio = rectWidth / rectHeight, targetWidthHeight = 1200, width = targetWidthHeight, height = targetWidthHeight, exportOptions; if (aspectRatio < 1) { width = Math.ceil(width * aspectRatio); } else if (aspectRatio > 1) { height = Math.ceil(height / aspectRatio); } exportOptions = { image: true, format: 'image/jpeg', margin: 10, width: width, height: height, includePrefix: false, zoomTo: rect }; editor.exportImage( exportOptions, function (image) { var byteCharacters = atob(image), byteNumbers = new Array(byteCharacters.length), byteArray, blob, i; for (i = 0; i < byteCharacters.length; i++) { byteNumbers[i] = byteCharacters.charCodeAt(i); } byteArray = new Uint8Array(byteNumbers); blob = new Blob([byteArray], {type: options.format}); saveAs(blob, 'export' + '.' + options.format.substr(6)); }, onError('Export failed') ); } ); ... // Remove the lassoed area export action. exportAction.remove();