Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                PhotoKit editor demo ifraem URL: 

window.addEventListener("message", function (event) {

			if("photokitsdk" &&"editorLoaded"){
				console.log("editor loaded");
				photokit.contentWindow.postMessage({type: 'photokitsdk',name:'saveimagetype',savetype:'local'},'*'); //"local" or "postMessage"
					The image save mode "local" and "postMessage", the user clicks the save button or saves through the api:
						In local mode, the image will be saved locally.
						In postMessage mode, the image base64 data is passed to the parent window through possMessage.
				save_base64_button.disabled = false;
				save_local_button.disabled = false;
				open_image_button.disabled = false;
				place_image_button.disabled = false;
			// Get saved image (In postMessage mode, monitor the saved image data.) :
			if("photokitsdk" &&"saveimage"){
				var imagebase64 =;
				var imagename =;
				alert("Successfully obtained png image base64 data");

addEventListener('DOMContentLoaded', function(){
	var save_base64_button = document.getElementById("save_base64_button");
	var save_local_button = document.getElementById("save_local_button");
	var open_image_button = document.getElementById("open_image_button");
	var place_image_button = document.getElementById("place_image_button");
	save_base64_button.addEventListener("click", function(){
			photokit.contentWindow.postMessage({type: 'photokitsdk',name:'saveimagetype',savetype:'postMessage'},'*');  //"local" or "postMessage"
			photokit.contentWindow.postMessage({type: 'photokitsdk',name:'saveimage'},'*');
	save_local_button.addEventListener("click", function(){
			photokit.contentWindow.postMessage({type: 'photokitsdk',name:'saveimagetype',savetype:'local'},'*');  //"local" or "postMessage"
			photokit.contentWindow.postMessage({type: 'photokitsdk',name:'saveimage'},'*');
	open_image_button.addEventListener("click", function(){
			toDataURL('',function(dataUrl) {
					photokit.contentWindow.postMessage({type: 'photokitsdk',name:'openimage',data:dataUrl,opentype:0},'*');
	place_image_button.addEventListener("click", function(){
			toDataURL('',function(dataUrl) {
					photokit.contentWindow.postMessage({type: 'photokitsdk',name:'openimage',data:dataUrl,opentype:1},'*');
//convert image url to base64 data
function toDataURL(src, callback, outputFormat) {
    var img = new Image();
    img.crossOrigin = 'Anonymous';
    img.onload = function() {
      var canvas = document.createElement('CANVAS');
      var ctx = canvas.getContext('2d');
      var dataURL;
      canvas.height = this.naturalHeight;
      canvas.width = this.naturalWidth;
      ctx.drawImage(this, 0, 0);
      dataURL = canvas.toDataURL(outputFormat);
    img.src = src;
    if (img.complete || img.complete === undefined) {
      img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
      img.src = src;

<button id="save_base64_button" type="button" disabled>save image( Get png image base64)</button>
<button id="save_local_button" type="button" disabled>save image( save to local)</button>
<button id="open_image_button" type="button" disabled>open an image</button>
<button id="place_image_button" type="button" disabled>place an image</button>
<iframe id="photokit" style="width:100%;height:850px;" src="" frameborder="no" border="0" scrolling="no" allow="storage-access; local-fonts; clipboard-read; clipboard-write">