mirror of
https://github.com/MultiMote/niimblue
synced 2026-01-19 19:37:11 +03:00
Remove "public" keyword (public by default)
This commit is contained in:
@@ -3,14 +3,14 @@ import { ExportedLabelTemplateSchema, type ExportedLabelTemplate, type LabelProp
|
||||
|
||||
export class FileUtils {
|
||||
/** Convert label template to JSON and download it */
|
||||
public static saveLabelAsJson(canvas: fabric.Canvas, labelProps: LabelProps) {
|
||||
static saveLabelAsJson(canvas: fabric.Canvas, labelProps: LabelProps) {
|
||||
const timestamp = Math.floor(Date.now() / 1000);
|
||||
|
||||
const labelRaw: ExportedLabelTemplate = {
|
||||
canvas: canvas.toJSON(),
|
||||
label: labelProps,
|
||||
};
|
||||
|
||||
|
||||
const label = ExportedLabelTemplateSchema.parse(labelRaw);
|
||||
const json: string = JSON.stringify(label);
|
||||
const link = document.createElement("a");
|
||||
@@ -27,7 +27,7 @@ export class FileUtils {
|
||||
* fixme: never ends if dialog closed
|
||||
*
|
||||
* */
|
||||
public static async pickAndReadTextFile(acceptExtension: string): Promise<string> {
|
||||
static async pickAndReadTextFile(acceptExtension: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const input: HTMLInputElement = document.createElement("input");
|
||||
const reader = new FileReader();
|
||||
|
||||
@@ -16,7 +16,7 @@ export class ImageEditorUtils {
|
||||
// noScaleCache: true,
|
||||
};
|
||||
|
||||
public static addSvg(canvas: fabric.Canvas, svgCode: string): void {
|
||||
static addSvg(canvas: fabric.Canvas, svgCode: string): void {
|
||||
fabric.loadSVGFromString(svgCode, (objects, options) => {
|
||||
const obj = fabric.util.groupSVGElements(objects, options);
|
||||
|
||||
@@ -29,7 +29,7 @@ export class ImageEditorUtils {
|
||||
}
|
||||
|
||||
// todo: return object
|
||||
public static addImageFile(canvas: fabric.Canvas, file: File) {
|
||||
static addImageFile(canvas: fabric.Canvas, file: File) {
|
||||
const reader = new FileReader();
|
||||
|
||||
if (file.type.startsWith("image/svg")) {
|
||||
@@ -76,7 +76,7 @@ export class ImageEditorUtils {
|
||||
input.click();
|
||||
}
|
||||
|
||||
public static addText(canvas: fabric.Canvas, text?: string, options?: ITextOptions): fabric.IText {
|
||||
static addText(canvas: fabric.Canvas, text?: string, options?: ITextOptions): fabric.IText {
|
||||
const obj = new fabric.IText(text ?? "Text", {
|
||||
...this.OBJECT_DEFAULTS,
|
||||
fontFamily: "Noto Sans Variable",
|
||||
@@ -91,7 +91,7 @@ export class ImageEditorUtils {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static addStaticText(canvas: fabric.Canvas, text?: string, options?: TextOptions): fabric.Text {
|
||||
static addStaticText(canvas: fabric.Canvas, text?: string, options?: TextOptions): fabric.Text {
|
||||
const obj = new fabric.Text(text ?? "Text", {
|
||||
...this.OBJECT_DEFAULTS,
|
||||
fontFamily: "Noto Sans Variable",
|
||||
@@ -106,7 +106,7 @@ export class ImageEditorUtils {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static addHLine(canvas: fabric.Canvas): fabric.Line {
|
||||
static addHLine(canvas: fabric.Canvas): fabric.Line {
|
||||
const obj = new fabric.Line([10, 10, 10 + this.SIZE_DEFAULT, 10], {
|
||||
...this.OBJECT_DEFAULTS,
|
||||
stroke: "#000",
|
||||
@@ -125,7 +125,7 @@ export class ImageEditorUtils {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static addCircle(canvas: fabric.Canvas): fabric.Circle {
|
||||
static addCircle(canvas: fabric.Canvas): fabric.Circle {
|
||||
const obj = new fabric.Circle({
|
||||
...this.OBJECT_DEFAULTS,
|
||||
radius: this.SIZE_DEFAULT / 2,
|
||||
@@ -138,7 +138,7 @@ export class ImageEditorUtils {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static addRect(canvas: fabric.Canvas): fabric.Rect {
|
||||
static addRect(canvas: fabric.Canvas): fabric.Rect {
|
||||
const obj = new fabric.Rect({
|
||||
...this.OBJECT_DEFAULTS,
|
||||
width: this.SIZE_DEFAULT,
|
||||
@@ -152,7 +152,7 @@ export class ImageEditorUtils {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static addQrCode(canvas: fabric.Canvas): QRCode {
|
||||
static addQrCode(canvas: fabric.Canvas): QRCode {
|
||||
const qr = new QRCode({
|
||||
text: "NiimBlue",
|
||||
top: this.OBJECT_DEFAULTS.top,
|
||||
@@ -165,7 +165,7 @@ export class ImageEditorUtils {
|
||||
return qr;
|
||||
}
|
||||
|
||||
public static addBarcode(canvas: fabric.Canvas): Barcode {
|
||||
static addBarcode(canvas: fabric.Canvas): Barcode {
|
||||
const barcode = new Barcode({
|
||||
top: this.OBJECT_DEFAULTS.top,
|
||||
left: this.OBJECT_DEFAULTS.left,
|
||||
@@ -179,7 +179,7 @@ export class ImageEditorUtils {
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public static addObject(canvas: fabric.Canvas, objType: OjectType): fabric.Object | undefined {
|
||||
static addObject(canvas: fabric.Canvas, objType: OjectType): fabric.Object | undefined {
|
||||
switch (objType) {
|
||||
case "text":
|
||||
return this.addText(canvas);
|
||||
|
||||
@@ -2,7 +2,7 @@ import Toastify from "toastify-js";
|
||||
import { z } from "zod";
|
||||
|
||||
export class Toasts {
|
||||
public static error(e: any) {
|
||||
static error(e: any) {
|
||||
Toastify({
|
||||
text: `${e}`,
|
||||
gravity: "bottom",
|
||||
@@ -11,7 +11,7 @@ export class Toasts {
|
||||
}).showToast();
|
||||
}
|
||||
|
||||
public static zodErrors(e: any, prefix: string) {
|
||||
static zodErrors(e: any, prefix: string) {
|
||||
if (e instanceof z.ZodError) {
|
||||
console.error(e);
|
||||
e.issues.forEach((i) => {
|
||||
|
||||
Reference in New Issue
Block a user