Code Monkey home page Code Monkey logo

Comments (2)

tilgovi avatar tilgovi commented on June 8, 2024

There are not, but it should be fairly easy to implement yourself.

The annotator.ui.main function returns a block of hooks:

    {
        // ... left out for brevity ...

        beforeAnnotationCreated: function (annotation) {
            // Editor#load returns a promise that is resolved if editing
            // completes, and rejected if editing is cancelled. We return it
            // here to "stall" the annotation process until the editing is
            // done.
            return s.editor.load(annotation, s.interactionPoint);
        },

        beforeAnnotationUpdated: function (annotation) {
            return s.editor.load(annotation, s.interactionPoint);
        }
    }

Instead, you can use something like this:

function myAppExtension(options) {
  var hooks = annotator.ui.main(options);

  // We'll have to capture the default hooks. They have the reference
  // to the editor object and we do not, so we'll invoke them to show the
  // editor.
  var beforeAnnotationCreated = hooks.beforeAnnotationCreated;
  var beforeAnnotationUpdated = hooks.beforeAnnotationUpdated;

  hooks.beforeAnnotationCreated = function (annotation) {
    // Custom logic here, then either invoke or skip the base hook

    // Either invoke this, or not, as you wish, but if you do make sure to return the promise
    var promise = beforeAnnotationCreated(annotation);

    // Custom logic here, at which point the editor should be shown

    // You can attach more then clauses to the promise before you return it
    // if you want to take action after the editor is closed.
    return promise;
  }

  // Same thing for beforeAnnotationUpdated (left out for brevity)
}

from annotatorjs.org.

tilgovi avatar tilgovi commented on June 8, 2024

In general, v2 is decomposed more into into components and you should feel free to use them as is, extend their hooks, or build a whole new application by copying the annotator.ui.main function and building your own.

I found that with the Annotator v1.2.x event model it was very difficult to change the way annotator behaved. It was possible to react to Annotator's events, but little else. With the promise-based hooks you can resolve asynchronous hooks to result values, defer resolution, or reject them. You have much more control, but fewer quick conveniences.

from annotatorjs.org.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.