Skip to content

serialise layouts (e.g. persist layouts between sessions) #727

@oliver-sanders

Description

@oliver-sanders

Can we serialise Lumino layouts?

This might be useful to:

  • Persist layouts between sessions (e.g. on the filesystem or in LocalStorage).
  • Define default layouts.
  • Test Lumino applications.

Note, the app would need its own logic to restore the components within the Lumino layout, this is beyond the scope of Lumino itself.

Problem

With Lumino, we can save layouts in a format that we can restore later:

const layout = dockPanel.saveLayout()
dockPanel.restoreLayout(layout)

This works great, however, it is difficult to persist these layouts beyond the life of the session because they contain references to HTML elements:

>> layout.main.children[0].widgets[0].node
<div id="widget3" class="lm-Widget content lm-DockPanel-widget" role="tabpanel" aria-labelledby="tab-key-1-0" style="position: absolute; cont…: 300px; height: 996px;">

And cannot be easily serialised:

>> JSON.stringify(layout)
Uncaught TypeError: cyclic object value

Proposed Solution

The ability to reconstruct a layout in a new session.

E.g, something along the lines of:

function serialise(layout) {}

function deserialise(layout, context) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions