This commit is contained in:
Timothy Jaeryang Baek 2026-10-09 18:53:44 +04:00
parent 6a7678ac70
commit ccc7174371
3 changed files with 19 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<script lang="ts">
import '$lib/utils/codemirror';
import { basicSetup, EditorView } from 'codemirror';
import { keymap } from '@codemirror/view';
import { keymap, placeholder as editorPlaceholder } from '@codemirror/view';
import { Compartment, EditorState } from '@codemirror/state';
import { indentWithTab } from '@codemirror/commands';
import { indentUnit, LanguageDescription } from '@codemirror/language';
@ -11,6 +11,8 @@
export let value = '';
export let readOnly = false;
export let placeholder = '';
export let ariaLabel = '';
export let filePath: string | null = null;
export let onSave: ((content: string) => Promise<void>) | null = null;
export let searchTarget: {
@ -75,7 +77,9 @@
editor.dispatch({
effects: editorReadOnly.reconfigure([
EditorState.readOnly.of(readOnly),
EditorView.editable.of(!readOnly)
EditorView.editable.of(!readOnly),
EditorView.contentAttributes.of(ariaLabel ? { 'aria-label': ariaLabel } : {}),
placeholder ? editorPlaceholder(placeholder) : []
])
});
@ -123,7 +127,12 @@
}),
editorTheme.of(isDark ? oneDark : []),
editorLanguage.of([]),
editorReadOnly.of([EditorState.readOnly.of(readOnly), EditorView.editable.of(!readOnly)]),
editorReadOnly.of([
EditorState.readOnly.of(readOnly),
EditorView.editable.of(!readOnly),
EditorView.contentAttributes.of(ariaLabel ? { 'aria-label': ariaLabel } : {}),
placeholder ? editorPlaceholder(placeholder) : []
]),
EditorView.theme({
'&': { fontSize: '0.75rem', height: '100%' },
'.cm-content': {

View file

@ -166,6 +166,7 @@
>
<div slot="content">
<DropdownMenu className="min-w-44">
<!-- Previous label: {$i18n.t('File content')} -->
<button
type="button"
role="menuitemcheckbox"
@ -194,6 +195,7 @@
on:click={() => (direction = direction === 'asc' ? 'desc' : 'asc')}
>{direction === 'asc' ? $i18n.t('Ascending') : $i18n.t('Descending')}</button
>
<!-- Previous labels: {$i18n.t('Asc')} {$i18n.t('Desc')} -->
</DropdownMenu>
</div></Dropdown
>

View file

@ -21,6 +21,7 @@
export let selected = false;
export let onSelect: () => void;
export let onDelete: (() => void) | undefined = undefined;
export let deleteDisabledReason = '';
const i18n = getContext<any>('i18n');
$: authorId = entry?.user?.id || entry?.user_id;
$: message = entry?.commit_message || entry?.id.slice(0, 7) || status;
@ -56,7 +57,7 @@
{#if status && entry}<span class="shrink-0 text-[0.625rem] text-gray-400">{status}</span>{/if}
{#if selected}<Check className="size-3.5 shrink-0 text-blue-500" />{/if}
</button>
{#if onDelete}
{#if onDelete || deleteDisabledReason}
<Dropdown bind:show={showActions} align="end">
<button
type="button"
@ -68,6 +69,9 @@
<DropdownMenu className="min-w-32">
<button
type="button"
disabled={!!deleteDisabledReason}
class="disabled:cursor-not-allowed disabled:opacity-40"
title={deleteDisabledReason || undefined}
on:click={() => {
showActions = false;
onDelete?.();