style: run prettier

pull/9192/head^2
Konstantinos Kaloutas 2023-04-18 17:12:32 +03:00 committed by Tienson Qin
parent f5673da476
commit 78c3427923
20 changed files with 395 additions and 296 deletions

View File

@ -56,7 +56,9 @@ export const ContextMenu = observer(function ContextMenu({
tabIndex={-1}
>
<div>
{app.selectedShapes?.size > 1 && !app.readOnly && app.selectedShapesArray?.some(s => !s.props.isLocked) && (
{app.selectedShapes?.size > 1 &&
!app.readOnly &&
app.selectedShapesArray?.some(s => !s.props.isLocked) && (
<>
<ReactContextMenu.Item>
<div className="tl-menu-button-row pb-0">
@ -110,7 +112,9 @@ export const ContextMenu = observer(function ContextMenu({
<Separator.Root className="tl-toolbar-separator" orientation="vertical" />
<Button
tooltip="Distribute vertically"
onClick={() => runAndTransition(() => app.distribute(DistributeType.Vertical))}
onClick={() =>
runAndTransition(() => app.distribute(DistributeType.Vertical))
}
>
<TablerIcon name="layout-distribute-horizontal" />
</Button>
@ -162,7 +166,8 @@ export const ContextMenu = observer(function ContextMenu({
</div>
</ReactContextMenu.Item>
)}
{app.selectedShapesArray.length > 1 && app.selectedShapesArray?.some(s => !s.props.isLocked) && (
{app.selectedShapesArray.length > 1 &&
app.selectedShapesArray?.some(s => !s.props.isLocked) && (
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.api.doGroup)}
@ -295,7 +300,9 @@ export const ContextMenu = observer(function ContextMenu({
Unlock
</ReactContextMenu.Item>
)}
{app.selectedShapes?.size > 0 && !app.readOnly && app.selectedShapesArray?.some(s => !s.props.isLocked) && (
{app.selectedShapes?.size > 0 &&
!app.readOnly &&
app.selectedShapesArray?.some(s => !s.props.isLocked) && (
<>
<ReactContextMenu.Item
className="tl-menu-item"

View File

@ -172,7 +172,14 @@ export class BoxShape extends TLBoxShape<BoxShapeProps> {
return (
<g>
<rect width={w} height={h} rx={borderRadius} ry={borderRadius} fill="transparent" strokeDasharray={isLocked ? '8 2' : undefined} />
<rect
width={w}
height={h}
rx={borderRadius}
ry={borderRadius}
fill="transparent"
strokeDasharray={isLocked ? '8 2' : undefined}
/>
</g>
)
})

View File

@ -44,7 +44,15 @@ export class DotShape extends TLDotShape<DotShapeProps> {
ReactIndicator = observer(() => {
const { radius, isLocked } = this.props
return <circle cx={radius} cy={radius} r={radius} pointerEvents="all" strokeDasharray={isLocked ? "8 2" : "undefined"} />
return (
<circle
cx={radius}
cy={radius}
r={radius}
pointerEvents="all"
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
validateProps = (props: Partial<DotShapeProps>) => {

View File

@ -159,7 +159,15 @@ export class EllipseShape extends TLEllipseShape<EllipseShapeProps> {
return (
<g>
<ellipse cx={w / 2} cy={h / 2} rx={w / 2} ry={h / 2} strokeWidth={2} fill="transparent" strokeDasharray={isLocked ? "8 2" : "undefined"}/>
<ellipse
cx={w / 2}
cy={h / 2}
rx={w / 2}
ry={h / 2}
strokeWidth={2}
fill="transparent"
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
</g>
)
})

View File

@ -139,7 +139,14 @@ export class HTMLShape extends TLBoxShape<HTMLShapeProps> {
isLocked,
},
} = this
return <rect width={w} height={h} fill="transparent" strokeDasharray={isLocked ? "8 2" : "undefined"}/>
return (
<rect
width={w}
height={h}
fill="transparent"
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
validateProps = (props: Partial<HTMLShapeProps>) => {

View File

@ -84,7 +84,9 @@ export class HighlighterShape extends TLDrawShape<HighlighterShapeProps> {
ReactIndicator = observer(() => {
const { pointsPath, props } = this
return <path d={pointsPath} fill="none" strokeDasharray={props.isLocked ? "8 2" : "undefined"}/>
return (
<path d={pointsPath} fill="none" strokeDasharray={props.isLocked ? '8 2' : 'undefined'} />
)
})
validateProps = (props: Partial<HighlighterShapeProps>) => {

View File

@ -85,6 +85,15 @@ export class IFrameShape extends TLBoxShape<IFrameShapeProps> {
isLocked,
},
} = this
return <rect width={w} height={h} fill="transparent" rx={8} ry={8} strokeDasharray={isLocked ? "8 2" : "undefined"}/>
return (
<rect
width={w}
height={h}
fill="transparent"
rx={8}
ry={8}
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
}

View File

@ -77,7 +77,14 @@ export class ImageShape extends TLImageShape<ImageShapeProps> {
isLocked,
},
} = this
return <rect width={w} height={h} fill="transparent" strokeDasharray={isLocked ? "8 2" : "undefined"}/>
return (
<rect
width={w}
height={h}
fill="transparent"
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
getShapeSVGJsx({ assets }: { assets: TLAsset[] }) {

View File

@ -77,7 +77,7 @@ export class LineShape extends TLLineShape<LineShapeProps> {
const labelSize =
label || isEditing
? getTextLabelSize(
label || "Enter text",
label || 'Enter text',
{ fontFamily: 'var(--ls-font-family)', fontSize, lineHeight: 1, fontWeight },
6
)
@ -99,7 +99,11 @@ export class LineShape extends TLLineShape<LineShapeProps> {
[label]
)
return (
<div {...events} style={{ width: '100%', height: '100%', overflow: 'hidden' }} className="tl-line-container">
<div
{...events}
style={{ width: '100%', height: '100%', overflow: 'hidden' }}
className="tl-line-container"
>
<TextLabel
font={font}
text={label}
@ -177,7 +181,7 @@ export class LineShape extends TLLineShape<LineShapeProps> {
decorations?.start,
decorations?.end
)}
strokeDasharray={isLocked ? "8 2" : "undefined"}
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
{label && !isEditing && (
<rect

View File

@ -79,7 +79,8 @@ const LogseqPortalShapeHeader = observer(
className="absolute inset-0 tl-logseq-portal-header-bg"
style={{
opacity,
background: type === 'P' ? bgColor : `linear-gradient(0deg, ${fillGradient}, ${bgColor})`,
background:
type === 'P' ? bgColor : `linear-gradient(0deg, ${fillGradient}, ${bgColor})`,
}}
></div>
<div className="relative">{children}</div>
@ -536,7 +537,16 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
ReactIndicator = observer(() => {
const bounds = this.getBounds()
return <rect width={bounds.width} height={bounds.height} fill="transparent" rx={8} ry={8} strokeDasharray={this.props.isLocked ? "8 2" : "undefined"}/>
return (
<rect
width={bounds.width}
height={bounds.height}
fill="transparent"
rx={8}
ry={8}
strokeDasharray={this.props.isLocked ? '8 2' : 'undefined'}
/>
)
})
validateProps = (props: Partial<LogseqPortalShapeProps>) => {

View File

@ -66,7 +66,7 @@ export class PenShape extends TLDrawShape<PenShapeProps> {
ReactIndicator = observer(() => {
const { pointsPath } = this
return <path d={pointsPath} strokeDasharray={this.props.isLocked ? "8 2" : "undefined"}/>
return <path d={pointsPath} strokeDasharray={this.props.isLocked ? '8 2' : 'undefined'} />
})
validateProps = (props: Partial<PenShapeProps>) => {

View File

@ -133,7 +133,7 @@ export class PencilShape extends TLDrawShape<PencilShapeProps> {
ReactIndicator = observer(() => {
const { pointsPath } = this
return <path d={pointsPath} strokeDasharray={this.props.isLocked ? "8 2" : "undefined"}/>
return <path d={pointsPath} strokeDasharray={this.props.isLocked ? '8 2' : 'undefined'} />
})
validateProps = (props: Partial<PencilShapeProps>) => {

View File

@ -176,7 +176,7 @@ export class PolygonShape extends TLPolygonShape<PolygonShapeProps> {
<polygon
transform={`translate(${x}, ${y})`}
points={this.getVertices(strokeWidth / 2).join()}
strokeDasharray={isLocked ? "8 2" : "undefined"}
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
</g>
)

View File

@ -250,7 +250,7 @@ export class TextShape extends TLTextShape<TextShapeProps> {
rx={borderRadius}
ry={borderRadius}
fill="transparent"
strokeDasharray={isLocked ? "8 2" : "undefined"}
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})

View File

@ -91,9 +91,9 @@ export class TweetShape extends TLBoxShape<TweetShapeProps> {
>
{this.embedId ? (
<div ref={cpRefContainer}>
<Tweet tweetId={this.embedId}/>
<Tweet tweetId={this.embedId} />
</div>
) : (null)}
) : null}
</div>
</HTMLContainer>
)
@ -106,7 +106,16 @@ export class TweetShape extends TLBoxShape<TweetShapeProps> {
isLocked,
},
} = this
return <rect width={w} height={h} fill="transparent" rx={8} ry={8} strokeDasharray={isLocked ? "8 2" : "undefined"}/>
return (
<rect
width={w}
height={h}
fill="transparent"
rx={8}
ry={8}
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
useComponentSize<T extends HTMLElement>(ref: React.RefObject<T> | null, selector = '') {
@ -192,12 +201,7 @@ export class TweetShape extends TLBoxShape<TweetShapeProps> {
if (embedId) {
return (
<g>
<rect
width={bounds.width}
height={bounds.height}
fill="#15202b"
rx={8}
ry={8} />
<rect width={bounds.width} height={bounds.height} fill="#15202b" rx={8} ry={8} />
<svg
x={bounds.width / 4}
y={bounds.height / 4}

View File

@ -93,6 +93,13 @@ export class VideoShape extends TLBoxShape<VideoShapeProps> {
isLocked,
},
} = this
return <rect width={w} height={h} fill="transparent" strokeDasharray={isLocked ? "8 2" : "undefined"}/>
return (
<rect
width={w}
height={h}
fill="transparent"
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
}

View File

@ -122,7 +122,16 @@ export class YouTubeShape extends TLBoxShape<YouTubeShapeProps> {
isLocked,
},
} = this
return <rect width={w} height={h} fill="transparent" rx={8} ry={8} strokeDasharray={isLocked ? "8 2" : "undefined"} />
return (
<rect
width={w}
height={h}
fill="transparent"
rx={8}
ry={8}
strokeDasharray={isLocked ? '8 2' : 'undefined'}
/>
)
})
validateProps = (props: Partial<YouTubeShapeProps>) => {

View File

@ -336,9 +336,11 @@ export class TLApp<
}
@action updateShapes = <T extends S>(shapes: ({ id: string } & Partial<T['props']>)[]): this => {
if (this.readOnly ) return this
if (this.readOnly) return this
const shapesToUpdate = shapes.map(shape => this.getShapeById(shape.id)).filter(shape => shape?.props.isLocked)
const shapesToUpdate = shapes
.map(shape => this.getShapeById(shape.id))
.filter(shape => shape?.props.isLocked)
if (shapesToUpdate.length === 0) return this

View File

@ -40,7 +40,11 @@ export const Indicator = observer(function Shape({
zIndex={isEditing ? 1000 : 10000}
>
<SVGContainer>
<g className={`tl-indicator-container ${isSelected ? 'tl-selected' : 'tl-hovered'} ${isLocked ? 'tl-locked' : ''}`}>
<g
className={`tl-indicator-container ${isSelected ? 'tl-selected' : 'tl-hovered'} ${
isLocked ? 'tl-locked' : ''
}`}
>
<ReactIndicator
isEditing={isEditing}
isBinding={isBinding}

View File

@ -27,15 +27,18 @@ export const SelectionForeground = observer(function SelectionForeground<S exten
return (
<>
{shapes.length > 0 && <SVGContainer>
{!app.editingShape && (<rect
{shapes.length > 0 && (
<SVGContainer>
{!app.editingShape && (
<rect
className="tl-bounds-fg"
width={Math.max(width, 1)}
height={Math.max(height, 1)}
rx={borderRadius}
ry={borderRadius}
pointerEvents="none"
/>)}
/>
)}
<EdgeHandle
x={targetSize * 2}
y={0}
@ -140,7 +143,8 @@ export const SelectionForeground = observer(function SelectionForeground<S exten
/>
</>
)}
</SVGContainer>}
</SVGContainer>
)}
</>
)
})