Skip to content

Commit 70fdb18

Browse files
authored
Merge pull request ycnmhd#81 from ycnmhd/next
next
2 parents 48eeaab + dd931a2 commit 70fdb18

98 files changed

Lines changed: 1667 additions & 939 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.lintstagedrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"*.{js,jsx,ts,tsx, svelte}": [
33
"prettier --write",
4-
"eslint --fix"
4+
"eslint"
55
]
66
}

esbuild.config.mjs

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,63 +11,69 @@ if you want to view the source, please visit the github repository of this plugi
1111
*/
1212
`;
1313

14-
const prod = process.argv[2] === "production";
14+
const prod = process.argv[2] === 'production';
1515

16-
const context = await esbuild.context({
17-
banner: {
18-
js: banner
19-
},
20-
entryPoints: ["src/main.ts"],
21-
bundle: true,
22-
external: [
23-
"obsidian",
24-
"electron",
25-
"@codemirror/autocomplete",
26-
"@codemirror/collab",
27-
"@codemirror/commands",
28-
"@codemirror/language",
29-
"@codemirror/lint",
30-
"@codemirror/search",
31-
"@codemirror/state",
32-
"@codemirror/view",
33-
"@lezer/common",
34-
"@lezer/highlight",
35-
"@lezer/lr",
36-
...builtins
37-
],
38-
format: "cjs",
39-
target: "es2021",
40-
logLevel: "info",
41-
sourcemap: prod ? false : "inline",
42-
treeShaking: true,
43-
outfile: "temp/vault/.obsidian/plugins/lineage-dev/main.js",
44-
plugins: [
45-
inlineWorkerPlugin({ minify: prod }),
46-
esbuildSvelte({
47-
compilerOptions: {
48-
css: true
49-
},
50-
preprocess: sveltePreprocess(),
51-
filterWarnings: (warning) => {
52-
// disable a11y warnings
53-
return !(warning.code.startsWith("a11y-"));
54-
}
16+
const options = {
17+
banner: {
18+
js: banner,
19+
},
20+
entryPoints: ['src/main.ts'],
21+
bundle: true,
22+
external: [
23+
'obsidian',
24+
'electron',
25+
'@codemirror/autocomplete',
26+
'@codemirror/collab',
27+
'@codemirror/commands',
28+
'@codemirror/language',
29+
'@codemirror/lint',
30+
'@codemirror/search',
31+
'@codemirror/state',
32+
'@codemirror/view',
33+
'@lezer/common',
34+
'@lezer/highlight',
35+
'@lezer/lr',
36+
...builtins,
37+
],
38+
format: 'cjs',
39+
target: 'es2021',
40+
logLevel: 'info',
41+
sourcemap: prod ? false : 'inline',
42+
treeShaking: true,
43+
outfile: 'temp/vault/.obsidian/plugins/lineage-dev/main.js',
44+
plugins: [
45+
inlineWorkerPlugin({ minify: prod }),
46+
esbuildSvelte({
47+
compilerOptions: {
48+
css: true,
49+
},
50+
preprocess: sveltePreprocess(),
51+
filterWarnings: (warning) => {
52+
// disable a11y warnings
53+
return !warning.code.startsWith('a11y-');
54+
},
55+
}),
56+
],
57+
};
58+
const context = await esbuild.context(options);
5559

56-
})
57-
58-
]
59-
});
60-
61-
const cssContext = await esbuild.context({
62-
entryPoints: ["src/styles/styles.css",],
63-
bundle: true,
64-
outfile: "temp/vault/.obsidian/plugins/lineage-dev/styles.css"
65-
});
60+
const cssOptions = {
61+
entryPoints: ['src/styles/styles.css'],
62+
bundle: true,
63+
outfile: 'temp/vault/.obsidian/plugins/lineage-dev/styles.css',
64+
};
65+
const cssContext = await esbuild.context(cssOptions);
6666

6767
if (prod) {
68-
await context.rebuild();
69-
await cssContext.rebuild();
70-
process.exit(0);
68+
await esbuild.build({
69+
...options,
70+
define: { 'process.env.NODE_ENV': '"production"' },
71+
});
72+
await esbuild.build({
73+
...cssOptions,
74+
define: { 'process.env.NODE_ENV': '"production"' },
75+
});
76+
process.exit(0);
7177
} else {
72-
await Promise.all([cssContext.watch(), context.watch()]);
78+
await Promise.all([cssContext.watch(), context.watch()]);
7379
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "lineage",
33
"name": "Lineage",
4-
"version": "0.8.0",
4+
"version": "0.8.1",
55
"minAppVersion": "0.15.0",
66
"description": "Edit Markdown in a keyboard-centric Miller columns interface. Inspired by Gingko Writer.",
77
"author": "ycnmhd",

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lineage",
3-
"version": "0.8.0",
3+
"version": "0.8.1",
44
"description": "",
55
"scripts": {
66
"dev": "node esbuild.config.mjs",
@@ -9,7 +9,8 @@
99
"test:watch": "vitest",
1010
"test": "vitest run",
1111
"test:e2e": "playwright test",
12-
"prepare": "husky install"
12+
"prepare": "husky install",
13+
"lint": "eslint src"
1314
},
1415
"keywords": [],
1516
"author": "",

src/helpers/delay.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1-
export const delay = async (milliseconds: number): Promise<void> => {
2-
return new Promise((resolve) => setTimeout(resolve, milliseconds));
1+
export const delay = async (
2+
milliseconds: number,
3+
signal?: AbortSignal,
4+
): Promise<void> => {
5+
return new Promise((resolve) => {
6+
const timeout = setTimeout(() => resolve(), milliseconds);
7+
8+
if (signal) {
9+
signal.addEventListener('abort', () => {
10+
clearTimeout(timeout);
11+
resolve();
12+
});
13+
}
14+
});
315
};

src/helpers/load-custom-icons.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ type SvgStyleType = 'fill' | 'stroke';
44
const svgWrapper = (innerSVG: string, mode: SvgStyleType = 'stroke') =>
55
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="svg-icon" ${mode === 'fill' ? 'stroke="transparent" fill="currentColor"' : 'stroke="currentColor" fill="transparent"'}> ${innerSVG.trim().replace(/\n/g, '')}</svg>`;
66

7-
type Icon = {
7+
export type CustomIcon = {
88
name: string;
99
svg: string;
1010
mode: SvgStyleType;
1111
};
1212

13-
const cards: Icon = {
13+
const cards: CustomIcon = {
1414
name: 'lineage-cards',
1515
svg: `
1616
<path
@@ -20,13 +20,13 @@ const cards: Icon = {
2020
mode: 'fill',
2121
};
2222

23-
const split: Icon = {
23+
const split: CustomIcon = {
2424
name: 'lineage-split',
2525
svg: `<path d="M16 3h5v5"/><path d="M8 3H3v5"/><path d="M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3"/><path d="m15 9 6-6"/>`,
2626
mode: 'stroke',
2727
};
2828

29-
const alignH: Icon = {
29+
const alignH: CustomIcon = {
3030
name: 'lineage-align-horizontal',
3131
svg: `<g>
3232
<rect width="20" height="12" x="2" y="6" rx="2"/>
@@ -35,7 +35,7 @@ const alignH: Icon = {
3535
mode: 'stroke',
3636
};
3737

38-
const alignV: Icon = {
38+
const alignV: CustomIcon = {
3939
name: 'lineage-align-vertical',
4040
svg: `<g>
4141
<rect width="18" height="12" x="3" y="6" rx="2"/>
@@ -51,7 +51,7 @@ const alignV: Icon = {
5151
mode: 'stroke',
5252
};
5353

54-
const gap: Icon = {
54+
const gap: CustomIcon = {
5555
name: 'cards-gap',
5656
svg: `
5757
<rect width="20" height="12" x="-11.600009" y="6" rx="2" />
@@ -66,15 +66,15 @@ const gap: Icon = {
6666
mode: 'stroke',
6767
};
6868

69-
const outline: Icon = {
69+
const outline: CustomIcon = {
7070
name: 'outline',
7171
svg: `<path d="M 7.563873,12 H 21.24698" />
7272
<path d="M 7.56116,18 H 21.159058" />
7373
<path d="M3 6h18" /> `,
7474
mode: 'stroke',
7575
};
7676

77-
const cursorOff: Icon = {
77+
const cursorOff: CustomIcon = {
7878
name: 'cursor-off',
7979
svg: `<path d="m 8.0036101,3.8555957 h 1 a 3,3 0 0 1 2.9999999,3 3,3 0 0 1 3,-3 h 1" />
8080
<path d="m 16.00361,19.855596 h -1 a 3,3 0 0 1 -3,-3 3,3 0 0 1 -2.9999999,3 h -1" />
@@ -83,7 +83,7 @@ const cursorOff: Icon = {
8383
mode: 'stroke',
8484
};
8585

86-
const cursor: Icon = {
86+
const cursor: CustomIcon = {
8787
name: 'cursor',
8888
svg: `<path d="m 8.0036101,3.8555957 h 1 a 3,3 0 0 1 2.9999999,3 3,3 0 0 1 3,-3 h 1" />
8989
<path d="m 16.00361,19.855596 h -1 a 3,3 0 0 1 -3,-3 3,3 0 0 1 -2.9999999,3 h -1" />

src/helpers/logger.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable no-console */
2+
23
type Logger = {
34
debug: (...message: unknown[]) => void;
45
info: (...message: unknown[]) => void;
@@ -34,3 +35,16 @@ const createLogger = (): Logger => {
3435
};
3536

3637
export const logger = createLogger();
38+
39+
/*let i = 0;
40+
export const AlignBranchLogger = (action: PluginAction) => {
41+
const id = i++;
42+
let t = 0;
43+
return {
44+
log: (...params: any[]) => {
45+
const delta = t > 0 ? Date.now() - t : 0;
46+
t = Date.now();
47+
console.log(`[${id}] [${action.type}] [${delta}]`, ...params);
48+
},
49+
};
50+
}*/

src/lang/lang.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const lang = {
3939
modals_snapshots_updated_card: 'Updated card ',
4040
modal_hk_editor_state_on: 'Enable only when the editor is active',
4141
modal_hk_editor_state_off: 'Enable only when the editor is inactive',
42-
modal_hk_editor_state_both: "Enable regardless of the editor's state",
42+
modal_hk_editor_state_both: 'Enable regardless of the editor state',
4343

4444
// save
4545
card_btn_save: 'Save',
@@ -198,7 +198,7 @@ export const lang = {
198198
controls_zoom_in: 'Zoom in',
199199
controls_zoom_out: 'Zoom out',
200200
controls_zoom_reset: 'Reset (hold shift to undo)',
201-
controls_zoom_presets: '',
201+
controls_zoom_presets: 'Zoom menu',
202202
hk_zoom_in: 'Zoom in',
203203
hk_zoom_out: 'Zoom out',
204204
hk_zoom_reset: 'Reset zoom',
@@ -245,6 +245,11 @@ export const lang = {
245245
hk_outline_toggle_collapse_all: 'Collapse/expand all cards',
246246
hkg_outline: 'Outline',
247247

248+
// toolbar
249+
settings_vertical_toolbar_icons: 'Vertical toolbar buttons',
250+
settings_vertical_toolbar_icons_desc:
251+
'Configure what buttons appear in the vertical toolbar',
252+
248253
// space between cards
249254
controls_gap_between_cards: 'Space between cards',
250255
cmd_space_between_cards: `Toggle 'space between cards'`,

src/lib/align-element/align-element-horizontally.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { calculateScrollLeft } from 'src/lib/align-element/helpers/calculate-scroll-left';
22

33
import { THRESHOLD } from 'src/lib/align-element/constants';
4-
import { AlignBranchContext } from 'src/stores/view/subscriptions/effects/align-branch/align-branch';
4+
import { AlignBranchContext } from 'src/stores/view/subscriptions/effects/align-branch/helpers/create-context';
55
import { getElementById } from 'src/lib/align-element/helpers/get-element-by-id';
66

77
export const alignElementHorizontally = (

src/lib/align-element/align-element-vertically.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { THRESHOLD } from 'src/lib/align-element/constants';
33
import {
44
AlignBranchContext,
55
PartialDOMRect,
6-
} from 'src/stores/view/subscriptions/effects/align-branch/align-branch';
6+
} from 'src/stores/view/subscriptions/effects/align-branch/helpers/create-context';
77
import { calculateScrollTopRelative } from 'src/lib/align-element/helpers/calculate-scroll-top-relative';
88
import { getElementById } from 'src/lib/align-element/helpers/get-element-by-id';
99

0 commit comments

Comments
 (0)