Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanchauict committed Dec 18, 2024
1 parent e7749b9 commit a5c2f9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ export const SerializableLineConnectorArraySerializer = {
// @ts-expect-error fromJson is attached by Jsonizable
return value.map(json => SerializableLineConnector.fromJson(json));
},
}
};
/* eslint-enable @typescript-eslint/no-explicit-any */
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('ClipboardObjectTest', () => {
lineId: '1',
anchor: LineAnchor.START,
targetId: '2',
ratio: PointF.create({left: 0, top: 0}),
ratio: PointF.create({ left: 0, top: 0 }),
offset: Point.ZERO,
},
);
Expand Down
16 changes: 8 additions & 8 deletions monosketch-svelte/src/lib/mono/shape/shape-clipboard-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ShapeClipboardManager {
private clipboardShapeMutableFlow: Flow<ClipboardObject> = new Flow(ClipboardObject.create([], []));
public clipboardShapeFlow: Flow<ClipboardObject> = this.clipboardShapeMutableFlow.immutable();

constructor(private body: HTMLElement) {
constructor() {
document.onpaste = (event) => {
event.preventDefault();
event.stopPropagation();
Expand All @@ -48,14 +48,15 @@ export class ShapeClipboardManager {
}

private parseJsonFromString(text: string) {
let json: any = null;
try {
json = JSON.parse(text);
const json = JSON.parse(text);
// Backward compatibility with old clipboard format
return Array.isArray(json) ? { shapes: json, connectors: [] } : json;
} catch (e) {
console.error('Failed to parse JSON from clipboard text', e);
return null;
}
// Backward compatibility with old clipboard format
return Array.isArray(json) ? { shapes: json, connectors: [] } : json;

}

private createTextShapeFromText(text: string): SerializableText {
Expand All @@ -77,8 +78,7 @@ export class ShapeClipboardManager {

public setClipboard(clipboardObject: ClipboardObject) {
// @ts-expect-error toJson is attached by Jsonizable
const json = clipboardObject.toJson();
const text = JSON.stringify(clipboardObject);
const text = JSON.stringify(clipboardObject.toJson());
this.setClipboardText(text);
}

Expand Down Expand Up @@ -120,4 +120,4 @@ export class ClipboardObject {
result.connectors = connectors;
return result;
}
}
}

0 comments on commit a5c2f9a

Please sign in to comment.