feat(plugins): add settings shortcut entry and drag edge avoidance
This commit is contained in:
1 parent
fd6b7bd502
commit
e444c15e0c
32 files changed
+483
-34
No files matched your search
@@ -1,4 +1,9 @@
|
||||
import type { InjectionKey } from "vue";
|
||||
|
||||
export const OPEN_PLUGIN_SETTINGS: InjectionKey<() => void> = Symbol("open-plugin-settings");
|
||||
|
||||
export interface PluginCenterFocus {
|
||||
section?: "settings";
|
||||
pluginId?: string;
|
||||
providerId?: string;
|
||||
}
|
||||
+4
-2
@@ -45,8 +45,10 @@ describe("plugin shortcuts", () => {
|
||||
expect(clampPluginShortcutHeight(40, 130)).toBe(10);
|
||||
});
|
||||
it("normalizes old and malformed preferences with independent default arrays", () => {
|
||||
expect(normalizePluginShortcutSettings(null)).toEqual({ enabled: true, position: "right-top", order: [], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3 });
|
||||
expect(normalizePluginShortcutSettings({ enabled: "false", position: "top", order: [null, "a", "", "a", "b"] })).toEqual({ enabled: true, position: "right-top", order: ["a", "b"], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3 });
|
||||
expect(normalizePluginShortcutSettings({ showSettingsEntry: "false" }).showSettingsEntry).toBe(true);
|
||||
expect(normalizePluginShortcutSettings({ showSettingsEntry: false }).showSettingsEntry).toBe(false);
|
||||
expect(normalizePluginShortcutSettings(null)).toEqual({ enabled: true, position: "right-top", order: [], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3, showSettingsEntry: true });
|
||||
expect(normalizePluginShortcutSettings({ enabled: "false", position: "top", order: [null, "a", "", "a", "b"] })).toEqual({ enabled: true, position: "right-top", order: ["a", "b"], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3, showSettingsEntry: true });
|
||||
expect(normalizePluginShortcutSettings({ enabled: false, position: "sidebar-bottom" }).enabled).toBe(false);
|
||||
});
|
||||
it("includes legacy standalone workbenches and filesystems but not connection-bound surfaces", () => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { PluginCommandContribution } from "@/types/database";
|
||||
export type PluginShortcutPosition = "left-top" | "left-bottom" | "right-top" | "right-bottom" | "sidebar-bottom" | "toolbar" | "plugin-center";
|
||||
export interface PluginShortcutSettings {
|
||||
enabled: boolean;
|
||||
showSettingsEntry: boolean;
|
||||
position: PluginShortcutPosition;
|
||||
order: string[];
|
||||
hiddenPluginIds: string[];
|
||||
@@ -17,6 +18,7 @@ export function normalizePluginShortcutSettings(value: unknown): PluginShortcutS
|
||||
const strings = (values: unknown): string[] => (Array.isArray(values) ? [...new Set(values.filter((id): id is string => typeof id === "string" && id.length > 0))] : []);
|
||||
return {
|
||||
enabled: typeof input.enabled === "boolean" ? input.enabled : true,
|
||||
showSettingsEntry: typeof input.showSettingsEntry === "boolean" ? input.showSettingsEntry : true,
|
||||
position: position === "left" ? "left-top" : position === "left-top" || position === "left-bottom" || position === "right-bottom" || position === "sidebar-bottom" || position === "toolbar" || position === "plugin-center" ? position : "right-top",
|
||||
order: strings(input.order),
|
||||
hiddenPluginIds: strings(input.hiddenPluginIds),
|
||||
|
||||
Reference in new issue
Block a user