Search code examples
javascripteventssdkphotoeditorsdk

Getting all user operation events via the photoeditorsdk - getOperationsStack is not a function


I have setup the HTML5 SDK for the photoeditorsdk plugin and it generally works really well - I need to be able to determine if an image 'is dirty' (e.g has had any form of edit made to the original image - note I am using the latest v4 of the library/sdk

I am trying to use the following code below to output to the console the user operations however when I click the Export button and the 'export' event below is executed I get the following error:

var editor = new PhotoEditorSDK.UI.ReactUI();
editor.on('export', function (result, editor) {
  // User has clicked export, find out what operations he used
  var stack = editor.getOperationsStack();
  console.log('User used operations:');

  stack.forEach(function (operation) {
    console.log(operation.constructor.identifier);
  });
});

Error

TypeError: editor.getOperationsStack is not a function

This is the exact code used from the SDK website here for events - can anyone suggest the way to get around the problem to get all the user operations and/or determine if an image 'is dirty'? https://docs.photoeditorsdk.com/guides/html5/v4/concepts/events


Solution

  • I have been getting the exact same error, I've noticed that the Docs do not accurately represent the latest version (in many places).

    I've managed to get the operations like so;

    var stack = editor.operations.getStack().getStack()
    

    I have no idea why the method has been removed. Frustrating they don't have issues on github, and take several days to reply to support tickets (still waiting to hear back why CORS images don't work).

    Cheers