chore(control): save text and url

This commit is contained in:
E44
2026-01-19 18:57:56 +01:00
parent 4d5d9849da
commit 671c74f25d
2 changed files with 12 additions and 3 deletions
@@ -47,6 +47,8 @@
title: '', title: '',
}); });
let current_text = $state('');
function popup_close_function() { function popup_close_function() {
popup_content.open = false; popup_content.open = false;
} }
@@ -144,7 +146,6 @@
await run_on_all_selected_displays((d) => await run_on_all_selected_displays((d) =>
show_html(d.ip, `<iframe src="${website_url}"></iframe>`) show_html(d.ip, `<iframe src="${website_url}"></iframe>`)
); );
website_url = '';
} }
</script> </script>
@@ -188,7 +189,7 @@
{/snippet} {/snippet}
{#snippet text_popup()} {#snippet text_popup()}
<TipTapInput /> <TipTapInput bind:text={current_text}/>
{/snippet} {/snippet}
<div class="grid grid-rows-[2.5rem_auto] bg-stone-800 rounded-2xl min-w-0"> <div class="grid grid-rows-[2.5rem_auto] bg-stone-800 rounded-2xl min-w-0">
@@ -20,6 +20,12 @@
import { Color } from '@tiptap/extension-text-style'; import { Color } from '@tiptap/extension-text-style';
import Highlight from '@tiptap/extension-highlight'; import Highlight from '@tiptap/extension-highlight';
let {
text = $bindable()
}: {
text: string;
} = $props();
type TextEditOption = { type TextEditOption = {
onclick: () => void; onclick: () => void;
is_selected: () => boolean; is_selected: () => boolean;
@@ -128,15 +134,17 @@
Highlight.configure({ Highlight.configure({
multicolor: true multicolor: true
}) })
], ],
content: text, content: text,
onTransaction: ({ editor }) => { onTransaction: ({ editor }) => {
// Increment the state signal to force a re-render // Increment the state signal to force a re-render
editor_state = { editor }; editor_state = { editor };
}, },
autofocus: true autofocus: true
});
editor_state.editor.commands.selectAll(); editor_state.editor.commands.selectAll();
}); });
onDestroy(() => {
if (editor_state.editor) text = editor_state.editor.getHTML(); if (editor_state.editor) text = editor_state.editor.getHTML();
editor_state.editor?.destroy(); editor_state.editor?.destroy();
}); });