Skip to content

Commit 4abd96a

Browse files
Merge pull request #92 from ArthurLobopro/some-changes
Some changes
2 parents a09d82a + ab92706 commit 4abd96a

File tree

14 files changed

+181
-101
lines changed

14 files changed

+181
-101
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.22.0
2+
3+
Feat: New Watermark position input
4+
15
## 1.21.1
26

37
Feat: New expansible menus on One Time Config

l10n/bundle.l10n.pt-br.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@
5858
"You can edit the default Watermark text clicking": "Você pode editar o texto padrão da Marca D'água clicando",
5959
"Enables manual resizing of the `Snap Window`.": "Ativa o redimencionamento manual da `Snap Window`.",
6060
"Disabling this will also reset the `Snap Window` size.": "Desativar isso também irá resetar o tamanho da `Snap Window`.",
61-
"Watermark Y position": "Posição Y da marca d'água",
62-
"Watermark X position": "Posição X da marca d'água"
61+
"Show Watermark": "Mostrar marca d'água",
62+
"The position of the watermark in the snapshot. Top positions are only available when `Target` is `container`": "A posição da marca d'água na captura de tela. Posições superiores só são disponíveis quando `Alvo` é `container`"
6363
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "easy-codesnap",
33
"displayName": "Easy CodeSnap",
44
"description": "Take beautiful screenshots of your code 📷",
5-
"version": "1.21.1",
5+
"version": "1.22.0",
66
"l10n": "./l10n",
77
"repository": {
88
"type": "git",

screenshots/one-time-config.gif

2.46 MB
Loading

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function getSettings(group: string, keys: string[]) {
1616
config[key] = languageSettings[`${group}.${key}`];
1717
}
1818

19-
config[key] = config[key] ?? settings.get(key);
19+
config[key] ??= settings.get(key);
2020

2121
return config;
2222
}, {} as untypedObject);

src/webview/SessionConfig.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ export class SessionConfig {
3131
? Object.assign({}, this.__config, config)
3232
: config;
3333

34-
newConfig.zoom = newConfig.zoom ?? 100;
35-
newConfig.shouldUpdateTitle = newConfig.shouldUpdateTitle ?? true;
36-
newConfig.watermarkText =
37-
newConfig.watermarkText ?? newConfig.defaultWatermarkText;
34+
newConfig.zoom ??= 100;
35+
newConfig.shouldUpdateTitle ??= true;
36+
newConfig.watermarkText ??= newConfig.defaultWatermarkText;
3837

3938
this.__config = newConfig as WebviewConfig;
4039

src/webview/ui/elements.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export const windowStyleSelect = getSelect("windowStyle");
5252
export const zoomSelect = getSelect("zoom");
5353
export const saveScaleSelect = getSelect("saveScale");
5454
export const aspectRatioSelect = getSelect("aspectRatio");
55-
export const watermarkPositionYSelect = getSelect("watermarkPosition-Y");
56-
export const watermarkPositionXSelect = getSelect("watermarkPosition-X");
5755

5856
//Buttons
5957
export const openSettingsButton = getButton("open-settings");
@@ -63,3 +61,13 @@ export const toggleLockedButton = getButton("toggle-lock");
6361
export const toggleLinkedButton = getButton("toggle-link");
6462
export const zoomInButton = getButton("zoom-in");
6563
export const zoomOutButton = getButton("zoom-out");
64+
65+
//Watermark
66+
function getRadio(value: string) {
67+
return $<HTMLInputElement>(`input[value="${value}"]`);
68+
}
69+
70+
export const watermarkTopLeft = getRadio("top-left");
71+
export const watermarkTopRight = getRadio("top-right");
72+
export const watermarkBottomLeft = getRadio("bottom-left");
73+
export const watermarkBottomRight = getRadio("bottom-right");
Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import type { ExtensionConfig } from "../../../types";
2-
import { SessionConfig } from "../../SessionConfig";
31
import {
42
aspectRatioSelect,
53
roundingLevelSelect,
64
saveFormatSelect,
75
saveScaleSelect,
86
shutterActionSelect,
97
targetSelect,
10-
watermarkPositionXSelect,
11-
watermarkPositionYSelect,
128
windowStyleSelect,
139
zoomSelect,
1410
} from "../elements";
@@ -23,26 +19,4 @@ export function addSelectListeners() {
2319
handleSelectBasedChange(windowStyleSelect, "windowStyle");
2420
handleSelectBasedChange(zoomSelect, "zoom");
2521
handleSelectBasedChange(aspectRatioSelect, "aspectRatio");
26-
27-
watermarkPositionXSelect.addEventListener("change", () => {
28-
const watermarkPosition = SessionConfig.get("watermarkPosition");
29-
30-
SessionConfig.set({
31-
watermarkPosition: [
32-
watermarkPosition.split("-")[0],
33-
watermarkPositionXSelect.value,
34-
].join("-") as ExtensionConfig["watermarkPosition"],
35-
});
36-
});
37-
38-
watermarkPositionYSelect.addEventListener("change", () => {
39-
const watermarkPosition = SessionConfig.get("watermarkPosition");
40-
41-
SessionConfig.set({
42-
watermarkPosition: [
43-
watermarkPositionYSelect.value,
44-
watermarkPosition.split("-")[1],
45-
].join("-") as ExtensionConfig["watermarkPosition"],
46-
});
47-
});
4822
}

src/webview/ui/listeners/addToggleListeners.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { WebviewConfig } from "../../../types";
2+
import { SessionConfig } from "../../SessionConfig";
13
import {
24
enableResizingInput,
35
highlightLineNumberInput,
@@ -9,7 +11,11 @@ import {
911
toggleLinkedButton,
1012
toggleLockedButton,
1113
transparentBackgroundInput,
14+
watermarkBottomLeft,
15+
watermarkBottomRight,
1216
watermarkInput,
17+
watermarkTopLeft,
18+
watermarkTopRight,
1319
} from "../elements";
1420
import { handleToggleBasedChange, handleToggleBasedClick } from "./handlers";
1521

@@ -31,4 +37,20 @@ export function addToogleListeners() {
3137

3238
handleToggleBasedClick(toggleLinkedButton, "isLinked");
3339
handleToggleBasedClick(toggleLockedButton, "isLocked");
40+
41+
[
42+
watermarkTopLeft,
43+
watermarkTopRight,
44+
watermarkBottomRight,
45+
watermarkBottomLeft,
46+
].forEach((input) => {
47+
input.addEventListener("change", () => {
48+
if (input.checked) {
49+
SessionConfig.set({
50+
watermarkPosition:
51+
input.value as WebviewConfig["watermarkPosition"],
52+
});
53+
}
54+
});
55+
});
3456
}

src/webview/ui/updaters/OneTimeConfigUpdater.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
targetSelect,
1616
transparentBackgroundInput,
1717
watermarkInput,
18-
watermarkPositionXSelect,
19-
watermarkPositionYSelect,
2018
windowStyleSelect,
2119
} from "../elements";
2220

@@ -58,7 +56,6 @@ export class OneTimeConfigUpdater extends Updater {
5856
saveScale,
5957
highlightLineNumber,
6058
watermark,
61-
watermarkPosition,
6259
} = SessionConfig.get();
6360

6461
showWindowTitleInput.checked = showWindowTitle;
@@ -82,11 +79,5 @@ export class OneTimeConfigUpdater extends Updater {
8279
saveFormatSelect.value = saveFormat;
8380
windowStyleSelect.value = windowStyle;
8481
saveScaleSelect.value = saveScale.toString();
85-
86-
if (watermarkPosition) {
87-
const [watermarkY, watermarkX] = watermarkPosition.split("-");
88-
watermarkPositionXSelect.value = watermarkX;
89-
watermarkPositionYSelect.value = watermarkY;
90-
}
9182
}
9283
}

0 commit comments

Comments
 (0)