@lvl99dotcom/paintcanvas 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/lib/classes/PaintCanvas/index.js +2 -1
- package/dist/lib/i18n/index.d.ts +50 -13
- package/dist/lib/i18n/index.js +121 -26
- package/dist/locales/en-GB.js +177 -184
- package/dist/locales/en-US.js +177 -184
- package/dist/locales/fr.js +177 -184
- package/dist/locales/ja.js +177 -184
- package/dist/locales/ko.js +177 -184
- package/dist/locales/zh-Hans.js +177 -184
- package/dist/locales/zh-Hant.js +177 -184
- package/dist/package.js +1 -1
- package/dist/ui/base/index.d.ts +1 -1
- package/dist/ui/base/index.js +1 -1
- package/dist/ui/elements/PaintCanvas/index.js +20 -11
- package/dist/ui/elements/PcBrushConfig/index.d.ts +3 -3
- package/dist/ui/elements/PcBrushConfig/index.js +44 -41
- package/dist/ui/elements/PcBrushMenu/index.js +20 -19
- package/dist/ui/elements/PcBrushTest/index.js +2 -2
- package/dist/ui/elements/PcButton/index.js +1 -0
- package/dist/ui/elements/PcCanvas/index.js +1 -1
- package/dist/ui/elements/PcCanvasMap/index.js +1 -1
- package/dist/ui/elements/PcDialog/index.js +1 -0
- package/dist/ui/elements/PcIconToggle/index.js +1 -0
- package/dist/ui/elements/PcInfoTip/index.js +1 -1
- package/dist/ui/elements/PcInputSettings/index.js +17 -13
- package/dist/ui/elements/PcLayerItem/index.js +34 -34
- package/dist/ui/elements/PcLayersMenu/index.js +1 -1
- package/dist/ui/elements/PcStats/index.js +8 -5
- package/dist/ui/elements/PcThemePicker/index.js +3 -2
- package/dist/ui/elements/PcToast/index.js +2 -1
- package/dist/ui/elements/PcToolSettings/index.js +51 -45
- package/dist/ui/elements/PcToolbar/index.js +19 -19
- package/locales/en-GB.json +177 -184
- package/locales/en-US.json +177 -184
- package/locales/fr.json +177 -184
- package/locales/ja.json +177 -184
- package/locales/ko.json +177 -184
- package/locales/zh-Hans.json +177 -184
- package/locales/zh-Hant.json +177 -184
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import style_default from "./style.js";
|
|
|
2
2
|
import { ICON_CONTROLS_CSS, PILLS_CSS, WINDOWS_CSS } from "../../styles/index.js";
|
|
3
3
|
import { iconLabel } from "../../icons/index.js";
|
|
4
4
|
import { PcElement, defineElement } from "../../base/index.js";
|
|
5
|
+
import "../PcBrushTest/index.js";
|
|
5
6
|
import { SmoothingType } from "../../../lib/brushes/types/index.js";
|
|
6
7
|
import { PARAM_LIMITS, VARIATION_SOURCES, readRange, toggleSource, writeRange } from "../../../lib/brushes/configRanges/index.js";
|
|
7
8
|
import { SHAPE_ERRORS, ShapeImageError, readClipboardShape, readShapeImage } from "../../../lib/brushes/shapeImage/index.js";
|
|
@@ -13,17 +14,17 @@ import { styleMap } from "lit/directives/style-map.js";
|
|
|
13
14
|
var SMOOTHING_CHOICES = [
|
|
14
15
|
{
|
|
15
16
|
value: SmoothingType.Linear,
|
|
16
|
-
label: "brushConfig.smoothingLinear",
|
|
17
|
+
label: "paintCanvas.brushConfig.smoothingLinear",
|
|
17
18
|
icon: "smoothingLinear"
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
value: SmoothingType.BezierQuad,
|
|
21
|
-
label: "brushConfig.smoothingQuadratic",
|
|
22
|
+
label: "paintCanvas.brushConfig.smoothingQuadratic",
|
|
22
23
|
icon: "smoothingBezierQuad"
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
value: SmoothingType.BezierCubic,
|
|
26
|
-
label: "brushConfig.smoothingCubic",
|
|
27
|
+
label: "paintCanvas.brushConfig.smoothingCubic",
|
|
27
28
|
icon: "smoothingBezierCubic"
|
|
28
29
|
}
|
|
29
30
|
];
|
|
@@ -35,16 +36,16 @@ var SOURCE_ICONS = {
|
|
|
35
36
|
};
|
|
36
37
|
/** Translation keys of the variation sources' names */
|
|
37
38
|
var SOURCE_LABELS = {
|
|
38
|
-
pressure: "toolSettings.pressure",
|
|
39
|
-
tilt: "toolSettings.tilt",
|
|
40
|
-
randomise: "brushConfig.randomise"
|
|
39
|
+
pressure: "paintCanvas.toolSettings.pressure",
|
|
40
|
+
tilt: "paintCanvas.toolSettings.tilt",
|
|
41
|
+
randomise: "paintCanvas.brushConfig.randomise"
|
|
41
42
|
};
|
|
42
43
|
/** Translation keys of the brush shape error messages */
|
|
43
44
|
var SHAPE_ERROR_KEYS = {
|
|
44
|
-
[SHAPE_ERRORS.type]: "shape.notPng",
|
|
45
|
-
[SHAPE_ERRORS.size]: "shape.tooLarge",
|
|
46
|
-
[SHAPE_ERRORS.decode]: "shape.readFailed",
|
|
47
|
-
[SHAPE_ERRORS.noImage]: "shape.noPngToPaste"
|
|
45
|
+
[SHAPE_ERRORS.type]: "paintCanvas.shape.notPng",
|
|
46
|
+
[SHAPE_ERRORS.size]: "paintCanvas.shape.tooLarge",
|
|
47
|
+
[SHAPE_ERRORS.decode]: "paintCanvas.shape.readFailed",
|
|
48
|
+
[SHAPE_ERRORS.noImage]: "paintCanvas.shape.noPngToPaste"
|
|
48
49
|
};
|
|
49
50
|
/** Largest stamp spacing in pixels */
|
|
50
51
|
var MAX_SPACING = 200;
|
|
@@ -169,7 +170,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
169
170
|
});
|
|
170
171
|
} catch (error) {
|
|
171
172
|
this.emit("pc-toast", {
|
|
172
|
-
message: this.t(error instanceof ShapeImageError && SHAPE_ERROR_KEYS[error.message] || "brushConfig.shapeFailed"),
|
|
173
|
+
message: this.t(error instanceof ShapeImageError && SHAPE_ERROR_KEYS[error.message] || "paintCanvas.brushConfig.shapeFailed"),
|
|
173
174
|
kind: "error"
|
|
174
175
|
});
|
|
175
176
|
}
|
|
@@ -182,10 +183,10 @@ var PcBrushConfig = class extends PcElement {
|
|
|
182
183
|
const app = this.app;
|
|
183
184
|
const draft = this.draft;
|
|
184
185
|
if (!app || !draft) return;
|
|
185
|
-
const name = this.prompt(this.t("brushConfig.presetName"), draft.name ?? "")?.trim();
|
|
186
|
+
const name = this.prompt(this.t("paintCanvas.brushConfig.presetName"), draft.name ?? "")?.trim();
|
|
186
187
|
if (!name) return;
|
|
187
188
|
const existing = app.customPresets.findOwn(name, app.authorHandle, app.names.unknownAuthor);
|
|
188
|
-
if (existing && !this.confirm(this.t("presets.replaceConfirm", { name }))) return;
|
|
189
|
+
if (existing && !this.confirm(this.t("paintCanvas.presets.replaceConfirm", { name }))) return;
|
|
189
190
|
const preset = {
|
|
190
191
|
...app.newPreset(draft, name),
|
|
191
192
|
...existing ? { id: existing.id } : {}
|
|
@@ -195,13 +196,13 @@ var PcBrushConfig = class extends PcElement {
|
|
|
195
196
|
await app.customPresets.save(preset);
|
|
196
197
|
(this.kind === "eraser" ? app.eraser : app.brush).select(preset.id);
|
|
197
198
|
this.emit("pc-toast", {
|
|
198
|
-
message: this.t("presets.saved", { name }),
|
|
199
|
+
message: this.t("paintCanvas.presets.saved", { name }),
|
|
199
200
|
kind: "success"
|
|
200
201
|
});
|
|
201
202
|
this.close();
|
|
202
203
|
} catch {
|
|
203
204
|
this.emit("pc-toast", {
|
|
204
|
-
message: this.t("presets.saveFailed", { name }),
|
|
205
|
+
message: this.t("paintCanvas.presets.saveFailed", { name }),
|
|
205
206
|
kind: "error"
|
|
206
207
|
});
|
|
207
208
|
} finally {
|
|
@@ -216,18 +217,18 @@ var PcBrushConfig = class extends PcElement {
|
|
|
216
217
|
const id = this.editingId;
|
|
217
218
|
if (!app || !id) return;
|
|
218
219
|
const name = app.customPresets.get(id)?.name ?? "this preset";
|
|
219
|
-
if (!this.confirm(this.t("presets.deleteConfirm", { name }))) return;
|
|
220
|
+
if (!this.confirm(this.t("paintCanvas.presets.deleteConfirm", { name }))) return;
|
|
220
221
|
this.busy = true;
|
|
221
222
|
try {
|
|
222
223
|
await app.customPresets.remove(id);
|
|
223
224
|
this.emit("pc-toast", {
|
|
224
|
-
message: this.t("presets.deleted", { name }),
|
|
225
|
+
message: this.t("paintCanvas.presets.deleted", { name }),
|
|
225
226
|
kind: "success"
|
|
226
227
|
});
|
|
227
228
|
this.close();
|
|
228
229
|
} catch {
|
|
229
230
|
this.emit("pc-toast", {
|
|
230
|
-
message: this.t("presets.deleteFailed", { name }),
|
|
231
|
+
message: this.t("paintCanvas.presets.deleteFailed", { name }),
|
|
231
232
|
kind: "error"
|
|
232
233
|
});
|
|
233
234
|
} finally {
|
|
@@ -282,7 +283,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
282
283
|
<input
|
|
283
284
|
type="checkbox"
|
|
284
285
|
class=${`${param} ${source}`}
|
|
285
|
-
aria-label=${this.t("brushConfig.variation", {
|
|
286
|
+
aria-label=${this.t("paintCanvas.brushConfig.variation", {
|
|
286
287
|
param: label,
|
|
287
288
|
source: this.t(SOURCE_LABELS[source])
|
|
288
289
|
})}
|
|
@@ -298,7 +299,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
298
299
|
renderShape(draft) {
|
|
299
300
|
const smoothing = draft.smoothingType === SmoothingType.None || draft.smoothingType === void 0 ? SmoothingType.Linear : draft.smoothingType;
|
|
300
301
|
return html`<div class="row shape-row">
|
|
301
|
-
<span class="label">${this.t("brushConfig.shape")}</span>
|
|
302
|
+
<span class="label">${this.t("paintCanvas.brushConfig.shape")}</span>
|
|
302
303
|
<span
|
|
303
304
|
class=${draft.image ? "shape-preview image" : "shape-preview"}
|
|
304
305
|
style=${styleMap({ maskImage: typeof draft.image === "string" ? `url("${draft.image}")` : void 0 })}
|
|
@@ -309,7 +310,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
309
310
|
?disabled=${this.busy}
|
|
310
311
|
@click=${() => this.renderRoot.querySelector("input.shape")?.click()}
|
|
311
312
|
>
|
|
312
|
-
${this.t("brushConfig.upload")}
|
|
313
|
+
${this.t("paintCanvas.brushConfig.upload")}
|
|
313
314
|
</button>
|
|
314
315
|
<!-- Chosen through "Upload" -->
|
|
315
316
|
<label class="visually-hidden">
|
|
@@ -331,14 +332,14 @@ var PcBrushConfig = class extends PcElement {
|
|
|
331
332
|
<button
|
|
332
333
|
type="button"
|
|
333
334
|
class="icon-button paste"
|
|
334
|
-
title=${this.t("brushConfig.paste")}
|
|
335
|
+
title=${this.t("paintCanvas.brushConfig.paste")}
|
|
335
336
|
?disabled=${this.busy}
|
|
336
337
|
@click=${() => void this.useShape(this.readClipboard)}
|
|
337
338
|
>
|
|
338
|
-
${iconLabel(this.iconUrl("clipboard"), this.t("brushConfig.paste"))}
|
|
339
|
+
${iconLabel(this.iconUrl("clipboard"), this.t("paintCanvas.brushConfig.paste"))}
|
|
339
340
|
</button>
|
|
340
341
|
<fieldset class="smoothing">
|
|
341
|
-
<legend>${this.t("brushConfig.smoothing")}</legend>
|
|
342
|
+
<legend>${this.t("paintCanvas.brushConfig.smoothing")}</legend>
|
|
342
343
|
${SMOOTHING_CHOICES.map((choice) => html`<label class="icon-toggle" title=${this.t(choice.label)}>
|
|
343
344
|
<input
|
|
344
345
|
type="radio"
|
|
@@ -368,11 +369,11 @@ var PcBrushConfig = class extends PcElement {
|
|
|
368
369
|
return html`<div
|
|
369
370
|
role="dialog"
|
|
370
371
|
aria-modal="true"
|
|
371
|
-
aria-label=${this.t(this.kind === "eraser" ? "brushConfig.eraserTitle" : "brushConfig.brushTitle")}
|
|
372
|
+
aria-label=${this.t(this.kind === "eraser" ? "paintCanvas.brushConfig.eraserTitle" : "paintCanvas.brushConfig.brushTitle")}
|
|
372
373
|
>
|
|
373
374
|
<div class="row header">
|
|
374
375
|
<label>
|
|
375
|
-
${this.t("brushConfig.name")}
|
|
376
|
+
${this.t("paintCanvas.brushConfig.name")}
|
|
376
377
|
<input
|
|
377
378
|
class="name"
|
|
378
379
|
.value=${draft.name ?? ""}
|
|
@@ -385,17 +386,17 @@ var PcBrushConfig = class extends PcElement {
|
|
|
385
386
|
class="close dismiss"
|
|
386
387
|
@click=${() => this.close()}
|
|
387
388
|
>
|
|
388
|
-
${this.t("common.dismiss")}
|
|
389
|
+
${this.t("paintCanvas.common.dismiss")}
|
|
389
390
|
</button>
|
|
390
391
|
</div>
|
|
391
392
|
<pc-brush-test .config=${draft} .tips=${this.app?.tips}></pc-brush-test>
|
|
392
393
|
${this.renderShape(draft)}
|
|
393
|
-
${this.renderParam(draft, "width", this.t("common.width"))}
|
|
394
|
+
${this.renderParam(draft, "width", this.t("paintCanvas.common.width"))}
|
|
394
395
|
<div class="row">
|
|
395
396
|
<span class="label"></span>
|
|
396
397
|
<label
|
|
397
398
|
class="icon-toggle"
|
|
398
|
-
title=${this.t("toolSettings.constrainProportions")}
|
|
399
|
+
title=${this.t("paintCanvas.toolSettings.constrainProportions")}
|
|
399
400
|
>
|
|
400
401
|
<input
|
|
401
402
|
type="checkbox"
|
|
@@ -404,19 +405,21 @@ var PcBrushConfig = class extends PcElement {
|
|
|
404
405
|
?disabled=${this.busy}
|
|
405
406
|
@change=${(e) => this.change({ constrainProportions: e.target.checked })}
|
|
406
407
|
/>
|
|
407
|
-
${iconLabel(this.iconUrl(constrained ? "linked" : "unlinked"), this.t("toolSettings.constrainProportions"))}
|
|
408
|
+
${iconLabel(this.iconUrl(constrained ? "linked" : "unlinked"), this.t("paintCanvas.toolSettings.constrainProportions"))}
|
|
408
409
|
</label>
|
|
409
410
|
</div>
|
|
410
|
-
${this.renderParam(draft, "height", this.t("common.height"), constrained)}
|
|
411
|
-
${this.renderParam(draft, "alpha", this.t("common.opacity"))}
|
|
412
|
-
${this.renderParam(draft, "rotation", this.t("brushConfig.rotation"))}
|
|
413
|
-
${this.renderParam(draft, "offsetX", this.t("brushConfig.offsetX"))}
|
|
414
|
-
${this.renderParam(draft, "offsetY", this.t("brushConfig.offsetY"))}
|
|
411
|
+
${this.renderParam(draft, "height", this.t("paintCanvas.common.height"), constrained)}
|
|
412
|
+
${this.renderParam(draft, "alpha", this.t("paintCanvas.common.opacity"))}
|
|
413
|
+
${this.renderParam(draft, "rotation", this.t("paintCanvas.brushConfig.rotation"))}
|
|
414
|
+
${this.renderParam(draft, "offsetX", this.t("paintCanvas.brushConfig.offsetX"))}
|
|
415
|
+
${this.renderParam(draft, "offsetY", this.t("paintCanvas.brushConfig.offsetY"))}
|
|
415
416
|
<div class="row">
|
|
416
|
-
<span class="label"
|
|
417
|
+
<span class="label"
|
|
418
|
+
>${this.t("paintCanvas.brushConfig.sampleRate")}</span
|
|
419
|
+
>
|
|
417
420
|
${this.number("sample-rate", draft.sampleRate ?? 5, sampleLimits, (sampleRate) => this.change({ sampleRate }))}
|
|
418
421
|
${this.slider("sample-rate", draft.sampleRate ?? 5, sampleLimits, (sampleRate) => this.change({ sampleRate }))}
|
|
419
|
-
<span class="label">${this.t("brushConfig.spacing")}</span>
|
|
422
|
+
<span class="label">${this.t("paintCanvas.brushConfig.spacing")}</span>
|
|
420
423
|
${this.number("spacing", draft.spacing ?? 5, spacingLimits, (spacing) => this.change({ spacing }))}
|
|
421
424
|
${this.slider("spacing", draft.spacing ?? 5, spacingLimits, (spacing) => this.change({ spacing }))}
|
|
422
425
|
</div>
|
|
@@ -428,7 +431,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
428
431
|
?disabled=${this.busy}
|
|
429
432
|
@change=${(e) => this.change({ snapToPixelGrid: e.target.checked })}
|
|
430
433
|
/>
|
|
431
|
-
${this.t("brushConfig.snapToPixelGrid")}
|
|
434
|
+
${this.t("paintCanvas.brushConfig.snapToPixelGrid")}
|
|
432
435
|
</label>
|
|
433
436
|
<div class="row">
|
|
434
437
|
${this.editingId ? html`<button
|
|
@@ -437,7 +440,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
437
440
|
?disabled=${this.busy}
|
|
438
441
|
@click=${() => void this.deletePreset()}
|
|
439
442
|
>
|
|
440
|
-
${this.t("brushConfig.deletePreset")}
|
|
443
|
+
${this.t("paintCanvas.brushConfig.deletePreset")}
|
|
441
444
|
</button>` : nothing}
|
|
442
445
|
<button
|
|
443
446
|
type="button"
|
|
@@ -445,7 +448,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
445
448
|
?disabled=${this.busy}
|
|
446
449
|
@click=${() => void this.addToPresets()}
|
|
447
450
|
>
|
|
448
|
-
${this.t("brushConfig.addToPresets")}
|
|
451
|
+
${this.t("paintCanvas.brushConfig.addToPresets")}
|
|
449
452
|
</button>
|
|
450
453
|
<button
|
|
451
454
|
type="button"
|
|
@@ -453,7 +456,7 @@ var PcBrushConfig = class extends PcElement {
|
|
|
453
456
|
?disabled=${this.busy}
|
|
454
457
|
@click=${() => this.save()}
|
|
455
458
|
>
|
|
456
|
-
${this.t("common.save")}
|
|
459
|
+
${this.t("paintCanvas.common.save")}
|
|
457
460
|
</button>
|
|
458
461
|
</div>
|
|
459
462
|
</div>`;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import style_default from "./style.js";
|
|
2
|
+
import { BRUSH_PRESET_FILE_FORMAT } from "../../../lib/presets/schema.js";
|
|
2
3
|
import { NO_TEXT_SELECTION_CSS, PILLS_CSS, WINDOWS_CSS } from "../../styles/index.js";
|
|
3
4
|
import { PcElement, defineElement } from "../../base/index.js";
|
|
4
5
|
import ChangeController from "../../ChangeController/index.js";
|
|
5
6
|
import { groupPresetsByAuthor } from "../../../lib/brushes/authors/index.js";
|
|
6
|
-
import
|
|
7
|
+
import "../../../lib/presets/index.js";
|
|
7
8
|
import { PRESET_FILE_ERRORS, PresetFileError, exportPresetFile, parsePresetFile, presetFileName } from "../../../lib/brushes/presetFile/index.js";
|
|
8
9
|
import { svgCursor } from "../../../lib/rendering/cursors/index.js";
|
|
9
10
|
import { JSON_FILE_TYPE, saveFile } from "../../../lib/rendering/screenshot/index.js";
|
|
@@ -12,10 +13,10 @@ import { styleMap } from "lit/directives/style-map.js";
|
|
|
12
13
|
// src/ui/elements/PcBrushMenu/index.ts
|
|
13
14
|
/** Translation keys of the preset file error messages */
|
|
14
15
|
var PRESET_FILE_ERROR_KEYS = {
|
|
15
|
-
[PRESET_FILE_ERRORS.incompatible]: "presets.fileIncompatible",
|
|
16
|
-
[PRESET_FILE_ERRORS.read]: "presets.fileReadFailed",
|
|
17
|
-
[PRESET_FILE_ERRORS.export]: "presets.exportFailed",
|
|
18
|
-
[PRESET_FILE_ERRORS.empty]: "presets.nothingToExport"
|
|
16
|
+
[PRESET_FILE_ERRORS.incompatible]: "paintCanvas.presets.fileIncompatible",
|
|
17
|
+
[PRESET_FILE_ERRORS.read]: "paintCanvas.presets.fileReadFailed",
|
|
18
|
+
[PRESET_FILE_ERRORS.export]: "paintCanvas.presets.exportFailed",
|
|
19
|
+
[PRESET_FILE_ERRORS.empty]: "paintCanvas.presets.nothingToExport"
|
|
19
20
|
};
|
|
20
21
|
/** Cursor over a preset that a click deletes (Alt/Option held) */
|
|
21
22
|
var DELETE_CURSOR = svgCursor("M6 6 L18 18 M18 6 L6 18", [12, 12], "not-allowed");
|
|
@@ -129,16 +130,16 @@ var PcBrushMenu = class extends PcElement {
|
|
|
129
130
|
const app = this.app;
|
|
130
131
|
if (!app) return;
|
|
131
132
|
const name = preset.name ?? preset.id;
|
|
132
|
-
if (!this.confirm(this.t("presets.deleteConfirm", { name }))) return;
|
|
133
|
+
if (!this.confirm(this.t("paintCanvas.presets.deleteConfirm", { name }))) return;
|
|
133
134
|
try {
|
|
134
135
|
await app.customPresets.remove(preset.id);
|
|
135
136
|
this.emit("pc-toast", {
|
|
136
|
-
message: this.t("presets.deleted", { name }),
|
|
137
|
+
message: this.t("paintCanvas.presets.deleted", { name }),
|
|
137
138
|
kind: "success"
|
|
138
139
|
});
|
|
139
140
|
} catch {
|
|
140
141
|
this.emit("pc-toast", {
|
|
141
|
-
message: this.t("presets.deleteFailed", { name }),
|
|
142
|
+
message: this.t("paintCanvas.presets.deleteFailed", { name }),
|
|
142
143
|
kind: "error"
|
|
143
144
|
});
|
|
144
145
|
}
|
|
@@ -163,7 +164,7 @@ var PcBrushMenu = class extends PcElement {
|
|
|
163
164
|
const presets = parsePresetFile(text, [app.names.presetFileFormat, BRUSH_PRESET_FILE_FORMAT]);
|
|
164
165
|
await app.customPresets.save(...presets);
|
|
165
166
|
this.emit("pc-toast", {
|
|
166
|
-
message: this.t("presets.imported", { count: presets.length }),
|
|
167
|
+
message: this.t("paintCanvas.presets.imported", { count: presets.length }),
|
|
167
168
|
kind: "success"
|
|
168
169
|
});
|
|
169
170
|
} catch (error) {
|
|
@@ -201,8 +202,8 @@ var PcBrushMenu = class extends PcElement {
|
|
|
201
202
|
* A preset group's heading in the chosen language ("My presets" and "Unknown" are translated; author names aren't).
|
|
202
203
|
*/
|
|
203
204
|
groupLabel(label) {
|
|
204
|
-
if (label === "My presets") return this.t("presets.myPresets");
|
|
205
|
-
if (label === "Unknown") return this.t("presets.unknownAuthor");
|
|
205
|
+
if (label === "My presets") return this.t("paintCanvas.presets.myPresets");
|
|
206
|
+
if (label === "Unknown") return this.t("paintCanvas.presets.unknownAuthor");
|
|
206
207
|
return label;
|
|
207
208
|
}
|
|
208
209
|
/** The brush or eraser settings this menu controls */
|
|
@@ -273,7 +274,7 @@ var PcBrushMenu = class extends PcElement {
|
|
|
273
274
|
render() {
|
|
274
275
|
const settings = this.settings;
|
|
275
276
|
if (!settings) return html``;
|
|
276
|
-
const title = this.t(this.kind === "eraser" ? "tool.eraser" : "tool.brush");
|
|
277
|
+
const title = this.t(this.kind === "eraser" ? "paintCanvas.tool.eraser" : "paintCanvas.tool.brush");
|
|
277
278
|
const presets = Object.values(settings.presets);
|
|
278
279
|
const sizes = previewSizes(presets);
|
|
279
280
|
const app = this.app;
|
|
@@ -294,9 +295,9 @@ var PcBrushMenu = class extends PcElement {
|
|
|
294
295
|
<div
|
|
295
296
|
class="size"
|
|
296
297
|
role="slider"
|
|
297
|
-
aria-label=${this.t("brushMenu.size", { tool: title })}
|
|
298
|
+
aria-label=${this.t("paintCanvas.brushMenu.size", { tool: title })}
|
|
298
299
|
aria-valuenow=${settings.width}
|
|
299
|
-
title=${this.t("brushMenu.dragToResize")}
|
|
300
|
+
title=${this.t("paintCanvas.brushMenu.dragToResize")}
|
|
300
301
|
@pointerdown=${this.onPointerDown}
|
|
301
302
|
@pointermove=${this.onPointerMove}
|
|
302
303
|
@pointerup=${this.onPointerUp}
|
|
@@ -307,7 +308,7 @@ var PcBrushMenu = class extends PcElement {
|
|
|
307
308
|
</div>
|
|
308
309
|
<div
|
|
309
310
|
class="presets"
|
|
310
|
-
aria-label=${this.t("brushMenu.presets", { tool: title })}
|
|
311
|
+
aria-label=${this.t("paintCanvas.brushMenu.presets", { tool: title })}
|
|
311
312
|
>
|
|
312
313
|
${groups.map((group) => html`
|
|
313
314
|
<h3>${this.groupLabel(group.label)}</h3>
|
|
@@ -322,18 +323,18 @@ var PcBrushMenu = class extends PcElement {
|
|
|
322
323
|
class="pill new-preset"
|
|
323
324
|
@click=${() => this.emit("pc-new-preset", this.kind)}
|
|
324
325
|
>
|
|
325
|
-
${this.t("brushMenu.create")}
|
|
326
|
+
${this.t("paintCanvas.brushMenu.create")}
|
|
326
327
|
</button>
|
|
327
328
|
<button
|
|
328
329
|
type="button"
|
|
329
330
|
class="pill import"
|
|
330
331
|
@click=${() => this.renderRoot.querySelector(".import-file")?.click()}
|
|
331
332
|
>
|
|
332
|
-
${this.t("brushMenu.import")}
|
|
333
|
+
${this.t("paintCanvas.brushMenu.import")}
|
|
333
334
|
</button>
|
|
334
335
|
<!-- Chosen through "Import" -->
|
|
335
336
|
<label class="visually-hidden">
|
|
336
|
-
${this.t("brushMenu.importFile")}
|
|
337
|
+
${this.t("paintCanvas.brushMenu.importFile")}
|
|
337
338
|
<input
|
|
338
339
|
type="file"
|
|
339
340
|
class="import-file"
|
|
@@ -352,7 +353,7 @@ var PcBrushMenu = class extends PcElement {
|
|
|
352
353
|
class="pill export"
|
|
353
354
|
@click=${() => void this.exportFile()}
|
|
354
355
|
>
|
|
355
|
-
${this.t("brushMenu.export")}
|
|
356
|
+
${this.t("paintCanvas.brushMenu.export")}
|
|
356
357
|
</button>
|
|
357
358
|
</div>
|
|
358
359
|
`;
|
|
@@ -120,14 +120,14 @@ var PcBrushTest = class extends PcElement {
|
|
|
120
120
|
<canvas
|
|
121
121
|
width=${800}
|
|
122
122
|
height=${320}
|
|
123
|
-
aria-label=${this.t("brushConfig.testArea")}
|
|
123
|
+
aria-label=${this.t("paintCanvas.brushConfig.testArea")}
|
|
124
124
|
@pointerdown=${this.onPointerDown}
|
|
125
125
|
@pointermove=${this.onPointerMove}
|
|
126
126
|
@pointerup=${this.onPointerUp}
|
|
127
127
|
@pointercancel=${this.onPointerUp}
|
|
128
128
|
></canvas>
|
|
129
129
|
<button type="button" class="clear" @click=${() => this.clear()}>
|
|
130
|
-
${this.t("common.clear")}
|
|
130
|
+
${this.t("paintCanvas.common.clear")}
|
|
131
131
|
</button>
|
|
132
132
|
`;
|
|
133
133
|
}
|
|
@@ -981,7 +981,7 @@ var PcCanvas = class extends PcElement {
|
|
|
981
981
|
render() {
|
|
982
982
|
return html`<canvas
|
|
983
983
|
class="scene"
|
|
984
|
-
aria-label=${this.t("canvas.label")}
|
|
984
|
+
aria-label=${this.t("paintCanvas.canvas.label")}
|
|
985
985
|
@pointerdown=${this.onPointerDown}
|
|
986
986
|
@pointermove=${this.onPointerMove}
|
|
987
987
|
@pointerup=${this.onPointerUp}
|
|
@@ -165,7 +165,7 @@ var PcCanvasMap = class extends PcElement {
|
|
|
165
165
|
};
|
|
166
166
|
return html`
|
|
167
167
|
<canvas
|
|
168
|
-
aria-label=${this.t("canvas.map")}
|
|
168
|
+
aria-label=${this.t("paintCanvas.canvas.map")}
|
|
169
169
|
@pointerdown=${this.onPointerDown}
|
|
170
170
|
@pointermove=${this.onPointerMove}
|
|
171
171
|
@pointerup=${() => this.dragging = false}
|
|
@@ -79,7 +79,7 @@ var PcInfoTip = class extends PcElement {
|
|
|
79
79
|
return html`<button
|
|
80
80
|
part="button"
|
|
81
81
|
type="button"
|
|
82
|
-
aria-label=${this.label || this.t("common.moreInformation")}
|
|
82
|
+
aria-label=${this.label || this.t("paintCanvas.common.moreInformation")}
|
|
83
83
|
aria-expanded=${String(this.open)}
|
|
84
84
|
aria-describedby=${this.open ? "tip" : nothing}
|
|
85
85
|
@click=${() => this.open = !this.open}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { PcElement, defineElement, emit } from "../../base/index.js";
|
|
2
2
|
import ChangeController from "../../ChangeController/index.js";
|
|
3
|
+
import { languageName } from "../../../lib/i18n/index.js";
|
|
3
4
|
import { isTouchDevice, zoomModifierName } from "../../../lib/classes/InputSettings/index.js";
|
|
4
5
|
import { GESTURE_ACTIONS, TOUCH_GESTURES, assignGesture } from "../../../lib/utils/gestures/index.js";
|
|
5
6
|
import { css, html, nothing } from "lit";
|
|
6
7
|
// src/ui/elements/PcInputSettings/index.ts
|
|
7
8
|
/** Translation keys of the gesture actions' names */
|
|
8
9
|
var ACTION_KEYS = {
|
|
9
|
-
undo: "common.undo",
|
|
10
|
-
redo: "common.redo",
|
|
11
|
-
copy: "common.copy",
|
|
12
|
-
paste: "common.paste"
|
|
10
|
+
undo: "paintCanvas.common.undo",
|
|
11
|
+
redo: "paintCanvas.common.redo",
|
|
12
|
+
copy: "paintCanvas.common.copy",
|
|
13
|
+
paste: "paintCanvas.common.paste"
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* How the user's input devices control the canvas: scrolling and pinching (with Cmd/Ctrl + scroll to zoom on devices
|
|
@@ -92,7 +93,7 @@ var PcInputSettings = class extends PcElement {
|
|
|
92
93
|
*/
|
|
93
94
|
renderGestures(data) {
|
|
94
95
|
return html`<fieldset part="gestures">
|
|
95
|
-
<legend>${this.t("inputSettings.gestures")}</legend>
|
|
96
|
+
<legend>${this.t("paintCanvas.inputSettings.gestures")}</legend>
|
|
96
97
|
${GESTURE_ACTIONS.map((action) => html`<label for="gesture-${action}"
|
|
97
98
|
>${this.t(ACTION_KEYS[action])}</label
|
|
98
99
|
>
|
|
@@ -105,7 +106,7 @@ var PcInputSettings = class extends PcElement {
|
|
|
105
106
|
value=${gesture}
|
|
106
107
|
?selected=${data.gestures[action] === gesture}
|
|
107
108
|
>
|
|
108
|
-
${this.t(gesture === "off" ? "common.off" : `gesture.${gesture}`)}
|
|
109
|
+
${this.t(gesture === "off" ? "paintCanvas.common.off" : `paintCanvas.gesture.${gesture}`)}
|
|
109
110
|
</option>`)}
|
|
110
111
|
</select>`)}
|
|
111
112
|
</fieldset>`;
|
|
@@ -114,7 +115,9 @@ var PcInputSettings = class extends PcElement {
|
|
|
114
115
|
renderLanguage() {
|
|
115
116
|
const translations = this.translations;
|
|
116
117
|
return html`<fieldset part="language">
|
|
117
|
-
<label for="language"
|
|
118
|
+
<label for="language"
|
|
119
|
+
>${this.t("paintCanvas.inputSettings.language")}</label
|
|
120
|
+
>
|
|
118
121
|
<select
|
|
119
122
|
id="language"
|
|
120
123
|
name="language"
|
|
@@ -125,9 +128,10 @@ var PcInputSettings = class extends PcElement {
|
|
|
125
128
|
>
|
|
126
129
|
${translations.locales.map((locale) => html`<option
|
|
127
130
|
value=${locale}
|
|
131
|
+
lang=${locale}
|
|
128
132
|
?selected=${translations.locale === locale}
|
|
129
133
|
>
|
|
130
|
-
${
|
|
134
|
+
${languageName(locale)}
|
|
131
135
|
</option>`)}
|
|
132
136
|
</select>
|
|
133
137
|
</fieldset>`;
|
|
@@ -136,11 +140,11 @@ var PcInputSettings = class extends PcElement {
|
|
|
136
140
|
const data = this.settings?.data;
|
|
137
141
|
if (!data) return nothing;
|
|
138
142
|
return html`<fieldset part="controls">
|
|
139
|
-
<legend>${this.t("inputSettings.title")}</legend>
|
|
140
|
-
${this.toggle(data, "scrollPan", this.t(this.touch ? "inputSettings.touchPan" : "inputSettings.scrollPan"))}
|
|
141
|
-
${this.toggle(data, "pinchZoom", this.t("inputSettings.pinchZoom"))}
|
|
142
|
-
${this.touch ? nothing : this.toggle(data, "modifierScrollZoom", this.t("inputSettings.modifierScrollZoom", { key: this.modifier }))}
|
|
143
|
-
${this.focusPen ? this.toggle(data, "focusPen", this.t("inputSettings.focusPen")) : nothing}
|
|
143
|
+
<legend>${this.t("paintCanvas.inputSettings.title")}</legend>
|
|
144
|
+
${this.toggle(data, "scrollPan", this.t(this.touch ? "paintCanvas.inputSettings.touchPan" : "paintCanvas.inputSettings.scrollPan"))}
|
|
145
|
+
${this.toggle(data, "pinchZoom", this.t("paintCanvas.inputSettings.pinchZoom"))}
|
|
146
|
+
${this.touch ? nothing : this.toggle(data, "modifierScrollZoom", this.t("paintCanvas.inputSettings.modifierScrollZoom", { key: this.modifier }))}
|
|
147
|
+
${this.focusPen ? this.toggle(data, "focusPen", this.t("paintCanvas.inputSettings.focusPen")) : nothing}
|
|
144
148
|
</fieldset>
|
|
145
149
|
${this.touch ? this.renderGestures(data) : nothing}
|
|
146
150
|
${this.languages ? this.renderLanguage() : nothing}`;
|