@polotno/schema 0.8.0 → 0.9.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/lib/defaults.d.ts +3 -2
- package/lib/defaults.js +3 -2
- package/lib/design.schema.json +16 -0
- package/lib/schema.d.ts +4 -0
- package/lib/schema.js +26 -0
- package/lib/types.d.ts +11 -0
- package/package.json +3 -3
package/lib/defaults.d.ts
CHANGED
|
@@ -68,8 +68,9 @@ export declare const TEXT_DEFAULTS: {
|
|
|
68
68
|
* shrink loop walked to `-1px`, html-export emitted an invisible `0px`. Three
|
|
69
69
|
* renderers, three answers, none of them the canvas.
|
|
70
70
|
*
|
|
71
|
-
* @polotno/core's
|
|
72
|
-
*
|
|
71
|
+
* @polotno/core's text-sizing fit stops at it and the editor's model clamps
|
|
72
|
+
* apply it — one rule, stated once. A fit below it could never take effect, so
|
|
73
|
+
* the editor would re-schedule the same fit on every render.
|
|
73
74
|
*/
|
|
74
75
|
export declare const MIN_FONT_SIZE = 1;
|
|
75
76
|
/**
|
package/lib/defaults.js
CHANGED
|
@@ -116,8 +116,9 @@ export const TEXT_DEFAULTS = {
|
|
|
116
116
|
* shrink loop walked to `-1px`, html-export emitted an invisible `0px`. Three
|
|
117
117
|
* renderers, three answers, none of them the canvas.
|
|
118
118
|
*
|
|
119
|
-
* @polotno/core's
|
|
120
|
-
*
|
|
119
|
+
* @polotno/core's text-sizing fit stops at it and the editor's model clamps
|
|
120
|
+
* apply it — one rule, stated once. A fit below it could never take effect, so
|
|
121
|
+
* the editor would re-schedule the same fit on every render.
|
|
121
122
|
*/
|
|
122
123
|
export const MIN_FONT_SIZE = 1;
|
|
123
124
|
/**
|
package/lib/design.schema.json
CHANGED
|
@@ -598,6 +598,22 @@
|
|
|
598
598
|
"legacyBackground": {
|
|
599
599
|
"description": "Internal compatibility flag stamped by the v2→v3 migration.",
|
|
600
600
|
"type": "boolean"
|
|
601
|
+
},
|
|
602
|
+
"textOverflow": {
|
|
603
|
+
"description": "What to do when the text does not fit: 'resize' | 'ellipsis' | 'fit'. Missing (or unknown) follows the global setting.",
|
|
604
|
+
"type": "string"
|
|
605
|
+
},
|
|
606
|
+
"maxLines": {
|
|
607
|
+
"description": "Line cap in every overflow mode; text past it ends in an ellipsis.",
|
|
608
|
+
"type": "number"
|
|
609
|
+
},
|
|
610
|
+
"minFontSize": {
|
|
611
|
+
"description": "Smallest size 'fit' may draw at, in pixels.",
|
|
612
|
+
"type": "number"
|
|
613
|
+
},
|
|
614
|
+
"maxFontSize": {
|
|
615
|
+
"description": "Largest size 'fit' may draw at, in pixels (defaults to fontSize). Above fontSize it grows text to fit.",
|
|
616
|
+
"type": "number"
|
|
601
617
|
}
|
|
602
618
|
},
|
|
603
619
|
"required": [
|
package/lib/schema.d.ts
CHANGED
|
@@ -147,6 +147,10 @@ export declare const leafSchemas: {
|
|
|
147
147
|
curveEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
148
148
|
curvePower: z.ZodDefault<z.ZodNumber>;
|
|
149
149
|
legacyBackground: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
textOverflow: z.ZodOptional<z.ZodString>;
|
|
151
|
+
maxLines: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
minFontSize: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
maxFontSize: z.ZodOptional<z.ZodNumber>;
|
|
150
154
|
id: z.ZodString;
|
|
151
155
|
name: z.ZodDefault<z.ZodString>;
|
|
152
156
|
custom: z.ZodOptional<z.ZodUnknown>;
|
package/lib/schema.js
CHANGED
|
@@ -310,6 +310,32 @@ function build(o) {
|
|
|
310
310
|
.boolean()
|
|
311
311
|
.optional()
|
|
312
312
|
.describe('Internal compatibility flag stamped by the v2→v3 migration.'),
|
|
313
|
+
// Text sizing. All optional with NO default, so existing JSON and every
|
|
314
|
+
// normalizeDesign snapshot stay unchanged; a missing field means "follow
|
|
315
|
+
// the global flag". @polotno/core/text-sizing resolves them.
|
|
316
|
+
//
|
|
317
|
+
// `textOverflow` is a plain string, not an enum, on purpose: the editor's
|
|
318
|
+
// model throws on an enum value it does not know, so a future value would
|
|
319
|
+
// crash an older SDK on load. Unknown values are read as missing.
|
|
320
|
+
textOverflow: z
|
|
321
|
+
.string()
|
|
322
|
+
.optional()
|
|
323
|
+
.describe("What to do when the text does not fit: 'resize' | 'ellipsis' | 'fit'. Missing (or unknown) follows the global setting."),
|
|
324
|
+
maxLines: z
|
|
325
|
+
.number()
|
|
326
|
+
.optional()
|
|
327
|
+
.describe('Line cap in every overflow mode; text past it ends in an ellipsis.'),
|
|
328
|
+
// Absolute px like fontSize, and held to the same floor.
|
|
329
|
+
minFontSize: z
|
|
330
|
+
.number()
|
|
331
|
+
.overwrite(clampFontSize)
|
|
332
|
+
.optional()
|
|
333
|
+
.describe("Smallest size 'fit' may draw at, in pixels."),
|
|
334
|
+
maxFontSize: z
|
|
335
|
+
.number()
|
|
336
|
+
.overwrite(clampFontSize)
|
|
337
|
+
.optional()
|
|
338
|
+
.describe("Largest size 'fit' may draw at, in pixels (defaults to fontSize). Above fontSize it grows text to fit."),
|
|
313
339
|
};
|
|
314
340
|
const imageShape = {
|
|
315
341
|
...shapeBase,
|
package/lib/types.d.ts
CHANGED
|
@@ -209,6 +209,17 @@ export interface TextElement extends ShapeAttributes {
|
|
|
209
209
|
curvePower: number;
|
|
210
210
|
/** Internal compatibility flag stamped by the v2→v3 migration. */
|
|
211
211
|
legacyBackground?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* 'resize' | 'ellipsis' | 'fit'. A plain string so an unknown future value
|
|
214
|
+
* never fails to load; unknown or missing follows the global setting.
|
|
215
|
+
*/
|
|
216
|
+
textOverflow?: string;
|
|
217
|
+
/** Line cap in every overflow mode; text past it ends in an ellipsis. */
|
|
218
|
+
maxLines?: number;
|
|
219
|
+
/** Smallest size 'fit' may draw at, in pixels. */
|
|
220
|
+
minFontSize?: number;
|
|
221
|
+
/** Largest size 'fit' may draw at, in pixels; defaults to fontSize. */
|
|
222
|
+
maxFontSize?: number;
|
|
212
223
|
}
|
|
213
224
|
/** Image-like crop/border properties shared by image, gif, and video. */
|
|
214
225
|
export interface BaseImageProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polotno/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Canonical Polotno design format: types, normalize, validate, JSON Schema. Authored in zod, DOM-free.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "module",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"LICENSE.md"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"zod": "^4.6.
|
|
49
|
+
"zod": "^4.6.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "~6.0.3",
|
|
53
|
-
"vitest": "^5.0.
|
|
53
|
+
"vitest": "^5.0.4"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "rm -rf lib && tsc && node scripts/generate-schema.mjs && node ../../scripts/check-pack.mjs",
|