From 1b12486a7a860d5b95875267a5a909fee5db773d Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 15:29:32 +0300 Subject: [PATCH 1/8] fix: cross platform build script --- tldraw/apps/tldraw-logseq/build.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tldraw/apps/tldraw-logseq/build.mjs b/tldraw/apps/tldraw-logseq/build.mjs index 995d6f175f..c474d2df68 100644 --- a/tldraw/apps/tldraw-logseq/build.mjs +++ b/tldraw/apps/tldraw-logseq/build.mjs @@ -2,6 +2,7 @@ /* eslint-disable no-undef */ import 'zx/globals' import fs from 'fs' +import path from 'path' // Build with [tsup](https://tsup.egoist.sh) await $`tsup` @@ -16,4 +17,7 @@ Object.assign(glob, { fs.writeFileSync('dist/package.json', JSON.stringify(glob, null, 2)) -await $`ln -f ${__dirname}/dist/index.js ${__dirname}/../../../src/js/tldraw-logseq.js` +const dest = path.join(__dirname, '/../../../src/js/tldraw-logseq.js') + +fs.unlinkSync(dest) +fs.linkSync(path.join(__dirname, '/dist/index.js'), dest) From fb8302e09c3833396cb2dc9b0141ca1a11f196f6 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 15:31:23 +0300 Subject: [PATCH 2/8] fix: context menu labels --- .../src/components/ContextMenu/ContextMenu.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx index 04cc926cc0..588919097f 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx @@ -60,7 +60,7 @@ export const ContextMenu = observer(function ContextMenu({ className="tl-context-menu-button" onClick={() => app.api.selectAll()} > - Select All + Select all
{MOD_KEY} A @@ -72,7 +72,7 @@ export const ContextMenu = observer(function ContextMenu({ className="tl-context-menu-button" onClick={() => app.api.deselectAll()} > - Deselect All + Deselect all )} {app.selectedShapes?.size > 0 && ( @@ -95,13 +95,13 @@ export const ContextMenu = observer(function ContextMenu({ className="tl-context-menu-button" onClick={() => app.flipHorizontal()} > - Flip Horizontally + Flip horizontally app.flipVertical()} > - Flip Vertically + Flip vertically )} @@ -110,7 +110,7 @@ export const ContextMenu = observer(function ContextMenu({ className="tl-context-menu-button" onClick={() => app.bringToFront()} > - Move to Front + Move to front
] From 27c0f0ebdd60c5b5b9a518a2e8e59d61fc0eb186 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 15:46:07 +0300 Subject: [PATCH 3/8] fix: block pan on context menu --- tldraw/packages/core/src/lib/TLApp/TLApp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tldraw/packages/core/src/lib/TLApp/TLApp.ts b/tldraw/packages/core/src/lib/TLApp/TLApp.ts index 6dee62e034..7c0a2f379b 100644 --- a/tldraw/packages/core/src/lib/TLApp/TLApp.ts +++ b/tldraw/packages/core/src/lib/TLApp/TLApp.ts @@ -819,7 +819,7 @@ export class TLApp< } readonly onWheel: TLEvents['wheel'] = (info, e) => { - if (e.ctrlKey) { + if (e.ctrlKey || this.isIn('select.contextMenu')) { return } From 89bf35d28282ab775aff8836c69e844d5a97df12 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 16:23:15 +0300 Subject: [PATCH 4/8] fix: context menu state --- .../components/ContextMenu/ContextMenu.tsx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx index 588919097f..13c98de6d2 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx @@ -19,17 +19,18 @@ export const ContextMenu = observer(function ContextMenu({ const app = useApp() const rContent = React.useRef(null) + const runAndTransition = (f: Function) => { + f() + app.transition('select') + } + return ( - { - if (!state) app.transition('select') - }} - > + {children} app.transition('select')} collisionBoundary={collisionRef.current} asChild tabIndex={-1} @@ -37,7 +38,7 @@ export const ContextMenu = observer(function ContextMenu({
{app.selectedShapes?.size > 0 && ( <> - app.copy()}> + runAndTransition(app.copy)}> Copy
@@ -47,7 +48,7 @@ export const ContextMenu = observer(function ContextMenu({ )} - app.paste()}> + runAndTransition(app.paste)}> Paste
@@ -58,7 +59,7 @@ export const ContextMenu = observer(function ContextMenu({ app.api.selectAll()} + onClick={() => runAndTransition(app.api.selectAll)} > Select all
@@ -70,7 +71,7 @@ export const ContextMenu = observer(function ContextMenu({ {app.selectedShapes?.size > 1 && ( app.api.deselectAll()} + onClick={() => runAndTransition(app.api.deselectAll)} > Deselect all @@ -79,7 +80,7 @@ export const ContextMenu = observer(function ContextMenu({ <> app.api.deleteShapes()} + onClick={() => runAndTransition(app.api.deleteShapes)} > Delete
@@ -93,13 +94,13 @@ export const ContextMenu = observer(function ContextMenu({ app.flipHorizontal()} + onClick={() => runAndTransition(app.flipHorizontal)} > Flip horizontally app.flipVertical()} + onClick={() => runAndTransition(app.flipVertical)} > Flip vertically @@ -108,7 +109,7 @@ export const ContextMenu = observer(function ContextMenu({ app.bringToFront()} + onClick={() => runAndTransition(app.bringToFront)} > Move to front
@@ -119,7 +120,7 @@ export const ContextMenu = observer(function ContextMenu({ app.sendToBack()} + onClick={() => runAndTransition(app.sendToBack)} > Move to back
From a50e8a206a1960760ee9bc8f41cb7569710ac86c Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 16:26:42 +0300 Subject: [PATCH 5/8] fix: zoom menu labels --- .../src/components/ZoomMenu/ZoomMenu.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ZoomMenu/ZoomMenu.tsx b/tldraw/apps/tldraw-logseq/src/components/ZoomMenu/ZoomMenu.tsx index 736dc65870..611cdae025 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ZoomMenu/ZoomMenu.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ZoomMenu/ZoomMenu.tsx @@ -24,14 +24,15 @@ export const ZoomMenu = observer(function ZoomMenu(): JSX.Element { onSelect={preventEvent} onClick={app.api.zoomToFit} > - Zoom to Fit
+ Zoom to fit +
- Zoom to Selection{' '} + Zoom to selection
{MOD_KEY} - @@ -43,7 +44,7 @@ export const ZoomMenu = observer(function ZoomMenu(): JSX.Element { onSelect={preventEvent} onClick={app.api.zoomIn} > - Zoom In{' '} + Zoom in
{MOD_KEY} + @@ -55,7 +56,7 @@ export const ZoomMenu = observer(function ZoomMenu(): JSX.Element { onSelect={preventEvent} onClick={app.api.zoomOut} > - Zoom Out{' '} + Zoom out
{MOD_KEY} - @@ -67,7 +68,7 @@ export const ZoomMenu = observer(function ZoomMenu(): JSX.Element { onSelect={preventEvent} onClick={app.api.resetZoom} > - Reset Zoom{' '} + Reset zoom
0 From 6f4541dcbef07c817d8b58714fa52b82d6c8f470 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 16:27:47 +0300 Subject: [PATCH 6/8] style: context menu component --- .../src/components/ContextMenu/ContextMenu.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx index 13c98de6d2..f8e2a29c84 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextMenu/ContextMenu.tsx @@ -30,7 +30,7 @@ export const ContextMenu = observer(function ContextMenu({ app.transition('select')} + onEscapeKeyDown={() => app.transition('select')} collisionBoundary={collisionRef.current} asChild tabIndex={-1} @@ -38,7 +38,10 @@ export const ContextMenu = observer(function ContextMenu({
{app.selectedShapes?.size > 0 && ( <> - runAndTransition(app.copy)}> + runAndTransition(app.copy)} + > Copy
@@ -48,7 +51,10 @@ export const ContextMenu = observer(function ContextMenu({ )} - runAndTransition(app.paste)}> + runAndTransition(app.paste)} + > Paste
From 1b6d8b054fe550cc3b12c07a8b15b119ce754f5a Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Wed, 31 Aug 2022 17:01:48 +0300 Subject: [PATCH 7/8] fix: hide context bar on context menu --- .../tldraw-logseq/src/components/ContextBar/ContextBar.tsx | 5 ++++- tldraw/packages/core/src/lib/TLApp/TLApp.ts | 1 + .../components/ContextBarContainer/ContextBarContainer.tsx | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx index 384a4854f7..14383deeab 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx @@ -43,7 +43,10 @@ const _ContextBar: TLContextBarComponent = ({ shapes, offsets, hidden })