From 6002853ce4e533d043df53959588ac662eaf4d87 Mon Sep 17 00:00:00 2001 From: sawhney17 <80150109+sawhney17@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:50:28 +0400 Subject: [PATCH 1/4] fix redo not working --- tldraw/packages/core/src/lib/TLHistory.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tldraw/packages/core/src/lib/TLHistory.ts b/tldraw/packages/core/src/lib/TLHistory.ts index 4f67b8dbec..44d593f069 100644 --- a/tldraw/packages/core/src/lib/TLHistory.ts +++ b/tldraw/packages/core/src/lib/TLHistory.ts @@ -64,12 +64,14 @@ export class TLHistory { From 5a264fad24e96f57673922710b64995acc2695ab Mon Sep 17 00:00:00 2001 From: sawhney17 <80150109+sawhney17@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:55:03 +0400 Subject: [PATCH 2/4] remove double call of pointer --- tldraw/packages/core/src/lib/TLHistory.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tldraw/packages/core/src/lib/TLHistory.ts b/tldraw/packages/core/src/lib/TLHistory.ts index 44d593f069..c62b2ed47e 100644 --- a/tldraw/packages/core/src/lib/TLHistory.ts +++ b/tldraw/packages/core/src/lib/TLHistory.ts @@ -64,7 +64,6 @@ export class TLHistory Date: Fri, 17 Jun 2022 18:54:28 +0400 Subject: [PATCH 3/4] add undo and redo buttons --- .../src/components/ActionBar/ActionBar.tsx | 31 +++++++++++++++++++ .../src/components/ActionBar/index.ts | 1 + .../tldraw-logseq/src/components/AppUI.tsx | 4 ++- tldraw/packages/core/src/lib/TLApi/TLApi.ts | 12 +++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx create mode 100644 tldraw/apps/tldraw-logseq/src/components/ActionBar/index.ts diff --git a/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx b/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx new file mode 100644 index 0000000000..348cca2dcf --- /dev/null +++ b/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx @@ -0,0 +1,31 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import * as React from 'react' +import { observer } from 'mobx-react-lite' +import type { Shape } from '~lib' +import { App, useApp } from '@tldraw/react' +import { Minimap } from '~components/Minimap' +import { RedoIcon, UndoIcon } from '~components/icons' + +export const ActionBar = observer(function ToolBar(): JSX.Element { + const app = useApp() + const undo = React.useCallback(() => { + app.api.undo() + }, [app]) + + const redo = React.useCallback(() => { + app.api.redo() + }, [app]) + + return ( +
+ + + +
+ ) +}) diff --git a/tldraw/apps/tldraw-logseq/src/components/ActionBar/index.ts b/tldraw/apps/tldraw-logseq/src/components/ActionBar/index.ts new file mode 100644 index 0000000000..4bf6759633 --- /dev/null +++ b/tldraw/apps/tldraw-logseq/src/components/ActionBar/index.ts @@ -0,0 +1 @@ +export * from './ActionBar'; \ No newline at end of file diff --git a/tldraw/apps/tldraw-logseq/src/components/AppUI.tsx b/tldraw/apps/tldraw-logseq/src/components/AppUI.tsx index 4f4c29b744..52d46b7e7d 100644 --- a/tldraw/apps/tldraw-logseq/src/components/AppUI.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/AppUI.tsx @@ -5,17 +5,19 @@ import { StatusBar } from './StatusBar' import { PrimaryTools } from './PrimaryTools' import { DevTools } from './Devtools' import { Minimap } from './Minimap' +import { ActionBar } from './ActionBar' const isDev = process.env.NODE_ENV === 'development' export const AppUI = observer(function AppUI() { return ( <> - {/* */} + {/* */} {isDev && } {isDev && } + ) }) diff --git a/tldraw/packages/core/src/lib/TLApi/TLApi.ts b/tldraw/packages/core/src/lib/TLApi/TLApi.ts index 6c37ccaef7..8eaa303f31 100644 --- a/tldraw/packages/core/src/lib/TLApi/TLApi.ts +++ b/tldraw/packages/core/src/lib/TLApi/TLApi.ts @@ -161,4 +161,16 @@ export class TLApi { + this.app.undo() + this.app.undo() + return this + } + + redo = () => { + this.app.redo() + this.app.redo() + return this + } } From 52a50bfd2461fdac67ac79e20c7747c4cc23a305 Mon Sep 17 00:00:00 2001 From: sawhney17 <80150109+sawhney17@users.noreply.github.com> Date: Fri, 17 Jun 2022 18:54:36 +0400 Subject: [PATCH 4/4] style fixes for whiteboard --- tldraw/apps/tldraw-logseq/src/styles.css | 34 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/styles.css b/tldraw/apps/tldraw-logseq/src/styles.css index 1d3b42a756..5c10a612af 100644 --- a/tldraw/apps/tldraw-logseq/src/styles.css +++ b/tldraw/apps/tldraw-logseq/src/styles.css @@ -30,7 +30,6 @@ background: none; border: none; cursor: pointer; - border-radius: 2px; padding: 4px 8px; } @@ -50,6 +49,35 @@ font-size: inherit; } + +.logseq-tldraw .action-bar { + position: relative; + top: 0; + /* width: 100%; */ + float:right; + grid-row: 1; + display: flex; + align-items: center; + padding: 8px; + color: black; + /* border-radius: 15px; */ + border-bottom-left-radius: 15px; + z-index: 100000; + user-select: none; + background: white; + border-left: 1px solid black; + border-bottom: 1px solid black; + font-size: inherit; +} + +.logseq-tldraw .action-bar button:hover { + background-color: var(--color-hover); +} + +.logseq-tldraw .action-bar button { + border-radius: 4px; +} + .logseq-tldraw .contextbar { pointer-events: all; position: relative; @@ -370,8 +398,8 @@ .logseq-tldraw .preview-minimap-toggle { position: absolute; - top: 24px; - right: 40px; + top: 60px; + right: 50px; z-index: 1; width: 32px; height: 32px;