Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How may I reload annotations from a json? #690

Open
cwlinghk opened this issue Aug 7, 2018 · 1 comment
Open

How may I reload annotations from a json? #690

cwlinghk opened this issue Aug 7, 2018 · 1 comment

Comments

@cwlinghk
Copy link

cwlinghk commented Aug 7, 2018

As loadAnnotations is deprecated in v2.0, how may I reload annotations from a json? Thank you very much.

@zahqresh
Copy link

zahqresh commented Dec 3, 2020

The json format should be as described on the annotatorjs documentation
{ "total": 43127, "rows": [ { "id": "d41d8cd98f00b204e9800998ecf8427e", "text": "Updated annotation text", ... }, ... ] }

You should setup the annotatorjs store plugin like this

var content = $('#content').annotator();
content.annotator('addPlugin', 'Store', {
// The endpoint of the store on your server.
prefix: '/store/endpoint',

  // Attach the uri of the current page to all annotations to allow search.
  annotationData: {
    'uri': 'http://this/document/only'
  },

  // This will perform a "search" action when the plugin loads. Will
  // request the last 20 annotations for the current url.
  // eg. /store/endpoint/search?limit=20&uri=http://this/document/only
  loadFromSearch: {
    'limit': 20,
    'uri': 'http://this/document/only'
  },
urls: {
    // These are the default URLs.
    create:  '/annotations',
    update:  '/annotations/:id',
    destroy: '/annotations/:id',
    search:  '/search'
  }
    });
                 });
});

So when you open the page annotatorjs sends a post request to fetch the json from the search route and data should be in the format as given above this should apply annotations that have been stored in the database you also need id with each annotation to edit and update the annotation.

Hope this helps i know im answering this like after two years but this might help someone in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants