feat: command template csv

This commit is contained in:
2026-03-01 11:52:09 +08:00
parent aac7fe575a
commit 3e14bff1e9
2 changed files with 21 additions and 4 deletions
+10 -4
View File
@@ -1,19 +1,25 @@
import { customElement, noShadowDOM } from "solid-element";
import { onMount, onCleanup, Show } from "solid-js";
import { onMount, onCleanup, Show, createEffect } from "solid-js";
import { useCommander } from "./hooks";
import { CommanderInput } from "./CommanderInput";
import { CommanderEntries } from "./CommanderEntries";
import { TrackerView } from "./TrackerView";
import { TabBar } from "./TabBar";
import type { MdCommanderProps, TrackerAttribute } from "./types";
import type { MdCommanderProps } from "./types";
import {loadElementSrc, resolvePath} from "../utils/path";
import {loadCommandTemplates} from "./utils/commandTemplates";
customElement<MdCommanderProps>(
"md-commander",
{ placeholder: "", class: "", height: "" },
{ placeholder: "", class: "", height: "", commandTemplates: "" },
(props, { element }) => {
noShadowDOM();
const {articlePath, rawSrc} = loadElementSrc(element as any);
const commander = useCommander(props.commands);
createEffect(async () => {
if(!rawSrc) return;
await loadCommandTemplates(commander.commands, resolvePath(articlePath, rawSrc));
});
const handleKeyDown = (e: KeyboardEvent) => {
if (commander.showCompletions() && commander.completions().length > 0) {