Skip to main content

Integrate CreativeEditor SDK with Electron

In this example, we will show you how to integrate CreativeEditor SDK with Electron. View the full code on GitHub.

Prerequisites#

No trial license key required.#

The trial of CreativeEditor SDK works without a license key. A commercial license key is required for use in a production environment. Get a license key at Pricing

Setup#

In this example, we will use the SDK directly via our CDN. For use in a production environment we recommend serving assets from your own servers.

1. Add CE.SDK to your Project#

Install the @cesdk/cesdk-js dependency via

npm install --save @cesdk/cesdk-js.

The SDK is served entirely via CDN, so we just need to require the CE.SDK module.

JavaScript
const CreativeEditorSDK = require('@cesdk/cesdk-js');

2. Create an empty Container#

We need to add an empty <div> with an id or class as container for the SDK. In this example, we set the inline style to create a <div> element that fills the whole browser window.

JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<title>Integrate CreativeEditor SDK with Electron</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<style>
body {
margin: 0;
overflow: hidden;
}
html {
overscroll-behavior-x: contain;
}
</style>
</head>
<body>
<!--// docs-integrate-electron-2-->
<div id="cesdk_container" style="width: 100%; height: 100vh"></div>
<!--// docs-integrate-electron-2-->
<script>
const CreativeEditorSDK = require('@cesdk/cesdk-js');
window.onload = function () {
let config = {
// Serve assets from IMG.LY cdn or locally
baseURL: 'https://cdn.img.ly/packages/imgly/cesdk-js/1.0.0/assets'
};
CreativeEditorSDK.init('#cesdk_container', config).then((instance) => {
/** do something with the instance of CreativeEditor SDK **/
});
};
</script>
</body>
</html>

3. Instantiate SDK#

The last step involves the configuration and instantiation of the SDK. We need to provide the aforementioned container and optionally a license file to instantiate the SDK.

JavaScript
let config = {
// Serve assets from IMG.LY cdn or locally
baseURL: 'https://cdn.img.ly/packages/imgly/cesdk-js/1.0.0/assets'
};
CreativeEditorSDK.init('#cesdk_container', config).then((instance) => {
/** do something with the instance of CreativeEditor SDK **/
});

4. Running CE.SDK in Electron#

In order to use the editor we need to run our project via npx which comes bundled with npm.

npx electron . will spin up a native application window running CreativeEditor SDK.

Congratulations!#

You've got CE.SDK up and running. Get to know the SDK and dive into the next steps, when you're ready:


<!DOCTYPE html>
<html lang="en">
<head>
<title>Integrate CreativeEditor SDK with Electron</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<style>
body {
margin: 0;
overflow: hidden;
}
html {
overscroll-behavior-x: contain;
}
</style>
</head>
<body>
<!--// docs-integrate-electron-2-->
<div id="cesdk_container" style="width: 100%; height: 100vh"></div>
<!--// docs-integrate-electron-2-->
<script>
const CreativeEditorSDK = require('@cesdk/cesdk-js');
window.onload = function () {
let config = {
// Serve assets from IMG.LY cdn or locally
baseURL: 'https://cdn.img.ly/packages/imgly/cesdk-js/1.0.0/assets'
};
CreativeEditorSDK.init('#cesdk_container', config).then((instance) => {
/** do something with the instance of CreativeEditor SDK **/
});
};
</script>
</body>
</html>