Skip to content

Commit

Permalink
コード入力ボックスでTabを入力できるように (#12671)
Browse files Browse the repository at this point in the history
  • Loading branch information
1Step621 authored Dec 15, 2023
1 parent eacc204 commit c419243
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions packages/frontend/src/components/MkTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ const onKeydown = (ev: KeyboardEvent) => {
if (ev.code === 'Enter') {
emit('enter');
}

if (props.code && ev.key === 'Tab') {
const pos = inputEl.value?.selectionStart ?? 0;
const posEnd = inputEl.value?.selectionEnd ?? v.value.length;
v.value = v.value.slice(0, pos) + '\t' + v.value.slice(posEnd);
nextTick(() => {
inputEl.value?.setSelectionRange(pos + 1, pos + 1);
});
ev.preventDefault();
}
};

const updated = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/flash/flash-edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts._play.summary }}</template>
</MkTextarea>
<MkButton primary @click="selectPreset">{{ i18n.ts.selectFromPresets }}<i class="ti ti-chevron-down"></i></MkButton>
<MkTextarea v-model="script" class="_monospace" tall spellcheck="false">
<MkTextarea v-model="script" code tall spellcheck="false">
<template #label>{{ i18n.ts._play.script }}</template>
</MkTextarea>
<div class="_buttons">
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/registry.value.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkKeyValue>
</FormSplit>

<MkTextarea v-model="valueForEditor" tall class="_monospace">
<MkTextarea v-model="valueForEditor" tall code>
<template #label>{{ i18n.ts.value }} (JSON)</template>
</MkTextarea>

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/custom-css.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_m">
<FormInfo warn>{{ i18n.ts.customCssWarn }}</FormInfo>

<MkTextarea v-model="localCustomCss" manualSave tall class="_monospace" style="tab-size: 2;">
<MkTextarea v-model="localCustomCss" manualSave tall code style="tab-size: 2;">
<template #label>CSS</template>
</MkTextarea>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/plugin.install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_m">
<FormInfo warn>{{ i18n.ts._plugin.installWarn }}</FormInfo>

<MkTextarea v-model="code" tall>
<MkTextarea v-model="code" tall code>
<template #label>{{ i18n.ts.code }}</template>
</MkTextarea>

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/theme.install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<div class="_gaps_m">
<MkTextarea v-model="installThemeCode">
<MkTextarea v-model="installThemeCode" code>
<template #label>{{ i18n.ts._theme.code }}</template>
</MkTextarea>

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/theme-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts.editCode }}</template>

<div class="_gaps_m">
<MkTextarea v-model="themeCode" tall>
<MkTextarea v-model="themeCode" tall code>
<template #label>{{ i18n.ts._theme.code }}</template>
</MkTextarea>
<MkButton primary @click="applyThemeCode">{{ i18n.ts.apply }}</MkButton>
Expand Down

0 comments on commit c419243

Please sign in to comment.