Constructor
new Electron(controller, container)
Initialize a Sozi backend based on Electron.
Parameters:
Name | Type | Description |
---|---|---|
controller |
module:Controller.Controller | A controller instance. |
container |
HTMLElement | The element that will contain the menu for choosing a backend. |
- Source:
Extends
Members
autosavedFiles :Array
A list of files to save automatically.
This is an array of file descriptors. The actual type of the elements depends on the platform.
Type:
- Array
- Overrides:
- Source:
controller :module:Controller.Controller
The controller for this backend.
Type:
- Overrides:
- Source:
(readonly) hasOutdatedFiles :boolean
Check whether at least one file in the autosaved file list needs saving.
This is an accessor that uses the needsSaving
function passed to autosave.
Returns true
if at least one file has unsaved modifications.
Type:
- boolean
- Overrides:
- Source:
watchers :object.<string, fs.FSWatcher>
A dictionary of file watchers.
Populated by the load
method.
Type:
- object.<string, fs.FSWatcher>
- Source:
Methods
autosave(fileDescriptor, needsSaving, getData)
Add the given file to the list of files to save automatically.
Parameters:
Name | Type | Description |
---|---|---|
fileDescriptor |
any | The file to autosave (backend-dependent). |
needsSaving |
function | A function that returns |
getData |
function | A function that returns the data to save. |
- Overrides:
- Source:
create(name, location, mimeType, data) → {Promise}
Create a new file.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the file to create. |
location |
any | The location of the file to create (backend-dependent). |
mimeType |
string | The MIME type of the file to create. |
data |
string | The content of the file to create. |
- Overrides:
- Source:
Returns:
- A promise that resolves to a file descriptor.
- Type
- Promise
doAutosave() → {Promise.<Array>}
Save all files previously added to the autosaved file list.
Typically, we want to call this method each time the editor loses focus and when the editor closes.
- Overrides:
- Source:
Returns:
- A promise that resolves when all autosaved files have been saved.
- Type
- Promise.<Array>
find(name, location) → {Promise}
Find a file.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The base name of the file. |
location |
any | The location of the file (backend-dependent). |
- Overrides:
- Source:
Returns:
- A promise that resolves to a file descriptor, rejected if not found.
- Type
- Promise
getLocation(fileDescriptor) → {string}
Return the location of a file.
Parameters:
Name | Type | Description |
---|---|---|
fileDescriptor |
any | A file descriptor (backend-dependent). |
- Overrides:
- Source:
Returns:
The file location.
- Type
- string
getName(fileDescriptor) → {string}
Return the base name of a file.
Parameters:
Name | Type | Description |
---|---|---|
fileDescriptor |
any | A file descriptor (backend-dependent). |
- Overrides:
- Source:
Returns:
The file name.
- Type
- string
load(fileDescriptor) → {Promise.<string>}
Load a file.
This method loads a file and returns a promise with the content of this file.
Parameters:
Name | Type | Description |
---|---|---|
fileDescriptor |
any | A file to load (backend-dependent). |
- Overrides:
- Source:
Returns:
- A promise that resolves to the content of the file.
- Type
- Promise.<string>
loadConfiguration()
Load the configuration of the current browser window.
This method will restore the location, size, and fullscreen state of the window.
- Source:
loadSync(fileDescriptor) → {string}
Load a file synchronously.
Parameters:
Name | Type | Description |
---|---|---|
fileDescriptor |
any | A file to load (backend-dependent). |
- Overrides:
- Source:
Returns:
- The content of the file.
- Type
- string
openFileChooser()
Open a file chooser.
This method opens a file dialog to open an SVG document.
- Overrides:
- Source:
(async) quit(confirmSave)
Close the editor window and terminate the application.
Parameters:
Name | Type | Description |
---|---|---|
confirmSave |
boolean | If |
- Source:
sameFile(fd1, fd2) → {boolean}
Compare two file descriptors.
Parameters:
Name | Type | Description |
---|---|---|
fd1 |
any | A file descriptor (backend-dependent). |
fd2 |
any | A file descriptor (backend-dependent). |
- Overrides:
- Source:
Returns:
true
iffd1
andfd2
represent the same file.
- Type
- boolean
save(fileDescriptor, data) → {Promise}
Save data to an existing file.
Parameters:
Name | Type | Description |
---|---|---|
fileDescriptor |
any | The file to save (backend-dependent). |
data |
string | The new content of the file. |
- Overrides:
- Source:
Returns:
- A promise that resolves to the given file descriptor.
- Type
- Promise
saveConfiguration()
Save the configuration of the current browser window.
This method will save the location, size, and fullscreen state of the window.
- Source:
saveOutdatedFiles() → {Promise.<Array>}
Save all outdated files.
This method calls save for each file
in the autosaved file list
where needsSaving
returns true
.
It uses the function getData
passed to autosave
to write the new file content.
- Overrides:
- Source:
Returns:
- A promise that resolves when all autosaved files have been saved.
- Type
- Promise.<Array>
toggleDevTools()
Show or hide the development tools of the current web browser.