Skip to content

Commit

Permalink
style: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc authored and logseq-cldwalker committed Mar 27, 2023
1 parent 133d520 commit d00ec0a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 67 deletions.
Expand Up @@ -41,7 +41,7 @@ export const ActionBar = observer(function ActionBar(): JSX.Element {
</div>
)}

<div className={`tl-toolbar tl-zoom-bar ${app.readOnly ? "" : "ml-4"}`}>
<div className={`tl-toolbar tl-zoom-bar ${app.readOnly ? '' : 'ml-4'}`}>
<Button tooltip="Zoom in" onClick={zoomIn} id="tl-zoom-in">
<TablerIcon name="plus" />
</Button>
Expand Down
114 changes: 58 additions & 56 deletions tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx
Expand Up @@ -144,38 +144,38 @@ export const ContextMenu = observer(function ContextMenu({
{(app.selectedShapesArray.some(s => s.type === 'group' || app.getParentGroup(s)) ||
app.selectedShapesArray.length > 1) &&
!app.readOnly && (
<>
{app.selectedShapesArray.some(s => s.type === 'group' || app.getParentGroup(s)) && (
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.api.unGroup)}
>
<TablerIcon className="tl-menu-icon" name="ungroup" />
Ungroup
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code>{MOD_KEY}</code> <code></code> <code>G</code>
</span>
</div>
</ReactContextMenu.Item>
)}
{app.selectedShapesArray.length > 1 && (
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.api.doGroup)}
>
<TablerIcon className="tl-menu-icon" name="group" />
Group
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code>{MOD_KEY}</code> <code>G</code>
</span>
</div>
</ReactContextMenu.Item>
)}
<ReactContextMenu.Separator className="menu-separator" />
</>
)}
<>
{app.selectedShapesArray.some(s => s.type === 'group' || app.getParentGroup(s)) && (
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.api.unGroup)}
>
<TablerIcon className="tl-menu-icon" name="ungroup" />
Ungroup
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code>{MOD_KEY}</code> <code></code> <code>G</code>
</span>
</div>
</ReactContextMenu.Item>
)}
{app.selectedShapesArray.length > 1 && (
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.api.doGroup)}
>
<TablerIcon className="tl-menu-icon" name="group" />
Group
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code>{MOD_KEY}</code> <code>G</code>
</span>
</div>
</ReactContextMenu.Item>
)}
<ReactContextMenu.Separator className="menu-separator" />
</>
)}
{app.selectedShapes?.size > 0 && (
<>
{!app.readOnly && (
Expand Down Expand Up @@ -288,30 +288,32 @@ export const ContextMenu = observer(function ContextMenu({
)}
{!app.readOnly && (
<>
<ReactContextMenu.Separator className="menu-separator" />
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.bringToFront)}
>
Move to front
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code></code> <code>]</code>
</span>
</div>
</ReactContextMenu.Item>
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.sendToBack)}
>
Move to back
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code></code> <code>[</code>
</span>
</div>
</ReactContextMenu.Item>)
</>)}
<ReactContextMenu.Separator className="menu-separator" />
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.bringToFront)}
>
Move to front
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code></code> <code>]</code>
</span>
</div>
</ReactContextMenu.Item>
<ReactContextMenu.Item
className="tl-menu-item"
onClick={() => runAndTransition(app.sendToBack)}
>
Move to back
<div className="tl-menu-right-slot">
<span className="keyboard-shortcut">
<code></code> <code>[</code>
</span>
</div>
</ReactContextMenu.Item>
)
</>
)}

{developerMode && (
<ReactContextMenu.Item
Expand Down
13 changes: 6 additions & 7 deletions tldraw/packages/core/src/lib/TLApp/TLApp.ts
Expand Up @@ -377,11 +377,10 @@ export class TLApp<
})

const deleteBinding = (shapeA: string, shapeB: string) => {
if ([...ids].includes(shapeA) && this.getShapeById(shapeB)?.type === "line")
ids.add(shapeB)
if ([...ids].includes(shapeA) && this.getShapeById(shapeB)?.type === 'line') ids.add(shapeB)
}

this.currentPage.shapes
this.currentPage.shapes
.flatMap(s => Object.values(s.props.handles ?? {}))
.flatMap(h => h.bindingId)
.filter(isNonNullable)
Expand All @@ -391,7 +390,8 @@ export class TLApp<
if (toId && fromId) {
deleteBinding(toId, fromId)
deleteBinding(fromId, toId)
}})
}
})

const allShapesToDelete = [...ids].map(id => this.getShapeById(id)!)

Expand Down Expand Up @@ -446,7 +446,7 @@ export class TLApp<
}

align = (type: AlignType, shapes: S[] = this.selectedShapesArray): this => {
if (shapes.length < 2 || this.readOnly) return this
if (shapes.length < 2 || this.readOnly) return this

const boundsForShapes = shapes.map(shape => {
const bounds = shape.getBounds()
Expand Down Expand Up @@ -625,8 +625,7 @@ export class TLApp<
}

selectTool = (id: string, data: AnyObject = {}) => {
if (!this.readOnly || ['select', 'move'].includes(id) )
this.transition(id, data)
if (!this.readOnly || ['select', 'move'].includes(id)) this.transition(id, data)
}

registerTools(tools: TLToolConstructor<S, K>[]) {
Expand Down
2 changes: 1 addition & 1 deletion tldraw/packages/core/src/lib/TLHistory.ts
Expand Up @@ -30,7 +30,7 @@ export class TLHistory<S extends TLShape = TLShape, K extends TLEventMap = TLEve

@action persist = (replace = false) => {
if (this.isPaused || this.creating) return
this.app.notify('persist', {replace})
this.app.notify('persist', { replace })
}

@action undo = () => {
Expand Down
Expand Up @@ -147,7 +147,11 @@ export class IdleState<
const { selectedShapesArray } = this.app
switch (e.key) {
case 'Enter': {
if (selectedShapesArray.length === 1 && selectedShapesArray[0].canEdit && !this.app.readOnly) {
if (
selectedShapesArray.length === 1 &&
selectedShapesArray[0].canEdit &&
!this.app.readOnly
) {
this.tool.transition('editingShape', {
type: TLTargetType.Shape,
shape: selectedShapesArray[0],
Expand Down
4 changes: 3 additions & 1 deletion tldraw/packages/react/src/hooks/useAppSetup.ts
Expand Up @@ -6,7 +6,9 @@ export function useAppSetup<S extends TLReactShape, R extends TLReactApp<S> = TL
props: TLAppPropsWithoutApp<S, R> | TLAppPropsWithApp<S, R>
): R {
if ('app' in props) return props.app
const [app] = React.useState<R>(() => new TLReactApp(props.model, props.Shapes, props.Tools, props.readOnly) as R)
const [app] = React.useState<R>(
() => new TLReactApp(props.model, props.Shapes, props.Tools, props.readOnly) as R
)

React.useLayoutEffect(() => {
app.initKeyboardShortcuts()
Expand Down

0 comments on commit d00ec0a

Please sign in to comment.