Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Version 1.3.0

Choose a tag to compare

@rsimon rsimon released this 03 Jul 07:47
· 119 commits to main since this release

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 (#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);  

Behavior improvements/fixes

  • When the editor opens, the first widget in the list now automatically gets initial focus
  • While RecogitoJS still generates annotations that contain both a TextPositionSelector and a QuoteSelector it will now properly load annotations that only contain a TextPositionSelector.