Closed MuiseDestiny closed 1 year ago
Thanks!
More comments and descriptions for APIs would be nice. It would be perfect if users can understand the methods through information in code hints, without reading the source code. I noticed these parts do not have a description and thus leave empty in the compiled docs:
Thanks for this exciting work!
I change the interface Command
, so now developers can see the code hints of types.
interface Command {
name: string;
label?: string;
when?: () => Boolean;
task: {
Default?: Function;
CreateView?: Function;
SetValue?: {
values: { intro: string, check: (text: string) => boolean }[],
get?: () => boolean | string | number | undefined;
set: (values) => void,
};
SelectValue?: {
values: string[],
set: (value: string) => void,
get: () => boolean | string | number | undefined;
};
Commands?: Command[];
}
}
But I admit it's not concise. @windingwind @volatile-static, Is there a better form of interface with code hinting? Looking forward to your answers, thank you.
I add a
Prompt
class. Different addons can register somecommands
that they themselves defined in thisPrompt
. The UI interface deeply mimicsObsidian
, but its short key isShift + P
instead ofCtrl + P
(Obsidian's short key). Because pressingCtrl
when a item is selected will hightlight item's collections.This
Prompt
will extend Zotero's interaction, it is a new arena. I define four application types, includingDefault
,CreateView
,SetValue
,SelectValue
.Default
type will execute a predefined function and no new view is generated , such asSplit Vertaically
.CreateView
type is same asDefault
but generate a new view, like Fig. 1.SetValue
type can receives the value entered by the user, like Fig. 2.SelectValue
type can receives the value selected by the user, like Fig. 3.Fig. 1
Fig. 2
Fig. 3
I registered different commands by calling
Prompt.register()
in both plugins and the tests worked fine. But there are still some problems when it is used by developers, for example, the Enumeration typeTaskType
cannot be read by developers.In the end, allow me to introduce the parameters received by the regeister function,
Command[]
.A Commad contains:
Split Vertically
command should be hidden whenselected Tab
is not aReader Tab
);Finally, Happy New Year!