-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfig.ts
144 lines (141 loc) · 4.23 KB
/
Config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import Electron from "electron";
import * as path from "path";
import activeWin from "active-win";
export type UserConfig = {
/**
* Enable debug mode
* Default: false
*/
DEBUG: boolean;
/**
* Output dir path
* if set the path, use the path instead of stored path
* Default: use stored path
*/
outputDir?: string;
/**
* Output content file name
* Default: README.md
*/
outputContentFileName: string;
/**
* Output image directory prefix
* If you want to put images to same dir with README.md, set "."
* Default: img/
*/
outputImageDirPrefix: string;
/**
* format input by this function and append the result
* Default: for markdown
*/
outputContentTemplate: (args: OutputContentTemplateArgs) => string;
/**
* Auto focus when open input window
* Default: true
*/
autoFocus: boolean;
/**
* Save content automatically without no focus the input window after autoSaveTimeoutMs
* Default: true
*/
autoSave: boolean;
/**
* config for autosave
* Default: 30 * 1000
*/
autoSaveTimeoutMs: number;
/**
* if quoteFrom is clipboard, quote text from clipboard
* if quoteFrom is selectedText, quote text from selected text
* Default: "selectedText"
*/
quoteFrom: "clipboard" | "selectedText";
/**
* If want to transform clipboard, pass the transform function
* @param text
*/
transformClipboard?: (text: string) => string;
/**
* Send key stroke when ready to input window
* Note: macOS only
*/
sendKeyStrokeWhenReadyInputWindow?: {
key: string;
shift?: boolean;
control?: boolean;
option?: boolean;
command?: boolean;
};
/**
* bound ratio for screenshot
* Increase actual focus area using this ratio.
* Default: 1.2
*/
screenshotBoundRatio: number;
/**
* Max search count for related content that is included into screenshot result
* The higher the number, screenshot size is large.
* Default: 5
*/
screenshotSearchRectangleMaxCount: number;
/**
* if the rectangle count is over, mumemo give up to create focus image.
* Just use screenshot image instead of focus image
* Default: 80
*/
screenshotGiveUpRectangleMaxCount: number;
/**
* if the factor value is defined, mumemo resize screenshot image with the factor.
* Retina display's the factor value is 2.
* display size * factor value is the result of screenshot image size.
* if you want to resize the screeenshot image size, set `1` to `screenshotResizeFactor`
* Default: displayFactor's value
*/
screenshotResizeFactor?: number;
};
export type MumemoConfigFile = {
shortcutKey?: string | string[];
create?: (args: UserConfigCreatorArgs) => UserConfig;
};
export type UserConfigCreatorArgs = {
app: Electron.App;
path: typeof path;
activeWindow?: activeWin.Result | {};
// What shortcut key is pressed
shortcutKey?: string;
};
export type OutputContentTemplateArgs = {
imgPath: string;
selectedContent: {
raw: string;
value: string;
};
inputContent: {
raw: string;
value: string;
};
};
export const defaultShortcutKey = "CommandOrControl+Shift+X";
export const createUserConfig = ({ app, path, activeWindow }: UserConfigCreatorArgs): UserConfig => {
return {
outputContentFileName: "README.md",
outputImageDirPrefix: "img/",
// Output Template Function
outputContentTemplate: ({ imgPath, selectedContent, inputContent }: OutputContentTemplateArgs) => {
return (
`![](${imgPath})\n` +
(selectedContent.value ? `\n> ${selectedContent.value.split("\n").join("\n> ")}\n` : "") +
(inputContent.raw ? `\n${inputContent.raw.trimRight()}\n` : "") +
"\n---\n\n"
);
},
autoFocus: true,
autoSave: true,
autoSaveTimeoutMs: 30 * 1000,
screenshotBoundRatio: 1.2,
screenshotSearchRectangleMaxCount: 5,
screenshotGiveUpRectangleMaxCount: 80,
quoteFrom: "selectedText",
DEBUG: false
};
};