🎨 binding keymap and extension
This commit is contained in:
@@ -343,11 +343,6 @@ export class Extension {
|
|||||||
*/
|
*/
|
||||||
"id": ExtensionID;
|
"id": ExtensionID;
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展分类
|
|
||||||
*/
|
|
||||||
"category": ExtensionCategory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否启用
|
* 是否启用
|
||||||
*/
|
*/
|
||||||
@@ -368,9 +363,6 @@ export class Extension {
|
|||||||
if (!("id" in $$source)) {
|
if (!("id" in $$source)) {
|
||||||
this["id"] = ("" as ExtensionID);
|
this["id"] = ("" as ExtensionID);
|
||||||
}
|
}
|
||||||
if (!("category" in $$source)) {
|
|
||||||
this["category"] = ("" as ExtensionCategory);
|
|
||||||
}
|
|
||||||
if (!("enabled" in $$source)) {
|
if (!("enabled" in $$source)) {
|
||||||
this["enabled"] = false;
|
this["enabled"] = false;
|
||||||
}
|
}
|
||||||
@@ -388,42 +380,17 @@ export class Extension {
|
|||||||
* Creates a new Extension instance from a string or object.
|
* Creates a new Extension instance from a string or object.
|
||||||
*/
|
*/
|
||||||
static createFrom($$source: any = {}): Extension {
|
static createFrom($$source: any = {}): Extension {
|
||||||
const $$createField4_0 = $$createType6;
|
const $$createField3_0 = $$createType6;
|
||||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||||
if ("config" in $$parsedSource) {
|
if ("config" in $$parsedSource) {
|
||||||
$$parsedSource["config"] = $$createField4_0($$parsedSource["config"]);
|
$$parsedSource["config"] = $$createField3_0($$parsedSource["config"]);
|
||||||
}
|
}
|
||||||
return new Extension($$parsedSource as Partial<Extension>);
|
return new Extension($$parsedSource as Partial<Extension>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExtensionCategory 扩展分类
|
* ExtensionConfig 扩展配置项
|
||||||
*/
|
|
||||||
export enum ExtensionCategory {
|
|
||||||
/**
|
|
||||||
* The Go zero value for the underlying type of the enum.
|
|
||||||
*/
|
|
||||||
$zero = "",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑增强
|
|
||||||
*/
|
|
||||||
CategoryEditing = "editing",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 界面增强
|
|
||||||
*/
|
|
||||||
CategoryUI = "ui",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工具类
|
|
||||||
*/
|
|
||||||
CategoryTools = "tools",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExtensionConfig 扩展配置项(动态配置)
|
|
||||||
*/
|
*/
|
||||||
export type ExtensionConfig = { [_: string]: any };
|
export type ExtensionConfig = { [_: string]: any };
|
||||||
|
|
||||||
@@ -470,6 +437,12 @@ export enum ExtensionID {
|
|||||||
* 代码块
|
* 代码块
|
||||||
*/
|
*/
|
||||||
ExtensionCodeBlock = "codeBlock",
|
ExtensionCodeBlock = "codeBlock",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核心扩展
|
||||||
|
* 编辑器核心功能
|
||||||
|
*/
|
||||||
|
ExtensionEditor = "editor",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,9 +586,9 @@ export class KeyBinding {
|
|||||||
"command": KeyBindingCommand;
|
"command": KeyBindingCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快捷键分类
|
* 所属扩展
|
||||||
*/
|
*/
|
||||||
"category": KeyBindingCategory;
|
"extension": ExtensionID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快捷键组合(如 "Mod-f", "Ctrl-Shift-p")
|
* 快捷键组合(如 "Mod-f", "Ctrl-Shift-p")
|
||||||
@@ -637,8 +610,8 @@ export class KeyBinding {
|
|||||||
if (!("command" in $$source)) {
|
if (!("command" in $$source)) {
|
||||||
this["command"] = ("" as KeyBindingCommand);
|
this["command"] = ("" as KeyBindingCommand);
|
||||||
}
|
}
|
||||||
if (!("category" in $$source)) {
|
if (!("extension" in $$source)) {
|
||||||
this["category"] = ("" as KeyBindingCategory);
|
this["extension"] = ("" as ExtensionID);
|
||||||
}
|
}
|
||||||
if (!("key" in $$source)) {
|
if (!("key" in $$source)) {
|
||||||
this["key"] = "";
|
this["key"] = "";
|
||||||
@@ -662,41 +635,6 @@ export class KeyBinding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* KeyBindingCategory 快捷键分类
|
|
||||||
*/
|
|
||||||
export enum KeyBindingCategory {
|
|
||||||
/**
|
|
||||||
* The Go zero value for the underlying type of the enum.
|
|
||||||
*/
|
|
||||||
$zero = "",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索相关
|
|
||||||
*/
|
|
||||||
CategorySearch = "search",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑相关
|
|
||||||
*/
|
|
||||||
CategoryEdit = "edit",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码块相关
|
|
||||||
*/
|
|
||||||
CategoryCodeBlock = "block",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 历史记录相关
|
|
||||||
*/
|
|
||||||
CategoryHistory = "history",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码折叠相关
|
|
||||||
*/
|
|
||||||
CategoryFold = "fold",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KeyBindingCommand 快捷键命令
|
* KeyBindingCommand 快捷键命令
|
||||||
*/
|
*/
|
||||||
@@ -707,7 +645,7 @@ export enum KeyBindingCommand {
|
|||||||
$zero = "",
|
$zero = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索相关
|
* 搜索扩展相关
|
||||||
* 显示搜索
|
* 显示搜索
|
||||||
*/
|
*/
|
||||||
ShowSearchCommand = "showSearch",
|
ShowSearchCommand = "showSearch",
|
||||||
@@ -743,7 +681,7 @@ export enum KeyBindingCommand {
|
|||||||
SearchReplaceAllCommand = "searchReplaceAll",
|
SearchReplaceAllCommand = "searchReplaceAll",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码块相关
|
* 代码块扩展相关
|
||||||
* 块内选择全部
|
* 块内选择全部
|
||||||
*/
|
*/
|
||||||
BlockSelectAllCommand = "blockSelectAll",
|
BlockSelectAllCommand = "blockSelectAll",
|
||||||
@@ -839,28 +777,7 @@ export enum KeyBindingCommand {
|
|||||||
BlockPasteCommand = "blockPaste",
|
BlockPasteCommand = "blockPaste",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 历史记录相关
|
* 代码折叠扩展相关
|
||||||
* 撤销
|
|
||||||
*/
|
|
||||||
HistoryUndoCommand = "historyUndo",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重做
|
|
||||||
*/
|
|
||||||
HistoryRedoCommand = "historyRedo",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销选择
|
|
||||||
*/
|
|
||||||
HistoryUndoSelectionCommand = "historyUndoSelection",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重做选择
|
|
||||||
*/
|
|
||||||
HistoryRedoSelectionCommand = "historyRedoSelection",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码折叠相关
|
|
||||||
* 折叠代码
|
* 折叠代码
|
||||||
*/
|
*/
|
||||||
FoldCodeCommand = "foldCode",
|
FoldCodeCommand = "foldCode",
|
||||||
@@ -881,7 +798,7 @@ export enum KeyBindingCommand {
|
|||||||
UnfoldAllCommand = "unfoldAll",
|
UnfoldAllCommand = "unfoldAll",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑相关
|
* 通用编辑扩展相关
|
||||||
* 光标按语法左移
|
* 光标按语法左移
|
||||||
*/
|
*/
|
||||||
CursorSyntaxLeftCommand = "cursorSyntaxLeft",
|
CursorSyntaxLeftCommand = "cursorSyntaxLeft",
|
||||||
@@ -980,6 +897,27 @@ export enum KeyBindingCommand {
|
|||||||
* 向前删除组
|
* 向前删除组
|
||||||
*/
|
*/
|
||||||
DeleteGroupForwardCommand = "deleteGroupForward",
|
DeleteGroupForwardCommand = "deleteGroupForward",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史记录扩展相关
|
||||||
|
* 撤销
|
||||||
|
*/
|
||||||
|
HistoryUndoCommand = "historyUndo",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重做
|
||||||
|
*/
|
||||||
|
HistoryRedoCommand = "historyRedo",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤销选择
|
||||||
|
*/
|
||||||
|
HistoryUndoSelectionCommand = "historyUndoSelection",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重做选择
|
||||||
|
*/
|
||||||
|
HistoryRedoSelectionCommand = "historyRedoSelection",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -5,6 +5,7 @@ import {EditorState, Extension} from '@codemirror/state';
|
|||||||
import {useConfigStore} from './configStore';
|
import {useConfigStore} from './configStore';
|
||||||
import {useDocumentStore} from './documentStore';
|
import {useDocumentStore} from './documentStore';
|
||||||
import {useThemeStore} from './themeStore';
|
import {useThemeStore} from './themeStore';
|
||||||
|
import {useKeybindingStore} from './keybindingStore';
|
||||||
import {SystemThemeType} from '@/../bindings/voidraft/internal/models/models';
|
import {SystemThemeType} from '@/../bindings/voidraft/internal/models/models';
|
||||||
import {DocumentService, ExtensionService} from '@/../bindings/voidraft/internal/services';
|
import {DocumentService, ExtensionService} from '@/../bindings/voidraft/internal/services';
|
||||||
import {ensureSyntaxTree} from "@codemirror/language"
|
import {ensureSyntaxTree} from "@codemirror/language"
|
||||||
@@ -14,7 +15,7 @@ import {getTabExtensions, updateTabConfig} from '@/views/editor/basic/tabExtensi
|
|||||||
import {createFontExtensionFromBackend, updateFontConfig} from '@/views/editor/basic/fontExtension';
|
import {createFontExtensionFromBackend, updateFontConfig} from '@/views/editor/basic/fontExtension';
|
||||||
import {createStatsUpdateExtension} from '@/views/editor/basic/statsExtension';
|
import {createStatsUpdateExtension} from '@/views/editor/basic/statsExtension';
|
||||||
import {createAutoSavePlugin, createSaveShortcutPlugin} from '@/views/editor/basic/autoSaveExtension';
|
import {createAutoSavePlugin, createSaveShortcutPlugin} from '@/views/editor/basic/autoSaveExtension';
|
||||||
import {createDynamicKeymapExtension} from '@/views/editor/keymap';
|
import {createDynamicKeymapExtension, updateKeymapExtension} from '@/views/editor/keymap';
|
||||||
import {createDynamicExtensions, getExtensionManager, setExtensionManagerView} from '@/views/editor/manager';
|
import {createDynamicExtensions, getExtensionManager, setExtensionManagerView} from '@/views/editor/manager';
|
||||||
import {useExtensionStore} from './extensionStore';
|
import {useExtensionStore} from './extensionStore';
|
||||||
|
|
||||||
@@ -271,18 +272,31 @@ export const useEditorStore = defineStore('editor', () => {
|
|||||||
await ExtensionService.UpdateExtensionState(id, enabled, config)
|
await ExtensionService.UpdateExtensionState(id, enabled, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新前端编辑器
|
// 更新前端编辑器扩展
|
||||||
const manager = getExtensionManager()
|
const manager = getExtensionManager()
|
||||||
if (manager) {
|
if (manager) {
|
||||||
manager.updateExtension(id, enabled, config || {})
|
manager.updateExtension(id, enabled, config || {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重新加载扩展配置
|
||||||
await extensionStore.loadExtensions()
|
await extensionStore.loadExtensions()
|
||||||
|
|
||||||
|
// 更新快捷键映射
|
||||||
|
if (editorView.value) {
|
||||||
|
updateKeymapExtension(editorView.value)
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听扩展状态变化,自动更新快捷键
|
||||||
|
watch(() => extensionStore.enabledExtensions.length, () => {
|
||||||
|
if (editorView.value) {
|
||||||
|
updateKeymapExtension(editorView.value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// 状态
|
// 状态
|
||||||
documentStats,
|
documentStats,
|
||||||
|
@@ -12,6 +12,11 @@ export const useExtensionStore = defineStore('extension', () => {
|
|||||||
extensions.value.filter(ext => ext.enabled)
|
extensions.value.filter(ext => ext.enabled)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 获取启用的扩展ID列表
|
||||||
|
const enabledExtensionIds = computed(() =>
|
||||||
|
enabledExtensions.value.map(ext => ext.id)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从后端加载扩展配置
|
* 从后端加载扩展配置
|
||||||
*/
|
*/
|
||||||
@@ -35,9 +40,10 @@ export const useExtensionStore = defineStore('extension', () => {
|
|||||||
// 状态
|
// 状态
|
||||||
extensions,
|
extensions,
|
||||||
enabledExtensions,
|
enabledExtensions,
|
||||||
|
enabledExtensionIds,
|
||||||
|
|
||||||
// 方法
|
// 方法
|
||||||
loadExtensions,
|
loadExtensions,
|
||||||
getExtensionConfig
|
getExtensionConfig,
|
||||||
}
|
}
|
||||||
})
|
})
|
@@ -1,18 +1,37 @@
|
|||||||
import {defineStore} from 'pinia'
|
import {defineStore} from 'pinia'
|
||||||
import {computed, ref} from 'vue'
|
import {computed, ref} from 'vue'
|
||||||
import {KeyBinding, KeyBindingCommand} from '@/../bindings/voidraft/internal/models/models'
|
import {ExtensionID, KeyBinding, KeyBindingCommand} from '@/../bindings/voidraft/internal/models/models'
|
||||||
import {GetAllKeyBindings} from '@/../bindings/voidraft/internal/services/keybindingservice'
|
import {GetAllKeyBindings} from '@/../bindings/voidraft/internal/services/keybindingservice'
|
||||||
|
|
||||||
export const useKeybindingStore = defineStore('keybinding', () => {
|
export const useKeybindingStore = defineStore('keybinding', () => {
|
||||||
// 快捷键配置数据
|
// 快捷键配置数据
|
||||||
const keyBindings = ref<KeyBinding[]>([])
|
const keyBindings = ref<KeyBinding[]>([])
|
||||||
|
|
||||||
|
|
||||||
// 获取启用的快捷键
|
// 获取启用的快捷键
|
||||||
const enabledKeyBindings = computed(() =>
|
const enabledKeyBindings = computed(() =>
|
||||||
keyBindings.value.filter(kb => kb.enabled)
|
keyBindings.value.filter(kb => kb.enabled)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 按扩展分组的快捷键
|
||||||
|
const keyBindingsByExtension = computed(() => {
|
||||||
|
const groups = new Map<ExtensionID, KeyBinding[]>()
|
||||||
|
|
||||||
|
for (const binding of keyBindings.value) {
|
||||||
|
if (!groups.has(binding.extension)) {
|
||||||
|
groups.set(binding.extension, [])
|
||||||
|
}
|
||||||
|
groups.get(binding.extension)!.push(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取指定扩展的快捷键
|
||||||
|
const getKeyBindingsByExtension = computed(() =>
|
||||||
|
(extension: ExtensionID) =>
|
||||||
|
keyBindings.value.filter(kb => kb.extension === extension)
|
||||||
|
)
|
||||||
|
|
||||||
// 按命令获取快捷键
|
// 按命令获取快捷键
|
||||||
const getKeyBindingByCommand = computed(() =>
|
const getKeyBindingByCommand = computed(() =>
|
||||||
(command: KeyBindingCommand) =>
|
(command: KeyBindingCommand) =>
|
||||||
@@ -26,7 +45,7 @@ export const useKeybindingStore = defineStore('keybinding', () => {
|
|||||||
try {
|
try {
|
||||||
keyBindings.value = await GetAllKeyBindings()
|
keyBindings.value = await GetAllKeyBindings()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,16 +56,31 @@ export const useKeybindingStore = defineStore('keybinding', () => {
|
|||||||
return keyBindings.value.some(kb => kb.command === command && kb.enabled)
|
return keyBindings.value.some(kb => kb.command === command && kb.enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取扩展相关的所有扩展ID
|
||||||
|
*/
|
||||||
|
const getAllExtensionIds = computed(() => {
|
||||||
|
const extensionIds = new Set<ExtensionID>()
|
||||||
|
for (const binding of keyBindings.value) {
|
||||||
|
extensionIds.add(binding.extension)
|
||||||
|
}
|
||||||
|
return Array.from(extensionIds)
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// 状态
|
// 状态
|
||||||
keyBindings,
|
keyBindings,
|
||||||
enabledKeyBindings,
|
enabledKeyBindings,
|
||||||
|
keyBindingsByExtension,
|
||||||
|
getAllExtensionIds,
|
||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
getKeyBindingByCommand,
|
getKeyBindingByCommand,
|
||||||
|
getKeyBindingsByExtension,
|
||||||
|
|
||||||
// 方法
|
// 方法
|
||||||
loadKeyBindings,
|
loadKeyBindings,
|
||||||
hasCommand
|
hasCommand,
|
||||||
}
|
}
|
||||||
})
|
})
|
@@ -1,20 +1,55 @@
|
|||||||
import { Extension } from '@codemirror/state'
|
import { Extension } from '@codemirror/state'
|
||||||
import { useKeybindingStore } from '@/stores/keybindingStore'
|
import { useKeybindingStore } from '@/stores/keybindingStore'
|
||||||
|
import { useExtensionStore } from '@/stores/extensionStore'
|
||||||
import { KeymapManager } from './keymapManager'
|
import { KeymapManager } from './keymapManager'
|
||||||
|
import { ExtensionID } from '@/../bindings/voidraft/internal/models/models'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步创建快捷键扩展
|
* 异步创建快捷键扩展
|
||||||
* 确保快捷键配置已加载
|
* 确保快捷键配置和扩展配置已加载
|
||||||
*/
|
*/
|
||||||
export const createDynamicKeymapExtension = async (): Promise<Extension> => {
|
export const createDynamicKeymapExtension = async (): Promise<Extension> => {
|
||||||
const keybindingStore = useKeybindingStore()
|
const keybindingStore = useKeybindingStore()
|
||||||
|
const extensionStore = useExtensionStore()
|
||||||
|
|
||||||
// 确保快捷键配置已加载
|
// 确保快捷键配置已加载
|
||||||
if (keybindingStore.keyBindings.length === 0) {
|
if (keybindingStore.keyBindings.length === 0) {
|
||||||
await keybindingStore.loadKeyBindings()
|
await keybindingStore.loadKeyBindings()
|
||||||
}
|
}
|
||||||
|
|
||||||
return KeymapManager.createKeymapExtension(keybindingStore.enabledKeyBindings)
|
// 确保扩展配置已加载
|
||||||
|
if (extensionStore.extensions.length === 0) {
|
||||||
|
await extensionStore.loadExtensions()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取启用的扩展ID列表
|
||||||
|
const enabledExtensionIds = extensionStore.enabledExtensions.map(ext => ext.id)
|
||||||
|
|
||||||
|
return KeymapManager.createKeymapExtension(keybindingStore.keyBindings, enabledExtensionIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新快捷键映射
|
||||||
|
* @param view 编辑器视图
|
||||||
|
*/
|
||||||
|
export const updateKeymapExtension = (view: any): void => {
|
||||||
|
const keybindingStore = useKeybindingStore()
|
||||||
|
const extensionStore = useExtensionStore()
|
||||||
|
|
||||||
|
// 获取启用的扩展ID列表
|
||||||
|
const enabledExtensionIds = extensionStore.enabledExtensions.map(ext => ext.id)
|
||||||
|
|
||||||
|
KeymapManager.updateKeymap(view, keybindingStore.keyBindings, enabledExtensionIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定扩展的快捷键
|
||||||
|
* @param extensionId 扩展ID
|
||||||
|
* @returns 该扩展的快捷键列表
|
||||||
|
*/
|
||||||
|
export const getExtensionKeyBindings = (extensionId: ExtensionID) => {
|
||||||
|
const keybindingStore = useKeybindingStore()
|
||||||
|
return keybindingStore.getKeyBindingsByExtension(extensionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出相关模块
|
// 导出相关模块
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import {keymap} from '@codemirror/view'
|
import {keymap} from '@codemirror/view'
|
||||||
import {Extension} from '@codemirror/state'
|
import {Extension, Compartment} from '@codemirror/state'
|
||||||
import {KeyBinding as KeyBindingConfig} from '@/../bindings/voidraft/internal/models/models'
|
import {KeyBinding as KeyBindingConfig, ExtensionID} from '@/../bindings/voidraft/internal/models/models'
|
||||||
import {KeyBinding, KeymapResult} from './types'
|
import {KeyBinding, KeymapResult} from './types'
|
||||||
import {getCommandHandler, isCommandRegistered} from './commandRegistry'
|
import {getCommandHandler, isCommandRegistered} from './commandRegistry'
|
||||||
|
|
||||||
@@ -9,12 +9,15 @@ import {getCommandHandler, isCommandRegistered} from './commandRegistry'
|
|||||||
* 负责将后端配置转换为CodeMirror快捷键扩展
|
* 负责将后端配置转换为CodeMirror快捷键扩展
|
||||||
*/
|
*/
|
||||||
export class KeymapManager {
|
export class KeymapManager {
|
||||||
|
private static compartment = new Compartment()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将后端快捷键配置转换为CodeMirror快捷键绑定
|
* 将后端快捷键配置转换为CodeMirror快捷键绑定
|
||||||
* @param keyBindings 后端快捷键配置列表
|
* @param keyBindings 后端快捷键配置列表
|
||||||
|
* @param enabledExtensions 启用的扩展ID列表,如果不提供则使用所有启用的快捷键
|
||||||
* @returns 转换结果
|
* @returns 转换结果
|
||||||
*/
|
*/
|
||||||
static convertToKeyBindings(keyBindings: KeyBindingConfig[]): KeymapResult {
|
static convertToKeyBindings(keyBindings: KeyBindingConfig[], enabledExtensions?: ExtensionID[]): KeymapResult {
|
||||||
const result: KeyBinding[] = []
|
const result: KeyBinding[] = []
|
||||||
|
|
||||||
for (const binding of keyBindings) {
|
for (const binding of keyBindings) {
|
||||||
@@ -23,6 +26,11 @@ export class KeymapManager {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果提供了扩展列表,则只处理启用扩展的快捷键
|
||||||
|
if (enabledExtensions && !enabledExtensions.includes(binding.extension)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// 检查命令是否已注册
|
// 检查命令是否已注册
|
||||||
if (!isCommandRegistered(binding.command)) {
|
if (!isCommandRegistered(binding.command)) {
|
||||||
continue
|
continue
|
||||||
@@ -50,13 +58,47 @@ export class KeymapManager {
|
|||||||
/**
|
/**
|
||||||
* 创建CodeMirror快捷键扩展
|
* 创建CodeMirror快捷键扩展
|
||||||
* @param keyBindings 后端快捷键配置列表
|
* @param keyBindings 后端快捷键配置列表
|
||||||
|
* @param enabledExtensions 启用的扩展ID列表
|
||||||
* @returns CodeMirror扩展
|
* @returns CodeMirror扩展
|
||||||
*/
|
*/
|
||||||
static createKeymapExtension(keyBindings: KeyBindingConfig[]): Extension {
|
static createKeymapExtension(keyBindings: KeyBindingConfig[], enabledExtensions?: ExtensionID[]): Extension {
|
||||||
const {keyBindings: cmKeyBindings} =
|
const {keyBindings: cmKeyBindings} =
|
||||||
this.convertToKeyBindings(keyBindings)
|
this.convertToKeyBindings(keyBindings, enabledExtensions)
|
||||||
|
|
||||||
return keymap.of(cmKeyBindings)
|
return this.compartment.of(keymap.of(cmKeyBindings))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态更新快捷键扩展
|
||||||
|
* @param view 编辑器视图
|
||||||
|
* @param keyBindings 后端快捷键配置列表
|
||||||
|
* @param enabledExtensions 启用的扩展ID列表
|
||||||
|
*/
|
||||||
|
static updateKeymap(view: any, keyBindings: KeyBindingConfig[], enabledExtensions: ExtensionID[]): void {
|
||||||
|
const {keyBindings: cmKeyBindings} =
|
||||||
|
this.convertToKeyBindings(keyBindings, enabledExtensions)
|
||||||
|
|
||||||
|
view.dispatch({
|
||||||
|
effects: this.compartment.reconfigure(keymap.of(cmKeyBindings))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按扩展分组快捷键
|
||||||
|
* @param keyBindings 快捷键配置列表
|
||||||
|
* @returns 按扩展分组的快捷键映射
|
||||||
|
*/
|
||||||
|
static groupByExtension(keyBindings: KeyBindingConfig[]): Map<ExtensionID, KeyBindingConfig[]> {
|
||||||
|
const groups = new Map<ExtensionID, KeyBindingConfig[]>()
|
||||||
|
|
||||||
|
for (const binding of keyBindings) {
|
||||||
|
if (!groups.has(binding.extension)) {
|
||||||
|
groups.set(binding.extension, [])
|
||||||
|
}
|
||||||
|
groups.get(binding.extension)!.push(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,23 +3,33 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { onMounted, computed } from 'vue';
|
import { onMounted, computed } from 'vue';
|
||||||
import SettingSection from '../components/SettingSection.vue';
|
import SettingSection from '../components/SettingSection.vue';
|
||||||
import { useKeybindingStore } from '@/stores/keybindingStore';
|
import { useKeybindingStore } from '@/stores/keybindingStore';
|
||||||
|
import { useExtensionStore } from '@/stores/extensionStore';
|
||||||
import { useSystemStore } from '@/stores/systemStore';
|
import { useSystemStore } from '@/stores/systemStore';
|
||||||
import { getCommandDescription } from '@/views/editor/keymap/commandRegistry';
|
import { getCommandDescription } from '@/views/editor/keymap/commandRegistry';
|
||||||
import {KeyBindingCommand} from "@/../bindings/voidraft/internal/models";
|
import {KeyBindingCommand} from "@/../bindings/voidraft/internal/models";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const keybindingStore = useKeybindingStore();
|
const keybindingStore = useKeybindingStore();
|
||||||
|
const extensionStore = useExtensionStore();
|
||||||
const systemStore = useSystemStore();
|
const systemStore = useSystemStore();
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
onMounted(async () => {
|
||||||
|
await keybindingStore.loadKeyBindings();
|
||||||
|
await extensionStore.loadExtensions();
|
||||||
|
});
|
||||||
|
|
||||||
// 从store中获取快捷键数据并转换为显示格式
|
// 从store中获取快捷键数据并转换为显示格式
|
||||||
const keyBindings = computed(() => {
|
const keyBindings = computed(() => {
|
||||||
|
// 只显示启用扩展的快捷键
|
||||||
|
const enabledExtensionIds = new Set(extensionStore.enabledExtensionIds);
|
||||||
|
|
||||||
return keybindingStore.keyBindings
|
return keybindingStore.keyBindings
|
||||||
.filter(kb => kb.enabled)
|
.filter(kb => kb.enabled && enabledExtensionIds.has(kb.extension))
|
||||||
.map(kb => ({
|
.map(kb => ({
|
||||||
id: kb.command,
|
id: kb.command,
|
||||||
keys: parseKeyBinding(kb.key, kb.command),
|
keys: parseKeyBinding(kb.key, kb.command),
|
||||||
category: kb.category,
|
category: kb.extension,
|
||||||
description: getCommandDescription(kb.command) || kb.command
|
description: getCommandDescription(kb.command) || kb.command
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@@ -4,11 +4,10 @@ import "time"
|
|||||||
|
|
||||||
// Extension 单个扩展配置
|
// Extension 单个扩展配置
|
||||||
type Extension struct {
|
type Extension struct {
|
||||||
ID ExtensionID `json:"id"` // 扩展唯一标识
|
ID ExtensionID `json:"id"` // 扩展唯一标识
|
||||||
Category ExtensionCategory `json:"category"` // 扩展分类
|
Enabled bool `json:"enabled"` // 是否启用
|
||||||
Enabled bool `json:"enabled"` // 是否启用
|
IsDefault bool `json:"isDefault"` // 是否为默认扩展
|
||||||
IsDefault bool `json:"isDefault"` // 是否为默认扩展
|
Config ExtensionConfig `json:"config"` // 扩展配置项
|
||||||
Config ExtensionConfig `json:"config"` // 扩展配置项
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtensionID 扩展标识符
|
// ExtensionID 扩展标识符
|
||||||
@@ -28,18 +27,12 @@ const (
|
|||||||
// 工具扩展
|
// 工具扩展
|
||||||
ExtensionSearch ExtensionID = "search" // 搜索功能
|
ExtensionSearch ExtensionID = "search" // 搜索功能
|
||||||
ExtensionCodeBlock ExtensionID = "codeBlock" // 代码块
|
ExtensionCodeBlock ExtensionID = "codeBlock" // 代码块
|
||||||
|
|
||||||
|
// 核心扩展
|
||||||
|
ExtensionEditor ExtensionID = "editor" // 编辑器核心功能
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExtensionCategory 扩展分类
|
// ExtensionConfig 扩展配置项
|
||||||
type ExtensionCategory string
|
|
||||||
|
|
||||||
const (
|
|
||||||
CategoryEditing ExtensionCategory = "editing" // 编辑增强
|
|
||||||
CategoryUI ExtensionCategory = "ui" // 界面增强
|
|
||||||
CategoryTools ExtensionCategory = "tools" // 工具类
|
|
||||||
)
|
|
||||||
|
|
||||||
// ExtensionConfig 扩展配置项(动态配置)
|
|
||||||
type ExtensionConfig map[string]interface{}
|
type ExtensionConfig map[string]interface{}
|
||||||
|
|
||||||
// ExtensionMetadata 扩展配置元数据
|
// ExtensionMetadata 扩展配置元数据
|
||||||
@@ -71,21 +64,30 @@ func NewDefaultExtensions() []Extension {
|
|||||||
// 编辑增强扩展
|
// 编辑增强扩展
|
||||||
{
|
{
|
||||||
ID: ExtensionRainbowBrackets,
|
ID: ExtensionRainbowBrackets,
|
||||||
Category: CategoryEditing,
|
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{},
|
Config: ExtensionConfig{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: ExtensionHyperlink,
|
ID: ExtensionHyperlink,
|
||||||
Category: CategoryEditing,
|
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{},
|
Config: ExtensionConfig{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: ExtensionColorSelector,
|
ID: ExtensionColorSelector,
|
||||||
Category: CategoryEditing,
|
Enabled: true,
|
||||||
|
IsDefault: true,
|
||||||
|
Config: ExtensionConfig{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: ExtensionFold,
|
||||||
|
Enabled: true,
|
||||||
|
IsDefault: true,
|
||||||
|
Config: ExtensionConfig{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: ExtensionTextHighlight,
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{},
|
Config: ExtensionConfig{},
|
||||||
@@ -94,7 +96,6 @@ func NewDefaultExtensions() []Extension {
|
|||||||
// UI增强扩展
|
// UI增强扩展
|
||||||
{
|
{
|
||||||
ID: ExtensionMinimap,
|
ID: ExtensionMinimap,
|
||||||
Category: CategoryUI,
|
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{
|
Config: ExtensionConfig{
|
||||||
@@ -107,14 +108,12 @@ func NewDefaultExtensions() []Extension {
|
|||||||
// 工具扩展
|
// 工具扩展
|
||||||
{
|
{
|
||||||
ID: ExtensionSearch,
|
ID: ExtensionSearch,
|
||||||
Category: CategoryTools,
|
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{},
|
Config: ExtensionConfig{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: ExtensionCodeBlock,
|
ID: ExtensionCodeBlock,
|
||||||
Category: CategoryTools,
|
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{
|
Config: ExtensionConfig{
|
||||||
@@ -122,16 +121,10 @@ func NewDefaultExtensions() []Extension {
|
|||||||
"enableAutoDetection": true,
|
"enableAutoDetection": true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 核心扩展
|
||||||
{
|
{
|
||||||
ID: ExtensionFold,
|
ID: ExtensionEditor,
|
||||||
Category: CategoryEditing,
|
|
||||||
Enabled: true,
|
|
||||||
IsDefault: true,
|
|
||||||
Config: ExtensionConfig{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ID: ExtensionTextHighlight,
|
|
||||||
Category: CategoryEditing,
|
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
Config: ExtensionConfig{},
|
Config: ExtensionConfig{},
|
||||||
|
@@ -4,29 +4,18 @@ import "time"
|
|||||||
|
|
||||||
// KeyBinding 单个快捷键绑定
|
// KeyBinding 单个快捷键绑定
|
||||||
type KeyBinding struct {
|
type KeyBinding struct {
|
||||||
Command KeyBindingCommand `json:"command"` // 快捷键动作
|
Command KeyBindingCommand `json:"command"` // 快捷键动作
|
||||||
Category KeyBindingCategory `json:"category"` // 快捷键分类
|
Extension ExtensionID `json:"extension"` // 所属扩展
|
||||||
Key string `json:"key"` // 快捷键组合(如 "Mod-f", "Ctrl-Shift-p")
|
Key string `json:"key"` // 快捷键组合(如 "Mod-f", "Ctrl-Shift-p")
|
||||||
Enabled bool `json:"enabled"` // 是否启用
|
Enabled bool `json:"enabled"` // 是否启用
|
||||||
IsDefault bool `json:"isDefault"` // 是否为默认快捷键
|
IsDefault bool `json:"isDefault"` // 是否为默认快捷键
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyBindingCategory 快捷键分类
|
|
||||||
type KeyBindingCategory string
|
|
||||||
|
|
||||||
const (
|
|
||||||
CategorySearch KeyBindingCategory = "search" // 搜索相关
|
|
||||||
CategoryEdit KeyBindingCategory = "edit" // 编辑相关
|
|
||||||
CategoryCodeBlock KeyBindingCategory = "block" // 代码块相关
|
|
||||||
CategoryHistory KeyBindingCategory = "history" // 历史记录相关
|
|
||||||
CategoryFold KeyBindingCategory = "fold" // 代码折叠相关
|
|
||||||
)
|
|
||||||
|
|
||||||
// KeyBindingCommand 快捷键命令
|
// KeyBindingCommand 快捷键命令
|
||||||
type KeyBindingCommand string
|
type KeyBindingCommand string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// 搜索相关
|
// 搜索扩展相关
|
||||||
ShowSearchCommand KeyBindingCommand = "showSearch" // 显示搜索
|
ShowSearchCommand KeyBindingCommand = "showSearch" // 显示搜索
|
||||||
HideSearchCommand KeyBindingCommand = "hideSearch" // 隐藏搜索
|
HideSearchCommand KeyBindingCommand = "hideSearch" // 隐藏搜索
|
||||||
SearchToggleCaseCommand KeyBindingCommand = "searchToggleCase" // 搜索切换大小写
|
SearchToggleCaseCommand KeyBindingCommand = "searchToggleCase" // 搜索切换大小写
|
||||||
@@ -35,7 +24,7 @@ const (
|
|||||||
SearchShowReplaceCommand KeyBindingCommand = "searchShowReplace" // 显示替换
|
SearchShowReplaceCommand KeyBindingCommand = "searchShowReplace" // 显示替换
|
||||||
SearchReplaceAllCommand KeyBindingCommand = "searchReplaceAll" // 替换全部
|
SearchReplaceAllCommand KeyBindingCommand = "searchReplaceAll" // 替换全部
|
||||||
|
|
||||||
// 代码块相关
|
// 代码块扩展相关
|
||||||
BlockSelectAllCommand KeyBindingCommand = "blockSelectAll" // 块内选择全部
|
BlockSelectAllCommand KeyBindingCommand = "blockSelectAll" // 块内选择全部
|
||||||
BlockAddAfterCurrentCommand KeyBindingCommand = "blockAddAfterCurrent" // 在当前块后添加新块
|
BlockAddAfterCurrentCommand KeyBindingCommand = "blockAddAfterCurrent" // 在当前块后添加新块
|
||||||
BlockAddAfterLastCommand KeyBindingCommand = "blockAddAfterLast" // 在最后添加新块
|
BlockAddAfterLastCommand KeyBindingCommand = "blockAddAfterLast" // 在最后添加新块
|
||||||
@@ -56,19 +45,13 @@ const (
|
|||||||
BlockCutCommand KeyBindingCommand = "blockCut" // 剪切
|
BlockCutCommand KeyBindingCommand = "blockCut" // 剪切
|
||||||
BlockPasteCommand KeyBindingCommand = "blockPaste" // 粘贴
|
BlockPasteCommand KeyBindingCommand = "blockPaste" // 粘贴
|
||||||
|
|
||||||
// 历史记录相关
|
// 代码折叠扩展相关
|
||||||
HistoryUndoCommand KeyBindingCommand = "historyUndo" // 撤销
|
|
||||||
HistoryRedoCommand KeyBindingCommand = "historyRedo" // 重做
|
|
||||||
HistoryUndoSelectionCommand KeyBindingCommand = "historyUndoSelection" // 撤销选择
|
|
||||||
HistoryRedoSelectionCommand KeyBindingCommand = "historyRedoSelection" // 重做选择
|
|
||||||
|
|
||||||
// 代码折叠相关
|
|
||||||
FoldCodeCommand KeyBindingCommand = "foldCode" // 折叠代码
|
FoldCodeCommand KeyBindingCommand = "foldCode" // 折叠代码
|
||||||
UnfoldCodeCommand KeyBindingCommand = "unfoldCode" // 展开代码
|
UnfoldCodeCommand KeyBindingCommand = "unfoldCode" // 展开代码
|
||||||
FoldAllCommand KeyBindingCommand = "foldAll" // 折叠全部
|
FoldAllCommand KeyBindingCommand = "foldAll" // 折叠全部
|
||||||
UnfoldAllCommand KeyBindingCommand = "unfoldAll" // 展开全部
|
UnfoldAllCommand KeyBindingCommand = "unfoldAll" // 展开全部
|
||||||
|
|
||||||
// 编辑相关
|
// 通用编辑扩展相关
|
||||||
CursorSyntaxLeftCommand KeyBindingCommand = "cursorSyntaxLeft" // 光标按语法左移
|
CursorSyntaxLeftCommand KeyBindingCommand = "cursorSyntaxLeft" // 光标按语法左移
|
||||||
CursorSyntaxRightCommand KeyBindingCommand = "cursorSyntaxRight" // 光标按语法右移
|
CursorSyntaxRightCommand KeyBindingCommand = "cursorSyntaxRight" // 光标按语法右移
|
||||||
SelectSyntaxLeftCommand KeyBindingCommand = "selectSyntaxLeft" // 按语法选择左侧
|
SelectSyntaxLeftCommand KeyBindingCommand = "selectSyntaxLeft" // 按语法选择左侧
|
||||||
@@ -89,6 +72,12 @@ const (
|
|||||||
DeleteCharForwardCommand KeyBindingCommand = "deleteCharForward" // 向前删除字符
|
DeleteCharForwardCommand KeyBindingCommand = "deleteCharForward" // 向前删除字符
|
||||||
DeleteGroupBackwardCommand KeyBindingCommand = "deleteGroupBackward" // 向后删除组
|
DeleteGroupBackwardCommand KeyBindingCommand = "deleteGroupBackward" // 向后删除组
|
||||||
DeleteGroupForwardCommand KeyBindingCommand = "deleteGroupForward" // 向前删除组
|
DeleteGroupForwardCommand KeyBindingCommand = "deleteGroupForward" // 向前删除组
|
||||||
|
|
||||||
|
// 历史记录扩展相关
|
||||||
|
HistoryUndoCommand KeyBindingCommand = "historyUndo" // 撤销
|
||||||
|
HistoryRedoCommand KeyBindingCommand = "historyRedo" // 重做
|
||||||
|
HistoryUndoSelectionCommand KeyBindingCommand = "historyUndoSelection" // 撤销选择
|
||||||
|
HistoryRedoSelectionCommand KeyBindingCommand = "historyRedoSelection" // 重做选择
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeyBindingMetadata 快捷键配置元数据
|
// KeyBindingMetadata 快捷键配置元数据
|
||||||
@@ -117,389 +106,389 @@ func NewDefaultKeyBindingConfig() *KeyBindingConfig {
|
|||||||
// NewDefaultKeyBindings 创建默认快捷键配置
|
// NewDefaultKeyBindings 创建默认快捷键配置
|
||||||
func NewDefaultKeyBindings() []KeyBinding {
|
func NewDefaultKeyBindings() []KeyBinding {
|
||||||
return []KeyBinding{
|
return []KeyBinding{
|
||||||
// 搜索相关快捷键
|
// 搜索扩展快捷键
|
||||||
{
|
{
|
||||||
Command: ShowSearchCommand,
|
Command: ShowSearchCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Mod-f",
|
Key: "Mod-f",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: HideSearchCommand,
|
Command: HideSearchCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Escape",
|
Key: "Escape",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SearchToggleCaseCommand,
|
Command: SearchToggleCaseCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Alt-c",
|
Key: "Alt-c",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SearchToggleWordCommand,
|
Command: SearchToggleWordCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Alt-w",
|
Key: "Alt-w",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SearchToggleRegexCommand,
|
Command: SearchToggleRegexCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Alt-r",
|
Key: "Alt-r",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SearchShowReplaceCommand,
|
Command: SearchShowReplaceCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Mod-h",
|
Key: "Mod-h",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SearchReplaceAllCommand,
|
Command: SearchReplaceAllCommand,
|
||||||
Category: CategorySearch,
|
Extension: ExtensionSearch,
|
||||||
Key: "Mod-Alt-Enter",
|
Key: "Mod-Alt-Enter",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 代码块相关快捷键
|
// 代码块扩展快捷键
|
||||||
{
|
{
|
||||||
Command: BlockSelectAllCommand,
|
Command: BlockSelectAllCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-a",
|
Key: "Mod-a",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockAddAfterCurrentCommand,
|
Command: BlockAddAfterCurrentCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Enter",
|
Key: "Mod-Enter",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockAddAfterLastCommand,
|
Command: BlockAddAfterLastCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Shift-Enter",
|
Key: "Mod-Shift-Enter",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockAddBeforeCurrentCommand,
|
Command: BlockAddBeforeCurrentCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Alt-Enter",
|
Key: "Alt-Enter",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockGotoPreviousCommand,
|
Command: BlockGotoPreviousCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-ArrowUp",
|
Key: "Mod-ArrowUp",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockGotoNextCommand,
|
Command: BlockGotoNextCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-ArrowDown",
|
Key: "Mod-ArrowDown",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockSelectPreviousCommand,
|
Command: BlockSelectPreviousCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Shift-ArrowUp",
|
Key: "Mod-Shift-ArrowUp",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockSelectNextCommand,
|
Command: BlockSelectNextCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Shift-ArrowDown",
|
Key: "Mod-Shift-ArrowDown",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockDeleteCommand,
|
Command: BlockDeleteCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Shift-d",
|
Key: "Mod-Shift-d",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockMoveUpCommand,
|
Command: BlockMoveUpCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Alt-Mod-ArrowUp",
|
Key: "Alt-Mod-ArrowUp",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockMoveDownCommand,
|
Command: BlockMoveDownCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Alt-Mod-ArrowDown",
|
Key: "Alt-Mod-ArrowDown",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockDeleteLineCommand,
|
Command: BlockDeleteLineCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Shift-k",
|
Key: "Mod-Shift-k",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockMoveLineUpCommand,
|
Command: BlockMoveLineUpCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Alt-ArrowUp",
|
Key: "Alt-ArrowUp",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockMoveLineDownCommand,
|
Command: BlockMoveLineDownCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Alt-ArrowDown",
|
Key: "Alt-ArrowDown",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockTransposeCharsCommand,
|
Command: BlockTransposeCharsCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Ctrl-t",
|
Key: "Ctrl-t",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockFormatCommand,
|
Command: BlockFormatCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionCodeBlock,
|
||||||
Key: "Mod-Shift-f",
|
Key: "Mod-Shift-f",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockCopyCommand,
|
Command: BlockCopyCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionEditor,
|
||||||
Key: "Mod-c",
|
Key: "Mod-c",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockCutCommand,
|
Command: BlockCutCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionEditor,
|
||||||
Key: "Mod-x",
|
Key: "Mod-x",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: BlockPasteCommand,
|
Command: BlockPasteCommand,
|
||||||
Category: CategoryCodeBlock,
|
Extension: ExtensionEditor,
|
||||||
Key: "Mod-v",
|
Key: "Mod-v",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 历史记录相关快捷键
|
// 代码折叠扩展快捷键
|
||||||
{
|
|
||||||
Command: HistoryUndoCommand,
|
|
||||||
Category: CategoryHistory,
|
|
||||||
Key: "Mod-z",
|
|
||||||
Enabled: true,
|
|
||||||
IsDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Command: HistoryRedoCommand,
|
|
||||||
Category: CategoryHistory,
|
|
||||||
Key: "Mod-Shift-z",
|
|
||||||
Enabled: true,
|
|
||||||
IsDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Command: HistoryUndoSelectionCommand,
|
|
||||||
Category: CategoryHistory,
|
|
||||||
Key: "Mod-u",
|
|
||||||
Enabled: true,
|
|
||||||
IsDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Command: HistoryRedoSelectionCommand,
|
|
||||||
Category: CategoryHistory,
|
|
||||||
Key: "Mod-Shift-u",
|
|
||||||
Enabled: true,
|
|
||||||
IsDefault: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// 代码折叠相关快捷键
|
|
||||||
{
|
{
|
||||||
Command: FoldCodeCommand,
|
Command: FoldCodeCommand,
|
||||||
Category: CategoryFold,
|
Extension: ExtensionFold,
|
||||||
Key: "Ctrl-Shift-[",
|
Key: "Ctrl-Shift-[",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: UnfoldCodeCommand,
|
Command: UnfoldCodeCommand,
|
||||||
Category: CategoryFold,
|
Extension: ExtensionFold,
|
||||||
Key: "Ctrl-Shift-]",
|
Key: "Ctrl-Shift-]",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: FoldAllCommand,
|
Command: FoldAllCommand,
|
||||||
Category: CategoryFold,
|
Extension: ExtensionFold,
|
||||||
Key: "Ctrl-Alt-[",
|
Key: "Ctrl-Alt-[",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: UnfoldAllCommand,
|
Command: UnfoldAllCommand,
|
||||||
Category: CategoryFold,
|
Extension: ExtensionFold,
|
||||||
Key: "Ctrl-Alt-]",
|
Key: "Ctrl-Alt-]",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 编辑相关快捷键 (避免冲突的快捷键)
|
// 历史记录扩展快捷键
|
||||||
|
{
|
||||||
|
Command: HistoryUndoCommand,
|
||||||
|
Extension: ExtensionEditor,
|
||||||
|
Key: "Mod-z",
|
||||||
|
Enabled: true,
|
||||||
|
IsDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Command: HistoryRedoCommand,
|
||||||
|
Extension: ExtensionEditor,
|
||||||
|
Key: "Mod-Shift-z",
|
||||||
|
Enabled: true,
|
||||||
|
IsDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Command: HistoryUndoSelectionCommand,
|
||||||
|
Extension: ExtensionEditor,
|
||||||
|
Key: "Mod-u",
|
||||||
|
Enabled: true,
|
||||||
|
IsDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Command: HistoryRedoSelectionCommand,
|
||||||
|
Extension: ExtensionEditor,
|
||||||
|
Key: "Mod-Shift-u",
|
||||||
|
Enabled: true,
|
||||||
|
IsDefault: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
// 通用编辑扩展快捷键
|
||||||
{
|
{
|
||||||
Command: CursorSyntaxLeftCommand,
|
Command: CursorSyntaxLeftCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Alt-ArrowLeft",
|
Key: "Alt-ArrowLeft",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: CursorSyntaxRightCommand,
|
Command: CursorSyntaxRightCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Alt-ArrowRight",
|
Key: "Alt-ArrowRight",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SelectSyntaxLeftCommand,
|
Command: SelectSyntaxLeftCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Shift-Alt-ArrowLeft",
|
Key: "Shift-Alt-ArrowLeft",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SelectSyntaxRightCommand,
|
Command: SelectSyntaxRightCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Shift-Alt-ArrowRight",
|
Key: "Shift-Alt-ArrowRight",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: CopyLineUpCommand,
|
Command: CopyLineUpCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Shift-Alt-ArrowUp",
|
Key: "Shift-Alt-ArrowUp",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: CopyLineDownCommand,
|
Command: CopyLineDownCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Shift-Alt-ArrowDown",
|
Key: "Shift-Alt-ArrowDown",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: InsertBlankLineCommand,
|
Command: InsertBlankLineCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-Enter",
|
Key: "Ctrl-Enter",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SelectLineCommand,
|
Command: SelectLineCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Alt-l",
|
Key: "Alt-l",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: SelectParentSyntaxCommand,
|
Command: SelectParentSyntaxCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-i",
|
Key: "Ctrl-i",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: IndentLessCommand,
|
Command: IndentLessCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-[",
|
Key: "Ctrl-[",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: IndentMoreCommand,
|
Command: IndentMoreCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-]",
|
Key: "Ctrl-]",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: IndentSelectionCommand,
|
Command: IndentSelectionCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-Alt-\\",
|
Key: "Ctrl-Alt-\\",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: CursorMatchingBracketCommand,
|
Command: CursorMatchingBracketCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Shift-Ctrl-\\",
|
Key: "Shift-Ctrl-\\",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: ToggleCommentCommand,
|
Command: ToggleCommentCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-/",
|
Key: "Ctrl-/",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: ToggleBlockCommentCommand,
|
Command: ToggleBlockCommentCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Shift-Alt-a",
|
Key: "Shift-Alt-a",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: InsertNewlineAndIndentCommand,
|
Command: InsertNewlineAndIndentCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Enter",
|
Key: "Enter",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: DeleteCharBackwardCommand,
|
Command: DeleteCharBackwardCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Backspace",
|
Key: "Backspace",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: DeleteCharForwardCommand,
|
Command: DeleteCharForwardCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Delete",
|
Key: "Delete",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: DeleteGroupBackwardCommand,
|
Command: DeleteGroupBackwardCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-Backspace",
|
Key: "Ctrl-Backspace",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: DeleteGroupForwardCommand,
|
Command: DeleteGroupForwardCommand,
|
||||||
Category: CategoryEdit,
|
Extension: ExtensionEditor,
|
||||||
Key: "Ctrl-Delete",
|
Key: "Ctrl-Delete",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
|
Reference in New Issue
Block a user