fix: make migration view editor read-only so its code can scroll

This commit is contained in:
Diego Imbert
2026-06-20 16:14:53 +02:00
parent 32732e599b
commit ee65da8d83
2 changed files with 10 additions and 2 deletions
@@ -95,6 +95,7 @@
loadAsync = false,
key,
disabled = false,
readOnly = false,
minHeight = 1000,
renderLineHighlight = 'none',
suggestion
@@ -123,6 +124,9 @@
initialCursorPos?: IPosition
key?: string
disabled?: boolean
/** Read-only Monaco mode: not editable, but still scrollable/selectable
* (unlike `disabled`, which makes the editor non-interactive). */
readOnly?: boolean
minHeight?: number
renderLineHighlight?: 'all' | 'line' | 'gutter' | 'none'
suggestion?: string
@@ -239,6 +243,9 @@
lineNumbers: $relativeLineNumbers ? 'relative' : 'on'
})
})
$effect(() => {
editor?.updateOptions({ readOnly })
})
function onVimDisable() {
vimDisposable?.dispose()
@@ -342,6 +349,7 @@
),
model,
...(yPadding !== undefined ? { padding: { bottom: yPadding, top: yPadding } } : {}),
readOnly,
renderLineHighlight,
lineDecorationsWidth: 0,
lineNumbersMinChars: 2,
@@ -453,11 +453,11 @@
<Tab value="down" label="Down" />
{#snippet content()}
<TabContent value="up" class="h-80">
<SimpleEditor class="h-full" lang="sql" code={viewMigration?.code_up ?? ''} disabled />
<SimpleEditor class="h-full" lang="sql" code={viewMigration?.code_up ?? ''} readOnly />
</TabContent>
<TabContent value="down" class="h-80">
{#if viewMigration?.code_down}
<SimpleEditor class="h-full" lang="sql" code={viewMigration.code_down} disabled />
<SimpleEditor class="h-full" lang="sql" code={viewMigration.code_down} readOnly />
{:else}
<div class="p-6 text-center text-sm text-tertiary">No down migration</div>
{/if}