@polotno/schema 0.7.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 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 `FIT_MIN_FONT_SIZE` (the floor its fit loops converge to) and
72
- * the editor's model clamps both derive from this — one rule, stated once.
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 `FIT_MIN_FONT_SIZE` (the floor its fit loops converge to) and
120
- * the editor's model clamps both derive from this — one rule, stated once.
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
  /**
@@ -575,6 +575,16 @@
575
575
  "description": "Text background padding.",
576
576
  "type": "number"
577
577
  },
578
+ "borderColor": {
579
+ "default": "black",
580
+ "description": "Text box border color.",
581
+ "type": "string"
582
+ },
583
+ "borderSize": {
584
+ "default": 0,
585
+ "description": "Text box border width in pixels.",
586
+ "type": "number"
587
+ },
578
588
  "curveEnabled": {
579
589
  "default": false,
580
590
  "description": "Whether the text curve effect is enabled.",
@@ -588,6 +598,22 @@
588
598
  "legacyBackground": {
589
599
  "description": "Internal compatibility flag stamped by the v2→v3 migration.",
590
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"
591
617
  }
592
618
  },
593
619
  "required": [
package/lib/schema.d.ts CHANGED
@@ -142,9 +142,15 @@ export declare const leafSchemas: {
142
142
  backgroundOpacity: z.ZodDefault<z.ZodNumber>;
143
143
  backgroundCornerRadius: z.ZodDefault<z.ZodNumber>;
144
144
  backgroundPadding: z.ZodDefault<z.ZodNumber>;
145
+ borderColor: z.ZodDefault<z.ZodString>;
146
+ borderSize: z.ZodDefault<z.ZodNumber>;
145
147
  curveEnabled: z.ZodDefault<z.ZodBoolean>;
146
148
  curvePower: z.ZodDefault<z.ZodNumber>;
147
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>;
148
154
  id: z.ZodString;
149
155
  name: z.ZodDefault<z.ZodString>;
150
156
  custom: z.ZodOptional<z.ZodUnknown>;
package/lib/schema.js CHANGED
@@ -293,6 +293,11 @@ function build(o) {
293
293
  .number()
294
294
  .default(0.5)
295
295
  .describe('Text background padding.'),
296
+ borderColor: z.string().default('black').describe('Text box border color.'),
297
+ borderSize: z
298
+ .number()
299
+ .default(0)
300
+ .describe('Text box border width in pixels.'),
296
301
  curveEnabled: z
297
302
  .boolean()
298
303
  .default(TEXT_DEFAULTS.curveEnabled)
@@ -305,6 +310,32 @@ function build(o) {
305
310
  .boolean()
306
311
  .optional()
307
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."),
308
339
  };
309
340
  const imageShape = {
310
341
  ...shapeBase,
package/lib/types.d.ts CHANGED
@@ -203,10 +203,23 @@ export interface TextElement extends ShapeAttributes {
203
203
  backgroundOpacity: number;
204
204
  backgroundCornerRadius: number;
205
205
  backgroundPadding: number;
206
+ borderColor: string;
207
+ borderSize: number;
206
208
  curveEnabled: boolean;
207
209
  curvePower: number;
208
210
  /** Internal compatibility flag stamped by the v2→v3 migration. */
209
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;
210
223
  }
211
224
  /** Image-like crop/border properties shared by image, gif, and video. */
212
225
  export interface BaseImageProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polotno/schema",
3
- "version": "0.7.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.5"
49
+ "zod": "^4.6.7"
50
50
  },
51
51
  "devDependencies": {
52
52
  "typescript": "~6.0.3",
53
- "vitest": "^5.0.1"
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",