kopia lustrzana https://github.com/Tldraw/Tldraw
51 wiersze
1.3 KiB
TypeScript
51 wiersze
1.3 KiB
TypeScript
import { T } from '@tldraw/validate'
|
|
import {
|
|
RETIRED_DOWN_MIGRATION,
|
|
createShapePropsMigrationIds,
|
|
createShapePropsMigrationSequence,
|
|
} from '../records/TLShape'
|
|
import { DefaultColorStyle } from '../styles/TLColorStyle'
|
|
import { DefaultFontStyle } from '../styles/TLFontStyle'
|
|
import { DefaultHorizontalAlignStyle } from '../styles/TLHorizontalAlignStyle'
|
|
import { DefaultSizeStyle } from '../styles/TLSizeStyle'
|
|
import { ShapePropsType, TLBaseShape } from './TLBaseShape'
|
|
|
|
/** @public */
|
|
export const textShapeProps = {
|
|
color: DefaultColorStyle,
|
|
size: DefaultSizeStyle,
|
|
font: DefaultFontStyle,
|
|
align: DefaultHorizontalAlignStyle,
|
|
w: T.nonZeroNumber,
|
|
text: T.string,
|
|
scale: T.nonZeroNumber,
|
|
autoSize: T.boolean,
|
|
}
|
|
|
|
/** @public */
|
|
export type TLTextShapeProps = ShapePropsType<typeof textShapeProps>
|
|
|
|
/** @public */
|
|
export type TLTextShape = TLBaseShape<'text', TLTextShapeProps>
|
|
|
|
const Versions = createShapePropsMigrationIds('text', {
|
|
RemoveJustify: 1,
|
|
})
|
|
|
|
export { Versions as textShapeVersions }
|
|
|
|
/** @public */
|
|
export const textShapeMigrations = createShapePropsMigrationSequence({
|
|
sequence: [
|
|
{
|
|
id: Versions.RemoveJustify,
|
|
up: (props) => {
|
|
if (props.align === 'justify') {
|
|
props.align = 'start'
|
|
}
|
|
},
|
|
down: RETIRED_DOWN_MIGRATION,
|
|
},
|
|
],
|
|
})
|