aboutsummaryrefslogtreecommitdiff
path: root/source/library/components/Editor.svelte
diff options
context:
space:
mode:
authornetop://ウィビ <paul@webb.page>2026-04-24 17:57:26 -0700
committernetop://ウィビ <paul@webb.page>2026-04-24 17:57:26 -0700
commit41eef08bc409ba2a5a49e7d785bd113da51bab23 (patch)
treece45faaafcded4e7b8de1154db5270203926c164 /source/library/components/Editor.svelte
parent216441d3564e00aabfac7e8acf346e34a5db9598 (diff)
downloadgraphiql-41eef08bc409ba2a5a49e7d785bd113da51bab23.tar.gz
graphiql-41eef08bc409ba2a5a49e7d785bd113da51bab23.zip
Push value prop changes into Editor's CodeMirror state
Editor read the value prop once at mount and never reconciled later mutations into the CodeMirror doc. Result viewer never showed query output, format button output never reached the editor, and history loads stayed invisible. Add an effect that diffs the doc against the incoming value and dispatches a replacement transaction when they differ — guard against the user-typing echo by skipping when they already match.
Diffstat (limited to '')
-rw-r--r--source/library/components/Editor.svelte12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/library/components/Editor.svelte b/source/library/components/Editor.svelte
index 393812a..073a76a 100644
--- a/source/library/components/Editor.svelte
+++ b/source/library/components/Editor.svelte
@@ -115,6 +115,18 @@
// Invalid SDL — silently skip; editor keeps working without schema awareness
}
});
+
+ $effect(() => {
+ if (!view)
+ return;
+
+ if (view.state.doc.toString() === value)
+ return;
+
+ view.dispatch({
+ changes: { from: 0, insert: value, to: view.state.doc.length }
+ });
+ });
</script>
<style lang="scss">