@overtone-art/canvas-editor-core 0.6.1 → 0.6.3
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/dist/index.d.mts +64 -4
- package/dist/index.d.ts +64 -4
- package/dist/index.global.js +52 -52
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +279 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -24
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{types-LM7pOkkj.d.mts → types-DSu2jbiV.d.mts} +8 -0
- package/dist/{types-LM7pOkkj.d.ts → types-DSu2jbiV.d.ts} +8 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Canvas, FabricObject, Point, ImageFormat, Group } from 'fabric';
|
|
2
|
-
import { b as EditorEvents, o as LayerType, m as LayerMeta, L as LayerData, X as SerializedLayer, P as PatternConfig, K as PatternLocks, a1 as TextCurveConfig, a2 as TextCurveInput, t as MaskPresetId, Y as ShapeMaskPresetId, a4 as TextureMaskPresetId, a6 as Unit, J as MockupPrintArea, z as MockupConfig, e as FontDefinition, p as LicenseConfig, r as LicenseStatus, T as ProjectState, M as MaskBrushOptions, s as MaskPoint, v as MaskRefinementProvider, u as MaskRefinementPrompt, x as MaskRefinementResult, k as LayerMaskEntry, l as LayerMaskMode, E as EditorConfig, Z as ShapePlugin, $ as TemplateDefinition, I as ImageAdjustments, c as EditorState, V as SemanticExportOptions, _ as SvgExportOptions, R as PrintifyPositioning, N as NormalizedLayerPosition, Q as PositioningAdapter, h as ImageProviderResult, i as ImageSearchOptions, j as ImageSearchResult, F as FileAdapter, g as ImageProvider, W as SerializedBackgroundImageOptions, B as BackgroundImageOptions, U as ResizeOptions, a as DpiIssue, n as LayerShadowConfig, C as CanvasSizePreset, A as MockupDisplacement } from './types-
|
|
3
|
-
export { D as DEFAULT_PATTERN_CONFIG, d as ExportFormat, f as ImageAttribution, q as LicensePayload, w as MaskRefinementRequest, y as MockupBlendMode, G as MockupDisplacementChannel, H as MockupOverlay, O as PatternState, S as ProjectPage, a0 as TemplateParameter, a3 as TextCurveShape, a5 as TileMode } from './types-
|
|
2
|
+
import { b as EditorEvents, o as LayerType, m as LayerMeta, L as LayerData, X as SerializedLayer, P as PatternConfig, K as PatternLocks, a1 as TextCurveConfig, a2 as TextCurveInput, t as MaskPresetId, Y as ShapeMaskPresetId, a4 as TextureMaskPresetId, a6 as Unit, J as MockupPrintArea, z as MockupConfig, e as FontDefinition, p as LicenseConfig, r as LicenseStatus, T as ProjectState, M as MaskBrushOptions, s as MaskPoint, v as MaskRefinementProvider, u as MaskRefinementPrompt, x as MaskRefinementResult, k as LayerMaskEntry, l as LayerMaskMode, E as EditorConfig, Z as ShapePlugin, $ as TemplateDefinition, I as ImageAdjustments, c as EditorState, V as SemanticExportOptions, _ as SvgExportOptions, R as PrintifyPositioning, N as NormalizedLayerPosition, Q as PositioningAdapter, h as ImageProviderResult, i as ImageSearchOptions, j as ImageSearchResult, F as FileAdapter, g as ImageProvider, W as SerializedBackgroundImageOptions, B as BackgroundImageOptions, U as ResizeOptions, a as DpiIssue, n as LayerShadowConfig, C as CanvasSizePreset, A as MockupDisplacement } from './types-DSu2jbiV.mjs';
|
|
3
|
+
export { D as DEFAULT_PATTERN_CONFIG, d as ExportFormat, f as ImageAttribution, q as LicensePayload, w as MaskRefinementRequest, y as MockupBlendMode, G as MockupDisplacementChannel, H as MockupOverlay, O as PatternState, S as ProjectPage, a0 as TemplateParameter, a3 as TextCurveShape, a5 as TileMode } from './types-DSu2jbiV.mjs';
|
|
4
4
|
|
|
5
5
|
type EventHandler<T> = (data: T) => void;
|
|
6
6
|
declare class EventEmitter<TEvents extends {} = Record<string, unknown>> {
|
|
@@ -63,6 +63,14 @@ declare class LayerManager {
|
|
|
63
63
|
* group's matrix must NOT be re-applied on top of it.
|
|
64
64
|
*/
|
|
65
65
|
private dissolve;
|
|
66
|
+
/**
|
|
67
|
+
* Move existing layer records under a group, and announce the new tree.
|
|
68
|
+
* Assigning `group.children` directly emits nothing, and the reorder that
|
|
69
|
+
* follows a grouping is a no-op whenever the group already sits where it
|
|
70
|
+
* belongs — leaving `layers:changed` describing a childless group, so a panel
|
|
71
|
+
* built on it renders the group with nothing inside.
|
|
72
|
+
*/
|
|
73
|
+
adoptChildren(group: Layer, children: Layer[]): void;
|
|
66
74
|
/**
|
|
67
75
|
* Re-attach child records to an enlivened group. `data[i]` describes
|
|
68
76
|
* `group._objects[i]` — the order fabric serializes and restores them in. A
|
|
@@ -368,7 +376,7 @@ declare class TiledPatternObject extends FabricObject {
|
|
|
368
376
|
*/
|
|
369
377
|
clone(): Promise<this>;
|
|
370
378
|
/**
|
|
371
|
-
* The source's tile footprint:
|
|
379
|
+
* The source's tile footprint: the art it paints, minus a stroke it reserves
|
|
372
380
|
* room for but never paints.
|
|
373
381
|
*
|
|
374
382
|
* fabric keeps `strokeWidth` inside an object's box whether or not a `stroke`
|
|
@@ -376,8 +384,18 @@ declare class TiledPatternObject extends FabricObject {
|
|
|
376
384
|
* stroke. Stepping the grid by that box puts a transparent seam between every
|
|
377
385
|
* pair of neighbours at zero spacing: the artwork is a pixel narrower than the
|
|
378
386
|
* box it is stepped by.
|
|
387
|
+
*
|
|
388
|
+
* Text is the same problem an order of magnitude larger — see {@link textInk}.
|
|
379
389
|
*/
|
|
380
390
|
private sourceBox;
|
|
391
|
+
/**
|
|
392
|
+
* Vector from the source's centre to the centre of the art it paints.
|
|
393
|
+
*
|
|
394
|
+
* Zero for everything except text that does not fill its box: the tile has to
|
|
395
|
+
* sit on the glyphs, or the frame the user drags frames empty space and the
|
|
396
|
+
* grid registers off the run by half the padding.
|
|
397
|
+
*/
|
|
398
|
+
private inkOffset;
|
|
381
399
|
/** The source's on-canvas width, before the tile scale. */
|
|
382
400
|
private baseW;
|
|
383
401
|
/** The source's on-canvas height, before the tile scale. */
|
|
@@ -505,7 +523,18 @@ declare class TextCurveManager {
|
|
|
505
523
|
private layers;
|
|
506
524
|
private history;
|
|
507
525
|
private events;
|
|
526
|
+
/**
|
|
527
|
+
* Typing on the canvas changes the run the paths were built for. Fabric drops
|
|
528
|
+
* a glyph whose centre falls past the end of the path, so without rebuilding
|
|
529
|
+
* here a longer replacement simply vanishes — select-all-and-retype rendered
|
|
530
|
+
* an empty box — and a shorter one piles up on a path built for the old text.
|
|
531
|
+
*
|
|
532
|
+
* No history entry: fabric records the edit when editing exits, and one save
|
|
533
|
+
* per keystroke would bury every earlier step under the typing.
|
|
534
|
+
*/
|
|
535
|
+
private readonly onTextChanged;
|
|
508
536
|
constructor(canvas: Canvas, layers: LayerManager, history: HistoryManager, events: EventEmitter<EditorEvents>);
|
|
537
|
+
dispose(): void;
|
|
509
538
|
/** Curve parameters for a layer, or null when it is not curved text. */
|
|
510
539
|
get(layerId: string): TextCurveConfig | null;
|
|
511
540
|
isCurved(layerId: string): boolean;
|
|
@@ -536,6 +565,15 @@ declare class TextCurveManager {
|
|
|
536
565
|
* outside the layer's box — where object caching clips it away.
|
|
537
566
|
*/
|
|
538
567
|
private attach;
|
|
568
|
+
/**
|
|
569
|
+
* Re-apply {@link growBoxToInk} after every one of fabric's own dimension
|
|
570
|
+
* passes. Typing, a font change, a style edit and a state restore all call
|
|
571
|
+
* `initDimensions`, and each one puts the box back to the path's bounding box
|
|
572
|
+
* — so growing it once, here, would hold only until the next keystroke.
|
|
573
|
+
*/
|
|
574
|
+
private patchDimensions;
|
|
575
|
+
/** Restore fabric's own dimension pass, if this manager replaced it. */
|
|
576
|
+
private unpatchDimensions;
|
|
539
577
|
/**
|
|
540
578
|
* Fabric lays every line of a text object along `this.path`, from one
|
|
541
579
|
* `pathStartOffset` — so a multi-line run piles all its lines on top of each
|
|
@@ -1190,6 +1228,28 @@ declare class CanvasEditor {
|
|
|
1190
1228
|
private setupCanvasEvents;
|
|
1191
1229
|
}
|
|
1192
1230
|
|
|
1231
|
+
/**
|
|
1232
|
+
* Fit a text layer's box to the run it holds, leaving the letters where they
|
|
1233
|
+
* were on screen.
|
|
1234
|
+
*
|
|
1235
|
+
* The box becomes **auto-width**: it follows the run in both directions, so
|
|
1236
|
+
* raising the font size or opening up the letter spacing widens the frame
|
|
1237
|
+
* instead of silently breaking the line, and lowering them again takes the width
|
|
1238
|
+
* back — which fabric never does on its own, since `Textbox` only ratchets its
|
|
1239
|
+
* width up and only when a word cannot fit at all.
|
|
1240
|
+
*
|
|
1241
|
+
* Line breaks stay under the author's control through the text itself: the run
|
|
1242
|
+
* is measured per hard newline, so `One\nTwo` stays two lines. What goes away is
|
|
1243
|
+
* *soft* wrapping, which in an editor whose text tool opens at a fixed 200px box
|
|
1244
|
+
* was mostly accidental anyway.
|
|
1245
|
+
*
|
|
1246
|
+
* Curved text is skipped — `TextCurveManager` owns that box and sizes it to the
|
|
1247
|
+
* glyphs along the path, which this would fight.
|
|
1248
|
+
*
|
|
1249
|
+
* Returns whether anything changed, so a caller can skip a history checkpoint.
|
|
1250
|
+
*/
|
|
1251
|
+
declare function fitTextWidth(object: FabricObject | null | undefined): boolean;
|
|
1252
|
+
|
|
1193
1253
|
/**
|
|
1194
1254
|
* A template is a bootstrap, not a frozen picture: it is taken apart into the
|
|
1195
1255
|
* layers it is drawn from, so every run of copy stays editable afterwards.
|
|
@@ -1346,4 +1406,4 @@ declare class AnnotationOverlay {
|
|
|
1346
1406
|
*/
|
|
1347
1407
|
declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
|
|
1348
1408
|
|
|
1349
|
-
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, type CurvePath, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, type TemplateLayerSpec, TextCurveConfig, TextCurveInput, TextCurveManager, TextureMaskPresetId, type TileDrawSize, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurveLinePaths, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, explodeTemplateSvg, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, normalizeTextCurve, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, textPathCurve, textPathSpec, toCanvasSpace, toHostSpace, unwrapGroup };
|
|
1409
|
+
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, type CurvePath, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, type TemplateLayerSpec, TextCurveConfig, TextCurveInput, TextCurveManager, TextureMaskPresetId, type TileDrawSize, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurveLinePaths, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, explodeTemplateSvg, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitTextWidth, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, normalizeTextCurve, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, textPathCurve, textPathSpec, toCanvasSpace, toHostSpace, unwrapGroup };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Canvas, FabricObject, Point, ImageFormat, Group } from 'fabric';
|
|
2
|
-
import { b as EditorEvents, o as LayerType, m as LayerMeta, L as LayerData, X as SerializedLayer, P as PatternConfig, K as PatternLocks, a1 as TextCurveConfig, a2 as TextCurveInput, t as MaskPresetId, Y as ShapeMaskPresetId, a4 as TextureMaskPresetId, a6 as Unit, J as MockupPrintArea, z as MockupConfig, e as FontDefinition, p as LicenseConfig, r as LicenseStatus, T as ProjectState, M as MaskBrushOptions, s as MaskPoint, v as MaskRefinementProvider, u as MaskRefinementPrompt, x as MaskRefinementResult, k as LayerMaskEntry, l as LayerMaskMode, E as EditorConfig, Z as ShapePlugin, $ as TemplateDefinition, I as ImageAdjustments, c as EditorState, V as SemanticExportOptions, _ as SvgExportOptions, R as PrintifyPositioning, N as NormalizedLayerPosition, Q as PositioningAdapter, h as ImageProviderResult, i as ImageSearchOptions, j as ImageSearchResult, F as FileAdapter, g as ImageProvider, W as SerializedBackgroundImageOptions, B as BackgroundImageOptions, U as ResizeOptions, a as DpiIssue, n as LayerShadowConfig, C as CanvasSizePreset, A as MockupDisplacement } from './types-
|
|
3
|
-
export { D as DEFAULT_PATTERN_CONFIG, d as ExportFormat, f as ImageAttribution, q as LicensePayload, w as MaskRefinementRequest, y as MockupBlendMode, G as MockupDisplacementChannel, H as MockupOverlay, O as PatternState, S as ProjectPage, a0 as TemplateParameter, a3 as TextCurveShape, a5 as TileMode } from './types-
|
|
2
|
+
import { b as EditorEvents, o as LayerType, m as LayerMeta, L as LayerData, X as SerializedLayer, P as PatternConfig, K as PatternLocks, a1 as TextCurveConfig, a2 as TextCurveInput, t as MaskPresetId, Y as ShapeMaskPresetId, a4 as TextureMaskPresetId, a6 as Unit, J as MockupPrintArea, z as MockupConfig, e as FontDefinition, p as LicenseConfig, r as LicenseStatus, T as ProjectState, M as MaskBrushOptions, s as MaskPoint, v as MaskRefinementProvider, u as MaskRefinementPrompt, x as MaskRefinementResult, k as LayerMaskEntry, l as LayerMaskMode, E as EditorConfig, Z as ShapePlugin, $ as TemplateDefinition, I as ImageAdjustments, c as EditorState, V as SemanticExportOptions, _ as SvgExportOptions, R as PrintifyPositioning, N as NormalizedLayerPosition, Q as PositioningAdapter, h as ImageProviderResult, i as ImageSearchOptions, j as ImageSearchResult, F as FileAdapter, g as ImageProvider, W as SerializedBackgroundImageOptions, B as BackgroundImageOptions, U as ResizeOptions, a as DpiIssue, n as LayerShadowConfig, C as CanvasSizePreset, A as MockupDisplacement } from './types-DSu2jbiV.js';
|
|
3
|
+
export { D as DEFAULT_PATTERN_CONFIG, d as ExportFormat, f as ImageAttribution, q as LicensePayload, w as MaskRefinementRequest, y as MockupBlendMode, G as MockupDisplacementChannel, H as MockupOverlay, O as PatternState, S as ProjectPage, a0 as TemplateParameter, a3 as TextCurveShape, a5 as TileMode } from './types-DSu2jbiV.js';
|
|
4
4
|
|
|
5
5
|
type EventHandler<T> = (data: T) => void;
|
|
6
6
|
declare class EventEmitter<TEvents extends {} = Record<string, unknown>> {
|
|
@@ -63,6 +63,14 @@ declare class LayerManager {
|
|
|
63
63
|
* group's matrix must NOT be re-applied on top of it.
|
|
64
64
|
*/
|
|
65
65
|
private dissolve;
|
|
66
|
+
/**
|
|
67
|
+
* Move existing layer records under a group, and announce the new tree.
|
|
68
|
+
* Assigning `group.children` directly emits nothing, and the reorder that
|
|
69
|
+
* follows a grouping is a no-op whenever the group already sits where it
|
|
70
|
+
* belongs — leaving `layers:changed` describing a childless group, so a panel
|
|
71
|
+
* built on it renders the group with nothing inside.
|
|
72
|
+
*/
|
|
73
|
+
adoptChildren(group: Layer, children: Layer[]): void;
|
|
66
74
|
/**
|
|
67
75
|
* Re-attach child records to an enlivened group. `data[i]` describes
|
|
68
76
|
* `group._objects[i]` — the order fabric serializes and restores them in. A
|
|
@@ -368,7 +376,7 @@ declare class TiledPatternObject extends FabricObject {
|
|
|
368
376
|
*/
|
|
369
377
|
clone(): Promise<this>;
|
|
370
378
|
/**
|
|
371
|
-
* The source's tile footprint:
|
|
379
|
+
* The source's tile footprint: the art it paints, minus a stroke it reserves
|
|
372
380
|
* room for but never paints.
|
|
373
381
|
*
|
|
374
382
|
* fabric keeps `strokeWidth` inside an object's box whether or not a `stroke`
|
|
@@ -376,8 +384,18 @@ declare class TiledPatternObject extends FabricObject {
|
|
|
376
384
|
* stroke. Stepping the grid by that box puts a transparent seam between every
|
|
377
385
|
* pair of neighbours at zero spacing: the artwork is a pixel narrower than the
|
|
378
386
|
* box it is stepped by.
|
|
387
|
+
*
|
|
388
|
+
* Text is the same problem an order of magnitude larger — see {@link textInk}.
|
|
379
389
|
*/
|
|
380
390
|
private sourceBox;
|
|
391
|
+
/**
|
|
392
|
+
* Vector from the source's centre to the centre of the art it paints.
|
|
393
|
+
*
|
|
394
|
+
* Zero for everything except text that does not fill its box: the tile has to
|
|
395
|
+
* sit on the glyphs, or the frame the user drags frames empty space and the
|
|
396
|
+
* grid registers off the run by half the padding.
|
|
397
|
+
*/
|
|
398
|
+
private inkOffset;
|
|
381
399
|
/** The source's on-canvas width, before the tile scale. */
|
|
382
400
|
private baseW;
|
|
383
401
|
/** The source's on-canvas height, before the tile scale. */
|
|
@@ -505,7 +523,18 @@ declare class TextCurveManager {
|
|
|
505
523
|
private layers;
|
|
506
524
|
private history;
|
|
507
525
|
private events;
|
|
526
|
+
/**
|
|
527
|
+
* Typing on the canvas changes the run the paths were built for. Fabric drops
|
|
528
|
+
* a glyph whose centre falls past the end of the path, so without rebuilding
|
|
529
|
+
* here a longer replacement simply vanishes — select-all-and-retype rendered
|
|
530
|
+
* an empty box — and a shorter one piles up on a path built for the old text.
|
|
531
|
+
*
|
|
532
|
+
* No history entry: fabric records the edit when editing exits, and one save
|
|
533
|
+
* per keystroke would bury every earlier step under the typing.
|
|
534
|
+
*/
|
|
535
|
+
private readonly onTextChanged;
|
|
508
536
|
constructor(canvas: Canvas, layers: LayerManager, history: HistoryManager, events: EventEmitter<EditorEvents>);
|
|
537
|
+
dispose(): void;
|
|
509
538
|
/** Curve parameters for a layer, or null when it is not curved text. */
|
|
510
539
|
get(layerId: string): TextCurveConfig | null;
|
|
511
540
|
isCurved(layerId: string): boolean;
|
|
@@ -536,6 +565,15 @@ declare class TextCurveManager {
|
|
|
536
565
|
* outside the layer's box — where object caching clips it away.
|
|
537
566
|
*/
|
|
538
567
|
private attach;
|
|
568
|
+
/**
|
|
569
|
+
* Re-apply {@link growBoxToInk} after every one of fabric's own dimension
|
|
570
|
+
* passes. Typing, a font change, a style edit and a state restore all call
|
|
571
|
+
* `initDimensions`, and each one puts the box back to the path's bounding box
|
|
572
|
+
* — so growing it once, here, would hold only until the next keystroke.
|
|
573
|
+
*/
|
|
574
|
+
private patchDimensions;
|
|
575
|
+
/** Restore fabric's own dimension pass, if this manager replaced it. */
|
|
576
|
+
private unpatchDimensions;
|
|
539
577
|
/**
|
|
540
578
|
* Fabric lays every line of a text object along `this.path`, from one
|
|
541
579
|
* `pathStartOffset` — so a multi-line run piles all its lines on top of each
|
|
@@ -1190,6 +1228,28 @@ declare class CanvasEditor {
|
|
|
1190
1228
|
private setupCanvasEvents;
|
|
1191
1229
|
}
|
|
1192
1230
|
|
|
1231
|
+
/**
|
|
1232
|
+
* Fit a text layer's box to the run it holds, leaving the letters where they
|
|
1233
|
+
* were on screen.
|
|
1234
|
+
*
|
|
1235
|
+
* The box becomes **auto-width**: it follows the run in both directions, so
|
|
1236
|
+
* raising the font size or opening up the letter spacing widens the frame
|
|
1237
|
+
* instead of silently breaking the line, and lowering them again takes the width
|
|
1238
|
+
* back — which fabric never does on its own, since `Textbox` only ratchets its
|
|
1239
|
+
* width up and only when a word cannot fit at all.
|
|
1240
|
+
*
|
|
1241
|
+
* Line breaks stay under the author's control through the text itself: the run
|
|
1242
|
+
* is measured per hard newline, so `One\nTwo` stays two lines. What goes away is
|
|
1243
|
+
* *soft* wrapping, which in an editor whose text tool opens at a fixed 200px box
|
|
1244
|
+
* was mostly accidental anyway.
|
|
1245
|
+
*
|
|
1246
|
+
* Curved text is skipped — `TextCurveManager` owns that box and sizes it to the
|
|
1247
|
+
* glyphs along the path, which this would fight.
|
|
1248
|
+
*
|
|
1249
|
+
* Returns whether anything changed, so a caller can skip a history checkpoint.
|
|
1250
|
+
*/
|
|
1251
|
+
declare function fitTextWidth(object: FabricObject | null | undefined): boolean;
|
|
1252
|
+
|
|
1193
1253
|
/**
|
|
1194
1254
|
* A template is a bootstrap, not a frozen picture: it is taken apart into the
|
|
1195
1255
|
* layers it is drawn from, so every run of copy stays editable afterwards.
|
|
@@ -1346,4 +1406,4 @@ declare class AnnotationOverlay {
|
|
|
1346
1406
|
*/
|
|
1347
1407
|
declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
|
|
1348
1408
|
|
|
1349
|
-
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, type CurvePath, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, type TemplateLayerSpec, TextCurveConfig, TextCurveInput, TextCurveManager, TextureMaskPresetId, type TileDrawSize, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurveLinePaths, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, explodeTemplateSvg, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, normalizeTextCurve, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, textPathCurve, textPathSpec, toCanvasSpace, toHostSpace, unwrapGroup };
|
|
1409
|
+
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, type CurvePath, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, type TemplateLayerSpec, TextCurveConfig, TextCurveInput, TextCurveManager, TextureMaskPresetId, type TileDrawSize, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurveLinePaths, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, explodeTemplateSvg, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitTextWidth, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, normalizeTextCurve, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, textPathCurve, textPathSpec, toCanvasSpace, toHostSpace, unwrapGroup };
|