Spaces:
Running
Running
what did you do to this project - Follow Up Deployment
Browse files- index.html +87 -14
index.html
CHANGED
|
@@ -9,36 +9,109 @@
|
|
| 9 |
href="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.min.css"
|
| 10 |
/>
|
| 11 |
<style>
|
| 12 |
-
body { margin: 0; padding: 20px; }
|
| 13 |
-
#tui-image-editor { width: 700px; height: 500px; }
|
|
|
|
|
|
|
|
|
|
| 14 |
</style>
|
| 15 |
</head>
|
| 16 |
<body>
|
| 17 |
|
| 18 |
-
<input type="file" id="load-image" />
|
|
|
|
| 19 |
<div id="tui-image-editor"></div>
|
| 20 |
|
| 21 |
<script src="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.min.js"></script>
|
| 22 |
<script>
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
document.getElementById('load-image').addEventListener('change', function(event) {
|
|
|
|
| 33 |
const file = event.target.files[0];
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
imageEditor.loadImageFromFile(file)
|
| 36 |
-
.then(() =>
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
});
|
| 40 |
</script>
|
| 41 |
|
| 42 |
-
</body>
|
| 43 |
</html>
|
| 44 |
|
|
|
|
| 9 |
href="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.min.css"
|
| 10 |
/>
|
| 11 |
<style>
|
| 12 |
+
body { margin: 0; padding: 20px; font-family: Arial, sans-serif; }
|
| 13 |
+
#tui-image-editor { width: 100%; max-width: 700px; height: 500px; }
|
| 14 |
+
#status { margin: 10px 0; color: #666; }
|
| 15 |
+
.error { color: #d32f2f; }
|
| 16 |
+
.success { color: #388e3c; }
|
| 17 |
</style>
|
| 18 |
</head>
|
| 19 |
<body>
|
| 20 |
|
| 21 |
+
<input type="file" id="load-image" accept="image/*" />
|
| 22 |
+
<div id="status">Select an image to edit</div>
|
| 23 |
<div id="tui-image-editor"></div>
|
| 24 |
|
| 25 |
<script src="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.min.js"></script>
|
| 26 |
<script>
|
| 27 |
+
let imageEditor;
|
| 28 |
+
let editorReady = false;
|
| 29 |
+
|
| 30 |
+
function initEditor() {
|
| 31 |
+
try {
|
| 32 |
+
if (typeof tui === 'undefined' || !tui.ImageEditor) {
|
| 33 |
+
throw new Error('Toast UI library failed to load');
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
imageEditor = new tui.ImageEditor('#tui-image-editor', {
|
| 37 |
+
includeUI: {
|
| 38 |
+
menu: ['crop', 'flip', 'rotate', 'draw', 'shape', 'icon', 'text', 'mask', 'filter'],
|
| 39 |
+
initMenu: '',
|
| 40 |
+
uiSize: { width: '700px', height: '500px' },
|
| 41 |
+
menuBarPosition: 'bottom'
|
| 42 |
+
}
|
| 43 |
+
});
|
| 44 |
+
editorReady = true;
|
| 45 |
+
} catch (err) {
|
| 46 |
+
document.getElementById('status').textContent = `Failed to initialize editor: ${err.message}`;
|
| 47 |
+
document.getElementById('status').className = 'error';
|
| 48 |
+
console.error('Editor initialization error:', err);
|
| 49 |
+
document.getElementById('load-image').disabled = true;
|
| 50 |
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// Initialize editor when library is loaded
|
| 54 |
+
if (document.readyState === 'complete') {
|
| 55 |
+
initEditor();
|
| 56 |
+
} else {
|
| 57 |
+
window.addEventListener('load', initEditor);
|
| 58 |
+
}
|
| 59 |
+
} catch (err) {
|
| 60 |
+
document.getElementById('status').textContent = `Failed to initialize editor: ${err.message}`;
|
| 61 |
+
document.getElementById('status').className = 'error';
|
| 62 |
+
console.error('Editor initialization error:', err);
|
| 63 |
+
}
|
| 64 |
|
| 65 |
document.getElementById('load-image').addEventListener('change', function(event) {
|
| 66 |
+
const statusEl = document.getElementById('status');
|
| 67 |
const file = event.target.files[0];
|
| 68 |
+
|
| 69 |
+
if (!file) {
|
| 70 |
+
statusEl.textContent = 'No file selected';
|
| 71 |
+
statusEl.className = 'error';
|
| 72 |
+
return;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// More robust file type checking
|
| 76 |
+
if (!file.type.startsWith('image/')) {
|
| 77 |
+
statusEl.textContent = 'Please select an image file (JPEG, PNG, etc.)';
|
| 78 |
+
statusEl.className = 'error';
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
if (!editorReady) {
|
| 83 |
+
statusEl.textContent = 'Editor is not ready yet. Please try again.';
|
| 84 |
+
statusEl.className = 'error';
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
statusEl.textContent = 'Loading image...';
|
| 89 |
+
statusEl.className = '';
|
| 90 |
+
event.target.disabled = true;
|
| 91 |
+
|
| 92 |
+
try {
|
| 93 |
imageEditor.loadImageFromFile(file)
|
| 94 |
+
.then(() => {
|
| 95 |
+
statusEl.textContent = 'Image loaded successfully!';
|
| 96 |
+
statusEl.className = 'success';
|
| 97 |
+
})
|
| 98 |
+
.catch(err => {
|
| 99 |
+
statusEl.textContent = `Error: ${err.message || 'Failed to load image'}`;
|
| 100 |
+
statusEl.className = 'error';
|
| 101 |
+
console.error('Image loading error:', err);
|
| 102 |
+
})
|
| 103 |
+
.finally(() => {
|
| 104 |
+
event.target.disabled = false;
|
| 105 |
+
event.target.value = ''; // Reset input to allow selecting same file again
|
| 106 |
+
});
|
| 107 |
+
} catch (err) {
|
| 108 |
+
statusEl.textContent = `Error: ${err.message || 'Unexpected error occurred'}`;
|
| 109 |
+
statusEl.className = 'error';
|
| 110 |
+
console.error('Unexpected error:', err);
|
| 111 |
}
|
| 112 |
});
|
| 113 |
</script>
|
| 114 |
|
| 115 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=jasvir-singh1021/Image_Editor" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 116 |
</html>
|
| 117 |
|