feat: add code folding toggle to preferences
This commit is contained in:
parent
d819502bc7
commit
44770a4a8e
|
@ -26,6 +26,7 @@ func NewPreferences() Preferences {
|
|||
Editor: PreferencesEditor{
|
||||
FontSize: consts.DEFAULT_FONT_SIZE,
|
||||
ShowLineNum: true,
|
||||
ShowFolding: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -54,4 +55,5 @@ type PreferencesEditor struct {
|
|||
Font string `json:"font" yaml:"font,omitempty"`
|
||||
FontSize int `json:"fontSize" yaml:"font_size"`
|
||||
ShowLineNum bool `json:"showLineNum" yaml:"show_line_num"`
|
||||
ShowFolding bool `json:"showFolding" yaml:"show_folding"`
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
4f3d1a3f7ec34feb214a2f699649e44e
|
||||
c645c91528721588c620ff74fd475d09
|
|
@ -22,6 +22,10 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
showFolding: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
border: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -65,7 +69,7 @@ onMounted(async () => {
|
|||
accessibilitySupport: 'off',
|
||||
wordWrap: 'on',
|
||||
tabSize: 2,
|
||||
folding: true,
|
||||
folding: props.showFolding !== false,
|
||||
fontFamily,
|
||||
fontSize,
|
||||
scrollBeyondLastLine: false,
|
||||
|
|
|
@ -179,6 +179,7 @@ const onSave = () => {
|
|||
:content="displayValue"
|
||||
:language="viewLanguage"
|
||||
:show-line-num="prefStore.showLineNum"
|
||||
:show-folding="prefStore.showFolding"
|
||||
class="flex-item-expand"
|
||||
@input="onInput"
|
||||
@reset="onInput"
|
||||
|
|
|
@ -211,6 +211,7 @@ defineExpose({
|
|||
:language="viewLanguage"
|
||||
:loading="props.loading"
|
||||
:show-line-num="prefStore.showLineNum"
|
||||
:show-folding="prefStore.showFolding"
|
||||
class="flex-item-expand"
|
||||
style="height: 100%"
|
||||
@input="onInput"
|
||||
|
|
|
@ -132,19 +132,28 @@ const onClose = () => {
|
|||
|
||||
<n-tab-pane :tab="$t('preferences.editor.name')" display-directive="show" name="editor">
|
||||
<n-form :disabled="loading" :model="prefStore.editor" :show-require-mark="false" label-placement="top">
|
||||
<n-form-item :label="$t('preferences.general.font')" required>
|
||||
<n-select
|
||||
v-model:value="prefStore.editor.font"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="prefStore.fontOption"
|
||||
filterable />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('preferences.general.font_size')">
|
||||
<n-input-number v-model:value="prefStore.editor.fontSize" :max="65535" :min="1" />
|
||||
</n-form-item>
|
||||
<n-checkbox v-model:checked="prefStore.editor.showLineNum">
|
||||
{{ $t('preferences.editor.show_linenum') }}
|
||||
</n-checkbox>
|
||||
<n-grid :x-gap="10">
|
||||
<n-form-item-gi :label="$t('preferences.general.font')" :span="24" required>
|
||||
<n-select
|
||||
v-model:value="prefStore.editor.font"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="prefStore.fontOption"
|
||||
filterable />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.font_size')" :show-feedback="false" :span="24">
|
||||
<n-input-number v-model:value="prefStore.editor.fontSize" :max="65535" :min="1" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :show-feedback="false" :span="24">
|
||||
<n-checkbox v-model:checked="prefStore.editor.showLineNum">
|
||||
{{ $t('preferences.editor.show_linenum') }}
|
||||
</n-checkbox>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :show-feedback="false" :span="24">
|
||||
<n-checkbox v-model:checked="prefStore.editor.showFolding">
|
||||
{{ $t('preferences.editor.show_folding') }}
|
||||
</n-checkbox>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"name": "Editor",
|
||||
"show_linenum": "Show Line Numbers"
|
||||
"show_linenum": "Show Line Numbers",
|
||||
"show_folding": "Enable Code Folding"
|
||||
}
|
||||
},
|
||||
"interface": {
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"name": "编辑器",
|
||||
"show_linenum": "显示行号"
|
||||
"show_linenum": "显示行号",
|
||||
"show_folding": "启用代码折叠"
|
||||
}
|
||||
},
|
||||
"interface": {
|
||||
|
|
|
@ -55,6 +55,7 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
font: '',
|
||||
fontSize: 14,
|
||||
showLineNum: true,
|
||||
showFolding: true,
|
||||
},
|
||||
lastPref: {},
|
||||
fontList: [],
|
||||
|
@ -190,6 +191,10 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
return get(this.editor, 'showLineNum', true)
|
||||
},
|
||||
|
||||
showFolding() {
|
||||
return get(this.editor, 'showFolding', true)
|
||||
},
|
||||
|
||||
keyIconType() {
|
||||
return get(this.general, 'keyIconStyle', typesIconStyle.SHORT)
|
||||
},
|
||||
|
@ -215,6 +220,10 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
if (showLineNum === undefined) {
|
||||
set(data, 'editor.showLineNum', true)
|
||||
}
|
||||
const showFolding = get(data, 'editor.showFolding')
|
||||
if (showFolding === undefined) {
|
||||
set(data, 'editor.showFolding', true)
|
||||
}
|
||||
i18nGlobal.locale.value = this.currentLanguage
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue