@yuzhouu/canvas-kit 0.1.4 → 0.1.6
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/_vendor/canvas-core/editor/editor.d.ts +8 -1
- package/_vendor/canvas-core/editor/managers/interactionTransientManager.d.ts +7 -1
- package/_vendor/canvas-core/editor/managers/shapeHierarchyManager.d.ts +3 -0
- package/_vendor/canvas-core/editor/managers/spatialIndexManager.d.ts +1 -0
- package/_vendor/canvas-core/editor/selection.d.ts +4 -0
- package/_vendor/canvas-core/editor/selectionBindingSegments.d.ts +7 -0
- package/_vendor/canvas-core/editor/selectionOverlay.d.ts +0 -1
- package/_vendor/canvas-core/index.d.ts +2 -2
- package/_vendor/canvas-core/reactivity.d.ts +3 -1
- package/_vendor/canvas-core/shapes/shapeUtil.d.ts +7 -2
- package/_vendor/canvas-react/components/ShapeLayer.d.ts +1 -4
- package/_vendor/canvas-react/components/overlays/BindingGuide.d.ts +1 -1
- package/_vendor/canvas-react/components/overlays/SelectionPathOverlay.d.ts +7 -0
- package/_vendor/canvas-react/components/overlays/TerminalBindingGuidesOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/useCanvasDomEvents.d.ts +1 -2
- package/_vendor/plugin-arrow/arrowBindingTargets.d.ts +3 -0
- package/_vendor/plugin-arrow/arrowBindingUtil.d.ts +1 -1
- package/_vendor/plugin-draw/drawShapeUtil.d.ts +1 -0
- package/_vendor/plugin-frame/frameShapeUtil.d.ts +2 -0
- package/_vendor/plugin-geo/geoShapeUtil.d.ts +1 -0
- package/_vendor/plugin-geo/geoTools.d.ts +1 -0
- package/_vendor/plugin-group/groupShapeUtil.d.ts +2 -1
- package/_vendor/plugin-image/imageShapeUtil.d.ts +1 -0
- package/_vendor/plugin-text/canvas.d.ts +4 -1
- package/_vendor/plugin-text/editor.d.ts +4 -1
- package/_vendor/plugin-text/feature.d.ts +3 -2
- package/_vendor/plugin-text/host/RichTextEditingBox.d.ts +3 -1
- package/_vendor/plugin-text/host/TiptapTextEditor.d.ts +3 -1
- package/_vendor/plugin-text/host/textEditingBoxStyle.d.ts +2 -1
- package/_vendor/plugin-text/host/textFontLoader.d.ts +2 -1
- package/_vendor/plugin-text/host/textMeasurement.d.ts +4 -3
- package/_vendor/plugin-text/host/textMeasurementSync.d.ts +2 -1
- package/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +2 -1
- package/_vendor/plugin-text/host/textShapeSync.d.ts +3 -1
- package/_vendor/plugin-text/host/tiptapTextEditorController.d.ts +3 -1
- package/_vendor/plugin-text/index.d.ts +2 -0
- package/_vendor/plugin-text/textFonts.d.ts +46 -0
- package/_vendor/plugin-text/textShapeSvgExporter.d.ts +3 -0
- package/_vendor/plugin-text/textShapeUtil.d.ts +1 -0
- package/_vendor/plugin-text/textStyle.d.ts +11 -2
- package/_vendor/plugin-text/textTypes.d.ts +2 -2
- package/builtins/controller/shapeCreationController.d.ts +2 -0
- package/builtins/extensions.d.ts +5 -2
- package/chrome/bindings/useCanvasKitLayerTree.d.ts +5 -0
- package/chrome/types.d.ts +5 -1
- package/chrome/useCanvasKitChromeContext.d.ts +1 -1
- package/controller/canvasKitController.d.ts +1 -1
- package/core/controller/canvasProductController.d.ts +10 -1
- package/core/controller/index.d.ts +1 -1
- package/core/index.d.ts +1 -0
- package/index.d.ts +5 -1
- package/index.mjs +74 -66
- package/package.json +1 -1
- package/product/canvasKitProduct.d.ts +2 -11
|
@@ -41,7 +41,7 @@ import type { DuplicateSelectionInput, EditorClipboardPayload, PasteClipboardPay
|
|
|
41
41
|
import { InteractionHandlerRegistry } from "./interactions";
|
|
42
42
|
import { SelectionHandleInteractionRegistry } from "./selectionHandleInteractions";
|
|
43
43
|
import { type SelectedShapeOverlayItem } from "./selectionOverlay";
|
|
44
|
-
import type { BindingPreviewState, SnapIndicatorState, SelectionBindingSegment, SelectionHandle, SelectionFrame, SelectionOverlayFrameState, SelectionOverlayFrameGeometryState, SelectionOverlayFrameStyleState, SelectionOverlayHandleAnchorsState, SelectionOverlayHandleCountsState, SelectionOverlayHandlesState, SelectionOverlayState } from "./selection";
|
|
44
|
+
import type { BindingPreviewState, SnapIndicatorState, SelectionBindingSegment, TerminalBindingGuideState, SelectionHandle, SelectionFrame, SelectionOverlayFrameState, SelectionOverlayFrameGeometryState, SelectionOverlayFrameStyleState, SelectionOverlayHandleAnchorsState, SelectionOverlayHandleCountsState, SelectionOverlayHandlesState, SelectionOverlayState } from "./selection";
|
|
45
45
|
export interface EditorOptions {
|
|
46
46
|
shapeUtils?: ShapeUtil[];
|
|
47
47
|
shapeSvgExporters?: ShapeSvgExporter[];
|
|
@@ -213,7 +213,9 @@ export declare class Editor {
|
|
|
213
213
|
readonly laserTrailActiveSignal: Signal<boolean>;
|
|
214
214
|
readonly bindingPreviewSignal: Signal<BindingPreviewState | null>;
|
|
215
215
|
readonly bindingPreviewActiveSignal: Signal<boolean>;
|
|
216
|
+
readonly terminalBindingGuidesSignal: Signal<TerminalBindingGuideState[]>;
|
|
216
217
|
readonly dropTargetShapeIdSignal: Signal<ShapeId | null>;
|
|
218
|
+
readonly hoveredShapeIdSignal: Signal<ShapeId | null>;
|
|
217
219
|
readonly selectionTranslationActiveSignal: Signal<boolean>;
|
|
218
220
|
readonly snapIndicatorsSignal: Signal<SnapIndicatorState[]>;
|
|
219
221
|
readonly snapIndicatorsActiveSignal: Signal<boolean>;
|
|
@@ -249,6 +251,7 @@ export declare class Editor {
|
|
|
249
251
|
readonly shapeEditingStateSignal: import("../../signals/index").Computed<EditorShapeEditingState>;
|
|
250
252
|
readonly currentCameraSignal: import("../../signals/index").Computed<Camera>;
|
|
251
253
|
readonly selectedShapeIdsSignal: import("../../signals/index").Computed<`shape:${string}`[]>;
|
|
254
|
+
readonly selectionCountSignal: import("../../signals/index").Computed<number>;
|
|
252
255
|
readonly selectedShapeIdSetSignal: import("../../signals/index").Computed<Set<`shape:${string}`>>;
|
|
253
256
|
readonly selectedShapesSignal: import("../../signals/index").Computed<ShapeRecord[]>;
|
|
254
257
|
readonly selectedShapeOverlayItemsSignal: import("../../signals/index").Computed<SelectedShapeOverlayItem[]>;
|
|
@@ -272,6 +275,7 @@ export declare class Editor {
|
|
|
272
275
|
private readonly shapeDocumentVisibleSignals;
|
|
273
276
|
private readonly shapeEditingSessionSignals;
|
|
274
277
|
private readonly shapeDropTargetSignals;
|
|
278
|
+
private readonly shapeHoveredSignals;
|
|
275
279
|
private readonly shapeErasingSignals;
|
|
276
280
|
private readonly shapeSelectedDescendantTransformAncestorSignals;
|
|
277
281
|
private lastPointerDownForClickCount;
|
|
@@ -390,6 +394,7 @@ export declare class Editor {
|
|
|
390
394
|
getShapeDocumentVisibleSignal(id: ShapeId): Signal<boolean>;
|
|
391
395
|
getShapeEditingSessionForShapeSignal(id: ShapeId): Signal<ShapeEditingSession | null>;
|
|
392
396
|
getShapeDropTargetSignal(id: ShapeId): Signal<boolean>;
|
|
397
|
+
getShapeHoveredSignal(id: ShapeId): Signal<boolean>;
|
|
393
398
|
getShapeErasingSignal(id: ShapeId): Signal<boolean>;
|
|
394
399
|
getShapeSelectedDescendantTransformAncestorSignal(id: ShapeId): Signal<boolean>;
|
|
395
400
|
getBinding(id: BindingId): BindingRecord | undefined;
|
|
@@ -464,7 +469,9 @@ export declare class Editor {
|
|
|
464
469
|
finishLaserTrail(sessionId: number): void;
|
|
465
470
|
clearLaserTrail(sessionId: number): void;
|
|
466
471
|
setBindingPreview(preview: BindingPreviewState | null): void;
|
|
472
|
+
setTerminalBindingGuides(guides: readonly TerminalBindingGuideState[] | null): void;
|
|
467
473
|
setDropTargetShapeId(shapeId: ShapeId | null): void;
|
|
474
|
+
setHoveredShapeId(shapeId: ShapeId | null): void;
|
|
468
475
|
setSelectionTranslationActive(active: boolean): void;
|
|
469
476
|
setSnapIndicators(indicators: SnapIndicatorState[] | null): void;
|
|
470
477
|
setTerminalBindingResolver(resolver: TerminalBindingResolver): void;
|
|
@@ -4,7 +4,7 @@ import type { Box } from "../../geometry/box";
|
|
|
4
4
|
import type { Vec } from "../../geometry/vec";
|
|
5
5
|
import type { ShapeId } from "../../schema/records";
|
|
6
6
|
import type { Editor } from "../editor";
|
|
7
|
-
import type { BindingPreviewState, SnapIndicatorState } from "../selection";
|
|
7
|
+
import type { BindingPreviewState, SnapIndicatorState, TerminalBindingGuideState } from "../selection";
|
|
8
8
|
export interface LaserTrailState {
|
|
9
9
|
sessionId: number;
|
|
10
10
|
phase: "active" | "ending";
|
|
@@ -28,8 +28,12 @@ export declare class InteractionTransientManager {
|
|
|
28
28
|
private readonly _bindingPreviewSignal;
|
|
29
29
|
readonly bindingPreviewSignal: Signal<BindingPreviewState | null>;
|
|
30
30
|
readonly bindingPreviewActiveSignal: import("../../../signals/index").Computed<boolean>;
|
|
31
|
+
private readonly _terminalBindingGuidesSignal;
|
|
32
|
+
readonly terminalBindingGuidesSignal: Signal<TerminalBindingGuideState[]>;
|
|
31
33
|
private readonly _dropTargetShapeIdSignal;
|
|
32
34
|
readonly dropTargetShapeIdSignal: Signal<ShapeId | null>;
|
|
35
|
+
private readonly _hoveredShapeIdSignal;
|
|
36
|
+
readonly hoveredShapeIdSignal: Signal<ShapeId | null>;
|
|
33
37
|
private readonly _selectionTranslationActiveSignal;
|
|
34
38
|
readonly selectionTranslationActiveSignal: Signal<boolean>;
|
|
35
39
|
private terminalBindingResolver;
|
|
@@ -46,7 +50,9 @@ export declare class InteractionTransientManager {
|
|
|
46
50
|
finishLaserTrail(sessionId: number): void;
|
|
47
51
|
clearLaserTrail(sessionId: number): void;
|
|
48
52
|
setBindingPreview(preview: BindingPreviewState | null): void;
|
|
53
|
+
setTerminalBindingGuides(guides: readonly TerminalBindingGuideState[] | null): void;
|
|
49
54
|
setDropTargetShapeId(shapeId: ShapeId | null): void;
|
|
55
|
+
setHoveredShapeId(shapeId: ShapeId | null): void;
|
|
50
56
|
setSelectionTranslationActive(active: boolean): void;
|
|
51
57
|
setSnapIndicators(indicators: SnapIndicatorState[] | null): void;
|
|
52
58
|
setTerminalBindingResolver(resolver: TerminalBindingResolver): void;
|
|
@@ -27,6 +27,9 @@ export declare class ShapeHierarchyManager {
|
|
|
27
27
|
canUngroupShapes(ids: readonly ShapeId[]): boolean;
|
|
28
28
|
ungroupShapes(ids: readonly ShapeId[], source?: ChangeSource): ShapeId[];
|
|
29
29
|
ungroupSelection(source?: ChangeSource): ShapeId[];
|
|
30
|
+
private getOutermostUngroupableShapeIds;
|
|
31
|
+
private isShapeDescendantOfAny;
|
|
32
|
+
private removeUngroupedContainerShapes;
|
|
30
33
|
getSelectionSiblingOrderState(): ShapeSiblingOrderState | null;
|
|
31
34
|
canMoveSelectionWithinParent(direction: ShapeSiblingOrderDirection): boolean;
|
|
32
35
|
canMoveSelectionInParentOrder(direction: ShapeSiblingOrderDirection): boolean;
|
|
@@ -8,6 +8,7 @@ export interface SpatialQueryOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export interface ShapeAtPointOptions extends SpatialQueryOptions {
|
|
10
10
|
filter?: (shape: ShapeRecord) => boolean;
|
|
11
|
+
hitTest?: "point" | "bindingTarget";
|
|
11
12
|
}
|
|
12
13
|
export interface ShapeLineSegmentHitTestOptions extends SpatialQueryOptions {
|
|
13
14
|
margin?: number;
|
|
@@ -118,6 +118,10 @@ export interface SelectionBindingSegment {
|
|
|
118
118
|
boundaryPagePoint: Vec;
|
|
119
119
|
guidePath?: string | null;
|
|
120
120
|
}
|
|
121
|
+
export interface TerminalBindingGuideState extends SelectionBindingSegment {
|
|
122
|
+
ownerShapeId: ShapeId;
|
|
123
|
+
targetShapeId?: ShapeId | null;
|
|
124
|
+
}
|
|
121
125
|
export interface PointSnapIndicatorState {
|
|
122
126
|
id: string;
|
|
123
127
|
type: "points";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SelectionBindingSegment, TerminalBindingGuideState } from "./selection";
|
|
2
|
+
export declare function cloneSelectionBindingSegment<T extends SelectionBindingSegment>(segment: T): T;
|
|
3
|
+
export declare function cloneSelectionBindingSegments<T extends SelectionBindingSegment>(segments: readonly T[]): T[];
|
|
4
|
+
export declare function areSelectionBindingSegmentsEqual(a: SelectionBindingSegment, b: SelectionBindingSegment): boolean;
|
|
5
|
+
export declare function areSelectionBindingSegmentArraysEqual(a: readonly SelectionBindingSegment[], b: readonly SelectionBindingSegment[]): boolean;
|
|
6
|
+
export declare function areTerminalBindingGuideStatesEqual(a: TerminalBindingGuideState, b: TerminalBindingGuideState): boolean;
|
|
7
|
+
export declare function areTerminalBindingGuideStateArraysEqual(a: readonly TerminalBindingGuideState[], b: readonly TerminalBindingGuideState[]): boolean;
|
|
@@ -18,7 +18,6 @@ export interface SelectionHandleState {
|
|
|
18
18
|
middleHandles: SelectionBindingMiddleHandle[];
|
|
19
19
|
customHandles: SelectionCustomHandle[];
|
|
20
20
|
}
|
|
21
|
-
export declare function areSelectionBindingSegmentArraysEqual(a: readonly SelectionBindingSegment[], b: readonly SelectionBindingSegment[]): boolean;
|
|
22
21
|
export declare function areSelectedShapeOverlayItemsEqual(a: SelectedShapeOverlayItem[], b: SelectedShapeOverlayItem[]): boolean;
|
|
23
22
|
export declare function areSelectionOverlayFrameStatesEqual(a: SelectionOverlayFrameState | null, b: SelectionOverlayFrameState | null): boolean;
|
|
24
23
|
export declare function areSelectionOverlayFrameGeometryStatesEqual(a: SelectionOverlayFrameGeometryState | null, b: SelectionOverlayFrameGeometryState | null): boolean;
|
|
@@ -3,7 +3,7 @@ export { createEditorWithPlugins, type CreateEditorWithPluginsOptions, } from ".
|
|
|
3
3
|
export { distanceBetweenSegments, distanceToSegment, nearestPointOnSegment, segmentsIntersect, } from "./geometry";
|
|
4
4
|
export { getShapeGeometry, getShapeExportBounds, getShapeExportPageBounds, getShapeExportToPageTransform, getShapeLocalBounds, getShapeLocalToPageTransform, getShapePositionedOutlineVertices, getShapePositionedToPageTransform, getShapePageBounds, getShapePageCenter, getShapePageCorners, getShapePageOutlineVertices, pagePointToShapePositionedPoint, positionedShapePointToPagePoint, getShapeRenderBounds, getShapeRenderToPageTransform, } from "./editor/queries/shapeTransforms";
|
|
5
5
|
export type { ShapeGeometry } from "./editor/queries/shapeTransforms";
|
|
6
|
-
export type { BindingPreviewState, GapSnapIndicatorGapState, GapSnapIndicatorState, PointSnapIndicatorState, SnapIndicatorState, SelectionBindingSegment, SelectionBindingMiddleHandle, SelectionBindingMiddleHandleAnchor, SelectionBindingTerminalHandle, SelectionBindingTerminalHandleAnchor, SelectionCustomHandle, SelectionCustomHandleAnchor, SelectionHandle, SelectionOverlayFrameState, SelectionOverlayFrameGeometryState, SelectionOverlayFrameStyleState, SelectionOverlayHandleAnchorsState, SelectionOverlayHandleCountsState, SelectionOverlayHandlesState, SelectionOverlayState, SelectionResizeHandle, SelectionResizeHandleAnchor, SelectionResizeHandleId, SelectionRotateHandle, SelectionRotateHandleAnchor, SelectionRotateHandleId, SelectionMirrorAxis, } from "./editor/selection";
|
|
6
|
+
export type { BindingPreviewState, GapSnapIndicatorGapState, GapSnapIndicatorState, PointSnapIndicatorState, SnapIndicatorState, SelectionBindingSegment, TerminalBindingGuideState, SelectionBindingMiddleHandle, SelectionBindingMiddleHandleAnchor, SelectionBindingTerminalHandle, SelectionBindingTerminalHandleAnchor, SelectionCustomHandle, SelectionCustomHandleAnchor, SelectionHandle, SelectionOverlayFrameState, SelectionOverlayFrameGeometryState, SelectionOverlayFrameStyleState, SelectionOverlayHandleAnchorsState, SelectionOverlayHandleCountsState, SelectionOverlayHandlesState, SelectionOverlayState, SelectionResizeHandle, SelectionResizeHandleAnchor, SelectionResizeHandleId, SelectionRotateHandle, SelectionRotateHandleAnchor, SelectionRotateHandleId, SelectionMirrorAxis, } from "./editor/selection";
|
|
7
7
|
export { flipSelectionLocalBounds, getSelectionLocalBoundsFromPagePoints, mapSelectionLocalBoundsBetweenBounds, mapSelectionLocalPointBetweenBounds, mirrorSelectionLocalPoint, rotateSelectionPagePoint, selectionLocalPointToPagePoint, selectionPagePointToLocalPoint, } from "./editor/selection";
|
|
8
8
|
export { getAnchoredSelectionResizeLocalBounds, getAspectRatioLockedSelectionResizeBounds, getCenteredSelectionResizeBounds, getConstrainedSelectionResizeBounds, getSelectionResizeBounds, getSelectionResizeScalesFromBounds, isSelectionResizeCorner, normalizeSelectionResizeBoundsFromEdges, selectionResizeHandleMovesBottomEdge, selectionResizeHandleMovesLeftEdge, selectionResizeHandleMovesRightEdge, selectionResizeHandleMovesTopEdge, } from "./editor/resizeGeometry";
|
|
9
9
|
export { InteractionHandlerRegistry } from "./editor/interactions";
|
|
@@ -26,7 +26,7 @@ export type { DocumentSnapshot, SessionSnapshot, SnapshotMigration, } from "./sc
|
|
|
26
26
|
export { createDocumentSnapshotSupport, filterDocumentSnapshotBySupport, getDocumentSnapshotRequirements, getUnsupportedDocumentSnapshotRequirements, } from "./schema/snapshotSupport";
|
|
27
27
|
export type { DocumentSnapshotRequirements, DocumentSnapshotSupport, FilterDocumentSnapshotBySupportResult, UnsupportedDocumentSnapshotRequirements, } from "./schema/snapshotSupport";
|
|
28
28
|
export { ShapeUtil } from "./shapes/shapeUtil";
|
|
29
|
-
export type { ShapeBoundsSnapGeometry, ShapeBrushSelectInput, ShapeBrushWrapInput, ShapeBindingPointInput, ShapeEditEndResult, ShapeGeometryInput, ShapeHandleSnapContext, ShapeHandleSnapGeometry, ShapeLineSegmentHitTestInput, ShapePointHitTestInput, ShapeSelectionHandleAnchorInput, ShapeSelectionHandleAnchors, ShapeSelectionFrameInput, ShapeSelectionFlipAxis, ShapeSelectionFlipInput, ShapeSelectionOverlayInfo, ShapeSelectionOverlayInfoInput, ShapeSelectionPagePoints, ShapeSelectionPagePointsInput, ShapeSelectionResizeAspectRatioLockInput, ShapeSelectionResizeInput, ShapeSelectionTranslateInput, } from "./shapes/shapeUtil";
|
|
29
|
+
export type { ShapeBoundsSnapGeometry, ShapeBrushSelectInput, ShapeBrushWrapInput, ShapeBindingPointInput, ShapeBindingTargetHitTestInput, ShapeEditEndResult, ShapeGeometryInput, ShapeHandleSnapContext, ShapeHandleSnapGeometry, ShapeLineSegmentHitTestInput, ShapePointHitTestInput, ShapeSelectionHandleAnchorInput, ShapeSelectionHandleAnchors, ShapeSelectionFrameInput, ShapeSelectionFlipAxis, ShapeSelectionFlipInput, ShapeSelectionOverlayInfo, ShapeSelectionOverlayInfoInput, ShapeSelectionPagePoints, ShapeSelectionPagePointsInput, ShapeSelectionResizeAspectRatioLockInput, ShapeSelectionResizeInput, ShapeSelectionTranslateInput, } from "./shapes/shapeUtil";
|
|
30
30
|
export type { LaserTrailState } from "./editor/managers/interactionTransientManager";
|
|
31
31
|
export type { HandleSnapContext, HandleSnapInput, HandleSnapMode, HandleSnapResult, HandleSnapSnapshot, HandleSnapSnapshotInput, ResizeSnapInput, ResizeSnapResult, ResizeSnapSnapshot, SnapAxis, SnapCoordinateSpace, TranslateSnapInput, TranslateSnapResult, TranslateSnapSnapshot, } from "./editor/managers/snapTypes";
|
|
32
32
|
export { ShapeUtilRegistry } from "./shapes/shapeUtilRegistry";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export interface ReadonlyValue<T> {
|
|
2
2
|
get(): T;
|
|
3
3
|
}
|
|
4
|
-
export declare function observeValue<T>(name: string, value: ReadonlyValue<T>, onChange: () => void
|
|
4
|
+
export declare function observeValue<T>(name: string, value: ReadonlyValue<T>, onChange: () => void, options?: {
|
|
5
|
+
fireImmediately?: boolean;
|
|
6
|
+
}): () => void;
|
|
@@ -63,6 +63,8 @@ export interface ShapePointHitTestInput extends ShapeGeometryInput {
|
|
|
63
63
|
pagePoint: Vec;
|
|
64
64
|
positionedPoint: Vec;
|
|
65
65
|
}
|
|
66
|
+
export interface ShapeBindingTargetHitTestInput extends ShapePointHitTestInput {
|
|
67
|
+
}
|
|
66
68
|
export interface ShapeBoundsSnapGeometry {
|
|
67
69
|
points?: readonly Vec[];
|
|
68
70
|
}
|
|
@@ -124,8 +126,9 @@ export declare abstract class ShapeUtil<S extends ShapeRecordBase = ShapeRecordB
|
|
|
124
126
|
canUseSelectionFrameHandles(_shape: S, _input: ShapeSelectionFrameInput): boolean;
|
|
125
127
|
getSelectionTargetId(shape: S, _input: ShapeSelectionFrameInput): ShapeId;
|
|
126
128
|
getTranslateTargetId(shape: S, _input: ShapeSelectionTranslateInput): ShapeId;
|
|
127
|
-
|
|
129
|
+
isTransformDescendantContainer(_shape: S): boolean;
|
|
128
130
|
shouldRotateDescendants(shape: S): boolean;
|
|
131
|
+
canUngroupChildren(_shape: S): boolean;
|
|
129
132
|
canStartTranslateFromSelectionBounds(_shape: S): boolean;
|
|
130
133
|
canSnap(_shape: S): boolean;
|
|
131
134
|
getBoundsSnapGeometry(_shape: S): ShapeBoundsSnapGeometry;
|
|
@@ -138,9 +141,11 @@ export declare abstract class ShapeUtil<S extends ShapeRecordBase = ShapeRecordB
|
|
|
138
141
|
getLocalToPageTransform(shape: S): Mat;
|
|
139
142
|
canEdit(_shape: S): boolean;
|
|
140
143
|
canReceiveChildren(_shape: S): boolean;
|
|
144
|
+
canReceiveTerminalBinding(_shape: S, _input?: ShapeGeometryInput): boolean;
|
|
141
145
|
repairLoadedShape(_shape: S): S | null;
|
|
142
146
|
onEditEnd(_shape: S): ShapeEditEndResult | void;
|
|
143
147
|
hitTest(shape: S, positionedPoint: Vec, _input?: ShapePointHitTestInput): boolean;
|
|
148
|
+
hitTestBindingTarget(shape: S, positionedPoint: Vec, input?: ShapeBindingTargetHitTestInput): boolean;
|
|
144
149
|
hitTestLineSegment(shape: S, input: ShapeLineSegmentHitTestInput): boolean;
|
|
145
|
-
resolveBindingPoint(
|
|
150
|
+
resolveBindingPoint(shape: S, input: ShapeBindingPointInput): Vec;
|
|
146
151
|
}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function ShapeLayer({ hoveredShapeId, }: {
|
|
3
|
-
hoveredShapeId?: ShapeId | null;
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function ShapeLayer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ export interface PagePointLike {
|
|
|
2
2
|
x: number;
|
|
3
3
|
y: number;
|
|
4
4
|
}
|
|
5
|
-
export type DashedGuideSegmentKind = "binding-preview" | "selection-binding";
|
|
5
|
+
export type DashedGuideSegmentKind = "binding-preview" | "selection-binding" | "terminal-binding-guide";
|
|
6
6
|
export declare function DashedGuideSegment({ start, end, startInset, endInset, strokeWidth, dashSize, gapSize, kind, terminal, }: {
|
|
7
7
|
start: PagePointLike;
|
|
8
8
|
end: PagePointLike;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import { type SelectionBindingSegment } from "../../../canvas-core/index";
|
|
2
|
+
import { type DashedGuideSegmentKind } from "./BindingGuide";
|
|
1
3
|
export declare const SelectionPathOverlay: import("react").NamedExoticComponent<object>;
|
|
4
|
+
export declare const BindingSegmentsOverlay: import("react").NamedExoticComponent<{
|
|
5
|
+
bindingSegments: readonly SelectionBindingSegment[];
|
|
6
|
+
kind?: DashedGuideSegmentKind;
|
|
7
|
+
strokeWidth: number;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TerminalBindingGuidesOverlay: import("react").NamedExoticComponent<object>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type RefObject } from "react";
|
|
2
|
-
import { type ActiveContextMenu, type Editor, type ShapeEditingSession
|
|
2
|
+
import { type ActiveContextMenu, type Editor, type ShapeEditingSession } from "../../canvas-core/index";
|
|
3
3
|
import type { CanvasDomEventGuardRegistry } from "../host/domEventGuards";
|
|
4
4
|
export interface CanvasDomEventHandlers {
|
|
5
5
|
onPointerDown: (event: ReactPointerEvent<HTMLDivElement>) => void;
|
|
@@ -8,7 +8,6 @@ export interface CanvasDomEventHandlers {
|
|
|
8
8
|
export interface CanvasDomEventState {
|
|
9
9
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
10
10
|
handlers: CanvasDomEventHandlers;
|
|
11
|
-
hoveredShapeId: ShapeId | null;
|
|
12
11
|
isPointerActive: boolean;
|
|
13
12
|
surfaceCursor: string | undefined;
|
|
14
13
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Editor, ShapeRecord } from "../canvas-core/index";
|
|
2
|
+
export declare function canReceiveArrowBindingTarget(editor: Editor, shape: ShapeRecord | undefined): shape is ShapeRecord;
|
|
3
|
+
export declare function getPreferredArrowBindingTarget(editor: Editor, candidates: readonly ShapeRecord[]): ShapeRecord | null;
|
|
@@ -4,7 +4,7 @@ export declare class ArrowBindingUtil extends BindingUtil<ArrowBindingRecord> {
|
|
|
4
4
|
readonly type: "arrow";
|
|
5
5
|
getDefaultProps(): ArrowBindingRecord["props"];
|
|
6
6
|
validateProps(props: unknown): ArrowBindingRecord["props"];
|
|
7
|
-
canBind(
|
|
7
|
+
canBind(editor: Editor, _binding: ArrowBindingRecord, context: {
|
|
8
8
|
fromShape: ShapeRecord;
|
|
9
9
|
toShape: ShapeRecord;
|
|
10
10
|
}): boolean;
|
|
@@ -8,6 +8,7 @@ export declare class DrawShapeUtil extends ShapeUtil<DrawShapeRecord> {
|
|
|
8
8
|
getLocalBounds(shape: DrawShapeRecord): Box;
|
|
9
9
|
getRenderBounds(shape: DrawShapeRecord): Box;
|
|
10
10
|
getExportBounds(shape: DrawShapeRecord): Box;
|
|
11
|
+
canReceiveTerminalBinding(_shape: DrawShapeRecord): boolean;
|
|
11
12
|
getSelectionResizeLocalBounds(shape: DrawShapeRecord): Box;
|
|
12
13
|
resizeSelectionBounds(shape: DrawShapeRecord, input: ShapeSelectionResizeInput): ShapeUpdate;
|
|
13
14
|
flipSelectionBounds(shape: DrawShapeRecord, input: ShapeSelectionFlipInput): ShapeUpdate;
|
|
@@ -15,9 +15,11 @@ export declare class FrameShapeUtil extends ShapeUtil<FrameShapeRecord> {
|
|
|
15
15
|
getBounds(shape: FrameShapeRecord): Box;
|
|
16
16
|
getPointHitTestBounds(shape: FrameShapeRecord): Box;
|
|
17
17
|
canReceiveChildren(_shape: FrameShapeRecord): boolean;
|
|
18
|
+
canReceiveTerminalBinding(_shape: FrameShapeRecord): boolean;
|
|
18
19
|
shouldRotateDescendants(_shape: FrameShapeRecord): boolean;
|
|
19
20
|
getChildClipLocalBounds(shape: FrameShapeRecord): Box | null;
|
|
20
21
|
canSelectByBrush(shape: FrameShapeRecord, input: ShapeBrushSelectInput): boolean;
|
|
21
22
|
hitTest(shape: FrameShapeRecord, positionedPoint: Vec): boolean;
|
|
23
|
+
hitTestBindingTarget(shape: FrameShapeRecord, positionedPoint: Vec): boolean;
|
|
22
24
|
hitTestLineSegment(shape: FrameShapeRecord, input: ShapeLineSegmentHitTestInput): boolean;
|
|
23
25
|
}
|
|
@@ -5,6 +5,7 @@ export declare class GeoShapeUtil extends ShapeUtil<GeoShapeRecord> {
|
|
|
5
5
|
getDefaultProps(): GeoShapeProps;
|
|
6
6
|
validateProps(props: unknown): GeoShapeProps;
|
|
7
7
|
getBounds(shape: GeoShapeRecord): Box;
|
|
8
|
+
canReceiveTerminalBinding(_shape: GeoShapeRecord): boolean;
|
|
8
9
|
getPositionedOutlineVertices(shape: GeoShapeRecord): Vec[];
|
|
9
10
|
getHandleSnapGeometry(shape: GeoShapeRecord): ShapeHandleSnapGeometry;
|
|
10
11
|
hitTest(shape: GeoShapeRecord, positionedPoint: Vec): boolean;
|
|
@@ -4,6 +4,7 @@ declare class BoxGeoTool extends StateNode {
|
|
|
4
4
|
private readonly geo;
|
|
5
5
|
constructor(editor: Editor, id: string, geo: GeoShapeKind);
|
|
6
6
|
getDefaultProps(): GeoShapeProps;
|
|
7
|
+
protected onEnter(): void;
|
|
7
8
|
}
|
|
8
9
|
export declare class RectangleTool extends BoxGeoTool {
|
|
9
10
|
constructor(editor: Editor);
|
|
@@ -10,6 +10,7 @@ export declare class GroupShapeUtil extends ShapeUtil<GroupShapeRecord> {
|
|
|
10
10
|
validateProps(props: unknown): GroupShapeProps;
|
|
11
11
|
getBounds(shape: GroupShapeRecord): Box;
|
|
12
12
|
hitTest(_shape: GroupShapeRecord, _positionedPoint: Vec): boolean;
|
|
13
|
-
|
|
13
|
+
isTransformDescendantContainer(_shape: GroupShapeRecord): boolean;
|
|
14
|
+
canUngroupChildren(_shape: GroupShapeRecord): boolean;
|
|
14
15
|
canReceiveChildren(_shape: GroupShapeRecord): boolean;
|
|
15
16
|
}
|
|
@@ -5,6 +5,7 @@ export declare class ImageShapeUtil extends ShapeUtil<ImageShapeRecord> {
|
|
|
5
5
|
getDefaultProps(): ImageShapeProps;
|
|
6
6
|
validateProps(props: unknown): ImageShapeProps;
|
|
7
7
|
getBounds(shape: ImageShapeRecord): Box;
|
|
8
|
+
canReceiveTerminalBinding(_shape: ImageShapeRecord): boolean;
|
|
8
9
|
getSelectionResizeAspectRatioLock(_shape: ImageShapeRecord, input: ShapeSelectionResizeAspectRatioLockInput): boolean | null;
|
|
9
10
|
canEdit(_shape: ImageShapeRecord): boolean;
|
|
10
11
|
getSelectionHandleAnchors(shape: ImageShapeRecord, input: ShapeSelectionHandleAnchorInput): ShapeSelectionHandleAnchors;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { type TextFontCatalog } from "./textFonts";
|
|
1
2
|
import { type LandCanvasPlugin } from "../canvas-react/host/index";
|
|
2
|
-
export declare function createTextCanvasPlugin(
|
|
3
|
+
export declare function createTextCanvasPlugin({ fontCatalog, }?: {
|
|
4
|
+
fontCatalog?: TextFontCatalog;
|
|
5
|
+
}): LandCanvasPlugin;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { type LandEditorPlugin } from "../canvas-core/index";
|
|
2
|
-
|
|
2
|
+
import { type TextFontCatalog } from "./textFonts";
|
|
3
|
+
export declare function createTextEditorPlugin({ fontCatalog, }?: {
|
|
4
|
+
fontCatalog?: TextFontCatalog;
|
|
5
|
+
}): LandEditorPlugin;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type LandFeatureBundle } from "../canvas-react/host/index";
|
|
2
|
-
|
|
3
|
-
export declare
|
|
2
|
+
import { type TextExtensionOptions } from "./textFonts";
|
|
3
|
+
export declare function createTextFeatureBundle(options?: Readonly<TextExtensionOptions>): LandFeatureBundle;
|
|
4
|
+
export declare const Text: import("../canvas-react/host/index").ConfigurableLandExtension<TextExtensionOptions>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TextShapeRecord } from "../textTypes";
|
|
2
|
-
|
|
2
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
3
|
+
export declare function ShapeEditingSessionBox({ shapeId, markId, fontCatalog, }: {
|
|
3
4
|
shapeId: TextShapeRecord["id"];
|
|
4
5
|
markId: string;
|
|
6
|
+
fontCatalog: TextFontCatalog;
|
|
5
7
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -2,6 +2,7 @@ import { type CSSProperties } from "react";
|
|
|
2
2
|
import { type Editor as TiptapEditor } from "@tiptap/react";
|
|
3
3
|
import type { Editor as LandEditor } from "../../canvas-core/index";
|
|
4
4
|
import type { RichTextDocument, TextShapeRecord } from "../textTypes";
|
|
5
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
5
6
|
import { type TiptapTextEditorController } from "./tiptapTextEditorController";
|
|
6
7
|
export interface TiptapTextEditorHandle {
|
|
7
8
|
readonly editor: TiptapEditor;
|
|
@@ -10,6 +11,7 @@ export interface TiptapTextEditorHandle {
|
|
|
10
11
|
export interface TiptapTextEditorProps {
|
|
11
12
|
landEditor: LandEditor;
|
|
12
13
|
shape: TextShapeRecord;
|
|
14
|
+
fontCatalog: TextFontCatalog;
|
|
13
15
|
initialRichText: RichTextDocument;
|
|
14
16
|
className: string;
|
|
15
17
|
editorStyle: CSSProperties;
|
|
@@ -21,4 +23,4 @@ export interface TiptapTextEditorProps {
|
|
|
21
23
|
richText: RichTextDocument;
|
|
22
24
|
}): void;
|
|
23
25
|
}
|
|
24
|
-
export declare function TiptapTextEditor({ landEditor, shape, initialRichText, className, editorStyle, onReady, onDispose, onRichTextChange, }: TiptapTextEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function TiptapTextEditor({ landEditor, shape, fontCatalog, initialRichText, className, editorStyle, onReady, onDispose, onRichTextChange, }: TiptapTextEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type CSSProperties } from "react";
|
|
2
2
|
import type { TextShapeRecord } from "../textTypes";
|
|
3
|
-
|
|
3
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
4
|
+
export declare function useTextEditingBoxStyle(shape: TextShapeRecord, fontCatalog: TextFontCatalog): CSSProperties;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { TextShapeFont } from "../textTypes";
|
|
2
|
-
|
|
2
|
+
import { type TextFontCatalog } from "../textFonts";
|
|
3
|
+
export declare function ensureTextFontLoaded(font: TextShapeFont, fontCatalog: TextFontCatalog, ownerDocument?: Document): Promise<void>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Editor as TiptapEditor } from "@tiptap/react";
|
|
2
2
|
import type { RichTextDocument, TextShapeRecord } from "../textTypes";
|
|
3
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
3
4
|
export declare const TEXT_AUTO_SIZE_MIN_W = 16;
|
|
4
|
-
export declare function measureTextShapeFromEditor(textEditor: TiptapEditor, shape: TextShapeRecord): {
|
|
5
|
+
export declare function measureTextShapeFromEditor(textEditor: TiptapEditor, shape: TextShapeRecord, fontCatalog: TextFontCatalog): {
|
|
5
6
|
w: number;
|
|
6
7
|
h: number;
|
|
7
8
|
} | undefined;
|
|
8
|
-
export declare function measureTextShapeFromRichText(richText: RichTextDocument, shape: TextShapeRecord): {
|
|
9
|
+
export declare function measureTextShapeFromRichText(richText: RichTextDocument, shape: TextShapeRecord, fontCatalog: TextFontCatalog): {
|
|
9
10
|
w: number;
|
|
10
11
|
h: number;
|
|
11
12
|
} | undefined;
|
|
12
|
-
export declare function applyTextShapeElementStyles(element: HTMLElement, shape: TextShapeRecord): void;
|
|
13
|
+
export declare function applyTextShapeElementStyles(element: HTMLElement, shape: TextShapeRecord, fontCatalog: TextFontCatalog): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChangeSource, Editor } from "../../canvas-core/index";
|
|
2
2
|
import type { TextShapeRecord } from "../textTypes";
|
|
3
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
3
4
|
import type { TiptapTextEditorController } from "./tiptapTextEditorController";
|
|
4
5
|
export declare function scheduleTextEditorMeasurement(editor: Editor, controller: TiptapTextEditorController, latestShapeRef: {
|
|
5
6
|
current: TextShapeRecord;
|
|
@@ -7,4 +8,4 @@ export declare function scheduleTextEditorMeasurement(editor: Editor, controller
|
|
|
7
8
|
current: number | null;
|
|
8
9
|
}): void;
|
|
9
10
|
export declare function measureTextEditorLayout(editor: Editor, controller: TiptapTextEditorController, shape: TextShapeRecord): void;
|
|
10
|
-
export declare function measureTextShapeRichTextLayout(editor: Editor, shape: TextShapeRecord, source?: ChangeSource): void;
|
|
11
|
+
export declare function measureTextShapeRichTextLayout(editor: Editor, shape: TextShapeRecord, fontCatalog: TextFontCatalog, source?: ChangeSource): void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { Editor } from "../../canvas-core/index";
|
|
3
3
|
import type { TextShapeRecord } from "../textTypes";
|
|
4
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
4
5
|
export interface TextShapeRendererRuntime {
|
|
5
6
|
isEditingThisShape: boolean;
|
|
6
7
|
editingHost: ReactNode;
|
|
7
8
|
}
|
|
8
|
-
export declare function useTextShapeRendererRuntime(editor: Editor, shape: TextShapeRecord): TextShapeRendererRuntime;
|
|
9
|
+
export declare function useTextShapeRendererRuntime(editor: Editor, shape: TextShapeRecord, fontCatalog: TextFontCatalog): TextShapeRendererRuntime;
|
|
@@ -2,14 +2,16 @@ import { type MutableRefObject } from "react";
|
|
|
2
2
|
import type { Editor as TiptapEditor } from "@tiptap/react";
|
|
3
3
|
import type { Editor } from "../../canvas-core/index";
|
|
4
4
|
import { type RichTextDocument, type TextShapeRecord } from "../textTypes";
|
|
5
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
5
6
|
import type { TiptapTextEditorController } from "./tiptapTextEditorController";
|
|
6
7
|
export declare function useLatestTextShapeRef(shape: TextShapeRecord): MutableRefObject<TextShapeRecord>;
|
|
7
|
-
export declare function useRichTextShapeSync({ editor, shape, tiptapEditor, richTextController, latestShapeRef, }: {
|
|
8
|
+
export declare function useRichTextShapeSync({ editor, shape, tiptapEditor, richTextController, latestShapeRef, fontCatalog, }: {
|
|
8
9
|
editor: Editor;
|
|
9
10
|
shape: TextShapeRecord;
|
|
10
11
|
tiptapEditor: TiptapEditor | null;
|
|
11
12
|
richTextController: TiptapTextEditorController | null;
|
|
12
13
|
latestShapeRef: MutableRefObject<TextShapeRecord>;
|
|
14
|
+
fontCatalog: TextFontCatalog;
|
|
13
15
|
}): (input: {
|
|
14
16
|
editor: TiptapEditor;
|
|
15
17
|
controller: TiptapTextEditorController;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Editor as TiptapEditor } from "@tiptap/react";
|
|
2
2
|
import { type Editor, type ShapeId } from "../../canvas-core/index";
|
|
3
3
|
import type { RichTextDocument, TextShapeRecord } from "../textTypes";
|
|
4
|
+
import type { TextFontCatalog } from "../textFonts";
|
|
4
5
|
export interface TiptapTextSelectionSnapshot {
|
|
5
6
|
type: string | null;
|
|
6
7
|
text: string | null;
|
|
@@ -27,7 +28,8 @@ export interface TiptapTextEditorController {
|
|
|
27
28
|
} | undefined;
|
|
28
29
|
onCompositionStateChange(listener: (isComposing: boolean) => void): () => void;
|
|
29
30
|
}
|
|
30
|
-
export declare function createTiptapTextEditorController({ shapeId, editor, }: {
|
|
31
|
+
export declare function createTiptapTextEditorController({ shapeId, editor, fontCatalog, }: {
|
|
31
32
|
shapeId: ShapeId;
|
|
32
33
|
editor: TiptapEditor;
|
|
34
|
+
fontCatalog: TextFontCatalog;
|
|
33
35
|
}): TiptapTextEditorController;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Text, createTextFeatureBundle } from "./feature";
|
|
2
|
+
export { DEFAULT_TEXT_FONT, HOST_TEXT_FONT, createDefaultTextFontCatalog, createDefaultTextExtensionOptions, } from "./textFonts";
|
|
2
3
|
export { createRichTextFromPlainText, getPlainTextFromRichText, validateRichTextDocument, } from "./richTextUtils";
|
|
3
4
|
export { isTextShapeRecord, updateTextShapeRichText, } from "./textShapeHelpers";
|
|
5
|
+
export type { TextExtensionOptions, TextFontDefinition, TextFontFaceSource, TextFontSource, TextStylesheetFontSource, TextSystemFontSource, } from "./textFonts";
|
|
4
6
|
export type { RichTextDocument, TextShapeAlign, TextShapeFont, TextShapeProps, TextShapeRecord, TextShapeSize, } from "./textTypes";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TextShapeFont } from "./textTypes";
|
|
2
|
+
export declare const DEFAULT_TEXT_FONT: "default";
|
|
3
|
+
export declare const DEFAULT_TEXT_FONT_LABEL = "Default";
|
|
4
|
+
export interface TextSystemFontSource {
|
|
5
|
+
readonly kind: "system";
|
|
6
|
+
}
|
|
7
|
+
export interface TextStylesheetFontSource {
|
|
8
|
+
readonly kind: "stylesheet";
|
|
9
|
+
readonly cssUrl: string;
|
|
10
|
+
readonly family: string;
|
|
11
|
+
readonly weights?: readonly number[];
|
|
12
|
+
readonly sampleText?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TextFontFaceSource {
|
|
15
|
+
readonly kind: "font-face";
|
|
16
|
+
readonly family: string;
|
|
17
|
+
readonly src: string | ArrayBuffer;
|
|
18
|
+
readonly descriptors?: FontFaceDescriptors;
|
|
19
|
+
readonly weights?: readonly number[];
|
|
20
|
+
readonly sampleText?: string;
|
|
21
|
+
}
|
|
22
|
+
export type TextFontSource = TextSystemFontSource | TextStylesheetFontSource | TextFontFaceSource;
|
|
23
|
+
export interface TextFontDefinition {
|
|
24
|
+
readonly id: TextShapeFont;
|
|
25
|
+
readonly label: string;
|
|
26
|
+
readonly cssFamily: string;
|
|
27
|
+
readonly source?: TextFontSource;
|
|
28
|
+
}
|
|
29
|
+
export interface TextFontCatalog {
|
|
30
|
+
readonly defaultFont: TextFontDefinition;
|
|
31
|
+
readonly defaultFontLabel: string;
|
|
32
|
+
readonly fontOptions: readonly TextFontDefinition[];
|
|
33
|
+
readonly fontsById: ReadonlyMap<TextShapeFont, TextFontDefinition>;
|
|
34
|
+
}
|
|
35
|
+
export type TextExtensionOptions = {
|
|
36
|
+
defaultFont: TextFontDefinition;
|
|
37
|
+
defaultFontLabel: string;
|
|
38
|
+
fonts: readonly TextFontDefinition[];
|
|
39
|
+
};
|
|
40
|
+
export declare const HOST_TEXT_FONT: TextFontDefinition;
|
|
41
|
+
export declare function createDefaultTextExtensionOptions(): TextExtensionOptions;
|
|
42
|
+
export declare function createDefaultTextFontCatalog(): TextFontCatalog;
|
|
43
|
+
export declare function createTextFontCatalog(options: Readonly<TextExtensionOptions>): TextFontCatalog;
|
|
44
|
+
export declare function isUsableFontId(value: unknown): value is TextShapeFont;
|
|
45
|
+
export declare function isTextFontInCatalog(fontCatalog: TextFontCatalog, font: unknown): font is TextShapeFont;
|
|
46
|
+
export declare function resolveTextFont(fontCatalog: TextFontCatalog, font: TextShapeFont): TextFontDefinition;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type ShapeSvgExporter, type SvgExportContext, type SvgNode } from "../canvas-core/index";
|
|
2
2
|
import type { TextShapeRecord } from "./textTypes";
|
|
3
|
+
import type { TextFontCatalog } from "./textFonts";
|
|
3
4
|
export declare class TextShapeSvgExporter implements ShapeSvgExporter<TextShapeRecord> {
|
|
5
|
+
private readonly fontCatalog;
|
|
4
6
|
readonly type: "text";
|
|
7
|
+
constructor(fontCatalog: TextFontCatalog);
|
|
5
8
|
toSvg(shape: TextShapeRecord, context: SvgExportContext): SvgNode | null;
|
|
6
9
|
}
|
|
@@ -8,6 +8,7 @@ export declare class TextShapeUtil extends ShapeUtil<TextShapeRecord> {
|
|
|
8
8
|
getLocalBounds(shape: TextShapeRecord): Box;
|
|
9
9
|
getRenderBounds(shape: TextShapeRecord): Box;
|
|
10
10
|
getExportBounds(shape: TextShapeRecord): Box;
|
|
11
|
+
canReceiveTerminalBinding(_shape: TextShapeRecord): boolean;
|
|
11
12
|
canEdit(_shape: TextShapeRecord): boolean;
|
|
12
13
|
contributesToSelectionFrame(shape: TextShapeRecord, input: ShapeSelectionFrameInput): boolean;
|
|
13
14
|
canUseSelectionFrameHandles(shape: TextShapeRecord, input: ShapeSelectionFrameInput): boolean;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { TextShapeAlign, TextShapeFont, TextShapeRecord, TextShapeSize } from "./textTypes";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
import { DEFAULT_TEXT_FONT, type TextFontCatalog } from "./textFonts";
|
|
3
|
+
export { DEFAULT_TEXT_FONT };
|
|
4
|
+
export declare const TEXT_SIZE_PRESETS: {
|
|
5
|
+
readonly s: 14;
|
|
6
|
+
readonly m: 16;
|
|
7
|
+
readonly l: 20;
|
|
8
|
+
readonly xl: 28;
|
|
9
|
+
};
|
|
10
|
+
export declare const DEFAULT_TEXT_SIZE: TextShapeSize;
|
|
11
|
+
export declare function normalizeTextSize(value: unknown, fallback?: TextShapeSize): TextShapeSize;
|
|
12
|
+
export declare function getTextFontFamily(font: TextShapeFont, fontCatalog: TextFontCatalog): string;
|
|
4
13
|
export declare function getTextFontSize(size: TextShapeSize): number;
|
|
5
14
|
export declare function getTextLineHeight(size: TextShapeSize): number;
|
|
6
15
|
export declare function getTextMinHeight(size: TextShapeSize, scale?: number): number;
|
|
@@ -8,8 +8,8 @@ export interface RichTextDocument {
|
|
|
8
8
|
attrs?: Record<string, RichTextJsonValue>;
|
|
9
9
|
content: JSONContent[];
|
|
10
10
|
}
|
|
11
|
-
export type TextShapeFont =
|
|
12
|
-
export type TextShapeSize =
|
|
11
|
+
export type TextShapeFont = string;
|
|
12
|
+
export type TextShapeSize = number;
|
|
13
13
|
export type TextShapeAlign = "start" | "middle" | "end";
|
|
14
14
|
export interface TextShapeProps {
|
|
15
15
|
richText: RichTextDocument;
|
|
@@ -17,8 +17,10 @@ export interface BuiltInCanvasTextInput {
|
|
|
17
17
|
text: string;
|
|
18
18
|
w?: number;
|
|
19
19
|
h?: number;
|
|
20
|
+
font?: TextShapeProps["font"];
|
|
20
21
|
color?: ShapeColor;
|
|
21
22
|
size?: TextShapeProps["size"];
|
|
23
|
+
textAlign?: TextShapeProps["textAlign"];
|
|
22
24
|
}
|
|
23
25
|
export interface BuiltInCanvasFrameInput extends BuiltInCanvasShapeInput {
|
|
24
26
|
name?: string;
|