Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Support a custom shortcut for prepending list items https://github.com/siyuan-note/siyuan/issues/17635

Daniel8ebcffa04ce1
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 3c93d2378a..d299e16cdc 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -627,6 +627,7 @@ export abstract class Constants {
indent: {default: "⇥", custom: "⇥"},
outdent: {default: "⇧⇥", custom: "⇧⇥"},
checkToggle: {default: "⌘↩", custom: "⌘↩"},
+ prependListItem: {default: "", custom: ""},
appendListItem: {default: "", custom: ""},
},
table: {
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index ec50635e61..cb31a61b33 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -1921,6 +1921,7 @@ export class Gutter {
id: "prependListItem",
icon: "iconBefore",
label: window.siyuan.languages.prependListItem,
+ accelerator: window.siyuan.config.keymap.editor.list.prependListItem.custom,
click() {
hideElements(["select"], protyle);
countBlockWord([], protyle.block.rootID);
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index c88805bc12..4b44021531 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -71,6 +71,7 @@ import {
insertEmptyListItem,
listIndent,
listOutdent,
+ prependListItem,
toggleTaskListItem
} from "./list";
import {
@@ -2126,6 +2127,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
+ if (matchHotKey(window.siyuan.config.keymap.editor.list.prependListItem.custom, event) &&
+ !isInEmbedBlock(nodeElement) && getAppendListContext(nodeElement, protyle.wysiwyg.element)) {
+ void prependListItem(protyle, nodeElement, range);
+ event.preventDefault();
+ event.stopPropagation();
+ return true;
+ }
+
if (matchHotKey(window.siyuan.config.keymap.editor.list.appendListItem.custom, event) &&
!isInEmbedBlock(nodeElement) && getAppendListContext(nodeElement, protyle.wysiwyg.element)) {
void appendListItem(protyle, nodeElement, range);
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index 65c7e5978d..86ce38a343 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -1262,6 +1262,7 @@ declare namespace Config {
* SiYuan editor list shortcut keys
*/
export interface IKeymapEditorList extends IKeys {
+ prependListItem: IKey;
appendListItem: IKey;
checkToggle: IKey;
indent: IKey;