refac
Some checks failed
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11.x) (push) Waiting to run
Python CI / Format Backend (3.12.x) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Has been cancelled
Frontend Build / Frontend Unit Tests (push) Has been cancelled

This commit is contained in:
Timothy Jaeryang Baek 2025-05-17 03:14:26 +04:00
parent 424f6f71cf
commit 9801a2d23f
5 changed files with 25 additions and 23 deletions

View File

@ -24,7 +24,7 @@
export let id = ''; export let id = '';
export let onSave = (e) => {}; export let onSave = (e) => {};
export let onCode = (e) => {}; export let onUpdate = (e) => {};
export let onPreview = (e) => {}; export let onPreview = (e) => {};
export let save = false; export let save = false;
@ -340,6 +340,8 @@
await drawMermaidDiagram(); await drawMermaidDiagram();
})(); })();
} }
onUpdate(token);
}; };
$: if (token) { $: if (token) {
@ -352,8 +354,6 @@
render(); render();
} }
$: onCode({ lang, code });
$: if (attributes) { $: if (attributes) {
onAttributesUpdate(); onAttributesUpdate();
} }
@ -386,10 +386,10 @@
onMount(async () => { onMount(async () => {
console.log('codeblock', lang, code); console.log('codeblock', lang, code);
if (token) {
if (lang) { onUpdate(token);
onCode({ lang, code });
} }
if (document.documentElement.classList.contains('dark')) { if (document.documentElement.classList.contains('dark')) {
mermaid.initialize({ mermaid.initialize({
startOnLoad: true, startOnLoad: true,

View File

@ -25,7 +25,7 @@
export let preview = false; export let preview = false;
export let floatingButtons = true; export let floatingButtons = true;
export let onUpdate = () => {}; export let onSave = () => {};
export let onSourceClick = () => {}; export let onSourceClick = () => {};
export let onTaskClick = () => {}; export let onTaskClick = () => {};
@ -164,15 +164,9 @@
}, [])} }, [])}
{onSourceClick} {onSourceClick}
{onTaskClick} {onTaskClick}
{onUpdate} {onSave}
onPreview={async (value) => { onUpdate={(token) => {
await artifactCode.set(value); const { lang, text: code } = token;
await showControls.set(true);
await showArtifacts.set(true);
await showOverview.set(false);
}}
onCode={(value) => {
const { lang, code } = value;
if ( if (
($settings?.detectArtifacts ?? true) && ($settings?.detectArtifacts ?? true) &&
@ -184,6 +178,13 @@
showControls.set(true); showControls.set(true);
} }
}} }}
onPreview={async (value) => {
console.log('Preview', value);
await artifactCode.set(value);
await showControls.set(true);
await showArtifacts.set(true);
await showOverview.set(false);
}}
/> />
</div> </div>

View File

@ -16,8 +16,9 @@
export let sourceIds = []; export let sourceIds = [];
export let onSave = () => {};
export let onUpdate = () => {}; export let onUpdate = () => {};
export let onCode = () => {};
export let onPreview = () => {}; export let onPreview = () => {};
export let onSourceClick = () => {}; export let onSourceClick = () => {};
@ -49,8 +50,8 @@
{preview} {preview}
{onTaskClick} {onTaskClick}
{onSourceClick} {onSourceClick}
{onSave}
{onUpdate} {onUpdate}
{onCode}
{onPreview} {onPreview}
/> />
{/key} {/key}

View File

@ -31,8 +31,8 @@
export let save = false; export let save = false;
export let preview = false; export let preview = false;
export let onSave: Function = () => {};
export let onUpdate: Function = () => {}; export let onUpdate: Function = () => {};
export let onCode: Function = () => {};
export let onPreview: Function = () => {}; export let onPreview: Function = () => {};
export let onTaskClick: Function = () => {}; export let onTaskClick: Function = () => {};
@ -98,15 +98,15 @@
{attributes} {attributes}
{save} {save}
{preview} {preview}
{onCode}
{onPreview}
onSave={(value) => { onSave={(value) => {
onUpdate({ onSave({
raw: token.raw, raw: token.raw,
oldContent: token.text, oldContent: token.text,
newContent: value newContent: value
}); });
}} }}
{onUpdate}
{onPreview}
/> />
{:else} {:else}
{token.text} {token.text}

View File

@ -841,7 +841,7 @@
onAddMessages={({ modelId, parentId, messages }) => { onAddMessages={({ modelId, parentId, messages }) => {
addMessages({ modelId, parentId, messages }); addMessages({ modelId, parentId, messages });
}} }}
onUpdate={({ raw, oldContent, newContent }) => { onSave={({ raw, oldContent, newContent }) => {
history.messages[message.id].content = history.messages[ history.messages[message.id].content = history.messages[
message.id message.id
].content.replace(raw, raw.replace(oldContent, newContent)); ].content.replace(raw, raw.replace(oldContent, newContent));