@filekit-studio/sketch 0.0.0-stage → 1.1.0
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/LICENSE +21 -0
- package/README.md +250 -2
- package/dist/export.d.mts +1 -0
- package/dist/export.d.ts +1 -0
- package/dist/export.js +91 -0
- package/dist/export.mjs +91 -0
- package/dist/index-DNRZSQHn.d.mts +192 -0
- package/dist/index-DNRZSQHn.d.ts +192 -0
- package/dist/index.d.mts +690 -0
- package/dist/index.d.ts +690 -0
- package/dist/index.js +133 -0
- package/dist/index.mjs +133 -0
- package/dist/styles.css +429 -0
- package/package.json +70 -4
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
type ToolType = 'select' | 'hand' | 'rectangle' | 'ellipse' | 'diamond' | 'triangle' | 'capsule' | 'parallelogram' | 'trapezoid' | 'hexagon' | 'cylinder' | 'cloud' | 'star' | 'table' | 'arrow' | 'line' | 'pen' | 'text' | 'sticky' | 'frame' | 'eraser' | 'laser';
|
|
2
|
+
type LaserMode = 'fading' | 'persistent';
|
|
3
|
+
interface LaserPoint {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
}
|
|
8
|
+
interface LaserStroke {
|
|
9
|
+
id: string;
|
|
10
|
+
points: LaserPoint[];
|
|
11
|
+
color: string;
|
|
12
|
+
mode: LaserMode;
|
|
13
|
+
}
|
|
14
|
+
interface TableCell {
|
|
15
|
+
text: string;
|
|
16
|
+
align?: 'left' | 'center' | 'right';
|
|
17
|
+
fill?: string;
|
|
18
|
+
bold?: boolean;
|
|
19
|
+
color?: string;
|
|
20
|
+
}
|
|
21
|
+
type TablePresetStyle = 'simple' | 'zebra' | 'header-accent' | 'swot' | 'kanban';
|
|
22
|
+
type ElementType = 'rectangle' | 'ellipse' | 'diamond' | 'triangle' | 'capsule' | 'parallelogram' | 'trapezoid' | 'hexagon' | 'cylinder' | 'cloud' | 'star' | 'table' | 'arrow' | 'line' | 'pen' | 'text' | 'sticky' | 'image' | 'frame';
|
|
23
|
+
type FillStyle = 'transparent' | 'solid' | 'hachure' | 'hachure-right' | 'cross-hatch' | 'dots';
|
|
24
|
+
type StrokeStyle = 'solid' | 'dashed' | 'dotted';
|
|
25
|
+
type FontFamily = 'fuzzy' | 'comic' | 'handlee' | 'edusa' | 'sans' | 'mono' | 'patrick' | 'caveat' | 'playpen' | 'serif';
|
|
26
|
+
type TextAlign = 'left' | 'center' | 'right';
|
|
27
|
+
type ArrowType = 'straight' | 'curved' | 'elbow';
|
|
28
|
+
type Arrowhead = 'none' | 'arrow' | 'triangle' | 'barbed' | 'dot' | 'circle' | 'diamond' | 'diamond_outline' | 'bar' | 'crowfoot_one' | 'crowfoot_many' | 'crowfoot_one_many' | 'crowfoot_strictly_one' | 'crowfoot_zero_one' | 'crowfoot_zero_many';
|
|
29
|
+
type EdgeStyle = 'sharp' | 'round';
|
|
30
|
+
type AnchorPosition = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-top' | 'left-bottom' | 'right' | 'right-top' | 'right-bottom' | 'center';
|
|
31
|
+
interface PointBinding {
|
|
32
|
+
elementId: string;
|
|
33
|
+
anchor: AnchorPosition;
|
|
34
|
+
}
|
|
35
|
+
interface Point {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
pressure?: number;
|
|
39
|
+
}
|
|
40
|
+
interface SketchBoardElement {
|
|
41
|
+
id: string;
|
|
42
|
+
type: ElementType;
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
rotation?: number;
|
|
48
|
+
strokeColor: string;
|
|
49
|
+
strokeWidth: number;
|
|
50
|
+
strokeStyle: StrokeStyle;
|
|
51
|
+
fillColor: string;
|
|
52
|
+
fillStyle: FillStyle;
|
|
53
|
+
opacity: number;
|
|
54
|
+
zIndex: number;
|
|
55
|
+
edgeStyle?: EdgeStyle;
|
|
56
|
+
roughStyle?: 'clean' | 'rough';
|
|
57
|
+
roughness?: number;
|
|
58
|
+
points?: Point[];
|
|
59
|
+
arrowType?: ArrowType;
|
|
60
|
+
startArrowhead?: Arrowhead | boolean | null;
|
|
61
|
+
endArrowhead?: Arrowhead | boolean | null;
|
|
62
|
+
startBinding?: PointBinding | null;
|
|
63
|
+
endBinding?: PointBinding | null;
|
|
64
|
+
controlPoint?: Point;
|
|
65
|
+
controlPoint1?: Point;
|
|
66
|
+
controlPoint2?: Point;
|
|
67
|
+
text?: string;
|
|
68
|
+
fontSize?: number;
|
|
69
|
+
fontFamily?: FontFamily;
|
|
70
|
+
textAlign?: TextAlign;
|
|
71
|
+
stickyColor?: string;
|
|
72
|
+
rows?: number;
|
|
73
|
+
cols?: number;
|
|
74
|
+
rowHeights?: number[];
|
|
75
|
+
colWidths?: number[];
|
|
76
|
+
cells?: Record<string, TableCell>;
|
|
77
|
+
hasHeaderRow?: boolean;
|
|
78
|
+
hasHeaderCol?: boolean;
|
|
79
|
+
tableStyle?: TablePresetStyle;
|
|
80
|
+
editingCell?: {
|
|
81
|
+
row: number;
|
|
82
|
+
col: number;
|
|
83
|
+
};
|
|
84
|
+
dataUrl?: string;
|
|
85
|
+
naturalWidth?: number;
|
|
86
|
+
naturalHeight?: number;
|
|
87
|
+
aspectRatioLocked?: boolean;
|
|
88
|
+
frameLabel?: string;
|
|
89
|
+
framePreset?: string;
|
|
90
|
+
frameId?: string;
|
|
91
|
+
groupIds?: string[];
|
|
92
|
+
isLocked?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface Camera {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
zoom: number;
|
|
98
|
+
}
|
|
99
|
+
type GridStyle = 'dots' | 'grid' | 'cross' | 'none';
|
|
100
|
+
interface ResizeHandle {
|
|
101
|
+
type: 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'rotate' | 'start' | 'middle' | 'control1' | 'control2' | 'end';
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
cursor: string;
|
|
105
|
+
}
|
|
106
|
+
interface MarqueeBox {
|
|
107
|
+
startX: number;
|
|
108
|
+
startY: number;
|
|
109
|
+
currentX: number;
|
|
110
|
+
currentY: number;
|
|
111
|
+
}
|
|
112
|
+
interface CanvasDimensions {
|
|
113
|
+
width: number;
|
|
114
|
+
height: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare function isDarkColor(color: string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Calculate the overall bounding box of all elements
|
|
120
|
+
*/
|
|
121
|
+
declare function getElementsBoundingBox(elements: SketchBoardElement[], padding?: number): {
|
|
122
|
+
minX: number;
|
|
123
|
+
minY: number;
|
|
124
|
+
maxX: number;
|
|
125
|
+
maxY: number;
|
|
126
|
+
width: number;
|
|
127
|
+
height: number;
|
|
128
|
+
};
|
|
129
|
+
interface ExportOptions {
|
|
130
|
+
scale?: number;
|
|
131
|
+
backgroundColor?: string;
|
|
132
|
+
gridStyle?: GridStyle;
|
|
133
|
+
padding?: number;
|
|
134
|
+
isDark?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Export elements to PNG blob / data URL
|
|
138
|
+
*/
|
|
139
|
+
declare function exportToPng(elements: SketchBoardElement[], options?: ExportOptions): Promise<string>;
|
|
140
|
+
/**
|
|
141
|
+
* Export elements as SVG markup string
|
|
142
|
+
*/
|
|
143
|
+
declare function exportToSvg(elements: SketchBoardElement[], options?: ExportOptions): string;
|
|
144
|
+
/**
|
|
145
|
+
* Trigger file download helper
|
|
146
|
+
*/
|
|
147
|
+
declare function downloadFile(content: string, filename: string, mimeType: string): void;
|
|
148
|
+
/**
|
|
149
|
+
* Copy exported PNG to system clipboard via navigator.clipboard.write
|
|
150
|
+
*/
|
|
151
|
+
declare function copyImageToClipboard(elements: SketchBoardElement[], options?: {
|
|
152
|
+
scale?: number;
|
|
153
|
+
backgroundColor?: string;
|
|
154
|
+
padding?: number;
|
|
155
|
+
}): Promise<boolean>;
|
|
156
|
+
/**
|
|
157
|
+
* Get all elements contained inside a specific frame
|
|
158
|
+
*/
|
|
159
|
+
declare function getFrameContainedElements(frame: SketchBoardElement, allElements: SketchBoardElement[]): SketchBoardElement[];
|
|
160
|
+
/**
|
|
161
|
+
* Export an individual frame with exact clipping
|
|
162
|
+
*/
|
|
163
|
+
declare function exportFrameToPng(frame: SketchBoardElement, allElements: SketchBoardElement[], options?: ExportOptions): Promise<string>;
|
|
164
|
+
|
|
165
|
+
type PdfOrientation = 'portrait' | 'landscape';
|
|
166
|
+
type PdfAppearance = 'original' | 'light' | 'dark';
|
|
167
|
+
|
|
168
|
+
interface ExportPdfOptions {
|
|
169
|
+
orientation?: PdfOrientation;
|
|
170
|
+
appearance?: PdfAppearance;
|
|
171
|
+
margin?: number;
|
|
172
|
+
boardName?: string;
|
|
173
|
+
canvasBackground?: string;
|
|
174
|
+
isDark?: boolean;
|
|
175
|
+
isSelection?: boolean;
|
|
176
|
+
onProgress?: (current: number, total: number) => void;
|
|
177
|
+
}
|
|
178
|
+
interface ExportPdfResult {
|
|
179
|
+
success: boolean;
|
|
180
|
+
pageCount: number;
|
|
181
|
+
filename: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Preload all image elements asynchronously before offscreen rendering
|
|
185
|
+
*/
|
|
186
|
+
declare function preloadImageElements(elements: SketchBoardElement[]): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Exports whiteboard elements to a paginated A4 PDF
|
|
189
|
+
*/
|
|
190
|
+
declare function exportWhiteboardToPdf(elements: SketchBoardElement[], options?: ExportPdfOptions): Promise<ExportPdfResult>;
|
|
191
|
+
|
|
192
|
+
export { type AnchorPosition as A, type Camera as C, type EdgeStyle as E, type FillStyle as F, type GridStyle as G, type LaserMode as L, type MarqueeBox as M, type Point as P, type ResizeHandle as R, type SketchBoardElement as S, type ToolType as T, type LaserStroke as a, type ArrowType as b, type Arrowhead as c, type CanvasDimensions as d, type ElementType as e, type ExportPdfOptions as f, type ExportPdfResult as g, type FontFamily as h, type LaserPoint as i, type PointBinding as j, type StrokeStyle as k, type TableCell as l, type TablePresetStyle as m, type TextAlign as n, copyImageToClipboard as o, downloadFile as p, exportFrameToPng as q, exportToPng as r, exportToSvg as s, exportWhiteboardToPdf as t, getElementsBoundingBox as u, type PdfAppearance as v, type PdfOrientation as w, getFrameContainedElements as x, isDarkColor as y, preloadImageElements as z };
|