preferences
preferences Property
Description
This property is used to exchange user preferences between the editor and the host application, which is responsible for persisting this data as desired.
For example, the host application could save these preferences as a string with JSON.stringify, then read that string back and parse it into a JavaScript object with JSON.parse when starting up the editor.
The host application can then provide user-specific preference data across editor sessions. This data includes the user’s editor preference settings and identification information for symbols that the user has identified as “favorites”.
Note: If you choose not to persist the user’s preferences, the editor will not remember the user’s preferences across different devices and browsers. By default, the user’s symbol favorites are stored in the browser’s local storage and will be available across different sessions only on the same device and browser.
Use the get and set methods of the ESDWeb object to get and set the value of this property as illustrated below:
Example
editor = new window.__editor(undefined, document.getElementById('editor-node'));
editor.startup(...);
/* Insert logic to read the persisted user data into userDataString */
var userData = JSON.parse(userDataString);
editor.set('preferences', userData);
In code that runs after the editor is closed:
// Retrieve user data from the editor
var userData = editor.get('preferences');
var userDataString = JSON.stringify(userData);
/* follow with additional logic to persist the user's data */