Skip to content

Version 2.5.0

Choose a tag to compare

@rsimon rsimon released this 07 Jul 17:00
· 1207 commits to main since this release

IMPORTANT: v2.5 drops built-in support for Internet Explorer!

If you need IE support: don't worry - it's still available. But from v2.5 onwards, you need to include the file
recogito-polyfills.js in addition to annotorious.min.js.

Features

  • New crosshair feature that can optionally replace the mouse cursor, for more precise selection. Enable via a crosshair:true init option
  • New .setWidgets API method that allows changing editor widget configuration at runtime

Behavior improvements/fixes

  • When the editor opens, the first widget in the list now automatically gets initial focus
  • The mouseEnterAnnotation, mouseLeaveAnnotation and selectAnnotation events now provide a reference to the SVG shape in addition to the annotation.
anno.on('mouseEnterAnnotation', function(annotation, element) {
  console.log(annotation); // W3C annotation as JS object
  console.log(element); // SVG <g> annotation shape element
});

Editor plugin API

  • The Editor was refactored from a React functional component to a class component. This allows attaching follow-up actions to state changes. (React this.setState({...}, callback) - which isn't available in functional components.) The use case for this are widget actions that modify the current annotation (add or remove bodies) and then save & close the editor immediately (recogito/recogito-client-core#66).
  • The editor plugin API callback function .onUpsertBody now simplifies the use of single-body plugins (i.e. plugins like dropdowns or input fields, which only insert or replace a single body of a given purpose).
// Replaces the first existing body of purpose 'my-purpose' or appends, if none 
props.onUpsertBody({ value: 'Some value', purpose: 'my-purpose' });
  • The widget API has a new callback onBatchModify which allows applying any combination of body modifications in one go (append, remove, update, upsert), with or without closing the editor immediately afterwards. (#65)
const changes = [
  { action: 'append', body: bodyToAppend },
  { action: 'update', previous: prevBody, updated: updatedBody }
  { action: 'remove', body: bodyToRemove },

  // Normal upsert, previous is optional
  { action: 'upsert', previous: prevBody, updated: updatedBody }
   
  // Auto-upsert based on purpose    
  { action: 'upsert', body: bodyToUpser }
];

const saveImmediately = true;

args.onBatchModify(changes, saveImmediately);  

Other

  • Separation of IE support reduces the core bundle size by 76kB (now ~260kB)