diff --git a/examples/resources/common.js b/examples/resources/common.js
index 0257267e5d..e5fcee19e5 100644
--- a/examples/resources/common.js
+++ b/examples/resources/common.js
@@ -1,4 +1,12 @@
(function() {
+
+ function compress(json) {
+ return LZString.compressToBase64(JSON.stringify(json))
+ .replace(/\+/g, `-`)
+ .replace(/\//g, `_`)
+ .replace(/=+$/, ``);
+ }
+
var htmlClipboard = new Clipboard('#copy-html-button');
htmlClipboard.on('success', function(e) {
e.clearSelection();
@@ -17,34 +25,22 @@
codepenButton.onclick = function(event) {
event.preventDefault();
var form = document.getElementById('codepen-form');
-
- // Doc : https://blog.codepen.io/documentation/api/prefill/
-
- var resources = form.resources.value.split(',');
-
- var data = {
- title: form.title.value,
- description: form.description.value,
- layout: 'left',
- html: form.html.value,
- css: form.css.value,
- js: form.js.value,
- css_external: resources.filter(function(resource) {
- return resource.lastIndexOf('.css') === resource.length - 4;
- }).join(';'),
- js_external: resources.filter(function(resource) {
- return resource.lastIndexOf('.js') === resource.length - 3;
- }).join(';')
- };
-
- // binary flags to display html, css, js and/or console tabs
- data.editors = '' + Number(data.html.length > 0) +
- Number(data.css.length > 0) +
- Number(data.js.length > 0) +
- Number(data.js.indexOf('console') > 0);
-
- form.data.value = JSON.stringify(data);
-
+ const html = document.getElementById('example-html-source').innerText;
+ const js = document.getElementById('example-js-source').innerText;
+ const pkgJson = document.getElementById('example-pkg-source').innerText;
+ form.parameters.value = compress({
+ files: {
+ 'index.html': {
+ content: html
+ },
+ 'index.js': {
+ content: js
+ },
+ "package.json": {
+ content: pkgJson
+ }
+ }
+ });
form.submit();
};
}
diff --git a/examples/templates/example.html b/examples/templates/example.html
index d5a72c96d6..03e4292bd7 100644
--- a/examples/templates/example.html
+++ b/examples/templates/example.html
@@ -27,6 +27,7 @@
+