@tldraw/tlschema 5.3.0-canary.fceaae5e9feb → 5.3.0-internal.1640468db8fd
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-cjs/TLStore.js +7 -0
- package/dist-cjs/TLStore.js.map +2 -2
- package/dist-cjs/index.d.ts +196 -1
- package/dist-cjs/index.js +11 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/misc/TLCursor.js +1 -0
- package/dist-cjs/misc/TLCursor.js.map +2 -2
- package/dist-cjs/records/TLComment.js +187 -0
- package/dist-cjs/records/TLComment.js.map +7 -0
- package/dist-cjs/shapes/TLGeoShape.js +15 -1
- package/dist-cjs/shapes/TLGeoShape.js.map +2 -2
- package/dist-esm/TLStore.mjs +7 -0
- package/dist-esm/TLStore.mjs.map +2 -2
- package/dist-esm/index.d.mts +196 -1
- package/dist-esm/index.mjs +21 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/misc/TLCursor.mjs +1 -0
- package/dist-esm/misc/TLCursor.mjs.map +2 -2
- package/dist-esm/records/TLComment.mjs +167 -0
- package/dist-esm/records/TLComment.mjs.map +7 -0
- package/dist-esm/shapes/TLGeoShape.mjs +15 -1
- package/dist-esm/shapes/TLGeoShape.mjs.map +2 -2
- package/package.json +5 -5
- package/src/TLStore.ts +16 -0
- package/src/index.ts +16 -0
- package/src/migrations.test.ts +12 -0
- package/src/misc/TLCursor.ts +1 -0
- package/src/records/TLComment.test.ts +182 -0
- package/src/records/TLComment.ts +330 -0
- package/src/shapes/TLGeoShape.ts +21 -1
package/dist-esm/index.d.mts
CHANGED
|
@@ -529,6 +529,34 @@ export declare const CameraRecordType: RecordType<TLCamera, never>;
|
|
|
529
529
|
*/
|
|
530
530
|
export declare const canvasUiColorTypeValidator: T.Validator<"accent" | "black" | "laser" | "muted-1" | "selection-fill" | "selection-stroke" | "white">;
|
|
531
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Config for registering the `comment` record type in a tldraw schema. Pass via
|
|
534
|
+
* `commentSchemaRecords`; see `TLComment`.
|
|
535
|
+
*
|
|
536
|
+
* @public
|
|
537
|
+
*/
|
|
538
|
+
export declare const commentRecordConfig: CustomRecordInfo;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* The `records` map to pass to `createTLSchema` / the client `records` option so comment
|
|
542
|
+
* threads and comments sync. Register both types together — a comment without its thread type
|
|
543
|
+
* (or vice versa) will fail schema validation on one side of the connection.
|
|
544
|
+
*
|
|
545
|
+
* @public
|
|
546
|
+
*/
|
|
547
|
+
export declare const commentSchemaRecords: {
|
|
548
|
+
'comment-thread': CustomRecordInfo;
|
|
549
|
+
comment: CustomRecordInfo;
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Config for registering the `comment-thread` record type in a tldraw schema. Pass via
|
|
554
|
+
* `commentSchemaRecords`; see `TLCommentThread`.
|
|
555
|
+
*
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
export declare const commentThreadRecordConfig: CustomRecordInfo;
|
|
559
|
+
|
|
532
560
|
/**
|
|
533
561
|
* Compress legacy draw shape segments by converting VecModel[] points to delta-encoded base64 format.
|
|
534
562
|
* This function is useful for converting old draw shape data to the new compressed format.
|
|
@@ -810,6 +838,39 @@ export declare function createBindingValidator<Type extends string, Props extend
|
|
|
810
838
|
*/
|
|
811
839
|
export declare function createCachedUserResolve(resolveFn: (userId: string) => null | TLUser): (userId: string) => Signal<null | TLUser>;
|
|
812
840
|
|
|
841
|
+
/**
|
|
842
|
+
* Create a new comment record within a thread.
|
|
843
|
+
*
|
|
844
|
+
* @public
|
|
845
|
+
*/
|
|
846
|
+
export declare function createComment(props: {
|
|
847
|
+
authorId: string;
|
|
848
|
+
body: TLRichText;
|
|
849
|
+
meta?: JsonObject;
|
|
850
|
+
now?: number;
|
|
851
|
+
pageId: TLPageId;
|
|
852
|
+
threadId: TLCommentThreadId;
|
|
853
|
+
}): TLComment;
|
|
854
|
+
|
|
855
|
+
/** @public */
|
|
856
|
+
export declare function createCommentId(id?: string): TLCommentId;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Create a new comment thread record. Pair with `createComment` for the thread's first message.
|
|
860
|
+
*
|
|
861
|
+
* @public
|
|
862
|
+
*/
|
|
863
|
+
export declare function createCommentThread(props: {
|
|
864
|
+
anchor: TLCommentAnchor;
|
|
865
|
+
createdBy: string;
|
|
866
|
+
meta?: JsonObject;
|
|
867
|
+
now?: number;
|
|
868
|
+
pageId: TLPageId;
|
|
869
|
+
}): TLCommentThread;
|
|
870
|
+
|
|
871
|
+
/** @public */
|
|
872
|
+
export declare function createCommentThreadId(id?: string): TLCommentThreadId;
|
|
873
|
+
|
|
813
874
|
/**
|
|
814
875
|
* Creates a unique ID for a custom record type.
|
|
815
876
|
*
|
|
@@ -2226,6 +2287,23 @@ export declare function isBinding(record?: UnknownRecord): record is TLBinding;
|
|
|
2226
2287
|
*/
|
|
2227
2288
|
export declare function isBindingId(id?: string): id is TLBindingId;
|
|
2228
2289
|
|
|
2290
|
+
/**
|
|
2291
|
+
* Type guard for `TLCommentId`. See `isCommentThreadId` for why `comment-thread:...` ids are
|
|
2292
|
+
* correctly rejected here.
|
|
2293
|
+
*
|
|
2294
|
+
* @public
|
|
2295
|
+
*/
|
|
2296
|
+
export declare function isCommentId(id: string): id is TLCommentId;
|
|
2297
|
+
|
|
2298
|
+
/**
|
|
2299
|
+
* Type guard for `TLCommentThreadId`. Note `isCommentId` does not accept these: the prefixes
|
|
2300
|
+
* are `comment-thread:` vs `comment:`, and the character after `comment` differs (`-` vs `:`),
|
|
2301
|
+
* so the two never overlap.
|
|
2302
|
+
*
|
|
2303
|
+
* @public
|
|
2304
|
+
*/
|
|
2305
|
+
export declare function isCommentThreadId(id: string): id is TLCommentThreadId;
|
|
2306
|
+
|
|
2229
2307
|
/**
|
|
2230
2308
|
* Type guard to check if a record is of a specific custom type.
|
|
2231
2309
|
*
|
|
@@ -4005,6 +4083,117 @@ export declare type TLCameraId = RecordId<TLCamera>;
|
|
|
4005
4083
|
*/
|
|
4006
4084
|
export declare type TLCanvasUiColor = SetValue<typeof TL_CANVAS_UI_COLOR_TYPES>;
|
|
4007
4085
|
|
|
4086
|
+
/**
|
|
4087
|
+
* A single comment message within a thread. See `TLCommentThread` for the overall model and
|
|
4088
|
+
* sync/registration notes.
|
|
4089
|
+
*
|
|
4090
|
+
* Comment mutations are deliberately not undoable — create/edit them with
|
|
4091
|
+
* `{ history: 'ignore' }` to avoid multiplayer surprises like a comment reappearing after
|
|
4092
|
+
* someone else deleted it.
|
|
4093
|
+
*
|
|
4094
|
+
* @public
|
|
4095
|
+
*/
|
|
4096
|
+
export declare interface TLComment extends BaseRecord<'comment', TLCommentId> {
|
|
4097
|
+
/** The thread this comment belongs to. */
|
|
4098
|
+
threadId: TLCommentThreadId;
|
|
4099
|
+
/** Denormalized from the thread so per-page queries don't need a join. */
|
|
4100
|
+
pageId: TLPageId;
|
|
4101
|
+
/** See `TLCommentThread.createdBy` — same server-stamping caveat applies. */
|
|
4102
|
+
authorId: string;
|
|
4103
|
+
createdAt: number;
|
|
4104
|
+
/** Null until the comment is first edited. */
|
|
4105
|
+
editedAt: null | number;
|
|
4106
|
+
/** Rich text body. Use `toRichText(...)` for plaintext input. */
|
|
4107
|
+
body: TLRichText;
|
|
4108
|
+
meta: JsonObject;
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
/**
|
|
4112
|
+
* Where a comment thread is anchored on the canvas. Modeled as a discriminated union so new
|
|
4113
|
+
* anchor kinds can be added without breaking existing threads:
|
|
4114
|
+
*
|
|
4115
|
+
* - `shape` — pinned to a shape. `x`/`y` are normalized (0–1) within the shape's page bounds, so
|
|
4116
|
+
* the pin keeps its spot as the shape moves and resizes. `isPrecise` mirrors arrow bindings: when
|
|
4117
|
+
* true the pin sits at exactly `x`/`y`; when false (the default) it sits at a consumer-defined
|
|
4118
|
+
* spot (top-right out of the box), and `x`/`y` are the remembered precise position
|
|
4119
|
+
* - `point` — pinned to a fixed point on the page, in page coordinates
|
|
4120
|
+
* - `region` — pinned to a rectangular area of the page, in page coordinates
|
|
4121
|
+
* - `page` — a page-level thread with no spatial anchor
|
|
4122
|
+
* - `text-range` — pinned to a character range inside a shape's text
|
|
4123
|
+
*
|
|
4124
|
+
* @public
|
|
4125
|
+
*/
|
|
4126
|
+
export declare type TLCommentAnchor = {
|
|
4127
|
+
/** The normalized (0–1) corner the pin sits on — where the creating drag was released.
|
|
4128
|
+
* Absent on older records; consumers fall back to their configured corner. */
|
|
4129
|
+
pinX?: number;
|
|
4130
|
+
h: number;
|
|
4131
|
+
pinY?: number;
|
|
4132
|
+
type: 'region';
|
|
4133
|
+
w: number;
|
|
4134
|
+
x: number;
|
|
4135
|
+
y: number;
|
|
4136
|
+
} | {
|
|
4137
|
+
from: number;
|
|
4138
|
+
shapeId: TLShapeId;
|
|
4139
|
+
to: number;
|
|
4140
|
+
type: 'text-range';
|
|
4141
|
+
} | {
|
|
4142
|
+
isPrecise: boolean;
|
|
4143
|
+
shapeId: TLShapeId;
|
|
4144
|
+
type: 'shape';
|
|
4145
|
+
x: number;
|
|
4146
|
+
y: number;
|
|
4147
|
+
} | {
|
|
4148
|
+
type: 'page';
|
|
4149
|
+
} | {
|
|
4150
|
+
type: 'point';
|
|
4151
|
+
x: number;
|
|
4152
|
+
y: number;
|
|
4153
|
+
};
|
|
4154
|
+
|
|
4155
|
+
/** @public */
|
|
4156
|
+
export declare type TLCommentId = RecordId<TLComment>;
|
|
4157
|
+
|
|
4158
|
+
/**
|
|
4159
|
+
* A comment thread. The thread owns the anchor (where the conversation lives on the canvas) and
|
|
4160
|
+
* the resolution state; the messages themselves are `TLComment` records pointing at the thread
|
|
4161
|
+
* via `threadId`, ordered by `createdAt`. v1 threads are flat — no nested replies.
|
|
4162
|
+
*
|
|
4163
|
+
* Threads and comments are document records, but they're intended to be served through the sync
|
|
4164
|
+
* server's object-store lane: gated by the session's `objectAccess` rather than `isReadonly`
|
|
4165
|
+
* (so "can comment but not edit" is expressible), excluded from document snapshots and `.tldr`
|
|
4166
|
+
* exports server-side, and persisted in a separate lane from the main document.
|
|
4167
|
+
*
|
|
4168
|
+
* Opt-in: register with `createTLSchema({ records: commentSchemaRecords })` on the server and
|
|
4169
|
+
* the matching `records` option on the client — neither type is part of the default schema, and
|
|
4170
|
+
* both sides must register them identically.
|
|
4171
|
+
*
|
|
4172
|
+
* @public
|
|
4173
|
+
*/
|
|
4174
|
+
export declare interface TLCommentThread extends BaseRecord<'comment-thread', TLCommentThreadId> {
|
|
4175
|
+
/** The page the thread lives on. */
|
|
4176
|
+
pageId: TLPageId;
|
|
4177
|
+
/** Where the thread is anchored on that page. */
|
|
4178
|
+
anchor: TLCommentAnchor;
|
|
4179
|
+
/**
|
|
4180
|
+
* Who started the thread. Client-supplied for now; the sync server should stamp/verify this
|
|
4181
|
+
* from the session's authenticated identity once record-level authorization lands (the same
|
|
4182
|
+
* model presence already uses for self-ownership).
|
|
4183
|
+
*/
|
|
4184
|
+
createdBy: string;
|
|
4185
|
+
createdAt: number;
|
|
4186
|
+
/** Resolution state: when and by whom the thread was resolved, or null while open. */
|
|
4187
|
+
resolved: {
|
|
4188
|
+
at: number;
|
|
4189
|
+
by: string;
|
|
4190
|
+
} | null;
|
|
4191
|
+
meta: JsonObject;
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
/** @public */
|
|
4195
|
+
export declare type TLCommentThreadId = RecordId<TLCommentThread>;
|
|
4196
|
+
|
|
4008
4197
|
/**
|
|
4009
4198
|
* A partial version of a shape, useful for creating shapes.
|
|
4010
4199
|
*
|
|
@@ -4730,7 +4919,9 @@ export declare interface TLFrameShapeProps {
|
|
|
4730
4919
|
* labelColor: 'black',
|
|
4731
4920
|
* url: '',
|
|
4732
4921
|
* growY: 0,
|
|
4733
|
-
* scale: 1
|
|
4922
|
+
* scale: 1,
|
|
4923
|
+
* flipX: false,
|
|
4924
|
+
* flipY: false
|
|
4734
4925
|
* },
|
|
4735
4926
|
* meta: {}
|
|
4736
4927
|
* }
|
|
@@ -4765,6 +4956,10 @@ export declare interface TLGeoShapeProps {
|
|
|
4765
4956
|
growY: number;
|
|
4766
4957
|
/** Scale factor applied to the shape */
|
|
4767
4958
|
scale: number;
|
|
4959
|
+
/** Whether to mirror the shape horizontally */
|
|
4960
|
+
flipX: boolean;
|
|
4961
|
+
/** Whether to mirror the shape vertically */
|
|
4962
|
+
flipY: boolean;
|
|
4768
4963
|
/** Color style for text label */
|
|
4769
4964
|
labelColor: TLDefaultColorStyle;
|
|
4770
4965
|
/** Color style for the shape outline */
|
package/dist-esm/index.mjs
CHANGED
|
@@ -56,6 +56,17 @@ import {
|
|
|
56
56
|
rootBindingMigrations
|
|
57
57
|
} from "./records/TLBinding.mjs";
|
|
58
58
|
import { CameraRecordType } from "./records/TLCamera.mjs";
|
|
59
|
+
import {
|
|
60
|
+
commentRecordConfig,
|
|
61
|
+
commentSchemaRecords,
|
|
62
|
+
commentThreadRecordConfig,
|
|
63
|
+
createComment,
|
|
64
|
+
createCommentId,
|
|
65
|
+
createCommentThread,
|
|
66
|
+
createCommentThreadId,
|
|
67
|
+
isCommentId,
|
|
68
|
+
isCommentThreadId
|
|
69
|
+
} from "./records/TLComment.mjs";
|
|
59
70
|
import {
|
|
60
71
|
createCustomRecordId,
|
|
61
72
|
createCustomRecordMigrationIds,
|
|
@@ -198,7 +209,7 @@ import {
|
|
|
198
209
|
} from "./translations/translations.mjs";
|
|
199
210
|
registerTldrawLibraryVersion(
|
|
200
211
|
"@tldraw/tlschema",
|
|
201
|
-
"5.3.0-
|
|
212
|
+
"5.3.0-internal.1640468db8fd",
|
|
202
213
|
"esm"
|
|
203
214
|
);
|
|
204
215
|
import { DIM_2D, DIM_3D, b64Vecs } from "./misc/b64Vecs.mjs";
|
|
@@ -255,6 +266,9 @@ export {
|
|
|
255
266
|
bookmarkShapeProps,
|
|
256
267
|
boxModelValidator,
|
|
257
268
|
canvasUiColorTypeValidator,
|
|
269
|
+
commentRecordConfig,
|
|
270
|
+
commentSchemaRecords,
|
|
271
|
+
commentThreadRecordConfig,
|
|
258
272
|
compressLegacySegments,
|
|
259
273
|
createAssetPropsMigrationIds,
|
|
260
274
|
createAssetPropsMigrationSequence,
|
|
@@ -265,6 +279,10 @@ export {
|
|
|
265
279
|
createBindingPropsMigrationSequence,
|
|
266
280
|
createBindingValidator,
|
|
267
281
|
createCachedUserResolve,
|
|
282
|
+
createComment,
|
|
283
|
+
createCommentId,
|
|
284
|
+
createCommentThread,
|
|
285
|
+
createCommentThreadId,
|
|
268
286
|
createCustomRecordId,
|
|
269
287
|
createCustomRecordMigrationIds,
|
|
270
288
|
createCustomRecordMigrationSequence,
|
|
@@ -301,6 +319,8 @@ export {
|
|
|
301
319
|
imageShapeProps,
|
|
302
320
|
isBinding,
|
|
303
321
|
isBindingId,
|
|
322
|
+
isCommentId,
|
|
323
|
+
isCommentThreadId,
|
|
304
324
|
isCustomRecord,
|
|
305
325
|
isCustomRecordId,
|
|
306
326
|
isDocument,
|
package/dist-esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview\n * Main entry point for the tldraw schema package. Exports the complete type system,\n * data structures, validation, and migrations for tldraw's persisted data.\n *\n * This package provides:\n * - Schema creation utilities (createTLSchema, defaultShapeSchemas, defaultBindingSchemas)\n * - All built-in shape types (TLGeoShape, TLTextShape, TLArrowShape, etc.)\n * - Asset management types and validators (TLImageAsset, TLVideoAsset, TLBookmarkAsset)\n * - Binding system for shape relationships (TLArrowBinding)\n * - Store integration types (TLStore, TLStoreProps, TLStoreSnapshot)\n * - Style properties for consistent styling (DefaultColorStyle, DefaultSizeStyle, etc.)\n * - Validation utilities and type guards\n * - Migration systems for schema evolution\n * - Geometry and utility types\n *\n * @example\n * ```ts\n * import { createTLSchema, defaultShapeSchemas, TLStore } from '@tldraw/tlschema'\n *\n * // Create a schema with default shapes\n * const schema = createTLSchema({\n * shapes: defaultShapeSchemas\n * })\n *\n * // Use with a store\n * const store = new Store({ schema })\n * ```\n *\n * @public\n */\n\nimport { registerTldrawLibraryVersion } from '@tldraw/utils'\nexport { assetIdValidator, createAssetValidator, type TLBaseAsset } from './assets/TLBaseAsset'\nexport {\n\tbookmarkAssetMigrations,\n\tbookmarkAssetProps,\n\ttype TLBookmarkAsset,\n} from './assets/TLBookmarkAsset'\nexport { imageAssetMigrations, imageAssetProps, type TLImageAsset } from './assets/TLImageAsset'\nexport { videoAssetMigrations, videoAssetProps, type TLVideoAsset } from './assets/TLVideoAsset'\nexport {\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tarrowBindingVersions,\n\tElbowArrowSnap,\n\ttype TLArrowBinding,\n\ttype TLArrowBindingProps,\n} from './bindings/TLArrowBinding'\nexport {\n\tbindingIdValidator,\n\tcreateBindingValidator,\n\ttype TLBaseBinding,\n} from './bindings/TLBaseBinding'\nexport {\n\tcreatePresenceStateDerivation,\n\tgetDefaultUserPresence,\n\ttype CreatePresenceStateDerivationOpts,\n\ttype TLPresenceStateInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\n\tdefaultAssetSchemas,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype TLSchema,\n\ttype UserSchemaInfo,\n} from './createTLSchema'\nexport {\n\tboxModelValidator,\n\tvecModelValidator,\n\ttype BoxModel,\n\ttype VecModel,\n} from './misc/geometry-types'\nexport { idValidator } from './misc/id-validator'\nexport {\n\tcanvasUiColorTypeValidator,\n\tTL_CANVAS_UI_COLOR_TYPES,\n\ttype TLCanvasUiColor,\n} from './misc/TLColor'\nexport { TL_CURSOR_TYPES, type TLCursor, type TLCursorType } from './misc/TLCursor'\nexport { TL_HANDLE_TYPES, type TLHandle, type TLHandleType } from './misc/TLHandle'\nexport { opacityValidator, type TLOpacityType } from './misc/TLOpacity'\nexport { richTextValidator, toRichText, type TLRichText } from './misc/TLRichText'\nexport { scribbleValidator, TL_SCRIBBLE_STATES, type TLScribble } from './misc/TLScribble'\nexport {\n\tassetMigrations,\n\tAssetRecordType,\n\tcreateAssetPropsMigrationIds,\n\tcreateAssetPropsMigrationSequence,\n\tcreateAssetRecordType,\n\ttype TLAsset,\n\ttype TLAssetId,\n\ttype TLAssetPartial,\n\ttype TLAssetShape,\n\ttype TLDefaultAsset,\n\ttype TLGlobalAssetPropsMap,\n\ttype TLIndexedAssets,\n\ttype TLUnknownAsset,\n} from './records/TLAsset'\nexport {\n\tcreateBindingId,\n\tcreateBindingPropsMigrationIds,\n\tcreateBindingPropsMigrationSequence,\n\tisBinding,\n\tisBindingId,\n\trootBindingMigrations,\n\ttype TLBinding,\n\ttype TLBindingCreate,\n\ttype TLBindingId,\n\ttype TLBindingUpdate,\n\ttype TLDefaultBinding,\n\ttype TLGlobalBindingPropsMap,\n\ttype TLIndexedBindings,\n\ttype TLUnknownBinding,\n} from './records/TLBinding'\nexport { CameraRecordType, type TLCamera, type TLCameraId } from './records/TLCamera'\nexport {\n\tcreateCustomRecordId,\n\tcreateCustomRecordMigrationIds,\n\tcreateCustomRecordMigrationSequence,\n\tisCustomRecord,\n\tisCustomRecordId,\n\ttype CustomRecordInfo,\n} from './records/TLCustomRecord'\nexport {\n\tDocumentRecordType,\n\tisDocument,\n\tTLDOCUMENT_ID,\n\ttype TLDocument,\n} from './records/TLDocument'\nexport {\n\tpluckPreservingValues,\n\tTLINSTANCE_ID,\n\ttype TLInstance,\n\ttype TLInstanceId,\n} from './records/TLInstance'\nexport {\n\tisPageId,\n\tpageIdValidator,\n\tPageRecordType,\n\ttype TLPage,\n\ttype TLPageId,\n} from './records/TLPage'\nexport {\n\tInstancePageStateRecordType,\n\ttype TLInstancePageState,\n\ttype TLInstancePageStateId,\n} from './records/TLPageState'\nexport {\n\tPointerRecordType,\n\tTLPOINTER_ID,\n\ttype TLPointer,\n\ttype TLPointerId,\n} from './records/TLPointer'\nexport {\n\tInstancePresenceRecordType,\n\ttype TLInstancePresence,\n\ttype TLInstancePresenceID,\n} from './records/TLPresence'\nexport {\n\ttype TLCustomRecord,\n\ttype TLDefaultRecord,\n\ttype TLGlobalRecordPropsMap,\n\ttype TLIndexedRecords,\n\ttype TLRecord,\n} from './records/TLRecord'\nexport {\n\tcreateShapeId,\n\tcreateShapePropsMigrationIds,\n\tcreateShapePropsMigrationSequence,\n\tgetShapePropKeysByStyle,\n\tisShape,\n\tisShapeId,\n\trootShapeMigrations,\n\ttype ExtractShapeByProps,\n\ttype TLCreateShapePartial,\n\ttype TLDefaultShape,\n\ttype TLGlobalShapePropsMap,\n\ttype TLIndexedShapes,\n\ttype TLParentId,\n\ttype TLShape,\n\ttype TLShapeId,\n\ttype TLShapePartial,\n\ttype TLUnknownShape,\n} from './records/TLShape'\nexport {\n\tcreateUserId,\n\tcreateUserRecordType,\n\tisUserId,\n\tuserIdValidator,\n\tUserRecordType,\n\ttype TLUser,\n\ttype TLUserId,\n} from './records/TLUser'\nexport {\n\ttype RecordProps,\n\ttype RecordPropsType,\n\ttype TLPropsMigration,\n\ttype TLPropsMigrations,\n} from './recordsWithProps'\nexport { type ShapeWithCrop, type TLShapeCrop } from './shapes/ShapeWithCrop'\nexport {\n\tArrowShapeArrowheadEndStyle,\n\tArrowShapeArrowheadStartStyle,\n\tArrowShapeKindStyle,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tarrowShapeVersions,\n\ttype TLArrowShape,\n\ttype TLArrowShapeArrowheadStyle,\n\ttype TLArrowShapeKind,\n\ttype TLArrowShapeProps,\n} from './shapes/TLArrowShape'\nexport {\n\tcreateShapeValidator,\n\tparentIdValidator,\n\tshapeIdValidator,\n\ttype TLBaseShape,\n} from './shapes/TLBaseShape'\nexport {\n\tbookmarkShapeMigrations,\n\tbookmarkShapeProps,\n\ttype TLBookmarkShape,\n\ttype TLBookmarkShapeProps,\n} from './shapes/TLBookmarkShape'\nexport {\n\tcompressLegacySegments,\n\tdrawShapeMigrations,\n\tdrawShapeProps,\n\ttype TLDrawShape,\n\ttype TLDrawShapeProps,\n\ttype TLDrawShapeSegment,\n} from './shapes/TLDrawShape'\nexport {\n\tembedShapeMigrations,\n\tembedShapeProps,\n\ttype TLEmbedShape,\n\ttype TLEmbedShapeProps,\n} from './shapes/TLEmbedShape'\nexport {\n\tframeShapeMigrations,\n\tframeShapeProps,\n\ttype TLFrameShape,\n\ttype TLFrameShapeProps,\n} from './shapes/TLFrameShape'\nexport {\n\tGeoShapeGeoStyle,\n\tgeoShapeMigrations,\n\tgeoShapeProps,\n\ttype TLGeoShape,\n\ttype TLGeoShapeGeoStyle,\n\ttype TLGeoShapeProps,\n} from './shapes/TLGeoShape'\nexport {\n\tgroupShapeMigrations,\n\tgroupShapeProps,\n\ttype TLGroupShape,\n\ttype TLGroupShapeProps,\n} from './shapes/TLGroupShape'\nexport {\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\ttype TLHighlightShape,\n\ttype TLHighlightShapeProps,\n} from './shapes/TLHighlightShape'\nexport {\n\tImageShapeCrop,\n\timageShapeMigrations,\n\timageShapeProps,\n\ttype TLImageShape,\n\ttype TLImageShapeProps,\n} from './shapes/TLImageShape'\nexport {\n\tlineShapeMigrations,\n\tlineShapeProps,\n\tLineShapeSplineStyle,\n\ttype TLLineShape,\n\ttype TLLineShapePoint,\n\ttype TLLineShapeProps,\n\ttype TLLineShapeSplineStyle,\n} from './shapes/TLLineShape'\nexport {\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\ttype TLNoteShape,\n\ttype TLNoteShapeProps,\n} from './shapes/TLNoteShape'\nexport {\n\ttextShapeMigrations,\n\ttextShapeProps,\n\ttype TLTextShape,\n\ttype TLTextShapeProps,\n} from './shapes/TLTextShape'\nexport {\n\tvideoShapeMigrations,\n\tvideoShapeProps,\n\ttype TLVideoShape,\n\ttype TLVideoShapeProps,\n} from './shapes/TLVideoShape'\nexport { EnumStyleProp, StyleProp, type StylePropValue } from './styles/StyleProp'\nexport {\n\tDefaultColorStyle,\n\tregisterColorsFromThemes,\n\ttype TLDefaultColorStyle,\n} from './styles/TLColorStyle'\nexport { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'\nexport { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'\nexport { type TLFontFace, type TLFontFaceSource } from './styles/TLFontFace'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\tisFontEntry,\n\tregisterFontsFromThemes,\n\ttype TLDefaultFontStyle,\n} from './styles/TLFontStyle'\nexport {\n\tDefaultHorizontalAlignStyle,\n\ttype TLDefaultHorizontalAlignStyle,\n} from './styles/TLHorizontalAlignStyle'\nexport { DefaultSizeStyle, type TLDefaultSizeStyle } from './styles/TLSizeStyle'\nexport { DefaultTextAlignStyle, type TLDefaultTextAlignStyle } from './styles/TLTextAlignStyle'\nexport {\n\ttype TLDefaultColor,\n\ttype TLRemovedDefaultThemeColors,\n\ttype TLTheme,\n\ttype TLThemeColors,\n\ttype TLThemeDefaultColors,\n\ttype TLThemeFont,\n\ttype TLThemeFonts,\n\ttype TLThemeId,\n\ttype TLThemes,\n\ttype TLThemeUiColorKeys,\n} from './styles/TLTheme'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype TLDefaultVerticalAlignStyle,\n} from './styles/TLVerticalAlignStyle'\nexport {\n\tcreateCachedUserResolve,\n\ttype TLAssetContext,\n\ttype TLAssetStore,\n\ttype TLSerializedStore,\n\ttype TLStore,\n\ttype TLStoreProps,\n\ttype TLStoreSchema,\n\ttype TLStoreSnapshot,\n\ttype TLUserStore,\n} from './TLStore'\nexport {\n\tgetDefaultTranslationLocale,\n\tLANGUAGES,\n\ttype TLLanguage,\n} from './translations/translations'\nexport { type SetValue } from './util-types'\n\nregisterTldrawLibraryVersion(\n\t(globalThis as any).TLDRAW_LIBRARY_NAME,\n\t(globalThis as any).TLDRAW_LIBRARY_VERSION,\n\t(globalThis as any).TLDRAW_LIBRARY_MODULES\n)\n\nexport { DIM_2D, DIM_3D, b64Vecs } from './misc/b64Vecs'\n"],
|
|
5
|
-
"mappings": "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",
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview\n * Main entry point for the tldraw schema package. Exports the complete type system,\n * data structures, validation, and migrations for tldraw's persisted data.\n *\n * This package provides:\n * - Schema creation utilities (createTLSchema, defaultShapeSchemas, defaultBindingSchemas)\n * - All built-in shape types (TLGeoShape, TLTextShape, TLArrowShape, etc.)\n * - Asset management types and validators (TLImageAsset, TLVideoAsset, TLBookmarkAsset)\n * - Binding system for shape relationships (TLArrowBinding)\n * - Store integration types (TLStore, TLStoreProps, TLStoreSnapshot)\n * - Style properties for consistent styling (DefaultColorStyle, DefaultSizeStyle, etc.)\n * - Validation utilities and type guards\n * - Migration systems for schema evolution\n * - Geometry and utility types\n *\n * @example\n * ```ts\n * import { createTLSchema, defaultShapeSchemas, TLStore } from '@tldraw/tlschema'\n *\n * // Create a schema with default shapes\n * const schema = createTLSchema({\n * shapes: defaultShapeSchemas\n * })\n *\n * // Use with a store\n * const store = new Store({ schema })\n * ```\n *\n * @public\n */\n\nimport { registerTldrawLibraryVersion } from '@tldraw/utils'\nexport { assetIdValidator, createAssetValidator, type TLBaseAsset } from './assets/TLBaseAsset'\nexport {\n\tbookmarkAssetMigrations,\n\tbookmarkAssetProps,\n\ttype TLBookmarkAsset,\n} from './assets/TLBookmarkAsset'\nexport { imageAssetMigrations, imageAssetProps, type TLImageAsset } from './assets/TLImageAsset'\nexport { videoAssetMigrations, videoAssetProps, type TLVideoAsset } from './assets/TLVideoAsset'\nexport {\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tarrowBindingVersions,\n\tElbowArrowSnap,\n\ttype TLArrowBinding,\n\ttype TLArrowBindingProps,\n} from './bindings/TLArrowBinding'\nexport {\n\tbindingIdValidator,\n\tcreateBindingValidator,\n\ttype TLBaseBinding,\n} from './bindings/TLBaseBinding'\nexport {\n\tcreatePresenceStateDerivation,\n\tgetDefaultUserPresence,\n\ttype CreatePresenceStateDerivationOpts,\n\ttype TLPresenceStateInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\n\tdefaultAssetSchemas,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype TLSchema,\n\ttype UserSchemaInfo,\n} from './createTLSchema'\nexport {\n\tboxModelValidator,\n\tvecModelValidator,\n\ttype BoxModel,\n\ttype VecModel,\n} from './misc/geometry-types'\nexport { idValidator } from './misc/id-validator'\nexport {\n\tcanvasUiColorTypeValidator,\n\tTL_CANVAS_UI_COLOR_TYPES,\n\ttype TLCanvasUiColor,\n} from './misc/TLColor'\nexport { TL_CURSOR_TYPES, type TLCursor, type TLCursorType } from './misc/TLCursor'\nexport { TL_HANDLE_TYPES, type TLHandle, type TLHandleType } from './misc/TLHandle'\nexport { opacityValidator, type TLOpacityType } from './misc/TLOpacity'\nexport { richTextValidator, toRichText, type TLRichText } from './misc/TLRichText'\nexport { scribbleValidator, TL_SCRIBBLE_STATES, type TLScribble } from './misc/TLScribble'\nexport {\n\tassetMigrations,\n\tAssetRecordType,\n\tcreateAssetPropsMigrationIds,\n\tcreateAssetPropsMigrationSequence,\n\tcreateAssetRecordType,\n\ttype TLAsset,\n\ttype TLAssetId,\n\ttype TLAssetPartial,\n\ttype TLAssetShape,\n\ttype TLDefaultAsset,\n\ttype TLGlobalAssetPropsMap,\n\ttype TLIndexedAssets,\n\ttype TLUnknownAsset,\n} from './records/TLAsset'\nexport {\n\tcreateBindingId,\n\tcreateBindingPropsMigrationIds,\n\tcreateBindingPropsMigrationSequence,\n\tisBinding,\n\tisBindingId,\n\trootBindingMigrations,\n\ttype TLBinding,\n\ttype TLBindingCreate,\n\ttype TLBindingId,\n\ttype TLBindingUpdate,\n\ttype TLDefaultBinding,\n\ttype TLGlobalBindingPropsMap,\n\ttype TLIndexedBindings,\n\ttype TLUnknownBinding,\n} from './records/TLBinding'\nexport { CameraRecordType, type TLCamera, type TLCameraId } from './records/TLCamera'\nexport {\n\tcommentRecordConfig,\n\tcommentSchemaRecords,\n\tcommentThreadRecordConfig,\n\tcreateComment,\n\tcreateCommentId,\n\tcreateCommentThread,\n\tcreateCommentThreadId,\n\tisCommentId,\n\tisCommentThreadId,\n\ttype TLComment,\n\ttype TLCommentAnchor,\n\ttype TLCommentId,\n\ttype TLCommentThread,\n\ttype TLCommentThreadId,\n} from './records/TLComment'\nexport {\n\tcreateCustomRecordId,\n\tcreateCustomRecordMigrationIds,\n\tcreateCustomRecordMigrationSequence,\n\tisCustomRecord,\n\tisCustomRecordId,\n\ttype CustomRecordInfo,\n} from './records/TLCustomRecord'\nexport {\n\tDocumentRecordType,\n\tisDocument,\n\tTLDOCUMENT_ID,\n\ttype TLDocument,\n} from './records/TLDocument'\nexport {\n\tpluckPreservingValues,\n\tTLINSTANCE_ID,\n\ttype TLInstance,\n\ttype TLInstanceId,\n} from './records/TLInstance'\nexport {\n\tisPageId,\n\tpageIdValidator,\n\tPageRecordType,\n\ttype TLPage,\n\ttype TLPageId,\n} from './records/TLPage'\nexport {\n\tInstancePageStateRecordType,\n\ttype TLInstancePageState,\n\ttype TLInstancePageStateId,\n} from './records/TLPageState'\nexport {\n\tPointerRecordType,\n\tTLPOINTER_ID,\n\ttype TLPointer,\n\ttype TLPointerId,\n} from './records/TLPointer'\nexport {\n\tInstancePresenceRecordType,\n\ttype TLInstancePresence,\n\ttype TLInstancePresenceID,\n} from './records/TLPresence'\nexport {\n\ttype TLCustomRecord,\n\ttype TLDefaultRecord,\n\ttype TLGlobalRecordPropsMap,\n\ttype TLIndexedRecords,\n\ttype TLRecord,\n} from './records/TLRecord'\nexport {\n\tcreateShapeId,\n\tcreateShapePropsMigrationIds,\n\tcreateShapePropsMigrationSequence,\n\tgetShapePropKeysByStyle,\n\tisShape,\n\tisShapeId,\n\trootShapeMigrations,\n\ttype ExtractShapeByProps,\n\ttype TLCreateShapePartial,\n\ttype TLDefaultShape,\n\ttype TLGlobalShapePropsMap,\n\ttype TLIndexedShapes,\n\ttype TLParentId,\n\ttype TLShape,\n\ttype TLShapeId,\n\ttype TLShapePartial,\n\ttype TLUnknownShape,\n} from './records/TLShape'\nexport {\n\tcreateUserId,\n\tcreateUserRecordType,\n\tisUserId,\n\tuserIdValidator,\n\tUserRecordType,\n\ttype TLUser,\n\ttype TLUserId,\n} from './records/TLUser'\nexport {\n\ttype RecordProps,\n\ttype RecordPropsType,\n\ttype TLPropsMigration,\n\ttype TLPropsMigrations,\n} from './recordsWithProps'\nexport { type ShapeWithCrop, type TLShapeCrop } from './shapes/ShapeWithCrop'\nexport {\n\tArrowShapeArrowheadEndStyle,\n\tArrowShapeArrowheadStartStyle,\n\tArrowShapeKindStyle,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tarrowShapeVersions,\n\ttype TLArrowShape,\n\ttype TLArrowShapeArrowheadStyle,\n\ttype TLArrowShapeKind,\n\ttype TLArrowShapeProps,\n} from './shapes/TLArrowShape'\nexport {\n\tcreateShapeValidator,\n\tparentIdValidator,\n\tshapeIdValidator,\n\ttype TLBaseShape,\n} from './shapes/TLBaseShape'\nexport {\n\tbookmarkShapeMigrations,\n\tbookmarkShapeProps,\n\ttype TLBookmarkShape,\n\ttype TLBookmarkShapeProps,\n} from './shapes/TLBookmarkShape'\nexport {\n\tcompressLegacySegments,\n\tdrawShapeMigrations,\n\tdrawShapeProps,\n\ttype TLDrawShape,\n\ttype TLDrawShapeProps,\n\ttype TLDrawShapeSegment,\n} from './shapes/TLDrawShape'\nexport {\n\tembedShapeMigrations,\n\tembedShapeProps,\n\ttype TLEmbedShape,\n\ttype TLEmbedShapeProps,\n} from './shapes/TLEmbedShape'\nexport {\n\tframeShapeMigrations,\n\tframeShapeProps,\n\ttype TLFrameShape,\n\ttype TLFrameShapeProps,\n} from './shapes/TLFrameShape'\nexport {\n\tGeoShapeGeoStyle,\n\tgeoShapeMigrations,\n\tgeoShapeProps,\n\ttype TLGeoShape,\n\ttype TLGeoShapeGeoStyle,\n\ttype TLGeoShapeProps,\n} from './shapes/TLGeoShape'\nexport {\n\tgroupShapeMigrations,\n\tgroupShapeProps,\n\ttype TLGroupShape,\n\ttype TLGroupShapeProps,\n} from './shapes/TLGroupShape'\nexport {\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\ttype TLHighlightShape,\n\ttype TLHighlightShapeProps,\n} from './shapes/TLHighlightShape'\nexport {\n\tImageShapeCrop,\n\timageShapeMigrations,\n\timageShapeProps,\n\ttype TLImageShape,\n\ttype TLImageShapeProps,\n} from './shapes/TLImageShape'\nexport {\n\tlineShapeMigrations,\n\tlineShapeProps,\n\tLineShapeSplineStyle,\n\ttype TLLineShape,\n\ttype TLLineShapePoint,\n\ttype TLLineShapeProps,\n\ttype TLLineShapeSplineStyle,\n} from './shapes/TLLineShape'\nexport {\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\ttype TLNoteShape,\n\ttype TLNoteShapeProps,\n} from './shapes/TLNoteShape'\nexport {\n\ttextShapeMigrations,\n\ttextShapeProps,\n\ttype TLTextShape,\n\ttype TLTextShapeProps,\n} from './shapes/TLTextShape'\nexport {\n\tvideoShapeMigrations,\n\tvideoShapeProps,\n\ttype TLVideoShape,\n\ttype TLVideoShapeProps,\n} from './shapes/TLVideoShape'\nexport { EnumStyleProp, StyleProp, type StylePropValue } from './styles/StyleProp'\nexport {\n\tDefaultColorStyle,\n\tregisterColorsFromThemes,\n\ttype TLDefaultColorStyle,\n} from './styles/TLColorStyle'\nexport { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'\nexport { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'\nexport { type TLFontFace, type TLFontFaceSource } from './styles/TLFontFace'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\tisFontEntry,\n\tregisterFontsFromThemes,\n\ttype TLDefaultFontStyle,\n} from './styles/TLFontStyle'\nexport {\n\tDefaultHorizontalAlignStyle,\n\ttype TLDefaultHorizontalAlignStyle,\n} from './styles/TLHorizontalAlignStyle'\nexport { DefaultSizeStyle, type TLDefaultSizeStyle } from './styles/TLSizeStyle'\nexport { DefaultTextAlignStyle, type TLDefaultTextAlignStyle } from './styles/TLTextAlignStyle'\nexport {\n\ttype TLDefaultColor,\n\ttype TLRemovedDefaultThemeColors,\n\ttype TLTheme,\n\ttype TLThemeColors,\n\ttype TLThemeDefaultColors,\n\ttype TLThemeFont,\n\ttype TLThemeFonts,\n\ttype TLThemeId,\n\ttype TLThemes,\n\ttype TLThemeUiColorKeys,\n} from './styles/TLTheme'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype TLDefaultVerticalAlignStyle,\n} from './styles/TLVerticalAlignStyle'\nexport {\n\tcreateCachedUserResolve,\n\ttype TLAssetContext,\n\ttype TLAssetStore,\n\ttype TLSerializedStore,\n\ttype TLStore,\n\ttype TLStoreProps,\n\ttype TLStoreSchema,\n\ttype TLStoreSnapshot,\n\ttype TLUserStore,\n} from './TLStore'\nexport {\n\tgetDefaultTranslationLocale,\n\tLANGUAGES,\n\ttype TLLanguage,\n} from './translations/translations'\nexport { type SetValue } from './util-types'\n\nregisterTldrawLibraryVersion(\n\t(globalThis as any).TLDRAW_LIBRARY_NAME,\n\t(globalThis as any).TLDRAW_LIBRARY_VERSION,\n\t(globalThis as any).TLDRAW_LIBRARY_MODULES\n)\n\nexport { DIM_2D, DIM_3D, b64Vecs } from './misc/b64Vecs'\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/misc/TLCursor.ts"],
|
|
4
|
-
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { SetValue } from '../util-types'\n\n/**\n * All available cursor types used throughout the tldraw editor.\n *\n * These cursor types correspond to CSS cursor values and are used to indicate\n * different interaction modes and states within the editor. The cursor types\n * cover selection, resizing, rotation, text editing, and various other editor\n * interactions.\n *\n * @example\n * ```ts\n * // Check if a cursor type is valid\n * if (TL_CURSOR_TYPES.has('resize-corner')) {\n * console.log('Valid cursor type')\n * }\n *\n * // Get all available cursor types\n * const allCursors = Array.from(TL_CURSOR_TYPES)\n * ```\n *\n * @public\n */\nexport const TL_CURSOR_TYPES = new Set([\n\t'none',\n\t'default',\n\t'pointer',\n\t'cross',\n\t'grab',\n\t'rotate',\n\t'grabbing',\n\t'resize-edge',\n\t'resize-corner',\n\t'text',\n\t'move',\n\t'ew-resize',\n\t'ns-resize',\n\t'nesw-resize',\n\t'nwse-resize',\n\t'nesw-rotate',\n\t'nwse-rotate',\n\t'swne-rotate',\n\t'senw-rotate',\n\t'zoom-in',\n\t'zoom-out',\n])\n\n/**\n * A union type representing all available cursor types in the tldraw editor.\n *\n * Each cursor type corresponds to a different interaction mode or state,\n * helping users understand what action they can perform at any given moment.\n *\n * @example\n * ```ts\n * const defaultCursor: TLCursorType = 'default'\n * const textCursor: TLCursorType = 'text'\n * const resizeCursor: TLCursorType = 'resize-corner'\n * const rotateCursor: TLCursorType = 'nesw-rotate'\n * ```\n *\n * @public\n */\nexport type TLCursorType = SetValue<typeof TL_CURSOR_TYPES>\n\n/**\n * A validator for cursor types.\n *\n * This validator ensures that cursor type values are one of the valid types\n * defined in {@link TL_CURSOR_TYPES}. It provides runtime type checking for\n * cursor properties throughout the editor.\n *\n * @example\n * ```ts\n * import { cursorTypeValidator } from '@tldraw/tlschema'\n *\n * // Validate a cursor type\n * try {\n * const validCursor = cursorTypeValidator.validate('pointer')\n * console.log('Valid cursor:', validCursor)\n * } catch (error) {\n * console.error('Invalid cursor:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cursorTypeValidator = T.setEnum(TL_CURSOR_TYPES)\n\n/**\n * A cursor object used throughout the tldraw editor.\n *\n * Represents both the cursor type (which determines the visual appearance)\n * and its rotation angle. The rotation is particularly useful for resize\n * and rotation cursors that need to align with the current interaction angle.\n *\n * @example\n * ```ts\n * // Default cursor\n * const defaultCursor: TLCursor = {\n * type: 'default',\n * rotation: 0\n * }\n *\n * // Rotated resize cursor\n * const rotatedResizeCursor: TLCursor = {\n * type: 'resize-corner',\n * rotation: Math.PI / 4 // 45 degrees\n * }\n *\n * // Text editing cursor\n * const textCursor: TLCursor = {\n * type: 'text',\n * rotation: 0\n * }\n * ```\n *\n * @public\n */\nexport interface TLCursor {\n\t/** The cursor type, determining the visual appearance and interaction mode */\n\ttype: TLCursorType\n\t/** The rotation angle in radians, used for rotated cursors like resize handles */\n\trotation: number\n}\n\n/**\n * A validator for TLCursor objects.\n *\n * This validator ensures that cursor objects have valid cursor types and\n * numeric rotation values. It provides runtime validation for cursor\n * properties used throughout the editor.\n *\n * @example\n * ```ts\n * import { cursorValidator } from '@tldraw/tlschema'\n *\n * // Validate a cursor object\n * try {\n * const validCursor = cursorValidator.validate({\n * type: 'pointer',\n * rotation: 0.5\n * })\n * console.log('Valid cursor:', validCursor)\n * } catch (error) {\n * console.error('Invalid cursor:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cursorValidator: T.ObjectValidator<TLCursor> = T.object<TLCursor>({\n\ttype: cursorTypeValidator,\n\trotation: T.number,\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAwBX,MAAM,kBAAkB,oBAAI,IAAI;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AA0CM,MAAM,sBAAsB,EAAE,QAAQ,eAAe;AAgErD,MAAM,kBAA+C,EAAE,OAAiB;AAAA,EAC9E,MAAM;AAAA,EACN,UAAU,EAAE;AACb,CAAC;",
|
|
4
|
+
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { SetValue } from '../util-types'\n\n/**\n * All available cursor types used throughout the tldraw editor.\n *\n * These cursor types correspond to CSS cursor values and are used to indicate\n * different interaction modes and states within the editor. The cursor types\n * cover selection, resizing, rotation, text editing, and various other editor\n * interactions.\n *\n * @example\n * ```ts\n * // Check if a cursor type is valid\n * if (TL_CURSOR_TYPES.has('resize-corner')) {\n * console.log('Valid cursor type')\n * }\n *\n * // Get all available cursor types\n * const allCursors = Array.from(TL_CURSOR_TYPES)\n * ```\n *\n * @public\n */\nexport const TL_CURSOR_TYPES = new Set([\n\t'none',\n\t'default',\n\t'pointer',\n\t'cross',\n\t'comment',\n\t'grab',\n\t'rotate',\n\t'grabbing',\n\t'resize-edge',\n\t'resize-corner',\n\t'text',\n\t'move',\n\t'ew-resize',\n\t'ns-resize',\n\t'nesw-resize',\n\t'nwse-resize',\n\t'nesw-rotate',\n\t'nwse-rotate',\n\t'swne-rotate',\n\t'senw-rotate',\n\t'zoom-in',\n\t'zoom-out',\n])\n\n/**\n * A union type representing all available cursor types in the tldraw editor.\n *\n * Each cursor type corresponds to a different interaction mode or state,\n * helping users understand what action they can perform at any given moment.\n *\n * @example\n * ```ts\n * const defaultCursor: TLCursorType = 'default'\n * const textCursor: TLCursorType = 'text'\n * const resizeCursor: TLCursorType = 'resize-corner'\n * const rotateCursor: TLCursorType = 'nesw-rotate'\n * ```\n *\n * @public\n */\nexport type TLCursorType = SetValue<typeof TL_CURSOR_TYPES>\n\n/**\n * A validator for cursor types.\n *\n * This validator ensures that cursor type values are one of the valid types\n * defined in {@link TL_CURSOR_TYPES}. It provides runtime type checking for\n * cursor properties throughout the editor.\n *\n * @example\n * ```ts\n * import { cursorTypeValidator } from '@tldraw/tlschema'\n *\n * // Validate a cursor type\n * try {\n * const validCursor = cursorTypeValidator.validate('pointer')\n * console.log('Valid cursor:', validCursor)\n * } catch (error) {\n * console.error('Invalid cursor:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cursorTypeValidator = T.setEnum(TL_CURSOR_TYPES)\n\n/**\n * A cursor object used throughout the tldraw editor.\n *\n * Represents both the cursor type (which determines the visual appearance)\n * and its rotation angle. The rotation is particularly useful for resize\n * and rotation cursors that need to align with the current interaction angle.\n *\n * @example\n * ```ts\n * // Default cursor\n * const defaultCursor: TLCursor = {\n * type: 'default',\n * rotation: 0\n * }\n *\n * // Rotated resize cursor\n * const rotatedResizeCursor: TLCursor = {\n * type: 'resize-corner',\n * rotation: Math.PI / 4 // 45 degrees\n * }\n *\n * // Text editing cursor\n * const textCursor: TLCursor = {\n * type: 'text',\n * rotation: 0\n * }\n * ```\n *\n * @public\n */\nexport interface TLCursor {\n\t/** The cursor type, determining the visual appearance and interaction mode */\n\ttype: TLCursorType\n\t/** The rotation angle in radians, used for rotated cursors like resize handles */\n\trotation: number\n}\n\n/**\n * A validator for TLCursor objects.\n *\n * This validator ensures that cursor objects have valid cursor types and\n * numeric rotation values. It provides runtime validation for cursor\n * properties used throughout the editor.\n *\n * @example\n * ```ts\n * import { cursorValidator } from '@tldraw/tlschema'\n *\n * // Validate a cursor object\n * try {\n * const validCursor = cursorValidator.validate({\n * type: 'pointer',\n * rotation: 0.5\n * })\n * console.log('Valid cursor:', validCursor)\n * } catch (error) {\n * console.error('Invalid cursor:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cursorValidator: T.ObjectValidator<TLCursor> = T.object<TLCursor>({\n\ttype: cursorTypeValidator,\n\trotation: T.number,\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAwBX,MAAM,kBAAkB,oBAAI,IAAI;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AA0CM,MAAM,sBAAsB,EAAE,QAAQ,eAAe;AAgErD,MAAM,kBAA+C,EAAE,OAAiB;AAAA,EAC9E,MAAM;AAAA,EACN,UAAU,EAAE;AACb,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createRecordMigrationSequence } from "@tldraw/store";
|
|
2
|
+
import { T } from "@tldraw/validate";
|
|
3
|
+
import { idValidator } from "../misc/id-validator.mjs";
|
|
4
|
+
import { richTextValidator } from "../misc/TLRichText.mjs";
|
|
5
|
+
import { createCustomRecordId, isCustomRecordId } from "./TLCustomRecord.mjs";
|
|
6
|
+
const commentAnchorValidator = T.union("type", {
|
|
7
|
+
shape: T.object({
|
|
8
|
+
type: T.literal("shape"),
|
|
9
|
+
shapeId: idValidator("shape"),
|
|
10
|
+
x: T.number,
|
|
11
|
+
y: T.number,
|
|
12
|
+
isPrecise: T.boolean
|
|
13
|
+
}),
|
|
14
|
+
point: T.object({
|
|
15
|
+
type: T.literal("point"),
|
|
16
|
+
x: T.number,
|
|
17
|
+
y: T.number
|
|
18
|
+
}),
|
|
19
|
+
region: T.object({
|
|
20
|
+
type: T.literal("region"),
|
|
21
|
+
x: T.number,
|
|
22
|
+
y: T.number,
|
|
23
|
+
w: T.number,
|
|
24
|
+
h: T.number,
|
|
25
|
+
pinX: T.number.optional(),
|
|
26
|
+
pinY: T.number.optional()
|
|
27
|
+
}),
|
|
28
|
+
page: T.object({
|
|
29
|
+
type: T.literal("page")
|
|
30
|
+
}),
|
|
31
|
+
"text-range": T.object({
|
|
32
|
+
type: T.literal("text-range"),
|
|
33
|
+
shapeId: idValidator("shape"),
|
|
34
|
+
from: T.number,
|
|
35
|
+
to: T.number
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
function createCommentGuardMigrations(typeName, extra = []) {
|
|
39
|
+
return createRecordMigrationSequence({
|
|
40
|
+
sequenceId: `com.tldraw.${typeName}`,
|
|
41
|
+
recordType: typeName,
|
|
42
|
+
retroactive: true,
|
|
43
|
+
sequence: [
|
|
44
|
+
{
|
|
45
|
+
id: `com.tldraw.${typeName}/1`,
|
|
46
|
+
up: (record) => record
|
|
47
|
+
},
|
|
48
|
+
...extra
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const commentThreadRecordConfig = {
|
|
53
|
+
scope: "document",
|
|
54
|
+
migrations: createCommentGuardMigrations("comment-thread", [
|
|
55
|
+
{
|
|
56
|
+
// Shape anchors gained normalized x/y + isPrecise; existing ones were imprecise (top-right).
|
|
57
|
+
id: "com.tldraw.comment-thread/2",
|
|
58
|
+
up: (record) => {
|
|
59
|
+
const anchor = record.anchor;
|
|
60
|
+
if (anchor?.type === "shape" && anchor.x === void 0) {
|
|
61
|
+
;
|
|
62
|
+
record.anchor = { ...anchor, x: 1, y: 0, isPrecise: false };
|
|
63
|
+
}
|
|
64
|
+
return record;
|
|
65
|
+
},
|
|
66
|
+
down: (record) => {
|
|
67
|
+
const anchor = record.anchor;
|
|
68
|
+
if (anchor?.type === "shape") {
|
|
69
|
+
;
|
|
70
|
+
record.anchor = { type: "shape", shapeId: anchor.shapeId };
|
|
71
|
+
}
|
|
72
|
+
return record;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
// Region anchors gained an optional pin corner (where the creating drag released).
|
|
77
|
+
id: "com.tldraw.comment-thread/3",
|
|
78
|
+
up: (record) => record,
|
|
79
|
+
down: (record) => {
|
|
80
|
+
const anchor = record.anchor;
|
|
81
|
+
if (anchor?.type === "region") {
|
|
82
|
+
const { pinX: _pinX, pinY: _pinY, ...rest } = anchor;
|
|
83
|
+
record.anchor = rest;
|
|
84
|
+
}
|
|
85
|
+
return record;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]),
|
|
89
|
+
validator: T.object({
|
|
90
|
+
id: idValidator("comment-thread"),
|
|
91
|
+
typeName: T.literal("comment-thread"),
|
|
92
|
+
pageId: idValidator("page"),
|
|
93
|
+
anchor: commentAnchorValidator,
|
|
94
|
+
createdBy: T.string,
|
|
95
|
+
createdAt: T.number,
|
|
96
|
+
resolved: T.object({ at: T.number, by: T.string }).nullable(),
|
|
97
|
+
meta: T.jsonValue
|
|
98
|
+
})
|
|
99
|
+
};
|
|
100
|
+
const commentRecordConfig = {
|
|
101
|
+
scope: "document",
|
|
102
|
+
migrations: createCommentGuardMigrations("comment"),
|
|
103
|
+
validator: T.object({
|
|
104
|
+
id: idValidator("comment"),
|
|
105
|
+
typeName: T.literal("comment"),
|
|
106
|
+
threadId: idValidator("comment-thread"),
|
|
107
|
+
pageId: idValidator("page"),
|
|
108
|
+
authorId: T.string,
|
|
109
|
+
createdAt: T.number,
|
|
110
|
+
editedAt: T.number.nullable(),
|
|
111
|
+
body: richTextValidator,
|
|
112
|
+
meta: T.jsonValue
|
|
113
|
+
})
|
|
114
|
+
};
|
|
115
|
+
const commentSchemaRecords = {
|
|
116
|
+
"comment-thread": commentThreadRecordConfig,
|
|
117
|
+
comment: commentRecordConfig
|
|
118
|
+
};
|
|
119
|
+
function createCommentThreadId(id) {
|
|
120
|
+
return createCustomRecordId("comment-thread", id);
|
|
121
|
+
}
|
|
122
|
+
function createCommentId(id) {
|
|
123
|
+
return createCustomRecordId("comment", id);
|
|
124
|
+
}
|
|
125
|
+
function isCommentThreadId(id) {
|
|
126
|
+
return isCustomRecordId("comment-thread", id);
|
|
127
|
+
}
|
|
128
|
+
function isCommentId(id) {
|
|
129
|
+
return isCustomRecordId("comment", id);
|
|
130
|
+
}
|
|
131
|
+
function createCommentThread(props) {
|
|
132
|
+
return {
|
|
133
|
+
id: createCommentThreadId(),
|
|
134
|
+
typeName: "comment-thread",
|
|
135
|
+
pageId: props.pageId,
|
|
136
|
+
anchor: props.anchor,
|
|
137
|
+
createdBy: props.createdBy,
|
|
138
|
+
createdAt: props.now ?? Date.now(),
|
|
139
|
+
resolved: null,
|
|
140
|
+
meta: props.meta ?? {}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function createComment(props) {
|
|
144
|
+
return {
|
|
145
|
+
id: createCommentId(),
|
|
146
|
+
typeName: "comment",
|
|
147
|
+
threadId: props.threadId,
|
|
148
|
+
pageId: props.pageId,
|
|
149
|
+
authorId: props.authorId,
|
|
150
|
+
createdAt: props.now ?? Date.now(),
|
|
151
|
+
editedAt: null,
|
|
152
|
+
body: props.body,
|
|
153
|
+
meta: props.meta ?? {}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
commentRecordConfig,
|
|
158
|
+
commentSchemaRecords,
|
|
159
|
+
commentThreadRecordConfig,
|
|
160
|
+
createComment,
|
|
161
|
+
createCommentId,
|
|
162
|
+
createCommentThread,
|
|
163
|
+
createCommentThreadId,
|
|
164
|
+
isCommentId,
|
|
165
|
+
isCommentThreadId
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=TLComment.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/records/TLComment.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseRecord, RecordId, createRecordMigrationSequence } from '@tldraw/store'\nimport { JsonObject } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { richTextValidator, TLRichText } from '../misc/TLRichText'\nimport { CustomRecordInfo, createCustomRecordId, isCustomRecordId } from './TLCustomRecord'\nimport { TLPageId } from './TLPage'\nimport { TLShapeId } from './TLShape'\n\n/**\n * Where a comment thread is anchored on the canvas. Modeled as a discriminated union so new\n * anchor kinds can be added without breaking existing threads:\n *\n * - `shape` \u2014 pinned to a shape. `x`/`y` are normalized (0\u20131) within the shape's page bounds, so\n * the pin keeps its spot as the shape moves and resizes. `isPrecise` mirrors arrow bindings: when\n * true the pin sits at exactly `x`/`y`; when false (the default) it sits at a consumer-defined\n * spot (top-right out of the box), and `x`/`y` are the remembered precise position\n * - `point` \u2014 pinned to a fixed point on the page, in page coordinates\n * - `region` \u2014 pinned to a rectangular area of the page, in page coordinates\n * - `page` \u2014 a page-level thread with no spatial anchor\n * - `text-range` \u2014 pinned to a character range inside a shape's text\n *\n * @public\n */\nexport type TLCommentAnchor =\n\t| { type: 'shape'; shapeId: TLShapeId; x: number; y: number; isPrecise: boolean }\n\t| { type: 'point'; x: number; y: number }\n\t| {\n\t\t\ttype: 'region'\n\t\t\tx: number\n\t\t\ty: number\n\t\t\tw: number\n\t\t\th: number\n\t\t\t/** The normalized (0\u20131) corner the pin sits on \u2014 where the creating drag was released.\n\t\t\t * Absent on older records; consumers fall back to their configured corner. */\n\t\t\tpinX?: number\n\t\t\tpinY?: number\n\t }\n\t| { type: 'page' }\n\t| { type: 'text-range'; shapeId: TLShapeId; from: number; to: number }\n\n/**\n * A comment thread. The thread owns the anchor (where the conversation lives on the canvas) and\n * the resolution state; the messages themselves are `TLComment` records pointing at the thread\n * via `threadId`, ordered by `createdAt`. v1 threads are flat \u2014 no nested replies.\n *\n * Threads and comments are document records, but they're intended to be served through the sync\n * server's object-store lane: gated by the session's `objectAccess` rather than `isReadonly`\n * (so \"can comment but not edit\" is expressible), excluded from document snapshots and `.tldr`\n * exports server-side, and persisted in a separate lane from the main document.\n *\n * Opt-in: register with `createTLSchema({ records: commentSchemaRecords })` on the server and\n * the matching `records` option on the client \u2014 neither type is part of the default schema, and\n * both sides must register them identically.\n *\n * @public\n */\nexport interface TLCommentThread extends BaseRecord<'comment-thread', TLCommentThreadId> {\n\t/** The page the thread lives on. */\n\tpageId: TLPageId\n\t/** Where the thread is anchored on that page. */\n\tanchor: TLCommentAnchor\n\t/**\n\t * Who started the thread. Client-supplied for now; the sync server should stamp/verify this\n\t * from the session's authenticated identity once record-level authorization lands (the same\n\t * model presence already uses for self-ownership).\n\t */\n\tcreatedBy: string\n\tcreatedAt: number\n\t/** Resolution state: when and by whom the thread was resolved, or null while open. */\n\tresolved: { at: number; by: string } | null\n\tmeta: JsonObject\n}\n\n/** @public */\nexport type TLCommentThreadId = RecordId<TLCommentThread>\n\n/**\n * A single comment message within a thread. See `TLCommentThread` for the overall model and\n * sync/registration notes.\n *\n * Comment mutations are deliberately not undoable \u2014 create/edit them with\n * `{ history: 'ignore' }` to avoid multiplayer surprises like a comment reappearing after\n * someone else deleted it.\n *\n * @public\n */\nexport interface TLComment extends BaseRecord<'comment', TLCommentId> {\n\t/** The thread this comment belongs to. */\n\tthreadId: TLCommentThreadId\n\t/** Denormalized from the thread so per-page queries don't need a join. */\n\tpageId: TLPageId\n\t/** See `TLCommentThread.createdBy` \u2014 same server-stamping caveat applies. */\n\tauthorId: string\n\tcreatedAt: number\n\t/** Null until the comment is first edited. */\n\teditedAt: number | null\n\t/** Rich text body. Use `toRichText(...)` for plaintext input. */\n\tbody: TLRichText\n\tmeta: JsonObject\n}\n\n/** @public */\nexport type TLCommentId = RecordId<TLComment>\n\nconst commentAnchorValidator: T.Validator<TLCommentAnchor> = T.union('type', {\n\tshape: T.object({\n\t\ttype: T.literal('shape'),\n\t\tshapeId: idValidator<TLShapeId>('shape'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\tisPrecise: T.boolean,\n\t}),\n\tpoint: T.object({\n\t\ttype: T.literal('point'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t}),\n\tregion: T.object({\n\t\ttype: T.literal('region'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\tw: T.number,\n\t\th: T.number,\n\t\tpinX: T.number.optional(),\n\t\tpinY: T.number.optional(),\n\t}),\n\tpage: T.object({\n\t\ttype: T.literal('page'),\n\t}),\n\t'text-range': T.object({\n\t\ttype: T.literal('text-range'),\n\t\tshapeId: idValidator<TLShapeId>('shape'),\n\t\tfrom: T.number,\n\t\tto: T.number,\n\t}),\n})\n\n/**\n * Guard migrations for the comment record types. Each sequence is retroactive and starts with an\n * identity migration that has no `down`: a sync server whose schema registers the comment types\n * cannot down-migrate records for a session whose schema predates them, so such sessions are\n * rejected with CLIENT_TOO_OLD (prompting a refresh) instead of being sent record types their\n * store cannot represent.\n */\nfunction createCommentGuardMigrations(\n\ttypeName: 'comment' | 'comment-thread',\n\textra: Parameters<typeof createRecordMigrationSequence>[0]['sequence'] = []\n) {\n\treturn createRecordMigrationSequence({\n\t\tsequenceId: `com.tldraw.${typeName}`,\n\t\trecordType: typeName,\n\t\tretroactive: true,\n\t\tsequence: [\n\t\t\t{\n\t\t\t\tid: `com.tldraw.${typeName}/1`,\n\t\t\t\tup: (record) => record,\n\t\t\t},\n\t\t\t...extra,\n\t\t],\n\t})\n}\n\n/**\n * Config for registering the `comment-thread` record type in a tldraw schema. Pass via\n * `commentSchemaRecords`; see `TLCommentThread`.\n *\n * @public\n */\nexport const commentThreadRecordConfig: CustomRecordInfo = {\n\tscope: 'document',\n\tmigrations: createCommentGuardMigrations('comment-thread', [\n\t\t{\n\t\t\t// Shape anchors gained normalized x/y + isPrecise; existing ones were imprecise (top-right).\n\t\t\tid: 'com.tldraw.comment-thread/2',\n\t\t\tup: (record) => {\n\t\t\t\tconst anchor = (record as any).anchor\n\t\t\t\tif (anchor?.type === 'shape' && anchor.x === undefined) {\n\t\t\t\t\t;(record as any).anchor = { ...anchor, x: 1, y: 0, isPrecise: false }\n\t\t\t\t}\n\t\t\t\treturn record\n\t\t\t},\n\t\t\tdown: (record) => {\n\t\t\t\tconst anchor = (record as any).anchor\n\t\t\t\tif (anchor?.type === 'shape') {\n\t\t\t\t\t;(record as any).anchor = { type: 'shape', shapeId: anchor.shapeId }\n\t\t\t\t}\n\t\t\t\treturn record\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t// Region anchors gained an optional pin corner (where the creating drag released).\n\t\t\tid: 'com.tldraw.comment-thread/3',\n\t\t\tup: (record) => record,\n\t\t\tdown: (record) => {\n\t\t\t\tconst anchor = (record as any).anchor\n\t\t\t\tif (anchor?.type === 'region') {\n\t\t\t\t\tconst { pinX: _pinX, pinY: _pinY, ...rest } = anchor\n\t\t\t\t\t;(record as any).anchor = rest\n\t\t\t\t}\n\t\t\t\treturn record\n\t\t\t},\n\t\t},\n\t]),\n\tvalidator: T.object({\n\t\tid: idValidator<TLCommentThreadId>('comment-thread'),\n\t\ttypeName: T.literal('comment-thread'),\n\t\tpageId: idValidator<TLPageId>('page'),\n\t\tanchor: commentAnchorValidator,\n\t\tcreatedBy: T.string,\n\t\tcreatedAt: T.number,\n\t\tresolved: T.object({ at: T.number, by: T.string }).nullable(),\n\t\tmeta: T.jsonValue,\n\t}),\n}\n\n/**\n * Config for registering the `comment` record type in a tldraw schema. Pass via\n * `commentSchemaRecords`; see `TLComment`.\n *\n * @public\n */\nexport const commentRecordConfig: CustomRecordInfo = {\n\tscope: 'document',\n\tmigrations: createCommentGuardMigrations('comment'),\n\tvalidator: T.object({\n\t\tid: idValidator<TLCommentId>('comment'),\n\t\ttypeName: T.literal('comment'),\n\t\tthreadId: idValidator<TLCommentThreadId>('comment-thread'),\n\t\tpageId: idValidator<TLPageId>('page'),\n\t\tauthorId: T.string,\n\t\tcreatedAt: T.number,\n\t\teditedAt: T.number.nullable(),\n\t\tbody: richTextValidator,\n\t\tmeta: T.jsonValue,\n\t}),\n}\n\n/**\n * The `records` map to pass to `createTLSchema` / the client `records` option so comment\n * threads and comments sync. Register both types together \u2014 a comment without its thread type\n * (or vice versa) will fail schema validation on one side of the connection.\n *\n * @public\n */\nexport const commentSchemaRecords = {\n\t'comment-thread': commentThreadRecordConfig,\n\tcomment: commentRecordConfig,\n}\n\n/** @public */\nexport function createCommentThreadId(id?: string): TLCommentThreadId {\n\treturn createCustomRecordId('comment-thread', id) as TLCommentThreadId\n}\n\n/** @public */\nexport function createCommentId(id?: string): TLCommentId {\n\treturn createCustomRecordId('comment', id) as TLCommentId\n}\n\n/**\n * Type guard for `TLCommentThreadId`. Note `isCommentId` does not accept these: the prefixes\n * are `comment-thread:` vs `comment:`, and the character after `comment` differs (`-` vs `:`),\n * so the two never overlap.\n *\n * @public\n */\nexport function isCommentThreadId(id: string): id is TLCommentThreadId {\n\treturn isCustomRecordId('comment-thread', id)\n}\n\n/**\n * Type guard for `TLCommentId`. See `isCommentThreadId` for why `comment-thread:...` ids are\n * correctly rejected here.\n *\n * @public\n */\nexport function isCommentId(id: string): id is TLCommentId {\n\treturn isCustomRecordId('comment', id)\n}\n\n/**\n * Create a new comment thread record. Pair with `createComment` for the thread's first message.\n *\n * @public\n */\nexport function createCommentThread(props: {\n\tpageId: TLPageId\n\tanchor: TLCommentAnchor\n\tcreatedBy: string\n\tnow?: number\n\tmeta?: JsonObject\n}): TLCommentThread {\n\treturn {\n\t\tid: createCommentThreadId(),\n\t\ttypeName: 'comment-thread',\n\t\tpageId: props.pageId,\n\t\tanchor: props.anchor,\n\t\tcreatedBy: props.createdBy,\n\t\tcreatedAt: props.now ?? Date.now(),\n\t\tresolved: null,\n\t\tmeta: props.meta ?? {},\n\t}\n}\n\n/**\n * Create a new comment record within a thread.\n *\n * @public\n */\nexport function createComment(props: {\n\tthreadId: TLCommentThreadId\n\tpageId: TLPageId\n\tauthorId: string\n\tbody: TLRichText\n\tnow?: number\n\tmeta?: JsonObject\n}): TLComment {\n\treturn {\n\t\tid: createCommentId(),\n\t\ttypeName: 'comment',\n\t\tthreadId: props.threadId,\n\t\tpageId: props.pageId,\n\t\tauthorId: props.authorId,\n\t\tcreatedAt: props.now ?? Date.now(),\n\t\teditedAt: null,\n\t\tbody: props.body,\n\t\tmeta: props.meta ?? {},\n\t}\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -49,6 +49,8 @@ const geoShapeProps = {
|
|
|
49
49
|
h: T.nonZeroNumber,
|
|
50
50
|
growY: T.positiveNumber,
|
|
51
51
|
scale: T.nonZeroNumber,
|
|
52
|
+
flipX: T.boolean,
|
|
53
|
+
flipY: T.boolean,
|
|
52
54
|
// Text properties
|
|
53
55
|
labelColor: DefaultLabelColorStyle,
|
|
54
56
|
color: DefaultColorStyle,
|
|
@@ -70,7 +72,8 @@ const geoShapeVersions = createShapePropsMigrationIds("geo", {
|
|
|
70
72
|
MakeUrlsValid: 8,
|
|
71
73
|
AddScale: 9,
|
|
72
74
|
AddRichText: 10,
|
|
73
|
-
AddRichTextAttrs: 11
|
|
75
|
+
AddRichTextAttrs: 11,
|
|
76
|
+
AddFlipProps: 12
|
|
74
77
|
});
|
|
75
78
|
const geoShapeMigrations = createShapePropsMigrationSequence({
|
|
76
79
|
sequence: [
|
|
@@ -174,6 +177,17 @@ const geoShapeMigrations = createShapePropsMigrationSequence({
|
|
|
174
177
|
delete props.richText.attrs;
|
|
175
178
|
}
|
|
176
179
|
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: geoShapeVersions.AddFlipProps,
|
|
183
|
+
up: (props) => {
|
|
184
|
+
props.flipX = false;
|
|
185
|
+
props.flipY = false;
|
|
186
|
+
},
|
|
187
|
+
down: (props) => {
|
|
188
|
+
delete props.flipX;
|
|
189
|
+
delete props.flipY;
|
|
190
|
+
}
|
|
177
191
|
}
|
|
178
192
|
]
|
|
179
193
|
});
|