Class: Storage

Storage.Storage(controller, presentation, selection)

File read/write manager.

Constructor

new Storage(controller, presentation, selection)

Initialize a storage manager for a presentation.

Parameters:
Name Type Description
controller module:Controller.Controller

The controller that manages the current editor.

presentation module:model/Presentation.Presentation

The Sozi presentation opened in the editor.

selection module:model/Selection.Selection

The object that represents the selection in the timeline.

Source:

Members

backend :module:backend/AbstractBackend.AbstractBackend

The current execution platform backend.

Type:
Source:

controller :module:Controller.Controller

The controller that manages the current editor.

Type:
Source:

document :module:svg/SVGDocumentWrapper.SVGDocumentWrapper

The current SVG document.

Type:
Source:

htmlFileDescriptor :any

The descriptor of the presentation HTML file.

Type:
  • any
Source:

htmlNeedsSaving :boolean

Do we need to update the presentation HTML file?

This property is true when the presentationChange event is detected.

Type:
  • boolean
Source:

jsonFileDescriptor :any

The descriptor of the presentation JSON file.

Type:
  • any
Source:

jsonNeedsSaving :boolean

Do we need to update the presentation JSON file?

This property is true when the presentationChange or the editorStateChange event is detected.

Type:
  • boolean
Source:

presentation :module:model/Presentation.Presentation

The Sozi presentation opened in the editor.

Type:
Source:

selection :module:model/Selection.Selection

The object that represents the selection in the timeline.

Type:
Source:

svgFileDescriptor :any

The descriptor of the current SVG document file.

Type:
  • any
Source:

Methods

activate()

Finalize the initialization of the application.

Show a load button for each supported backend in the preview area. Create an instance of each supported backend.

Source:

(async) createHTMLFile(name, location)

Create the presentation HTML file if it does not exist.

Parameters:
Name Type Description
name string

The name of the HTML file to create.

location any

The location of the file (backend-dependent).

Source:

(async) createPresenterHTMLFile(name, location, htmlFileName)

Create the presenter console HTML file if it does not exist.

Parameters:
Name Type Description
name string

The name of the HTML file to create.

location any

The location of the file (backend-dependent).

htmlFileName string

The name of the presentation HTML file.

Source:

exportHTML() → {string}

Generate the content of the presentation HTML file.

The result is derived from the player.html template. It contains a copy of the following items:

  • the SVG document,
  • the presentation data needed by the player,
  • a copy of the custom style sheets and scripts.
Source:
Returns:
  • An HTML document content, as text.
Type
string

exportPresenterHTML(htmlFileName) → {string}

Generate the content of the presenter console HTML file.

The result is derived from the presenter.html template.

Parameters:
Name Type Description
htmlFileName string

The name of the presentation HTML file to play.

Source:
Returns:
  • An HTML document content, as text.
Type
string

getJSONData() → {string}

Extract the data to save from the current presentation and the current editor state.

Source:
Returns:
  • A JSON representation of the presentation data and editor state.
Type
string

loadJSONData(data)

Load the presentation data and set the initial state of the editor.

Parameters:
Name Type Description
data object

An object containing presentation data and the editor state, as loaded from a JSON file.

Source:

loadSVGData(data)

Load the content of an SVG document.

This method creates an SVG document wrapper with the given data and assigns it to the current presentation. Then it loads the presentation data from a JSON file in the same folder.

Parameters:
Name Type Description
data string

The content of an SVG file, as text.

Source:

onSave(fileDescriptor)

Finalize a save operation.

This method is called by the current backend when a save operation has completed.

Parameters:
Name Type Description
fileDescriptor any

A descriptor of the file that was saved.

Source:
Fires:

(async) openJSONFile(name, location)

Open presentation data from a JSON file.

It the file does not exist, it is created and populated with the current presentation data.

Parameters:
Name Type Description
name string

The name of the JSON file to open.

location any

The location of the file (backend-dependent).

Source:

readCustomFiles(ext) → {string}

Read custom files to include in the presentation HTML.

Parameters:
Name Type Description
ext string

The extension of the files to read.

Source:
Returns:
  • The concatenated content of all the files read.
Type
string

(async) reload()

Reload the SVG document.

This method is called automatically or on user demand when the SVG document has changed. It saves the presentation and reloads it completely with the new SVG content.

Source:

resolveRelativeURLs(location)

Fix the href attribute of linked images when the target URL is relative.

In linked images, the href attribute can be either an absolute URL or a path relative to the location of the SVG file. But in the presentation editor, URLs are relative to the location of the index.html file of the application. For this reason, we modify image URLs by prefixing all relative URLs with the actual location of the SVG file.

Parameters:
Name Type Description
location string

The path or URL of the folder containing the current SVG file.

Source:

save() → {Promise}

Save the presentation.

This method delegates the operation to the current backend instance and triggers

Source:
See:
Returns:
  • A promise that will be resolved when the operation completes.
Type
Promise

(async) setSVGFile(fileDescriptor, backend)

Assign an SVG file descriptor and backend.

This method is called when opening a new SVG file.

Parameters:
Name Type Description
fileDescriptor any

A descriptor of the SVG file.

backend module:backend/AbstractBackend.AbstractBackend

The selected backend to manage the presentation files.

Source:

toRelativePath(filePath) → {string}

Get the path of a file relative to the location of the current SVG file.

Parameters:
Name Type Description
filePath string

The path of a file.

Source:
Returns:
  • The path of the same file, relative to the location of the current SVG file.
Type
string