hopefully fixing issues
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
|
||||
let locked = $derived(appState.locked);
|
||||
|
||||
let imageInput = $state<HTMLInputElement>(undefined!);
|
||||
let soundInput = $state<HTMLInputElement>(undefined!);
|
||||
let videoInput = $state<HTMLInputElement>(undefined!);
|
||||
let imageInput: HTMLInputElement | null = $state(null);
|
||||
let soundInput: HTMLInputElement | null = $state(null);
|
||||
let videoInput: HTMLInputElement | null = $state(null);
|
||||
|
||||
function getSpawnPosition() {
|
||||
return {
|
||||
@@ -56,11 +56,22 @@
|
||||
function addEmbed() {
|
||||
const url = prompt('Enter URL to embed:');
|
||||
if (!url) return;
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
||||
alert('Only HTTP/HTTPS URLs are allowed');
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
alert('Invalid URL');
|
||||
return;
|
||||
}
|
||||
const id = crypto.randomUUID();
|
||||
const pos = getSpawnPosition();
|
||||
const escapedUrl = url.replace(/"/g, '"');
|
||||
appState.addItem({
|
||||
id,
|
||||
html: `<iframe src="${url}" frameborder="0" allowfullscreen></iframe>`,
|
||||
html: `<iframe src="${escapedUrl}" frameborder="0" allowfullscreen></iframe>`,
|
||||
css: `iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -185,9 +196,9 @@
|
||||
<div class="palette">
|
||||
<button onclick={addTile} title="Tile"><Square size={14} /></button>
|
||||
<button onclick={addText} title="Text"><Type size={14} /></button>
|
||||
<button onclick={() => imageInput.click()} title="Image"><Image size={14} /></button>
|
||||
<button onclick={() => soundInput.click()} title="Sound"><Music size={14} /></button>
|
||||
<button onclick={() => videoInput.click()} title="Video"><Video size={14} /></button>
|
||||
<button onclick={() => imageInput?.click()} title="Image"><Image size={14} /></button>
|
||||
<button onclick={() => soundInput?.click()} title="Sound"><Music size={14} /></button>
|
||||
<button onclick={() => videoInput?.click()} title="Video"><Video size={14} /></button>
|
||||
<button onclick={addEmbed} title="Embed"><Globe size={14} /></button>
|
||||
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user