Render Image Editor in Dialog
14 Dec 20243 minutes to read
Rendering the Image Editor in a dialog involves displaying the image editor component within a modal dialog window, allowing users to edit images in a pop-up interface. This can be useful for maintaining a clean layout and providing a focused editing experience without navigating away from the current page.
import { ImageEditor } from '@syncfusion/ej2-image-editor';
import { Dialog } from '@syncfusion/ej2-popups';
//Image Editor items definition
var dialog: Dialog = new Dialog({
isModal: true,
content: document.getElementById("imageeditor"),
width: '340px',
height: '420px',
closeOnEscape: true,
visible: false,
minHeight: '400px',
});
dialog.appendTo('#profile-dialog');
let imageEditorObj: ImageEditor = new ImageEditor();
imageEditorObj.appendTo('#imageeditor');
(document.getElementById('openDialog') as HTMLElement).onclick = function () {
dialog.show();
setTimeout(() => {
imageEditorObj.open('flower.png');
}, 10);
};<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-buttons/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-inputs/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-lists/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-navigations/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-popups/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/34.1.29/ej2-image-editor/styles/material.css" rel="stylesheet" />
<!--style reference from app-->
<link href="styles.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='container'>
<button id="openDialog" class="e-control e-btn">Open Dialog</button>
<div id="profile-dialog">
<div class="control-section">
<div id="imageeditor" class="row"></div>
</div>
</div>
</div>
</body>
<style>
#profile-dialog {
max-height: 420px !important;
}
</style>
</html>