@fiduswriter/frontend 0.1.65 → 0.1.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,18 +24,24 @@ export class AdjustDocToTemplateWorker {
24
24
  }
25
25
 
26
26
  init(): void {
27
- const stateDoc = this.schema.nodeFromJSON(this.doc)
28
- const newStateDoc = this.schema.nodeFromJSON(
29
- adjustDocToTemplate(
30
- this.doc as any,
31
- this.template as any,
32
- this.documentStyleSlugs,
33
- this.schema
27
+ try {
28
+ const stateDoc = this.schema.nodeFromJSON(this.doc)
29
+ const newStateDoc = this.schema.nodeFromJSON(
30
+ adjustDocToTemplate(
31
+ this.doc as any,
32
+ this.template as any,
33
+ this.documentStyleSlugs,
34
+ this.schema
35
+ )
34
36
  )
35
- )
36
- const transform = recreateTransform(stateDoc, newStateDoc)
37
- const steps: Array<Record<string, unknown>> = []
38
- transform.steps.forEach((step: any) => steps.push(step.toJSON()))
39
- this.sendMessage({type: "result", steps})
37
+ const transform = recreateTransform(stateDoc, newStateDoc)
38
+ const steps: Array<Record<string, unknown>> = []
39
+ transform.steps.forEach((step: any) => steps.push(step.toJSON()))
40
+ this.sendMessage({type: "result", steps})
41
+ } catch (error) {
42
+ // Report the failure so the editor can clear its wait cover
43
+ // instead of waiting forever for a result message.
44
+ this.sendMessage({type: "error", error: String(error)})
45
+ }
40
46
  }
41
47
  }