Skip to content

Commit 8a8cd46

Browse files
committed
fix #500
1 parent 3609024 commit 8a8cd46

File tree

5 files changed

+292
-234
lines changed

5 files changed

+292
-234
lines changed

packages/core/src/api/SyntaxHighlightingAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
HLP_ViewFieldDeclaration,
1313
} from 'packages/core/src/parsers/syntaxHighlighting/HLPs';
1414
import { SyntaxHighlighting } from 'packages/core/src/parsers/syntaxHighlighting/SyntaxHighlighting';
15-
import { expectType } from '../utils/Utils';
15+
import { expectType } from 'packages/core/src/utils/Utils';
1616

1717
export class SyntaxHighlightingAPI {
1818
public readonly plugin: IPlugin;

packages/core/src/modals/modalContents/buttonBuilder/ButtonBuilderModalComponent.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@
148148
buttonConfig.backgroundImage = file;
149149
});
150150
}
151+
152+
function resetBackgroundImage(): void {
153+
buttonConfig.backgroundImage = undefined;
154+
}
151155
</script>
152156

153157
<SettingComponent name="Label" description="The label shown on the button.">
@@ -178,10 +182,13 @@
178182
</SettingComponent>
179183

180184
<SettingComponent name="Background image" description="A background image to use in the button.">
181-
<span style="word-break: break-word">{buttonConfig.backgroundImage ?? 'none'}</span>
185+
<span style="word-break: break-word">{buttonConfig.backgroundImage || 'none'}</span>
182186
<Button variant={ButtonStyleType.PRIMARY} onclick={() => changeBackgroundImage()} tooltip="Select from vault"
183187
>Change</Button
184188
>
189+
<Button variant={ButtonStyleType.DEFAULT} onclick={() => resetBackgroundImage()} tooltip="Reset to none"
190+
><Icon plugin={plugin} iconName="x"></Icon></Button
191+
>
185192
</SettingComponent>
186193

187194
<SettingComponent

tests/__mocks__/TestComponent.ts

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
export class TestComponent {
2-
loaded: boolean;
3-
used: boolean;
4-
callbacks: (() => void)[];
2+
loaded: boolean;
3+
used: boolean;
4+
callbacks: (() => void)[];
55

6-
constructor() {
7-
this.loaded = false;
8-
this.used = false;
9-
this.callbacks = [];
10-
}
6+
constructor() {
7+
this.loaded = false;
8+
this.used = false;
9+
this.callbacks = [];
10+
}
1111

12-
load() {
13-
if (this.loaded) {
14-
throw new Error('Attempted double load of TestComponent');
15-
}
16-
if (this.used) {
17-
throw new Error('Attempted reuse of TestComponent');
18-
}
19-
this.loaded = true;
20-
}
12+
load() {
13+
if (this.loaded) {
14+
throw new Error('Attempted double load of TestComponent');
15+
}
16+
if (this.used) {
17+
throw new Error('Attempted reuse of TestComponent');
18+
}
19+
this.loaded = true;
20+
}
2121

22-
unload() {
23-
if (!this.loaded && !this.used) {
24-
throw new Error('Attempted unload of TestComponent before it was loaded');
25-
}
26-
if (!this.loaded && this.used) {
27-
throw new Error('Attempted double unload of TestComponent');
28-
}
29-
this.loaded = false;
30-
this.used = true;
31-
this.callbacks.forEach(cb => cb());
32-
}
22+
unload() {
23+
if (!this.loaded && !this.used) {
24+
throw new Error('Attempted unload of TestComponent before it was loaded');
25+
}
26+
if (!this.loaded && this.used) {
27+
throw new Error('Attempted double unload of TestComponent');
28+
}
29+
this.loaded = false;
30+
this.used = true;
31+
this.callbacks.forEach(cb => cb());
32+
}
3333

34-
register(callback: () => void) {
35-
if (this.used) {
36-
throw new Error('Attempted to register callback after TestComponent was used. The callback will never be called.');
37-
}
34+
register(callback: () => void) {
35+
if (this.used) {
36+
throw new Error(
37+
'Attempted to register callback after TestComponent was used. The callback will never be called.',
38+
);
39+
}
3840

39-
this.callbacks.push(callback);
40-
}
41-
}
41+
this.callbacks.push(callback);
42+
}
43+
}

0 commit comments

Comments
 (0)