@tldraw/tlschema 5.2.0-canary.78bdee598fd9 → 5.2.0-canary.79ebf6ab5ef9
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/index.d.ts +2 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/shapes/TLNoteShape.js +14 -2
- package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
- package/dist-esm/index.d.mts +2 -2
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/shapes/TLNoteShape.mjs +14 -2
- package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
- package/package.json +5 -5
- package/src/migrations.test.ts +22 -0
- package/src/shapes/TLNoteShape.ts +15 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -5576,8 +5576,8 @@ export declare interface TLNoteShapeProps {
|
|
|
5576
5576
|
richText: TLRichText;
|
|
5577
5577
|
/** Scale factor applied to the note shape for display */
|
|
5578
5578
|
scale: number;
|
|
5579
|
-
/** User ID of the person who
|
|
5580
|
-
|
|
5579
|
+
/** User ID of the person who last edited the note text */
|
|
5580
|
+
textLastEditedBy: null | string;
|
|
5581
5581
|
}
|
|
5582
5582
|
|
|
5583
5583
|
/**
|
package/dist-cjs/index.js
CHANGED
|
@@ -207,7 +207,7 @@ var import_translations = require("./translations/translations");
|
|
|
207
207
|
var import_b64Vecs = require("./misc/b64Vecs");
|
|
208
208
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
209
209
|
"@tldraw/tlschema",
|
|
210
|
-
"5.2.0-canary.
|
|
210
|
+
"5.2.0-canary.79ebf6ab5ef9",
|
|
211
211
|
"cjs"
|
|
212
212
|
);
|
|
213
213
|
//# sourceMappingURL=index.js.map
|
|
@@ -43,7 +43,7 @@ const noteShapeProps = {
|
|
|
43
43
|
url: import_validate.T.linkUrl,
|
|
44
44
|
richText: import_TLRichText.richTextValidator,
|
|
45
45
|
scale: import_validate.T.nonZeroNumber,
|
|
46
|
-
|
|
46
|
+
textLastEditedBy: import_validate.T.string.nullable()
|
|
47
47
|
};
|
|
48
48
|
const Versions = (0, import_TLShape.createShapePropsMigrationIds)("note", {
|
|
49
49
|
AddUrlProp: 1,
|
|
@@ -57,7 +57,8 @@ const Versions = (0, import_TLShape.createShapePropsMigrationIds)("note", {
|
|
|
57
57
|
AddRichText: 9,
|
|
58
58
|
AddRichTextAttrs: 10,
|
|
59
59
|
AddFirstEditedBy: 11,
|
|
60
|
-
MakeFontSizeAdjustmentRatio: 12
|
|
60
|
+
MakeFontSizeAdjustmentRatio: 12,
|
|
61
|
+
RenameFirstEditedByToLast: 13
|
|
61
62
|
});
|
|
62
63
|
const noteShapeMigrations = (0, import_TLShape.createShapePropsMigrationSequence)({
|
|
63
64
|
sequence: [
|
|
@@ -176,6 +177,17 @@ const noteShapeMigrations = (0, import_TLShape.createShapePropsMigrationSequence
|
|
|
176
177
|
down: (props) => {
|
|
177
178
|
props.fontSizeAdjustment = 0;
|
|
178
179
|
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: Versions.RenameFirstEditedByToLast,
|
|
183
|
+
up: (props) => {
|
|
184
|
+
props.textLastEditedBy = props.textFirstEditedBy ?? null;
|
|
185
|
+
delete props.textFirstEditedBy;
|
|
186
|
+
},
|
|
187
|
+
down: (props) => {
|
|
188
|
+
props.textFirstEditedBy = props.textLastEditedBy ?? null;
|
|
189
|
+
delete props.textLastEditedBy;
|
|
190
|
+
}
|
|
179
191
|
}
|
|
180
192
|
]
|
|
181
193
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/shapes/TLNoteShape.ts"],
|
|
4
|
-
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { TLRichText, richTextValidator, toRichText } from '../misc/TLRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/TLShape'\nimport { RecordProps } from '../recordsWithProps'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tTLDefaultColorStyle,\n} from '../styles/TLColorStyle'\nimport { DefaultFontStyle, TLDefaultFontStyle } from '../styles/TLFontStyle'\nimport {\n\tDefaultHorizontalAlignStyle,\n\tTLDefaultHorizontalAlignStyle,\n} from '../styles/TLHorizontalAlignStyle'\nimport { DefaultSizeStyle, TLDefaultSizeStyle } from '../styles/TLSizeStyle'\nimport {\n\tDefaultVerticalAlignStyle,\n\tTLDefaultVerticalAlignStyle,\n} from '../styles/TLVerticalAlignStyle'\nimport { TLBaseShape } from './TLBaseShape'\n\n/**\n * Properties for a note shape. Note shapes represent sticky notes or text annotations\n * with rich formatting capabilities and various styling options.\n *\n * @public\n * @example\n * ```ts\n * const noteProps: TLNoteShapeProps = {\n * color: 'yellow',\n * labelColor: 'black',\n * size: 'm',\n * font: 'draw',\n * fontSizeAdjustment: null,\n * align: 'middle',\n * verticalAlign: 'middle',\n * growY: 0,\n * url: '',\n * richText: toRichText('Hello **world**!'),\n * scale: 1\n * }\n * ```\n */\nexport interface TLNoteShapeProps {\n\t/** Background color style of the note */\n\tcolor: TLDefaultColorStyle\n\t/** Text color style for the note content */\n\tlabelColor: TLDefaultColorStyle\n\t/** Size style determining the font size and note dimensions */\n\tsize: TLDefaultSizeStyle\n\t/** Font family style for the note text */\n\tfont: TLDefaultFontStyle\n\t/** Ratio to scale the base font size when text needs to shrink to fit. Null means needs recomputation, 1 means no adjustment, and values less than 1 indicate shrinkage. */\n\tfontSizeAdjustment: number | null\n\t/** Horizontal alignment of text within the note */\n\talign: TLDefaultHorizontalAlignStyle\n\t/** Vertical alignment of text within the note */\n\tverticalAlign: TLDefaultVerticalAlignStyle\n\t/** Additional height growth for the note beyond its base size */\n\tgrowY: number\n\t/** Optional URL associated with the note for linking */\n\turl: string\n\t/** Rich text content with formatting like bold, italic, etc. */\n\trichText: TLRichText\n\t/** Scale factor applied to the note shape for display */\n\tscale: number\n\t/** User ID of the person who
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkB;AAClB,wBAA0D;AAC1D,qBAAgF;AAEhF,0BAIO;AACP,yBAAqD;AACrD,oCAGO;AACP,yBAAqD;AACrD,kCAGO;AAwGA,MAAM,iBAA2C;AAAA,EACvD,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,oBAAoB,kBAAE,eAAe,SAAS;AAAA,EAC9C,OAAO;AAAA,EACP,eAAe;AAAA,EACf,OAAO,kBAAE;AAAA,EACT,KAAK,kBAAE;AAAA,EACP,UAAU;AAAA,EACV,OAAO,kBAAE;AAAA,EACT,
|
|
4
|
+
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { TLRichText, richTextValidator, toRichText } from '../misc/TLRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/TLShape'\nimport { RecordProps } from '../recordsWithProps'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tTLDefaultColorStyle,\n} from '../styles/TLColorStyle'\nimport { DefaultFontStyle, TLDefaultFontStyle } from '../styles/TLFontStyle'\nimport {\n\tDefaultHorizontalAlignStyle,\n\tTLDefaultHorizontalAlignStyle,\n} from '../styles/TLHorizontalAlignStyle'\nimport { DefaultSizeStyle, TLDefaultSizeStyle } from '../styles/TLSizeStyle'\nimport {\n\tDefaultVerticalAlignStyle,\n\tTLDefaultVerticalAlignStyle,\n} from '../styles/TLVerticalAlignStyle'\nimport { TLBaseShape } from './TLBaseShape'\n\n/**\n * Properties for a note shape. Note shapes represent sticky notes or text annotations\n * with rich formatting capabilities and various styling options.\n *\n * @public\n * @example\n * ```ts\n * const noteProps: TLNoteShapeProps = {\n * color: 'yellow',\n * labelColor: 'black',\n * size: 'm',\n * font: 'draw',\n * fontSizeAdjustment: null,\n * align: 'middle',\n * verticalAlign: 'middle',\n * growY: 0,\n * url: '',\n * richText: toRichText('Hello **world**!'),\n * scale: 1\n * }\n * ```\n */\nexport interface TLNoteShapeProps {\n\t/** Background color style of the note */\n\tcolor: TLDefaultColorStyle\n\t/** Text color style for the note content */\n\tlabelColor: TLDefaultColorStyle\n\t/** Size style determining the font size and note dimensions */\n\tsize: TLDefaultSizeStyle\n\t/** Font family style for the note text */\n\tfont: TLDefaultFontStyle\n\t/** Ratio to scale the base font size when text needs to shrink to fit. Null means needs recomputation, 1 means no adjustment, and values less than 1 indicate shrinkage. */\n\tfontSizeAdjustment: number | null\n\t/** Horizontal alignment of text within the note */\n\talign: TLDefaultHorizontalAlignStyle\n\t/** Vertical alignment of text within the note */\n\tverticalAlign: TLDefaultVerticalAlignStyle\n\t/** Additional height growth for the note beyond its base size */\n\tgrowY: number\n\t/** Optional URL associated with the note for linking */\n\turl: string\n\t/** Rich text content with formatting like bold, italic, etc. */\n\trichText: TLRichText\n\t/** Scale factor applied to the note shape for display */\n\tscale: number\n\t/** User ID of the person who last edited the note text */\n\ttextLastEditedBy: string | null\n}\n\n/**\n * A note shape representing a sticky note or text annotation on the canvas.\n * Note shapes support rich text formatting, various styling options, and can\n * be used for annotations, reminders, or general text content.\n *\n * @public\n * @example\n * ```ts\n * const noteShape: TLNoteShape = {\n * id: 'shape:note1',\n * type: 'note',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * color: 'light-blue',\n * labelColor: 'black',\n * size: 's',\n * font: 'sans',\n * fontSizeAdjustment: 0.85,\n * align: 'start',\n * verticalAlign: 'start',\n * growY: 50,\n * url: 'https://example.com',\n * richText: toRichText('Important **note**!'),\n * scale: 1\n * },\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type TLNoteShape = TLBaseShape<'note', TLNoteShapeProps>\n\n/**\n * Validation schema for note shape properties. Defines the runtime validation rules\n * for all properties of note shapes, ensuring data integrity and type safety.\n *\n * @public\n * @example\n * ```ts\n * import { noteShapeProps } from '@tldraw/tlschema'\n *\n * // Used internally by the validation system\n * const validator = T.object(noteShapeProps)\n * const validatedProps = validator.validate(someNoteProps)\n * ```\n */\nexport const noteShapeProps: RecordProps<TLNoteShape> = {\n\tcolor: DefaultColorStyle,\n\tlabelColor: DefaultLabelColorStyle,\n\tsize: DefaultSizeStyle,\n\tfont: DefaultFontStyle,\n\tfontSizeAdjustment: T.positiveNumber.nullable(),\n\talign: DefaultHorizontalAlignStyle,\n\tverticalAlign: DefaultVerticalAlignStyle,\n\tgrowY: T.positiveNumber,\n\turl: T.linkUrl,\n\trichText: richTextValidator,\n\tscale: T.nonZeroNumber,\n\ttextLastEditedBy: T.string.nullable(),\n}\n\nconst Versions = createShapePropsMigrationIds('note', {\n\tAddUrlProp: 1,\n\tRemoveJustify: 2,\n\tMigrateLegacyAlign: 3,\n\tAddVerticalAlign: 4,\n\tMakeUrlsValid: 5,\n\tAddFontSizeAdjustment: 6,\n\tAddScale: 7,\n\tAddLabelColor: 8,\n\tAddRichText: 9,\n\tAddRichTextAttrs: 10,\n\tAddFirstEditedBy: 11,\n\tMakeFontSizeAdjustmentRatio: 12,\n\tRenameFirstEditedByToLast: 13,\n})\n\n/**\n * Version identifiers for note shape migrations. These version numbers track\n * significant schema changes over time, enabling proper data migration between versions.\n *\n * @public\n */\nexport { Versions as noteShapeVersions }\n\n/**\n * Migration sequence for note shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade note shape data between different versions. Includes\n * migrations for URL properties, text alignment changes, vertical alignment addition,\n * font size adjustments, scaling support, label color, the transition from plain text to rich text,\n * and support for attrs property on richText.\n *\n * @public\n */\nexport const noteShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddUrlProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.url = ''\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.RemoveJustify,\n\t\t\tup: (props) => {\n\t\t\t\tif (props.align === 'justify') {\n\t\t\t\t\tprops.align = 'start'\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MigrateLegacyAlign,\n\t\t\tup: (props) => {\n\t\t\t\tswitch (props.align) {\n\t\t\t\t\tcase 'start':\n\t\t\t\t\t\tprops.align = 'start-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t\tcase 'end':\n\t\t\t\t\t\tprops.align = 'end-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tprops.align = 'middle-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddVerticalAlign,\n\t\t\tup: (props) => {\n\t\t\t\tprops.verticalAlign = 'middle'\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFontSizeAdjustment,\n\t\t\tup: (props) => {\n\t\t\t\tprops.fontSizeAdjustment = 0\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.fontSizeAdjustment\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddLabelColor,\n\t\t\tup: (props) => {\n\t\t\t\tprops.labelColor = 'black'\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.labelColor\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.richText = toRichText(props.text)\n\t\t\t\tdelete props.text\n\t\t\t},\n\t\t\t// N.B. Explicitly no down state so that we force clients to update.\n\t\t\t// down: (props) => {\n\t\t\t// \tdelete props.richText\n\t\t\t// },\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichTextAttrs,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop - attrs is optional so old records are valid\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Remove attrs from richText when migrating down\n\t\t\t\tif (props.richText && 'attrs' in props.richText) {\n\t\t\t\t\tdelete props.richText.attrs\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFirstEditedBy,\n\t\t\tup: (props) => {\n\t\t\t\tprops.textFirstEditedBy = null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.textFirstEditedBy\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeFontSizeAdjustmentRatio,\n\t\t\tup: (props) => {\n\t\t\t\t// Old system stored 0 for \"no adjustment\" or an absolute pixel font size.\n\t\t\t\t// New system stores a ratio (1 = no adjustment, <1 = shrunk).\n\t\t\t\t// We can convert 0 \u2192 1 (no adjustment), but non-zero values need\n\t\t\t\t// recomputation (null) since we don't know the base font size here.\n\t\t\t\tprops.fontSizeAdjustment = props.fontSizeAdjustment === 0 ? 1 : null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tprops.fontSizeAdjustment = 0\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.RenameFirstEditedByToLast,\n\t\t\tup: (props) => {\n\t\t\t\tprops.textLastEditedBy = props.textFirstEditedBy ?? null\n\t\t\t\tdelete props.textFirstEditedBy\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tprops.textFirstEditedBy = props.textLastEditedBy ?? null\n\t\t\t\tdelete props.textLastEditedBy\n\t\t\t},\n\t\t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CAAC,UAAU;AAEhB,YAAI,MAAM,YAAY,WAAW,MAAM,UAAU;AAChD,iBAAO,MAAM,SAAS;AAAA,QACvB;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,oBAAoB;AAAA,MAC3B;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,eAAO,MAAM;AAAA,MACd;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AAKd,cAAM,qBAAqB,MAAM,uBAAuB,IAAI,IAAI;AAAA,MACjE;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,cAAM,qBAAqB;AAAA,MAC5B;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,mBAAmB,MAAM,qBAAqB;AACpD,eAAO,MAAM;AAAA,MACd;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,cAAM,oBAAoB,MAAM,oBAAoB;AACpD,eAAO,MAAM;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-esm/index.d.mts
CHANGED
|
@@ -5576,8 +5576,8 @@ export declare interface TLNoteShapeProps {
|
|
|
5576
5576
|
richText: TLRichText;
|
|
5577
5577
|
/** Scale factor applied to the note shape for display */
|
|
5578
5578
|
scale: number;
|
|
5579
|
-
/** User ID of the person who
|
|
5580
|
-
|
|
5579
|
+
/** User ID of the person who last edited the note text */
|
|
5580
|
+
textLastEditedBy: null | string;
|
|
5581
5581
|
}
|
|
5582
5582
|
|
|
5583
5583
|
/**
|
package/dist-esm/index.mjs
CHANGED
|
@@ -198,7 +198,7 @@ import {
|
|
|
198
198
|
} from "./translations/translations.mjs";
|
|
199
199
|
registerTldrawLibraryVersion(
|
|
200
200
|
"@tldraw/tlschema",
|
|
201
|
-
"5.2.0-canary.
|
|
201
|
+
"5.2.0-canary.79ebf6ab5ef9",
|
|
202
202
|
"esm"
|
|
203
203
|
);
|
|
204
204
|
import { DIM_2D, DIM_3D, b64Vecs } from "./misc/b64Vecs.mjs";
|
|
@@ -25,7 +25,7 @@ const noteShapeProps = {
|
|
|
25
25
|
url: T.linkUrl,
|
|
26
26
|
richText: richTextValidator,
|
|
27
27
|
scale: T.nonZeroNumber,
|
|
28
|
-
|
|
28
|
+
textLastEditedBy: T.string.nullable()
|
|
29
29
|
};
|
|
30
30
|
const Versions = createShapePropsMigrationIds("note", {
|
|
31
31
|
AddUrlProp: 1,
|
|
@@ -39,7 +39,8 @@ const Versions = createShapePropsMigrationIds("note", {
|
|
|
39
39
|
AddRichText: 9,
|
|
40
40
|
AddRichTextAttrs: 10,
|
|
41
41
|
AddFirstEditedBy: 11,
|
|
42
|
-
MakeFontSizeAdjustmentRatio: 12
|
|
42
|
+
MakeFontSizeAdjustmentRatio: 12,
|
|
43
|
+
RenameFirstEditedByToLast: 13
|
|
43
44
|
});
|
|
44
45
|
const noteShapeMigrations = createShapePropsMigrationSequence({
|
|
45
46
|
sequence: [
|
|
@@ -158,6 +159,17 @@ const noteShapeMigrations = createShapePropsMigrationSequence({
|
|
|
158
159
|
down: (props) => {
|
|
159
160
|
props.fontSizeAdjustment = 0;
|
|
160
161
|
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: Versions.RenameFirstEditedByToLast,
|
|
165
|
+
up: (props) => {
|
|
166
|
+
props.textLastEditedBy = props.textFirstEditedBy ?? null;
|
|
167
|
+
delete props.textFirstEditedBy;
|
|
168
|
+
},
|
|
169
|
+
down: (props) => {
|
|
170
|
+
props.textFirstEditedBy = props.textLastEditedBy ?? null;
|
|
171
|
+
delete props.textLastEditedBy;
|
|
172
|
+
}
|
|
161
173
|
}
|
|
162
174
|
]
|
|
163
175
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/shapes/TLNoteShape.ts"],
|
|
4
|
-
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { TLRichText, richTextValidator, toRichText } from '../misc/TLRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/TLShape'\nimport { RecordProps } from '../recordsWithProps'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tTLDefaultColorStyle,\n} from '../styles/TLColorStyle'\nimport { DefaultFontStyle, TLDefaultFontStyle } from '../styles/TLFontStyle'\nimport {\n\tDefaultHorizontalAlignStyle,\n\tTLDefaultHorizontalAlignStyle,\n} from '../styles/TLHorizontalAlignStyle'\nimport { DefaultSizeStyle, TLDefaultSizeStyle } from '../styles/TLSizeStyle'\nimport {\n\tDefaultVerticalAlignStyle,\n\tTLDefaultVerticalAlignStyle,\n} from '../styles/TLVerticalAlignStyle'\nimport { TLBaseShape } from './TLBaseShape'\n\n/**\n * Properties for a note shape. Note shapes represent sticky notes or text annotations\n * with rich formatting capabilities and various styling options.\n *\n * @public\n * @example\n * ```ts\n * const noteProps: TLNoteShapeProps = {\n * color: 'yellow',\n * labelColor: 'black',\n * size: 'm',\n * font: 'draw',\n * fontSizeAdjustment: null,\n * align: 'middle',\n * verticalAlign: 'middle',\n * growY: 0,\n * url: '',\n * richText: toRichText('Hello **world**!'),\n * scale: 1\n * }\n * ```\n */\nexport interface TLNoteShapeProps {\n\t/** Background color style of the note */\n\tcolor: TLDefaultColorStyle\n\t/** Text color style for the note content */\n\tlabelColor: TLDefaultColorStyle\n\t/** Size style determining the font size and note dimensions */\n\tsize: TLDefaultSizeStyle\n\t/** Font family style for the note text */\n\tfont: TLDefaultFontStyle\n\t/** Ratio to scale the base font size when text needs to shrink to fit. Null means needs recomputation, 1 means no adjustment, and values less than 1 indicate shrinkage. */\n\tfontSizeAdjustment: number | null\n\t/** Horizontal alignment of text within the note */\n\talign: TLDefaultHorizontalAlignStyle\n\t/** Vertical alignment of text within the note */\n\tverticalAlign: TLDefaultVerticalAlignStyle\n\t/** Additional height growth for the note beyond its base size */\n\tgrowY: number\n\t/** Optional URL associated with the note for linking */\n\turl: string\n\t/** Rich text content with formatting like bold, italic, etc. */\n\trichText: TLRichText\n\t/** Scale factor applied to the note shape for display */\n\tscale: number\n\t/** User ID of the person who
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAqB,mBAAmB,kBAAkB;AAC1D,SAAS,8BAA8B,yCAAyC;AAEhF;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,wBAA4C;AACrD;AAAA,EACC;AAAA,OAEM;AACP,SAAS,wBAA4C;AACrD;AAAA,EACC;AAAA,OAEM;AAwGA,MAAM,iBAA2C;AAAA,EACvD,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,oBAAoB,EAAE,eAAe,SAAS;AAAA,EAC9C,OAAO;AAAA,EACP,eAAe;AAAA,EACf,OAAO,EAAE;AAAA,EACT,KAAK,EAAE;AAAA,EACP,UAAU;AAAA,EACV,OAAO,EAAE;AAAA,EACT,
|
|
4
|
+
"sourcesContent": ["import { T } from '@tldraw/validate'\nimport { TLRichText, richTextValidator, toRichText } from '../misc/TLRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/TLShape'\nimport { RecordProps } from '../recordsWithProps'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tTLDefaultColorStyle,\n} from '../styles/TLColorStyle'\nimport { DefaultFontStyle, TLDefaultFontStyle } from '../styles/TLFontStyle'\nimport {\n\tDefaultHorizontalAlignStyle,\n\tTLDefaultHorizontalAlignStyle,\n} from '../styles/TLHorizontalAlignStyle'\nimport { DefaultSizeStyle, TLDefaultSizeStyle } from '../styles/TLSizeStyle'\nimport {\n\tDefaultVerticalAlignStyle,\n\tTLDefaultVerticalAlignStyle,\n} from '../styles/TLVerticalAlignStyle'\nimport { TLBaseShape } from './TLBaseShape'\n\n/**\n * Properties for a note shape. Note shapes represent sticky notes or text annotations\n * with rich formatting capabilities and various styling options.\n *\n * @public\n * @example\n * ```ts\n * const noteProps: TLNoteShapeProps = {\n * color: 'yellow',\n * labelColor: 'black',\n * size: 'm',\n * font: 'draw',\n * fontSizeAdjustment: null,\n * align: 'middle',\n * verticalAlign: 'middle',\n * growY: 0,\n * url: '',\n * richText: toRichText('Hello **world**!'),\n * scale: 1\n * }\n * ```\n */\nexport interface TLNoteShapeProps {\n\t/** Background color style of the note */\n\tcolor: TLDefaultColorStyle\n\t/** Text color style for the note content */\n\tlabelColor: TLDefaultColorStyle\n\t/** Size style determining the font size and note dimensions */\n\tsize: TLDefaultSizeStyle\n\t/** Font family style for the note text */\n\tfont: TLDefaultFontStyle\n\t/** Ratio to scale the base font size when text needs to shrink to fit. Null means needs recomputation, 1 means no adjustment, and values less than 1 indicate shrinkage. */\n\tfontSizeAdjustment: number | null\n\t/** Horizontal alignment of text within the note */\n\talign: TLDefaultHorizontalAlignStyle\n\t/** Vertical alignment of text within the note */\n\tverticalAlign: TLDefaultVerticalAlignStyle\n\t/** Additional height growth for the note beyond its base size */\n\tgrowY: number\n\t/** Optional URL associated with the note for linking */\n\turl: string\n\t/** Rich text content with formatting like bold, italic, etc. */\n\trichText: TLRichText\n\t/** Scale factor applied to the note shape for display */\n\tscale: number\n\t/** User ID of the person who last edited the note text */\n\ttextLastEditedBy: string | null\n}\n\n/**\n * A note shape representing a sticky note or text annotation on the canvas.\n * Note shapes support rich text formatting, various styling options, and can\n * be used for annotations, reminders, or general text content.\n *\n * @public\n * @example\n * ```ts\n * const noteShape: TLNoteShape = {\n * id: 'shape:note1',\n * type: 'note',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * color: 'light-blue',\n * labelColor: 'black',\n * size: 's',\n * font: 'sans',\n * fontSizeAdjustment: 0.85,\n * align: 'start',\n * verticalAlign: 'start',\n * growY: 50,\n * url: 'https://example.com',\n * richText: toRichText('Important **note**!'),\n * scale: 1\n * },\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type TLNoteShape = TLBaseShape<'note', TLNoteShapeProps>\n\n/**\n * Validation schema for note shape properties. Defines the runtime validation rules\n * for all properties of note shapes, ensuring data integrity and type safety.\n *\n * @public\n * @example\n * ```ts\n * import { noteShapeProps } from '@tldraw/tlschema'\n *\n * // Used internally by the validation system\n * const validator = T.object(noteShapeProps)\n * const validatedProps = validator.validate(someNoteProps)\n * ```\n */\nexport const noteShapeProps: RecordProps<TLNoteShape> = {\n\tcolor: DefaultColorStyle,\n\tlabelColor: DefaultLabelColorStyle,\n\tsize: DefaultSizeStyle,\n\tfont: DefaultFontStyle,\n\tfontSizeAdjustment: T.positiveNumber.nullable(),\n\talign: DefaultHorizontalAlignStyle,\n\tverticalAlign: DefaultVerticalAlignStyle,\n\tgrowY: T.positiveNumber,\n\turl: T.linkUrl,\n\trichText: richTextValidator,\n\tscale: T.nonZeroNumber,\n\ttextLastEditedBy: T.string.nullable(),\n}\n\nconst Versions = createShapePropsMigrationIds('note', {\n\tAddUrlProp: 1,\n\tRemoveJustify: 2,\n\tMigrateLegacyAlign: 3,\n\tAddVerticalAlign: 4,\n\tMakeUrlsValid: 5,\n\tAddFontSizeAdjustment: 6,\n\tAddScale: 7,\n\tAddLabelColor: 8,\n\tAddRichText: 9,\n\tAddRichTextAttrs: 10,\n\tAddFirstEditedBy: 11,\n\tMakeFontSizeAdjustmentRatio: 12,\n\tRenameFirstEditedByToLast: 13,\n})\n\n/**\n * Version identifiers for note shape migrations. These version numbers track\n * significant schema changes over time, enabling proper data migration between versions.\n *\n * @public\n */\nexport { Versions as noteShapeVersions }\n\n/**\n * Migration sequence for note shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade note shape data between different versions. Includes\n * migrations for URL properties, text alignment changes, vertical alignment addition,\n * font size adjustments, scaling support, label color, the transition from plain text to rich text,\n * and support for attrs property on richText.\n *\n * @public\n */\nexport const noteShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddUrlProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.url = ''\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.RemoveJustify,\n\t\t\tup: (props) => {\n\t\t\t\tif (props.align === 'justify') {\n\t\t\t\t\tprops.align = 'start'\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MigrateLegacyAlign,\n\t\t\tup: (props) => {\n\t\t\t\tswitch (props.align) {\n\t\t\t\t\tcase 'start':\n\t\t\t\t\t\tprops.align = 'start-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t\tcase 'end':\n\t\t\t\t\t\tprops.align = 'end-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tprops.align = 'middle-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddVerticalAlign,\n\t\t\tup: (props) => {\n\t\t\t\tprops.verticalAlign = 'middle'\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFontSizeAdjustment,\n\t\t\tup: (props) => {\n\t\t\t\tprops.fontSizeAdjustment = 0\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.fontSizeAdjustment\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddLabelColor,\n\t\t\tup: (props) => {\n\t\t\t\tprops.labelColor = 'black'\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.labelColor\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.richText = toRichText(props.text)\n\t\t\t\tdelete props.text\n\t\t\t},\n\t\t\t// N.B. Explicitly no down state so that we force clients to update.\n\t\t\t// down: (props) => {\n\t\t\t// \tdelete props.richText\n\t\t\t// },\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichTextAttrs,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop - attrs is optional so old records are valid\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Remove attrs from richText when migrating down\n\t\t\t\tif (props.richText && 'attrs' in props.richText) {\n\t\t\t\t\tdelete props.richText.attrs\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFirstEditedBy,\n\t\t\tup: (props) => {\n\t\t\t\tprops.textFirstEditedBy = null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.textFirstEditedBy\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeFontSizeAdjustmentRatio,\n\t\t\tup: (props) => {\n\t\t\t\t// Old system stored 0 for \"no adjustment\" or an absolute pixel font size.\n\t\t\t\t// New system stores a ratio (1 = no adjustment, <1 = shrunk).\n\t\t\t\t// We can convert 0 \u2192 1 (no adjustment), but non-zero values need\n\t\t\t\t// recomputation (null) since we don't know the base font size here.\n\t\t\t\tprops.fontSizeAdjustment = props.fontSizeAdjustment === 0 ? 1 : null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tprops.fontSizeAdjustment = 0\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.RenameFirstEditedByToLast,\n\t\t\tup: (props) => {\n\t\t\t\tprops.textLastEditedBy = props.textFirstEditedBy ?? null\n\t\t\t\tdelete props.textFirstEditedBy\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tprops.textFirstEditedBy = props.textLastEditedBy ?? null\n\t\t\t\tdelete props.textLastEditedBy\n\t\t\t},\n\t\t},\n\t],\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAqB,mBAAmB,kBAAkB;AAC1D,SAAS,8BAA8B,yCAAyC;AAEhF;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,wBAA4C;AACrD;AAAA,EACC;AAAA,OAEM;AACP,SAAS,wBAA4C;AACrD;AAAA,EACC;AAAA,OAEM;AAwGA,MAAM,iBAA2C;AAAA,EACvD,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,oBAAoB,EAAE,eAAe,SAAS;AAAA,EAC9C,OAAO;AAAA,EACP,eAAe;AAAA,EACf,OAAO,EAAE;AAAA,EACT,KAAK,EAAE;AAAA,EACP,UAAU;AAAA,EACV,OAAO,EAAE;AAAA,EACT,kBAAkB,EAAE,OAAO,SAAS;AACrC;AAEA,MAAM,WAAW,6BAA6B,QAAQ;AAAA,EACrD,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,6BAA6B;AAAA,EAC7B,2BAA2B;AAC5B,CAAC;AAmBM,MAAM,sBAAsB,kCAAkC;AAAA,EACpE,UAAU;AAAA,IACT;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,MAAM;AAAA,MACb;AAAA,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AM;AAAA,MACd;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,WAAW,WAAW,MAAM,IAAI;AACtC,eAAO,MAAM;AAAA,MACd;AAAA;AAAA;AAAA;AAAA;AAAA,IAKD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,WAAW;AAAA,MAEhB;AAAA,MACA,MAAM,CAAC,UAAU;AAEhB,YAAI,MAAM,YAAY,WAAW,MAAM,UAAU;AAChD,iBAAO,MAAM,SAAS;AAAA,QACvB;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,oBAAoB;AAAA,MAC3B;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,eAAO,MAAM;AAAA,MACd;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AAKd,cAAM,qBAAqB,MAAM,uBAAuB,IAAI,IAAI;AAAA,MACjE;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,cAAM,qBAAqB;AAAA,MAC5B;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI,SAAS;AAAA,MACb,IAAI,CAAC,UAAU;AACd,cAAM,mBAAmB,MAAM,qBAAqB;AACpD,eAAO,MAAM;AAAA,MACd;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,cAAM,oBAAoB,MAAM,oBAAoB;AACpD,eAAO,MAAM;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/tlschema",
|
|
3
3
|
"description": "tldraw infinite canvas SDK (schema).",
|
|
4
|
-
"version": "5.2.0-canary.
|
|
4
|
+
"version": "5.2.0-canary.79ebf6ab5ef9",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"vitest": "^4.1.7"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@tldraw/state": "5.2.0-canary.
|
|
55
|
-
"@tldraw/store": "5.2.0-canary.
|
|
56
|
-
"@tldraw/utils": "5.2.0-canary.
|
|
57
|
-
"@tldraw/validate": "5.2.0-canary.
|
|
54
|
+
"@tldraw/state": "5.2.0-canary.79ebf6ab5ef9",
|
|
55
|
+
"@tldraw/store": "5.2.0-canary.79ebf6ab5ef9",
|
|
56
|
+
"@tldraw/utils": "5.2.0-canary.79ebf6ab5ef9",
|
|
57
|
+
"@tldraw/validate": "5.2.0-canary.79ebf6ab5ef9"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.2.0 || ^19.2.1",
|
package/src/migrations.test.ts
CHANGED
|
@@ -2638,6 +2638,28 @@ describe('Adding textFirstEditedBy to note shape', () => {
|
|
|
2638
2638
|
})
|
|
2639
2639
|
})
|
|
2640
2640
|
|
|
2641
|
+
describe('Renaming textFirstEditedBy to textLastEditedBy on note shape', () => {
|
|
2642
|
+
const { up, down } = getTestMigration(noteShapeVersions.RenameFirstEditedByToLast)
|
|
2643
|
+
|
|
2644
|
+
test('up renames the prop, preserving its value', () => {
|
|
2645
|
+
expect(up({ props: { textFirstEditedBy: 'user:1' } })).toEqual({
|
|
2646
|
+
props: { textLastEditedBy: 'user:1' },
|
|
2647
|
+
})
|
|
2648
|
+
expect(up({ props: { textFirstEditedBy: null } })).toEqual({
|
|
2649
|
+
props: { textLastEditedBy: null },
|
|
2650
|
+
})
|
|
2651
|
+
})
|
|
2652
|
+
|
|
2653
|
+
test('down renames the prop back, preserving its value', () => {
|
|
2654
|
+
expect(down({ props: { textLastEditedBy: 'user:1' } })).toEqual({
|
|
2655
|
+
props: { textFirstEditedBy: 'user:1' },
|
|
2656
|
+
})
|
|
2657
|
+
expect(down({ props: { textLastEditedBy: null } })).toEqual({
|
|
2658
|
+
props: { textFirstEditedBy: null },
|
|
2659
|
+
})
|
|
2660
|
+
})
|
|
2661
|
+
})
|
|
2662
|
+
|
|
2641
2663
|
describe('TLUser initial migration', () => {
|
|
2642
2664
|
const { up } = getTestMigration(userVersions.Initial)
|
|
2643
2665
|
|
|
@@ -64,8 +64,8 @@ export interface TLNoteShapeProps {
|
|
|
64
64
|
richText: TLRichText
|
|
65
65
|
/** Scale factor applied to the note shape for display */
|
|
66
66
|
scale: number
|
|
67
|
-
/** User ID of the person who
|
|
68
|
-
|
|
67
|
+
/** User ID of the person who last edited the note text */
|
|
68
|
+
textLastEditedBy: string | null
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -132,7 +132,7 @@ export const noteShapeProps: RecordProps<TLNoteShape> = {
|
|
|
132
132
|
url: T.linkUrl,
|
|
133
133
|
richText: richTextValidator,
|
|
134
134
|
scale: T.nonZeroNumber,
|
|
135
|
-
|
|
135
|
+
textLastEditedBy: T.string.nullable(),
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const Versions = createShapePropsMigrationIds('note', {
|
|
@@ -148,6 +148,7 @@ const Versions = createShapePropsMigrationIds('note', {
|
|
|
148
148
|
AddRichTextAttrs: 10,
|
|
149
149
|
AddFirstEditedBy: 11,
|
|
150
150
|
MakeFontSizeAdjustmentRatio: 12,
|
|
151
|
+
RenameFirstEditedByToLast: 13,
|
|
151
152
|
})
|
|
152
153
|
|
|
153
154
|
/**
|
|
@@ -292,5 +293,16 @@ export const noteShapeMigrations = createShapePropsMigrationSequence({
|
|
|
292
293
|
props.fontSizeAdjustment = 0
|
|
293
294
|
},
|
|
294
295
|
},
|
|
296
|
+
{
|
|
297
|
+
id: Versions.RenameFirstEditedByToLast,
|
|
298
|
+
up: (props) => {
|
|
299
|
+
props.textLastEditedBy = props.textFirstEditedBy ?? null
|
|
300
|
+
delete props.textFirstEditedBy
|
|
301
|
+
},
|
|
302
|
+
down: (props) => {
|
|
303
|
+
props.textFirstEditedBy = props.textLastEditedBy ?? null
|
|
304
|
+
delete props.textLastEditedBy
|
|
305
|
+
},
|
|
306
|
+
},
|
|
295
307
|
],
|
|
296
308
|
})
|