feat: editable code block

This commit is contained in:
Timothy J. Baek
2024-10-05 12:04:36 -07:00
parent 82ac2e4edb
commit 81440460f2
8 changed files with 155 additions and 31 deletions
@@ -22,6 +22,15 @@
description: ''
};
export let content = '';
let _content = '';
$: if (content) {
updateContent();
}
const updateContent = () => {
_content = content;
};
$: if (name && !edit && !clone) {
id = name.replace(/\s+/g, '_').toLowerCase();
@@ -224,10 +233,14 @@ class Tools:
<div class="mb-2 flex-1 overflow-auto h-0 rounded-lg">
<CodeEditor
bind:value={content}
bind:this={codeEditor}
value={content}
{boilerplate}
on:change={(e) => {
_content = e.detail.value;
}}
on:save={() => {
content = _content;
if (formElement) {
formElement.requestSubmit();
}