SCENE-CE / mirador-annotation-editor

Apache License 2.0
6 stars 0 forks source link

crash on workspace importation #98

Closed Drilio closed 7 months ago

Drilio commented 7 months ago

import workspace leads into this error :

Image

Drilio commented 7 months ago

This bug is present on mirador-annotations upstream and you can trigger it on : https://mirador-annotations.netlify.app/ :

Image

geourjoa commented 7 months ago

The problem is double.

The export function don't export the adapter (a function) --> first problem The missing value is config -> annotation -> adapter. So when the retrieve annotation function try to use the adapter, a TypeError error is thrown

The import don't check if the value is set --> second problem In retrieve function in externalStorageAnnotationplugin, I add the following checks. It can be improved

if (typeof config.annotation.adapter === 'string' && config.annotation.adapter === AnnotationAdapter.LOCAL_STORAGE) {
  config.annotation.adapter = (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`);
}
if(typeof config.annotation.adapter === 'string' && config.annotation.adapter  === AnnotationAdapter.ANNOTOT) {
  const endpointUrl = 'http://127.0.0.1:3000/annotations';
  config.annotation.adapter = (canvasId) => new AnnototAdapter(canvasId, endpointUrl);
}
if (!config.annotation.adapter) {
  // Default adapter set to LocalStorageAdapter
  config.annotation.adapter = (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`);
}
geourjoa commented 7 months ago

Code added in https://github.com/SCENE-CE/mirador-annotation-editor/tree/98-crash-on-workspace-importation