perf: add links option for value editor #143

This commit is contained in:
Lykin 2024-02-18 21:46:00 +08:00
parent 29ffd83486
commit f1e1a89baf
6 changed files with 23 additions and 3 deletions

View File

@ -30,6 +30,7 @@ func NewPreferences() Preferences {
ShowLineNum: true,
ShowFolding: true,
DropText: true,
Links: true,
},
Cli: PreferencesCli{
FontSize: consts.DEFAULT_FONT_SIZE,
@ -69,6 +70,7 @@ type PreferencesEditor struct {
ShowLineNum bool `json:"showLineNum" yaml:"show_line_num"`
ShowFolding bool `json:"showFolding" yaml:"show_folding"`
DropText bool `json:"dropText" yaml:"drop_text"`
Links bool `json:"links" yaml:"links"`
}
type PreferencesCli struct {

View File

@ -56,6 +56,7 @@ onMounted(async () => {
theme: pref.isDark ? 'rdm-dark' : 'rdm-light',
language: props.language,
lineNumbers: pref.showLineNum ? 'on' : 'off',
links: pref.editorLinks,
readOnly: readonlyValue.value,
colorDecorators: true,
accessibilitySupport: 'off',
@ -145,7 +146,7 @@ watch(
watch(
() => pref.editor,
({ showLineNum = true, showFolding = true, dropText = true }) => {
({ showLineNum = true, showFolding = true, dropText = true, links = true }) => {
if (editorNode != null) {
const { fontSize, fontFamily } = pref.editorFont
editorNode.updateOptions({
@ -154,6 +155,7 @@ watch(
lineNumbers: showLineNum ? 'on' : 'off',
folding: showFolding,
dragAndDrop: dropText,
links,
})
}
},

View File

@ -301,6 +301,11 @@ const onClose = () => {
{{ $t('preferences.editor.drop_text') }}
</n-checkbox>
</n-form-item-gi>
<n-form-item-gi :show-feedback="false" :show-label="false" :span="24">
<n-checkbox v-model:checked="prefStore.editor.links">
{{ $t('preferences.editor.links') }}
</n-checkbox>
</n-form-item-gi>
</n-grid>
</n-form>
</n-tab-pane>

View File

@ -55,7 +55,8 @@
"name": "Editor",
"show_linenum": "Show Line Numbers",
"show_folding": "Enable Code Folding",
"drop_text": "Allow Drag and Drop Text"
"drop_text": "Allow Drag and Drop Text",
"links": "Support links"
},
"cli": {
"name": "Command Line",

View File

@ -55,7 +55,8 @@
"name": "编辑器",
"show_linenum": "显示行号",
"show_folding": "启用代码折叠",
"drop_text": "允许拖放文本"
"drop_text": "允许拖放文本",
"links": "支持连接跳转"
},
"cli": {
"name": "命令行",

View File

@ -59,6 +59,7 @@ const usePreferencesStore = defineStore('preferences', {
showLineNum: true,
showFolding: true,
dropText: true,
links: true,
},
cli: {
fontFamily: [],
@ -259,6 +260,10 @@ const usePreferencesStore = defineStore('preferences', {
return get(this.editor, 'dropText', true)
},
editorLinks() {
return get(this.editor, 'links', true)
},
keyIconType() {
return get(this.general, 'keyIconStyle', typesIconStyle.SHORT)
},
@ -292,6 +297,10 @@ const usePreferencesStore = defineStore('preferences', {
if (dropText === undefined) {
set(data, 'editor.dropText', true)
}
const links = get(data, 'editor.links')
if (links === undefined) {
set(data, 'editor.links', true)
}
i18nGlobal.locale.value = this.currentLanguage
}
},