Hiyve Components - v1.0.0
    Preparing search index...
    • Load canvas from JSON data.

      Tolerates empty and partially-malformed inputs:

      • null/undefined/non-object → resolves with an empty canvas (no throw).
      • objects missing or empty → renders an empty canvas.
      • Objects with missing/invalid type are dropped up-front (salvage pass).
      • If Fabric still throws or times out on the sanitized input, a second attempt is made with an empty-objects canvas so the whiteboard at least loads (vs. hanging or erroring).

      Parameters

      • canvas: Canvas
      • json: unknown
      • OptionalonObjectLoaded: (object: WhiteboardObject) => void
      • Optionalopts: { preserveBackground?: boolean }
        • OptionalpreserveBackground?: boolean

          — capture canvas.backgroundImage / backgroundColor before the load and re-apply them after. Fabric's loadFromJSON clears the background as a side effect, and canvas payloads never carry it (backgrounds sync via their own channel). Use for whole-canvas replacements on a canvas whose background must survive (peer undo/redo). Leave OFF for file loads — switching files relies on the load wiping the previous file's background.

      Returns Promise<LoadCanvasResult>

      A LoadCanvasResult — droppedCount > 0 signals the caller should mark the file unsaved (or trigger save) to rewrite it clean.