@binay7587/ckeditor5-full-free
Version:
Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
56 lines (42 loc) • 1.57 kB
JavaScript
/**
* @license Copyright (c) 2014-2023, CKSource Holding sp. z o.o. All rights reserved.
* This file is licensed under the terms of the MIT License (see LICENSE.md).
*/
/* eslint-env browser */
( function() {
const LOCAL_STORAGE_KEY = 'CKEDITOR_CS_CONFIG';
function createDialog() {
const overlay = document.createElement( 'div' );
overlay.id = 'overlay';
overlay.innerHTML = `
<form class="body">
<h2>Connect CKEditor5 Premium Features</h2>
<p>If you do not have CKEditor5 license key yet, <a href="https://ckeditor.com/docs/trial/latest/guides/overview.html" target="_blank">see the documentation</a>.</p>
<div>
<label for="license-key">CKEditor5 License Key</label>
<input id="license-key">
</div>
<button id="start" type="submit">Start</button>
</form>`;
document.body.appendChild( overlay );
const config = getStoredConfig();
const licenseKeyInput = document.getElementById( 'license-key' );
licenseKeyInput.value = config.licenseKey || '';
return new Promise( resolve => {
overlay.querySelector( 'form' ).addEventListener( 'submit', event => {
event.preventDefault();
config.licenseKey = licenseKeyInput.value;
overlay.remove();
storeConfig( config );
resolve( config );
} );
} );
}
function getStoredConfig() {
return JSON.parse( localStorage.getItem( LOCAL_STORAGE_KEY ) || '{}' );
}
function storeConfig( config ) {
localStorage.setItem( LOCAL_STORAGE_KEY, JSON.stringify( config ) );
}
window.createDialog = createDialog;
}() );