new Editor()
- Description:
- Class representing an editor iframe on a page - Instantiate via DSHDLib.Editors factory
- Source:
Properties:
Name |
Type |
Description |
iframe |
HTMLIFrameElement
|
The iframe element in the DOM |
id |
string
|
The autogenerated unique identifier of the editor |
initialized |
bool
|
A value indicated whether that editor has fully loaded or re-loaded |
Example
DSHDLib.Editors.insert("parent_container_id", { project_id: "abc" }, function(err, e){
var editor = e;
});
Methods
addElement(elementnon-null, callbackopt)
- Description:
- Add a new element to a page/scene in the loaded project
- Source:
Examples
editor.addElement({
element_name: "unique_id",
element_classes: ["header"],
type: "text",
default_style: "header",
color: "#1eefc9",
text: "Lorem ipsum...",
top: 100,
left: 100,
width: 200
}, function(err, element){
console.log("New Element ID:", element.element_id);
});
editor.addElement({
page_id: "abc",
element_classes: ["image"],
type: "image",
placement: "foreground",
url: "https://publicorsignedurl.com/file.jpg",
top: 100,
selected: false
}, function(err, element){
console.log("New Element Width:", element.width);
});
editor.addElement({
type: "vector",
vector_type: "svg",
url: "data:image/svg+xml;base64, ... ",
color_map: {
"#1ccfc9": 'spot("Pantone Jade",84,2,33,1)',
"#eeffee": "cmyk(5,10,15,20)",
"#012639": "transparent"
},
width: 500
});
editor.addElement({
type: "video",
placement: "background",
asset: { store: "library", asset_code: "abc" },
top: 100,
trim_end: 8.5,
expand_scene: true
});
editor.addElement({
element_classes: ["music"],
type: "audio",
context: "global",
url: "https://publicorsignedurl.com/track.mp3",
track_name: "BG Track"
});
editor.addElement({
element_classes: ["logo_placeholder"],
type: "zone",
zone_type: "fit",
enforce_boundary: true,
width: 500,
height: 500,
top: 100,
left: 100
}, function(err, element){
console.log("New Element ID:", element.element_id);
});
Parameters:
addPage(optionsopt, callbackopt)
- Description:
- Add a new page to the current project
- Source:
Examples
editor.addPage();
editor.addPage({
clone_of_page_id: "abc",
position: "beginnning",
page_name: "Altered Name"
}, function(err, page){
console.log("New Page ID:", page.page_id);
});
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
clone_of_page_id |
string
|
<optional>
|
|
Supply the page_id to copy from an existing page or layout (retrieved from getProjectData). If not supplied a blank page will be created |
position |
string
|
number
|
<optional>
|
"end"
|
One of: "beginning", "end", "before_selection", "after_selection", 0-based numeric position |
page_name |
string
|
<optional>
|
|
An optional name for the page. Defaults to the name of the cloned page if clone_of_page_id is provided. |
|
callback |
DSHDLib.Editors.Editor.addPageCallback
|
<optional>
|
|
addScene(optionsopt, callbackopt)
- Description:
- Add a new scene to the current video project
- Source:
Examples
editor.addScene();
editor.addScene({
clone_of_scene_id: "abc",
position: "after_selection",
scene_name: "Altered Name",
duration: 3
}, function(err, scene){
console.log("New Scene ID:", scene.scene_id);
});
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
clone_of_scene_id |
string
|
<optional>
|
|
Supply the scene_id to copy from an existing scene or layout (retrieved from getProjectData). If not supplied a blank scene will be created. |
position |
string
|
number
|
<optional>
|
"end"
|
One of: "beginning", "end", "before_selection", "after_selection", 0-based numeric position |
scene_name |
string
|
<optional>
|
|
An optional name for the scene. Defaults to the name of the cloned scene if clone_of_scene_id is provided. |
duration |
number
|
<optional>
|
5
|
The duration of the new scene in seconds. Defaults to the duration of the cloned scene if clone_of_scene_id is provided. |
|
callback |
DSHDLib.Editors.Editor.addSceneCallback
|
<optional>
|
|
cancelPendingReview()
- Description:
- Cancel the pending review request for a project with an approval_status of "pending_review" (exposed via getProjectData)
- Source:
Example
editor.cancelPendingReview();
changeElements(objectnon-null)
- Description:
- Make one or more changes to the current project
- Source:
- Deprecated:
Parameters:
changeGalleryID(idnon-null, galleryopt)
- Description:
- Change the value used to filter a third party media gallery
- Source:
Example
editor.changeGalleryID("abc");
Parameters:
Name |
Type |
Attributes |
Description |
id |
string
|
|
The filter value |
gallery |
string
|
<optional>
|
The gallery to filter (required if multiple custom galleries connected) |
changePage(optionsnon-null)
- Description:
- Change the page currently visible in the editor (for projects with a digital or print media type)
- Source:
Example
editor.changePage({ page_id: "abc" });
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Description |
page_id |
string
|
The page to change to (ID retrievable via getProjectData or API) |
|
changeProductImage(optionsnon-null)
- Description:
- Source:
Example
editor.changeProductImage({ product_image_url: "https://publicorsignedurl.com/image.jpg" });
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Description |
product_image_url |
string
|
The url of the image to show. Must match the width and height of the currently displayed image. |
|
changeProject(project_idnon-null)
- Description:
- Load a different project into the editor
- Source:
Example
editor.changeProject("abc");
Parameters:
Name |
Type |
Description |
project_id |
string
|
The new project to load in the editor |
changeScene(optionsnon-null)
- Description:
- Change the scene currently visible in the editor (for projects with a video media type)
- Source:
Example
editor.changeScene({ scene_id: "abc" });
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Description |
scene_id |
string
|
The scene to change to (ID retrievable via getProjectData or API) |
|
changeTemporaryBackground(optionsnon-null)
- Description:
- Change the temporary background image or color. Great for simulating paper color/material on print projects. Will be masked inside the canvas (unlike images set via changeProductImage), and visible behind the actual (saved) project background, so make that transparent in the template/project to use this feature.
- Source:
Examples
editor.changeTemporaryBackground({ color: "#FF0000" });
editor.changeTemporaryBackground({ image_url: "https://publicorsignedurl.com/image.jpg" });
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Description |
color |
string
|
<optional>
|
The color to display in hex format. Required if image_url is not provided |
image_url |
string
|
<optional>
|
The url of the image to show. Must be added to CSP allowed origin list. Required if color is not provided |
|
cloneElements(element_idsnon-null, callbackopt)
- Description:
- Clone one or more elements within a page/scene in the loaded project
- Source:
Example
editor.cloneElements(["abc","def"], function(err, elements){
console.log("New Element IDs:", elements.map(el => el.element_id).join(", "));
});
Parameters:
Name |
Type |
Attributes |
Description |
element_ids |
Array.<string>
|
|
The list of elements to clone (usually retrieved via getProjectData). Note that the copies made of elements inside containers (zones, vectors) will be placed directly on the canvas, outside of any new/existing container |
callback |
DSHDLib.Editors.Editor.cloneElementsCallback
|
<optional>
|
|
convertToZone(element_idnon-null, optionsopt)
- Description:
- Wrap a zone around an existing element to make it easily replaceable, maintaining its exact size and position
- Source:
Example
editor.convertToZone("abc");
Parameters:
Name |
Type |
Attributes |
Description |
element_id |
string
|
|
The image, video or vector type element to convert to a zone (usually retrieved via getProjectData). Note that the new zone will inherit the element's element_name and element_classes but will be assigned a new element_id. |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
zone_type |
string
|
<optional>
|
"fit"
|
Either "fit" or "mask" depending on if contained elements should be sized to fully fit within the zone boundary or be masked to fully fill the zone boundary. Note that vector elements can only be converted to "fit" mode zones. |
|
getElementData(element_id, callbacknon-null)
- Description:
- Request and receive the properties of a specific element on any page/scene in the project
- Source:
Example
editor.getElementData("abc", function(err, element){
console.log("Element Type:", element.type);
});
Parameters:
getPageData(page_id, callbacknon-null)
- Description:
- Request and receive the properties of a specific page in the project and all of its elements
- Source:
Example
editor.getPageData("abc", function(err, page){
console.log("Width:", page.dimensions.width);
});
Parameters:
getProjectData(optionsopt, callbacknon-null)
- Description:
- Request and receive the properties of a project and all of its elements
- Source:
Example
editor.getProjectData({}, function(err, project){
console.log("Project Title:", project.project_title);
});
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
simple |
bool
|
<optional>
|
false
|
Supply true to only return high level metadata about the project very quickly |
include_layouts |
bool
|
<optional>
|
false
|
Supply true to include layouts in the returned data |
return_excluded_elements |
bool
|
<optional>
|
false
|
Supply true to include elements that are excluded on render |
|
callback |
DSHDLib.Editors.Editor.getProjectDataCallback
|
|
|
getRender(optionsopt, callbacknon-null)
- Description:
- Request and receive a rendered image of a page/scene from the editor
- Source:
Example
var options = {
max_width: 500,
max_height: 500,
customizations: {
elements: {
"full_name": {
text: "John Doe",
auto_fit: true
}
}
}
};
editor.getRender(options, function(err, data){
if (!err) {
var width = data.width;
var height = data.height;
var data_url = data.url;
var img = new Image();
img.src = data_url;
}
});
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
page_id |
string
|
<optional>
|
|
The page to render (ID retrievable via getProjectData or API). Uses the first page if not supplied |
scene_id |
string
|
<optional>
|
|
The scene to render the first frame of (ID retrievable via getProjectData or API). Uses the first scene if not supplied |
max_width |
number
|
<optional>
|
800
|
The maximum width of the requested image. Can be used by itself or in conjunction with max_height based on the project's aspect ratio |
max_height |
number
|
<optional>
|
800
|
The maximum height of the requested image. Can be used by itself or in conjunction with max_width based on the project's aspect ratio |
render_excluded_elements |
bool
|
<optional>
|
false
|
Value indicating whether or not to include elements in the rendered image that have been tagged with a class that removes them by default upon export |
product_image_background |
bool
|
<optional>
|
false
|
Value indicating whether or not you want to include the product image background in the rendered image |
temporary_background |
bool
|
<optional>
|
false
|
Value indicating whether or not you want to include the temporary background in the rendered image |
customizations |
DSHDLib.Editors.ProjectData.RenderCustomizationObjects.RenderCustomizationObject
|
<optional>
|
|
An object containing data to overwrite the persisted project data in this specific render request |
|
callback |
DSHDLib.Editors.Editor.getRenderCallback
|
|
|
getSceneData(scene_id, callbacknon-null)
- Description:
- Request and receive the properties of a specific scene in a video project and all of its elements
- Source:
Example
editor.getSceneData("abc", function(err, scene){
console.log("Width:", scene.dimensions.width);
});
Parameters:
handleApprovalStatusChange(callbacknon-null)
- Description:
- Source:
Example
editor.handleApprovalStatusChange(function(e, data){
console.log("New Status:", data.approval_status);
});
Parameters:
handleColorSelection(callbacknon-null)
- Description:
- Receive notification when the user clicks into a color swatch in one of the editor menus and suppress the built in color menu. Intended to override the default color controls with your own UI (e.g. with specific Pantone color swatch support) and then update the selected element(s) colors property via updateElements
- Source:
Example
editor.handleColorSelection(function(e, data){
var rgb_to_display = data.selected_color[0].rgb.hex;
});
Parameters:
handleElementData(callbacknon-null)
- Description:
- Receive information from every element data request
- Source:
Example
editor.handleElementData(function(e, element){
console.log("Element Type:", element.type);
});
Parameters:
handleElementSelection(callbacknon-null)
- Description:
- Receive notification when the user selects one or more elements inside the editor. Useful to show custom menus that update the selected elements via updateElements
- Source:
- Deprecated:
Example
editor.handleElementSelection(function(e, elements){
var element_ids = Object.keys(elements);
console.log("Selected Element(s): ", element_ids);
});
Parameters:
handleError(callbacknon-null)
- Description:
- Receive a notification upon any network connection issues or other unresolvable errors that render the Editor unusable
- Source:
Example
editor.handleError(function(e){
console.log("Error occurred");
});
Parameters:
- Description:
- Receive notification when the user clicks any Upload button in the editor. Intended to override the default file upload process with your own (e.g. custom file pre-processing) and then reference the file in adding a new element (addElement) or updating the selected element (updateElements). Note that this event is usually paired with the setting to disable media drag/drop functionality within the editor.
- Source:
Example
editor.handleMediaUploadRequest(function(e, data){
var e = document.createElement("input");
e.setAttribute("type", "file");
e.setAttribute("style", "display:none");
e.setAttribute("accept", "." + data.allowed_file_types.join(", ."));
document.body.appendChild(e);
e.click();
});
Parameters:
handleNavigateTemplateManagement(callbacknon-null)
- Description:
- Receive notification when the user clicks to view all templates after publising a template via showPublishTemplate
- Source:
Example
editor.handleNavigateTemplateManagement(function(e){
location.href = '/templates';
});
Parameters:
handlePageChange(callbacknon-null)
- Description:
- Receive a notification when the page is changed in the editor. Useful for displaying page-specific contextual info outside the editor
- Source:
Example
editor.handlePageChange(function(e, data){
console.log("New Page ID:", data.page_id);
});
Parameters:
handlePageData(callbacknon-null)
- Description:
- Receive information from every page data request
- Source:
Example
editor.handlePageData(function(e, page){
console.log("Width:", page.dimensions.width);
});
Parameters:
handleProjectChange(callbacknon-null)
- Description:
- Override the default behavior when the project context is changed based on an action taken within the editor (e.g. clone to new size/media type)
- Source:
Example
editor.handleProjectChange(function(e, data){
console.log("New Project ID:", data.project_id);
e.changeProject(data.project_id);
});
Parameters:
handleProjectData(callbacknon-null)
- Description:
- Receive information from every project data request
- Source:
Example
editor.handleProjectData(function(e, project){
console.log("Project Title:", project.project_title);
});
Parameters:
handleProjectDataChange(callbacknon-null, optionsopt)
- Description:
- Receive notification when any change to the project data occurs within the editor. Useful to trigger getProjectData for validation routines
- Source:
- Deprecated:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
DSHDLib.Editors.Editor.handleProjectDataModificationCallback
|
|
|
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
user_modifications_only |
bool
|
<optional>
|
false
|
Supply true to only return changes an actual user makes, ignoring other automatic conversion/correction alterations made in specific scenarios |
|
handleProjectDataModification(callbacknon-null, optionsopt)
- Description:
- Receive notification when any change to the project data occurs within the editor. Useful to trigger getProjectData for validation routines
- Source:
Example
editor.handleProjectDataModification(function(e, updates){
console.log("Pages/Scenes Altered:", Object.keys(updates.pages || updates.scenes).length);
});
Parameters:
Name |
Type |
Attributes |
Description |
callback |
DSHDLib.Editors.Editor.handleProjectDataModificationCallback
|
|
|
options |
object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
user_modifications_only |
bool
|
<optional>
|
false
|
Supply true to only return changes an actual user makes, ignoring other automatic conversion/correction alterations made in specific scenarios |
|
handleProjectTitleChange(callbacknon-null)
- Description:
- Receive notification after the user changes the project title via showChangeTitle
- Source:
- Deprecated:
Parameters:
handleProjectTitleUpdate(callbacknon-null)
- Description:
- Receive notification after the user changes the project title via showUpdateTitle
- Source:
Example
editor.handleProjectTitleUpdate(function(e, data){
console.log("New Title:", data.project_title);
});
Parameters:
handleReload(callbacknon-null)
- Description:
- Override the default behavior when the editor needs to reload
- Source:
Example
editor.handleReload(function(e, cfg){
console.log("Editor Reloading");
e.reload(cfg);
});
Parameters:
handleRender(callbacknon-null)
- Description:
- Receive information from every render request. To be used along with requestRender
- Source:
Example
editor.handleRender(function(e, data){
var width = data.width;
var height = data.height;
var data_url = data.url;
var img = new Image();
img.src = data_url;
});
Parameters:
handleSceneChange(callbacknon-null)
- Description:
- Receive a notification when the scene is changed in the editor. Useful for displaying scene-specific contextual info outside the editor
- Source:
Example
editor.handleSceneChange(function(e, data){
console.log("New Scene ID:", data.scene_id);
});
Parameters:
handleSceneData(callbacknon-null)
- Description:
- Receive information from every scene data request on a video project
- Source:
Example
editor.handleSceneData(function(e, scene){
console.log("Width:", scene.dimensions.width);
});
Parameters:
handleSelectionChange(callbacknon-null)
- Description:
- Receive notification when the user selects one or more elements inside the editor or when all elements are deselected. Useful to show custom menus that update the selected elements via updateElements
- Source:
Example
editor.handleSelectionChange(function(e, elements){
var element_ids = Object.keys(elements);
console.log("Selected Element(s): ", element_ids);
});
Parameters:
handleUnauthenticated(callbacknon-null)
- Description:
- Receive a notification when the access token being used has expired. You may then request a new access token and update the editor
- Source:
Example
editor.handleUnauthenticated(function(e){
//retrieve new access token
e.refreshAccessToken("new_token");
});
Parameters:
highlightElements(element_idsnon-null, optionsopt)
- Description:
- Highlight specific elements on the currently open page/scene in the editor
- Source:
Examples
editor.highlightElements([element_id1, element_id2]);
editor.highlightElements([element_id1, element_id2], { duration: 2000, fill_color: "#FF0000" });
Parameters:
Name |
Type |
Attributes |
Description |
element_ids |
Array.<string>
|
|
The list of elements to highlight (usually retrieved via getProjectData) |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
duration |
number
|
<optional>
|
1000
|
The desired length of the highlight animation in milliseconds |
fill_color |
string
|
<optional>
|
|
The desired fill color of the highlighted area in RGB hex notation. Uses theme_color2 if not supplied |
stroke_color |
string
|
<optional>
|
"#ffffff"
|
The desired stroke color of the highlighted area in RGB hex notation |
starting_opacity |
number
|
<optional>
|
0.5
|
The starting opacity for the animation of the highlighted area. Must be a number between 0 and 1 |
|
importPages(options)
- Description:
- Import pages from a different project into the current project
- Source:
Example
editor.importPages({
project_id: "abc",
page_ids: ["def"],
position: "end"
});
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Default |
Description |
project_id |
string
|
|
|
The project to import pages from |
page_ids |
Array.<string>
|
|
|
The list of page_id's to import from the specified project |
position |
string
|
number
|
<optional>
|
"after_selection"
|
One of: "beginning", "end", "before_selection", "after_selection", 0-based numeric position |
|
importScenes(options)
- Description:
- Import scenes from a different project into the current project
- Source:
Example
editor.importScenes({
project_id: "abc",
scene_ids: ["def"],
position: "end"
});
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Default |
Description |
project_id |
string
|
|
|
The project to import scenes from |
scene_ids |
Array.<string>
|
|
|
The list of scene_id's to import from the specified project |
position |
string
|
number
|
<optional>
|
"after_selection"
|
One of: "beginning", "end", "before_selection", "after_selection", 0-based numeric position |
|
onInitialized(callbacknon-null)
- Description:
- Wait for editor initialization before running other code
- Source:
Example
editor.onInitialized(function(e){
console.log('Editor Initialized');
});
Parameters:
playAll(optionsopt)
- Description:
- For video projects, open the Play All popup and start playing the entire video
- Source:
Example
editor.playAll();
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
pause |
bool
|
<optional>
|
Supply true to indicate that the currently playing video should be paused or false to unpause |
|
playScene(optionsopt)
- Description:
- For video projects, play the currently visible scene on the canvas
- Source:
Example
editor.playScene();
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
stop |
bool
|
<optional>
|
false
|
Supply true to indicate that a currently playing scene should be stopped |
|
refreshAccessToken(access_tokenopt, callbackopt)
- Description:
- Request a new guest token or update the explicitly-provided access token when approaching expiration or upon notification of authorization failure
- Source:
Example
editor.refreshAccessToken("abc");
Parameters:
Name |
Type |
Attributes |
Description |
access_token |
string
|
<optional>
|
A new access token retreived via backend authentication |
callback |
DSHDLib.errorCallback
|
<optional>
|
The function to run after guest token retrieval |
reload(optionsopt)
- Description:
- Reload the editor. Useful if making external project state changes
- Source:
Examples
editor.reload();
editor.reload({ page_number: 2 });
editor.reload({ scene_number: 3 });
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
page_number |
number
|
<optional>
|
The initial page to open upon project load |
scene_number |
number
|
<optional>
|
The initial scene to open upon project load |
|
remove()
- Description:
- Remove the editor iframe from the DOM and clean up state. This is required before initializing another editor with the same project
- Source:
Example
editor.remove();
removeElements(element_idsnon-null)
- Description:
- Remove elements from the current project
- Source:
Example
editor.removeElements(["abc"]);
Parameters:
Name |
Type |
Description |
element_ids |
Array.<string>
|
The list of elements to remove (usually retrieved via getProjectData). Note that elements in zones inherit the zone's element_id. Removing an element in a zone will leave the zone unpopulated. Zones themselves can only be removed if unpopulated. So to fully remove a populated zone, call this method twice in a row supplying the same element_id. |
removePages(page_idsnon-null)
- Description:
- Remove pages/layouts from the current project
- Source:
Example
editor.removePages(["abc"]);
Parameters:
Name |
Type |
Description |
page_ids |
Array.<string>
|
The list of pages/layouts to remove (usually retrieved via getProjectData). |
removeScenes(scene_idsnon-null)
- Description:
- Remove scenes/layouts from the current video project
- Source:
Example
editor.removeScenes(["abc"]);
Parameters:
Name |
Type |
Description |
scene_ids |
Array.<string>
|
The list of scenes/layouts to remove (usually retrieved via getProjectData). |
requestElementData(element_idnon-null)
- Description:
- Request the properties of a specific element on any page/scene in the project. To be used along with handleElementData
- Source:
Example
editor.requestElementData("abc");
Parameters:
Name |
Type |
Description |
element_id |
string
|
The autogenerated id of the element (usually initially retrieved via getProjectData). Note that element_name will also work here if enabled in your system |
requestPageData(page_idnon-null)
- Description:
- Request the properties of one page in a project and all of its elements. To be used along with handlePageData
- Source:
Example
editor.requestPageData("abc");
Parameters:
Name |
Type |
Description |
page_id |
string
|
The autogenerated id of the page (usually initially retrieved via getProjectData) |
requestProjectData(optionsopt)
- Description:
- Request the properties of a project and all of its elements. To be used along with handleProjectData
- Source:
Example
editor.requestProjectData();
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
simple |
bool
|
<optional>
|
false
|
Supply true to only return high level metadata about the project very quickly |
include_layouts |
bool
|
<optional>
|
false
|
Supply true to include layouts in the returned data |
|
requestRender(optionsopt)
- Description:
- Request a rendered image of a page/scene from the editor. To be used along with handleRender
- Source:
Example
var options = {
max_width: 500,
max_height: 500
};
editor.requestRender(options);
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
page_id |
string
|
<optional>
|
|
The page to render (ID retrievable via getProjectData or API). Uses the first page if not supplied |
scene_id |
string
|
<optional>
|
|
The scene to render the first frame of(ID retrievable via getProjectData or API). Uses the first scene if not supplied |
max_width |
number
|
<optional>
|
800
|
The maximum width of the requested image. Can be used by itself or in conjunction with max_height based on the project's aspect ratio |
max_height |
number
|
<optional>
|
800
|
The maximum height of the requested image. Can be used by itself or in conjunction with max_width based on the project's aspect ratio |
render_excluded_elements |
bool
|
<optional>
|
false
|
Value indicating whether or not to include elements in the rendered image that have been tagged with a class that removes them by default upon export |
product_image_background |
bool
|
<optional>
|
false
|
Value indicating whether or not you want to include the product image background in the rendered image |
temporary_background |
bool
|
<optional>
|
false
|
Value indicating whether or not you want to include the temporary background in the rendered image |
customizations |
DSHDLib.Editors.ProjectData.RenderCustomizationObjects.RenderCustomizationObject
|
<optional>
|
|
An object containing data to overwrite the persisted project data in this specific render request |
|
requestSceneData(scene_idnon-null)
- Description:
- Request the properties of one scene in a video project and all of its elements. To be used along with handleSceneData
- Source:
Example
editor.requestSceneData("abc");
Parameters:
Name |
Type |
Description |
scene_id |
string
|
The autogenerated id of the scene (usually initially retrieved via getProjectData) |
resizePage(options)
- Description:
- Resize pages in the current project
- Source:
Example
editor.resizePage({
width: 50,
height: 50,
page_id: "abc"
});
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Description |
width |
number
|
|
Supply the new width in the unit type of the current project |
height |
number
|
|
Supply the new height in the unit type of the current project |
page_id |
string
|
<optional>
|
Supply the page_id of the page or layout to update (retrieved from getProjectData). If not supplied, all pages and layouts will be updated |
|
resizeScenes(options)
- Description:
- Resize all scenes in the current project
- Source:
Example
editor.resizeScenes({
width: 1920,
height: 1080
});
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Description |
width |
number
|
Supply the new width in px |
height |
number
|
Supply the new height in px |
|
saveLockingConfig()
- Description:
- Save any unsaved locking configuration changes (exposed via unsaved_locking_config in getProjectData)
- Source:
Example
editor.saveLockingConfig();
selectElements(element_idsnon-null, optionsopt)
- Description:
- Select one or more elements on the currently visible page/scene
- Source:
Examples
editor.selectElements(["abc"]);
editor.selectElements(["abc","def"], { deselect: true });
Parameters:
Name |
Type |
Attributes |
Description |
element_ids |
Array.<string>
|
|
The list of elements to select (usually retrieved via getProjectData) |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
deselect |
bool
|
<optional>
|
false
|
Supply true to deselect any of the supplied elements that are currently selected |
|
showChangeTitle()
- Description:
- Open the built-in Set Title popup within the editor to allow the user to easily change the project title without building a custom title change workflow via the Update Project API endpoint
- Source:
- Deprecated:
showExport(optionsopt)
- Description:
- Open the built-in Export popup within the editor to allow the user to easily export an image/pdf/video without building a custom export workflow via the Export API endpoint
- Source:
Example
editor.showExport();
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Default |
Description |
filename |
string
|
<optional>
|
|
The value to populate in the filename textbox |
default_social_post_text |
string
|
<optional>
|
|
The text to populate for the caption in the built-in social media export workflows |
hide_email |
bool
|
<optional>
|
false
|
A value indicating whether or not the email option should be available in the export popup |
|
showPublishTemplate()
- Description:
- Open the built-in Publish Template popup within the editor to allow an admin to easily publish a template from the open project without building a custom template publishing workflow via the Publish Template API endpoint
- Source:
Example
editor.showPublishTemplate();
showSubmitForReview()
- Description:
- Open the built-in Submit For Approval popup within the editor to allow a user to easily submit this project for approval, for projects without an approval_status or those that have been previously "approved" (exposed via getProjectData)
- Source:
Example
editor.showSubmitForReview();
showSubmitRevision()
- Description:
- Open the built-in Submit Revision popup within the editor to allow a user to easily re-submit this project for approval, for projects with an approval_status of "awaiting_revisions" or "denied" (exposed via getProjectData)
- Source:
Example
editor.showSubmitRevision();
showUpdateTitle()
- Description:
- Open the built-in Set Title popup within the editor to allow the user to easily update the project title without building a custom title change workflow via the Update Project API endpoint
- Source:
Example
editor.showUpdateTitle();
updateBackgroundColor(optionsnon-null)
- Description:
- Update the background color of one or more pages/scenes. Note that addElement with "background" placement can be used to set a background image/video instead
- Source:
Example
editor.updateBackgroundColor({ color: "#ffffff" });
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Description |
color |
string
|
|
The color to use for the background |
page_id |
string
|
<optional>
|
Supply the page_id of the page or layout to update (retrieved from getProjectData). If not supplied, all pages and layouts will be updated |
scene_id |
string
|
<optional>
|
Supply the scene_id of the scene to update (retrieved from getProjectData). If not supplied, all scenes will be updated |
|
updateCanvasBorder(optionsnon-null)
- Description:
- Set a die cut border for stickers. Must be using a custom canvas shape on a Print project. Applied as an outer stroke
- Source:
Example
editor.updateCanvasBorder({ width: 0.25, color: "cmyk(0,0,0,0)" });
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Description |
width |
number
|
<optional>
|
The width of the border/stroke in the unit type of the project. Required when creating a new border |
color |
string
|
<optional>
|
The color to use for the border/stroke |
rounded |
bool
|
<optional>
|
A value indicating whether the border/stroke will be rounded around the edges of the canvas shape |
|
updateElements(objectnon-null)
- Description:
- Make one or more updates to elements in the current project
- Source:
Example
editor.updateElements({
elements: {
"abc": {
text: "My New Text"
},
"def": {
top: 300,
colors: ["#efefef"]
}
}
});
Parameters:
Type Definitions
ModifiedElement
- Description:
- Source:
Properties:
Name |
Type |
Description |
element_modification_type |
string
|
One of: "add", "update", "remove" |
Properties specific to modified elements referenced in
handleProjectDataModificationCallback
ModifiedPage
- Description:
- Source:
Properties:
Name |
Type |
Attributes |
Description |
page_modification_type |
string
|
<optional>
|
One of: "add", "update", "remove", "reorder" |
elements |
Object.<string, DSHDLib.Editors.Editor.ModifiedElement>
|
<optional>
|
A map of the elements that were modified on this page. Note that this won't be included with page_modification_type add/remove, so call getProjectData in those scenarios to retrieve newly added elements (from page clone/import/create from layout) or elements removed as part of a page removal. |
Properties specific to modified pages referenced in
handleProjectDataModificationCallback
ModifiedScene
- Description:
- Source:
Properties:
Name |
Type |
Attributes |
Description |
scene_modification_type |
string
|
<optional>
|
One of: "add", "update", "remove", "reorder" |
elements |
Object.<string, DSHDLib.Editors.Editor.ModifiedElement>
|
<optional>
|
A map of the elements that were modified on this scene. Note that this won't be included with scene_modification_type add/remove, so call getProjectData in those scenarios to retrieve newly added elements (from scene clone/import/create from layout) or elements removed as part of a scene removal. |
Properties specific to modified scenes referenced in
handleProjectDataModificationCallback
addElementCallback(erroropt, elementopt)
- Description:
- Callback supplying an error or the new element properties
- Source:
Parameters:
addPageCallback(erroropt, pageopt)
- Description:
- Callback supplying an error or the new page properties
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the page addition request failed |
page |
DSHDLib.Editors.ProjectData.PageData
|
<optional>
|
The properties of the new page and any elements it may contain (e.g. upon clone) |
addSceneCallback(erroropt, sceneopt)
- Description:
- Callback supplying an error or the new scene properties
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the scene addition request failed |
scene |
DSHDLib.Editors.ProjectData.SceneData
|
<optional>
|
The properties of the new scene and any elements it may contain (e.g. upon clone) |
cloneElementsCallback(erroropt, elementsopt)
- Description:
- Callback supplying an error or an array of the newly created elements
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the clone request failed |
elements |
Array.<DSHDLib.Editors.ProjectData.ElementProperties>
|
<optional>
|
The list of created elements, returned in the same order as the input array |
editorCallback(editor)
- Description:
- Callback supplying the editor instance a listener was triggered on
- Source:
Parameters:
getElementDataCallback(erroropt, elementopt)
- Description:
- Callback supplying an error or the requested element
- Source:
Parameters:
getPageDataCallback(erroropt, pageopt)
- Description:
- Callback supplying an error or the requested page
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the page retrieval request failed |
page |
DSHDLib.Editors.ProjectData.PageData
|
<optional>
|
The properties of the requested page and all of its elements |
getProjectDataCallback(erroropt, projectopt)
- Description:
- Callback supplying an error or the requested project properties
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the project retrieval request failed |
project |
DSHDLib.Editors.ProjectData.ProjectData
|
<optional>
|
All project metadata, page/scene properties and individual element properties |
getRenderCallback(erroropt, dataopt)
- Description:
- Callback supplying an error or the rendered image data
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the render request failed |
data |
Object
|
<optional>
|
Properties
Name |
Type |
Description |
width |
number
|
The width of the rendered image |
height |
number
|
The height of the rendered image |
url |
string
|
A data url of the rendered image |
|
getSceneDataCallback(erroropt, sceneopt)
- Description:
- Callback supplying an error or the requested scene on a video project
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
error |
Error
|
<optional>
|
An error if the scene retrieval request failed |
scene |
DSHDLib.Editors.ProjectData.SceneData
|
<optional>
|
The properties of the requested scene and all of its elements |
handleApprovalStatusChangeCallback(editor, data)
- Description:
- Callback supplying the editor instance the project approval status change was triggered on and the new approval status
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Attributes |
Default |
Description |
approval_status |
string
|
|
|
The new project approval status. Currently only "pending_review" or null to indicate status removal (re-submission required) |
state_updated |
bool
|
<optional>
|
false
|
A value indicating that the trigger of the status change was a project update |
|
handleColorSelectionCallback(editor, data)
- Description:
- Callback supplying the editor instance the color swatch click was triggered on, the current details of the color clicked, and information about the selected element(s)
- Source:
- Tutorials:
-
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Attributes |
Description |
context |
string
|
|
One of: "element", "background", "group" |
selected_color |
Array.<Object>
|
|
Details of the color the user clicked on. One item array unless it's a gradient in which case one item per color stop.
Properties
Name |
Type |
Attributes |
Description |
key |
string
|
|
The string representation of the color, matching the color format returned in getProjectData and expected in updateElements |
rgb |
Object
|
|
The RGB representation of the color. Converted for display using your ICC profile when the color is set as CMYK/SPOT.
Properties
Name |
Type |
Description |
r |
number
|
The Red value - integer from 0 to 255 |
g |
number
|
The Green value - integer from 0 to 255 |
b |
number
|
The Blue value - integer from 0 to 255 |
hex |
string
|
The hexadecimal representation |
|
cmyk |
Object
|
<optional>
|
Returned if the color is set as CMYK
Properties
Name |
Type |
Description |
c |
number
|
The Cyan value - integer from 0 to 100 |
m |
number
|
The Magenta value - integer from 0 to 100 |
y |
number
|
The Yellow value - integer from 0 to 100 |
k |
number
|
The Black value - integer from 0 to 100 |
|
spot |
Object
|
<optional>
|
Returned if the color is set as SPOT
Properties
Name |
Type |
Description |
c |
number
|
The CMYK fallback Cyan value - integer from 0 to 100 |
m |
number
|
The CMYK fallback Magenta value - integer from 0 to 100 |
y |
number
|
The CMYK fallback Yellow value - integer from 0 to 100 |
k |
number
|
The CMYK fallback Black value - integer from 0 to 100 |
name |
string
|
The SPOT color name (e.g. "PMS 123 C") |
|
alpha |
number
|
<optional>
|
Percentage based opacity of the color - from 0 to 1. Not returned if multiple elements are selected (context is "group") or if a multi-path SVG is selected with this color used across multiple paths with different opacities ("Separate Colors" option in the menu UI disabled) |
offset |
number
|
<optional>
|
Percentage based color-stop position - from 0 to 1. Only returned if key is "gradient" |
|
selected_color_index |
number
|
<optional>
|
Returned if a single element is selected (context is "element"), and points to the specific index this color selection references in the colors array property in the element's data. This index is necessary to distinguish between duplicate colors in the array representing fills vs strokes and when the user first enables "Separate Colors" in the menu UI when selecting a multi-path SVG. Note that by default duplicate fill colors are grouped together and duplicate stroke colors are grouped together in the menu UI and in the element colors array property. |
element_info |
Object.<string, DSHDLib.Editors.ProjectData.ElementProperties>
|
<optional>
|
A map of the selected elements. Not returned when context is "background" |
|
handleElementDataCallback(editor, element)
- Description:
- Callback supplying the editor instance the element data request was triggered on and the element properties
- Source:
Parameters:
- Description:
- Callback supplying the editor instance the Upload button click was triggered on and context about the upload request
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Attributes |
Description |
context |
string
|
|
One of: "element", "background", "root" |
allowed_file_types |
Array.<string>
|
|
The list of file types supported based on the upload request context (e.g. ["svg","png","jpg","webp","heic","gif","tiff"]) |
element_info |
DSHDLib.Editors.ProjectData.ElementProperties
|
<optional>
|
The properties of the selected (container) element. Only returned when context is "element" |
|
handlePageChangeCallback(editor, data)
- Description:
- Callback supplying the editor instance the page change was triggered on and the id of the newly open page
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Description |
page_id |
string
|
The id of the newly open page |
|
handlePageDataCallback(editor, page)
- Description:
- Callback supplying the editor instance the page data request was triggered on and the page properties
- Source:
Parameters:
handleProjectChangeCallback(editor, data)
- Description:
- Callback supplying the editor instance the project change was triggered on and the id of the new project
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Description |
project_id |
string
|
The unique identifier of the new project |
|
handleProjectDataCallback(editor, project)
- Description:
- Callback supplying the editor instance the element data request was triggered on and the project properties
- Source:
Parameters:
handleProjectDataModificationCallback(editor, updates)
- Description:
- Callback supplying the editor instance the update occurred on and the specifics of the update
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
updates |
Object
|
Properties
Name |
Type |
Attributes |
Description |
pages |
Object.<string, DSHDLib.Editors.Editor.ModifiedPage>
|
<optional>
|
A map of the pages, on non-video projects, that were modified or had elements on them modified |
scenes |
Object.<string, DSHDLib.Editors.Editor.ModifiedScene>
|
<optional>
|
A map of the scenes, on video projects, that were modified or had elements on them modified |
global_audio_tracks |
Object.<string, DSHDLib.Editors.Editor.ModifiedElement>
|
<optional>
|
A map of the global audio track elements, on video projects, that were modified |
system |
bool
|
<optional>
|
If true, indicates that the update triggering the event was a non-user-initiated conversion/correction alteration, only occurring in specific scenarios |
|
handleProjectTitleUpdateCallback(editor, data)
- Description:
- Callback supplying the editor instance the project title update was triggered on and the new project title
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Description |
project_title |
string
|
The new project title |
|
handleReloadCallback(editor, data)
- Description:
- Callback supplying the editor instance a reload was triggered on and the reload config
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Reload configuration data |
handleRenderCallback(editor, data)
- Description:
- Callback supplying the editor instance the render request was triggered on and the rendered image data
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Description |
width |
number
|
The width of the rendered image |
height |
number
|
The height of the rendered image |
url |
string
|
A data url of the rendered image |
|
handleSceneChangeCallback(editor, data)
- Description:
- Callback supplying the editor instance the scene change was triggered on and the id of the newly open scene
- Source:
Parameters:
Name |
Type |
Description |
editor |
DSHDLib.Editors.Editor
|
The editor instance triggering the event |
data |
Object
|
Properties
Name |
Type |
Description |
scene_id |
string
|
The id of the newly open scene |
|
handleSceneDataCallback(editor, scene)
- Description:
- Callback supplying the editor instance the scene data request was triggered on and the scene properties
- Source:
Parameters:
handleSelectionCallback(editor, elements, pointeropt)
- Description:
- Callback supplying the editor instance the element selection was triggered on and information about the selected element(s)
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
editor |
DSHDLib.Editors.Editor
|
|
The editor instance triggering the event |
elements |
Object.<string, DSHDLib.Editors.ProjectData.ElementProperties>
|
|
A map of the selected elements |
pointer |
Object
|
<optional>
|
If a simple click event triggered the selection, this value represents the coordinates of the click. Useful to detect the specific element that was clicked when selecting groups
Properties
Name |
Type |
Description |
x |
number
|
The x coordinate of the click, relative to the canvas, supplied in the unit type of the project (px, in or mm) |
y |
number
|
The y coordinate of the click, relative to the canvas, supplied in the unit type of the project (px, in or mm) |
|