From 0a91115f032f401f2e6df0d5c6e417a1973058dc Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Thu, 1 Jun 2023 13:14:27 +0300 Subject: [PATCH 01/10] fix: remove unneeded persist --- tldraw/packages/core/src/lib/TLApp/TLApp.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tldraw/packages/core/src/lib/TLApp/TLApp.ts b/tldraw/packages/core/src/lib/TLApp/TLApp.ts index b18251cc75..9246366445 100644 --- a/tldraw/packages/core/src/lib/TLApp/TLApp.ts +++ b/tldraw/packages/core/src/lib/TLApp/TLApp.ts @@ -399,7 +399,6 @@ export class TLApp< @action addAssets(assets: T[]): this { assets.forEach(asset => (this.assets[asset.id] = asset)) - this.persist() return this } From 6e101a8fbfa1bc78200d76cf970706cbf1f65ee1 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Thu, 1 Jun 2023 13:15:17 +0300 Subject: [PATCH 02/10] fix: endless loop --- tldraw/apps/tldraw-logseq/src/lib/shapes/TextShape.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/TextShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/TextShape.tsx index da56ea47b8..6e4bf93fe8 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/TextShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/TextShape.tsx @@ -132,7 +132,6 @@ export class TextShape extends TLTextShape { const handleBlur = React.useCallback( (e: React.FocusEvent) => { if (!isEditing) return - e.currentTarget.setSelectionRange(0, 0) onEditingEnd?.() }, [onEditingEnd] From 4c2e61cbd313c5db0817ef39348951673bb98f40 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Wed, 31 May 2023 16:46:50 -0400 Subject: [PATCH 03/10] Remove deprecated :editor/command-trigger option This option has been deprecated for a couple months --- src/main/frontend/commands.cljs | 27 ++++++++++--------- .../frontend/handler/common/config_edn.cljs | 2 +- src/main/frontend/handler/editor.cljs | 16 +++++------ src/main/frontend/state.cljs | 9 ------- .../handler/common/config_edn_test.cljs | 2 +- 5 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/main/frontend/commands.cljs b/src/main/frontend/commands.cljs index 9eeca2676f..060485a53a 100644 --- a/src/main/frontend/commands.cljs +++ b/src/main/frontend/commands.cljs @@ -30,6 +30,7 @@ (defonce angle-bracket "<") (defonce hashtag "#") (defonce colon ":") +(defonce command-trigger "/") (defonce *current-command (atom nil)) (def query-doc @@ -52,7 +53,7 @@ "."]]) (defn link-steps [] - [[:editor/input (str (state/get-editor-command-trigger) "link")] + [[:editor/input (str command-trigger "link")] [:editor/show-input [{:command :link :id :link :placeholder "Link" @@ -62,7 +63,7 @@ :placeholder "Label"}]]]) (defn image-link-steps [] - [[:editor/input (str (state/get-editor-command-trigger) "link")] + [[:editor/input (str command-trigger "link")] [:editor/show-input [{:command :image-link :id :link :placeholder "Link" @@ -72,7 +73,7 @@ :placeholder "Label"}]]]) (defn zotero-steps [] - [[:editor/input (str (state/get-editor-command-trigger) "zotero")] + [[:editor/input (str command-trigger "zotero")] [:editor/show-zotero]]) (def *extend-slash-commands (atom [])) @@ -96,19 +97,19 @@ [type] (let [template (util/format "@@%s: @@" type)] - [[:editor/input template {:last-pattern (state/get-editor-command-trigger) + [[:editor/input template {:last-pattern command-trigger :backward-pos 2}]])) (defn embed-page [] (conj - [[:editor/input "{{embed [[]]}}" {:last-pattern (state/get-editor-command-trigger) + [[:editor/input "{{embed [[]]}}" {:last-pattern command-trigger :backward-pos 4}]] [:editor/search-page :embed])) (defn embed-block [] - [[:editor/input "{{embed (())}}" {:last-pattern (state/get-editor-command-trigger) + [[:editor/input "{{embed (())}}" {:last-pattern command-trigger :backward-pos 4}] [:editor/search-block :embed]]) @@ -229,9 +230,9 @@ ["Image link" (image-link-steps) "Create a HTTP link to a image"] (when (state/markdown?) ["Underline" [[:editor/input "" - {:last-pattern (state/get-editor-command-trigger) + {:last-pattern command-trigger :backward-pos 6}]] "Create a underline text decoration"]) - ["Template" [[:editor/input (state/get-editor-command-trigger) nil] + ["Template" [[:editor/input command-trigger nil] [:editor/search-template]] "Insert a created template here"] (cond (and (util/electron?) (config/local-db? (state/get-current-repo))) @@ -239,7 +240,7 @@ ["Upload an asset" [[:editor/click-hidden-file-input :id]] "Upload file types like image, pdf, docx, etc.)"])] ;; ["Upload an image" [[:editor/click-hidden-file-input :id]]] - + (headings) @@ -290,12 +291,12 @@ text)) "Draw a graph with Excalidraw"] ["Embed HTML " (->inline "html")] - ["Embed Video URL" [[:editor/input "{{video }}" {:last-pattern (state/get-editor-command-trigger) + ["Embed Video URL" [[:editor/input "{{video }}" {:last-pattern command-trigger :backward-pos 2}]]] ["Embed Youtube timestamp" [[:youtube/insert-timestamp]]] - ["Embed Twitter tweet" [[:editor/input "{{tweet }}" {:last-pattern (state/get-editor-command-trigger) + ["Embed Twitter tweet" [[:editor/input "{{tweet }}" {:last-pattern command-trigger :backward-pos 2}]]]] @*extend-slash-commands @@ -335,7 +336,7 @@ (when-let [input (gdom/getElement id)] (let [last-pattern (when-not (= last-pattern :skip-check) (when-not backward-truncate-number - (or last-pattern (state/get-editor-command-trigger)))) + (or last-pattern command-trigger))) edit-content (gobj/get input "value") current-pos (cursor/pos input) current-pos (or @@ -527,7 +528,7 @@ (let [edit-content (gobj/get current-input "value") current-pos (cursor/pos current-input) prefix (subs edit-content 0 current-pos) - prefix (util/replace-last (state/get-editor-command-trigger) prefix "" (boolean space?)) + prefix (util/replace-last command-trigger prefix "" (boolean space?)) new-value (str prefix (subs edit-content current-pos))] (state/set-block-content-and-last-pos! input-id diff --git a/src/main/frontend/handler/common/config_edn.cljs b/src/main/frontend/handler/common/config_edn.cljs index 90b7233fb9..c26b0b20e7 100644 --- a/src/main/frontend/handler/common/config_edn.cljs +++ b/src/main/frontend/handler/common/config_edn.cljs @@ -92,7 +92,7 @@ nested keys or positional errors e.g. tuples" (let [body (try (edn/read-string content) (catch :default _ ::failed-to-detect)) warnings {:editor/command-trigger - "Will no longer be supported soon. Please use '/' and report bugs on it."}] + "is no longer supported. Please use '/' and report bugs on it."}] (cond (= body ::failed-to-detect) (log/info :msg "Skip deprecation check since config is not valid edn") diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 97802116a0..677cfa7104 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1536,7 +1536,7 @@ (if file-obj (.-name file-obj) (if image? "image" "asset")) image?) format - {:last-pattern (if drop-or-paste? "" (state/get-editor-command-trigger)) + {:last-pattern (if drop-or-paste? "" commands/command-trigger) :restore? true :command :insert-asset}))))) (p/finally @@ -1675,7 +1675,7 @@ last-command (and last-slash-caret-pos (subs edit-content last-slash-caret-pos pos))] (when (> pos 0) (or - (and (= (state/get-editor-command-trigger) (util/nth-safe edit-content (dec pos))) + (and (= commands/command-trigger (util/nth-safe edit-content (dec pos))) @commands/*initial-commands) (and last-command (commands/get-matched-commands last-command))))) @@ -1793,7 +1793,7 @@ id (get-link format link label) format - {:last-pattern (str (state/get-editor-command-trigger) "link") + {:last-pattern (str commands/command-trigger "link") :command :link}))) :image-link (let [{:keys [link label]} m] @@ -1802,7 +1802,7 @@ id (get-image-link format link label) format - {:last-pattern (str (state/get-editor-command-trigger) "link") + {:last-pattern (str commands/command-trigger "link") :command :image-link}))) nil) @@ -1879,7 +1879,7 @@ (-> (p/delay 10) (p/then #(state/pub-event! [:editor/toggle-own-number-list edit-block])))) - (and (= last-input-char (state/get-editor-command-trigger)) + (and (= last-input-char commands/command-trigger) (or (re-find #"(?m)^/" (str (.-value input))) (start-of-new-word? input pos))) (do (state/set-editor-action-data! {:pos (cursor/get-caret-pos input)}) @@ -2730,7 +2730,7 @@ (delete-block! repo false)))) (and (> current-pos 1) - (= (util/nth-safe value (dec current-pos)) (state/get-editor-command-trigger))) + (= (util/nth-safe value (dec current-pos)) commands/command-trigger)) (do (util/stop e) (commands/restore-state) @@ -3014,8 +3014,8 @@ (util/event-is-composing? e true)])] (cond ;; When you type something after / - (and (= :commands (state/get-editor-action)) (not= k (state/get-editor-command-trigger))) - (if (= (state/get-editor-command-trigger) (second (re-find #"(\S+)\s+$" value))) + (and (= :commands (state/get-editor-action)) (not= k commands/command-trigger)) + (if (= commands/command-trigger (second (re-find #"(\S+)\s+$" value))) (state/clear-editor-action!) (let [matched-commands (get-matched-commands input)] (if (seq matched-commands) diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index c079f245dd..5020180c04 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -426,15 +426,6 @@ should be done through this fn in order to get global config and config defaults (get-in @state [:me :preferred_format] "markdown"))))) -;; TODO: consider adding a pane in Settings to set this through the GUI (rather -;; than having to go through the config.edn file) -(defn get-editor-command-trigger - ([] (get-editor-command-trigger (get-current-repo))) - ([repo-url] - (or - (:editor/command-trigger (get-config repo-url)) ;; Get from user config - "/"))) ;; Set the default - (defn markdown? [] (= (keyword (get-preferred-format)) diff --git a/src/test/frontend/handler/common/config_edn_test.cljs b/src/test/frontend/handler/common/config_edn_test.cljs index c96e0be9cc..d8eb56d623 100644 --- a/src/test/frontend/handler/common/config_edn_test.cljs +++ b/src/test/frontend/handler/common/config_edn_test.cljs @@ -60,7 +60,7 @@ (deftest detect-deprecations (is (re-find - #":editor/command-trigger.*Will" + #":editor/command-trigger.*is" (deprecation-warnings-for "{:preferred-workflow :todo :editor/command-trigger \",\"}")) "Warning when there is a deprecation") From 960f324972cd3f68c7d55b17e782e066a70ee24a Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Fri, 2 Jun 2023 18:41:03 +0300 Subject: [PATCH 04/10] enhance: auto pan --- tldraw/packages/core/src/lib/TLViewport.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tldraw/packages/core/src/lib/TLViewport.ts b/tldraw/packages/core/src/lib/TLViewport.ts index 92e291ab26..bab9b5e264 100644 --- a/tldraw/packages/core/src/lib/TLViewport.ts +++ b/tldraw/packages/core/src/lib/TLViewport.ts @@ -19,6 +19,7 @@ export class TLViewport { static readonly minZoom = 0.1 static readonly maxZoom = 4 static readonly panMultiplier = 0.05 + static readonly panThreshold = 100 /* ------------------- Properties ------------------- */ @@ -50,8 +51,10 @@ export class TLViewport { } panToPointWhenOutOfBounds = (point: number[]) => { - const deltaMax = Vec.sub([this.currentView.maxX, this.currentView.maxY], point) - const deltaMin = Vec.sub([this.currentView.minX, this.currentView.minY], point) + const threshold = [TLViewport.panThreshold, TLViewport.panThreshold] + + const deltaMax = Vec.sub([this.currentView.maxX, this.currentView.maxY], Vec.add(point, threshold)) + const deltaMin = Vec.sub([this.currentView.minX, this.currentView.minY], Vec.sub(point, threshold)) const deltaX = deltaMax[0] < 0 ? deltaMax[0] : deltaMin[0] > 0 ? deltaMin[0] : 0 const deltaY = deltaMax[1] < 0 ? deltaMax[1] : deltaMin[1] > 0 ? deltaMin[1] : 0 From 6aed9edf3a6c2cbcca3ebeee5dbc083124b11271 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Fri, 2 Jun 2023 18:47:28 +0300 Subject: [PATCH 05/10] enhance: naming --- tldraw/packages/core/src/lib/TLViewport.ts | 2 +- .../core/src/lib/tools/TLSelectTool/states/BrushingState.ts | 2 +- .../core/src/lib/tools/TLSelectTool/states/ResizingState.ts | 2 +- .../core/src/lib/tools/TLSelectTool/states/TranslatingState.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tldraw/packages/core/src/lib/TLViewport.ts b/tldraw/packages/core/src/lib/TLViewport.ts index bab9b5e264..8fe2053a39 100644 --- a/tldraw/packages/core/src/lib/TLViewport.ts +++ b/tldraw/packages/core/src/lib/TLViewport.ts @@ -50,7 +50,7 @@ export class TLViewport { }) } - panToPointWhenOutOfBounds = (point: number[]) => { + panToPointWhenNearBounds = (point: number[]) => { const threshold = [TLViewport.panThreshold, TLViewport.panThreshold] const deltaMax = Vec.sub([this.currentView.maxX, this.currentView.maxY], Vec.add(point, threshold)) diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts index 9b3c722d90..9841b8c74b 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts @@ -69,7 +69,7 @@ export class BrushingState< // Select hit shapes this.app.setSelectedShapes(hits) } - this.app.viewport.panToPointWhenOutOfBounds(currentPoint) + this.app.viewport.panToPointWhenNearBounds(currentPoint) } onPointerUp: TLEvents['pointer'] = () => { diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts index 290b1fcc05..d056fd45e1 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts @@ -227,7 +227,7 @@ export class ResizingState< }) }) this.updateCursor(scaleX, scaleY) - this.app.viewport.panToPointWhenOutOfBounds(currentPoint) + this.app.viewport.panToPointWhenNearBounds(currentPoint) } onPointerUp: TLEvents['pointer'] = () => { diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/TranslatingState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/TranslatingState.ts index 07052cbe9e..7d3fa8e34d 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/TranslatingState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/TranslatingState.ts @@ -141,7 +141,7 @@ export class TranslatingState< } = this.app this.moveSelectedShapesToPointer() - this.app.viewport.panToPointWhenOutOfBounds(currentPoint) + this.app.viewport.panToPointWhenNearBounds(currentPoint) } onPointerDown: TLEvents['pointer'] = () => { From 776495d187f99640e13fce1e39796833fed2a7d5 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Fri, 2 Jun 2023 21:33:31 +0300 Subject: [PATCH 06/10] fix: e2e tests --- e2e-tests/whiteboards.spec.ts | 46 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/e2e-tests/whiteboards.spec.ts b/e2e-tests/whiteboards.spec.ts index fb10d871de..50edd8aaeb 100644 --- a/e2e-tests/whiteboards.spec.ts +++ b/e2e-tests/whiteboards.spec.ts @@ -85,10 +85,10 @@ test('draw a rectangle', async ({ page }) => { await page.keyboard.type('wr') - await page.mouse.move(bounds.x + 5, bounds.y + 5) + await page.mouse.move(bounds.x + 105, bounds.y + 105) await page.mouse.down() - await page.mouse.move(bounds.x + 50, bounds.y + 50 ) + await page.mouse.move(bounds.x + 150, bounds.y + 150 ) await page.mouse.up() await page.keyboard.press('Escape') @@ -114,12 +114,14 @@ test('clone the rectangle', async ({ page }) => { const canvas = await page.waitForSelector('.logseq-tldraw') const bounds = (await canvas.boundingBox())! - await page.mouse.move(bounds.x + 20, bounds.y + 20, {steps: 5}) + await page.mouse.move(bounds.x + 400, bounds.y + 400) + + await page.mouse.move(bounds.x + 120, bounds.y + 120, {steps: 5}) await page.keyboard.down('Alt') await page.mouse.down() - await page.mouse.move(bounds.x + 100, bounds.y + 100, {steps: 5}) + await page.mouse.move(bounds.x + 200, bounds.y + 200, {steps: 5}) await page.mouse.up() await page.keyboard.up('Alt') @@ -163,10 +165,10 @@ test('connect rectangles with an arrow', async ({ page }) => { await page.keyboard.type('wc') - await page.mouse.move(bounds.x + 20, bounds.y + 20) + await page.mouse.move(bounds.x + 120, bounds.y + 120) await page.mouse.down() - await page.mouse.move(bounds.x + 100, bounds.y + 100, {steps: 5}) // will fail without steps + await page.mouse.move(bounds.x + 200, bounds.y + 200, {steps: 5}) // will fail without steps await page.mouse.up() await page.keyboard.press('Escape') @@ -191,10 +193,15 @@ test('undo the delete action', async ({ page }) => { }) test('convert the first rectangle to ellipse', async ({ page }) => { + const canvas = await page.waitForSelector('.logseq-tldraw') + const bounds = (await canvas.boundingBox())! + await page.keyboard.press('Escape') - await page.waitForTimeout(1000) - await page.click('.logseq-tldraw .tl-box-container:first-of-type') - await page.mouse.move(0, 0) // move mouse to trigger a rerender of the context bar + await page.mouse.move(bounds.x + 220, bounds.y + 220) + await page.mouse.down() + await page.mouse.up() + await page.mouse.move(bounds.x + 520, bounds.y + 520) + await page.click('.tl-context-bar .tl-geometry-tools-pane-anchor') await page.click('.tl-context-bar .tl-geometry-toolbar [data-tool=ellipse]') @@ -223,9 +230,14 @@ test('undo the shape conversion', async ({ page }) => { }) test('locked elements should not be removed', async ({ page }) => { + const canvas = await page.waitForSelector('.logseq-tldraw') + const bounds = (await canvas.boundingBox())! + await page.keyboard.press('Escape') - await page.waitForTimeout(1000) - await page.click('.logseq-tldraw .tl-box-container:first-of-type') + await page.mouse.move(bounds.x + 220, bounds.y + 220) + await page.mouse.down() + await page.mouse.up() + await page.mouse.move(bounds.x + 520, bounds.y + 520) await page.keyboard.press(`${modKey}+l`) await page.keyboard.press('Delete') await page.keyboard.press(`${modKey}+Shift+l`) @@ -269,7 +281,7 @@ test('create a block', async ({ page }) => { const bounds = (await canvas.boundingBox())! await page.keyboard.type('ws') - await page.mouse.dblclick(bounds.x + 5, bounds.y + 5) + await page.mouse.dblclick(bounds.x + 105, bounds.y + 105) await page.waitForTimeout(100) await page.keyboard.type('a') @@ -304,7 +316,7 @@ test('copy/paste url to create an iFrame shape', async ({ page }) => { const bounds = (await canvas.boundingBox())! await page.keyboard.type('wt') - await page.mouse.move(bounds.x + 5, bounds.y + 5) + await page.mouse.move(bounds.x + 105, bounds.y + 105) await page.mouse.down() await page.waitForTimeout(100) @@ -323,7 +335,7 @@ test('copy/paste twitter status url to create a Tweet shape', async ({ page }) = const bounds = (await canvas.boundingBox())! await page.keyboard.type('wt') - await page.mouse.move(bounds.x + 5, bounds.y + 5) + await page.mouse.move(bounds.x + 105, bounds.y + 105) await page.mouse.down() await page.waitForTimeout(100) @@ -342,7 +354,7 @@ test('copy/paste youtube video url to create a Youtube shape', async ({ page }) const bounds = (await canvas.boundingBox())! await page.keyboard.type('wt') - await page.mouse.move(bounds.x + 5, bounds.y + 5) + await page.mouse.move(bounds.x + 105, bounds.y + 105) await page.mouse.down() await page.waitForTimeout(100) @@ -394,8 +406,8 @@ test('quick add another whiteboard', async ({ page }) => { const canvas = await page.waitForSelector('.logseq-tldraw') await canvas.dblclick({ position: { - x: 100, - y: 100, + x: 200, + y: 200, }, }) From fbf365ceff10c9f75adfc86337fe492a4da08900 Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Fri, 2 Jun 2023 15:49:41 +0300 Subject: [PATCH 07/10] enhance: support whiteboard translations --- src/main/frontend/extensions/tldraw.cljs | 4 +- src/resources/dicts/en.edn | 84 ++++++++++++++++ .../src/components/ActionBar/ActionBar.tsx | 12 ++- .../ContextBar/contextBarActionFactory.tsx | 59 ++++++++--- .../components/ContextMenu/ContextMenu.tsx | 98 ++++++++++--------- .../GeometryTools/GeometryTools.tsx | 40 +++++--- .../components/PrimaryTools/PrimaryTools.tsx | 20 ++-- .../src/components/QuickLinks/QuickLinks.tsx | 3 +- .../components/QuickSearch/QuickSearch.tsx | 18 ++-- .../src/components/inputs/ColorInput.tsx | 13 ++- .../src/components/inputs/ScaleInput.tsx | 19 ++-- .../src/components/inputs/ShapeLinksInput.tsx | 23 +++-- .../tldraw-logseq/src/lib/logseq-context.ts | 1 + .../handles/RotateHandle.tsx | 1 - 14 files changed, 281 insertions(+), 114 deletions(-) diff --git a/src/main/frontend/extensions/tldraw.cljs b/src/main/frontend/extensions/tldraw.cljs index 927de4c9c5..409fafcf6d 100644 --- a/src/main/frontend/extensions/tldraw.cljs +++ b/src/main/frontend/extensions/tldraw.cljs @@ -5,6 +5,7 @@ [frontend.components.export :as export] [frontend.components.page :as page] [frontend.config :as config] + [frontend.context.i18n :refer [t]] [frontend.db.model :as model] [frontend.handler.editor :as editor-handler] [frontend.handler.route :as route-handler] @@ -93,7 +94,8 @@ (def undo (fn [] (history/undo! nil))) (def redo (fn [] (history/redo! nil))) (defn get-tldraw-handlers [current-whiteboard-name] - {:search search-handler + {:t (fn [key] (t (keyword key))) + :search search-handler :queryBlockByUUID (fn [block-uuid] (clj->js (model/query-block-by-uuid (parse-uuid block-uuid)))) diff --git a/src/resources/dicts/en.edn b/src/resources/dicts/en.edn index 03eef0405c..d8d55e3e2b 100644 --- a/src/resources/dicts/en.edn +++ b/src/resources/dicts/en.edn @@ -249,6 +249,90 @@ :search/publishing "Search" :search "Search or create page" :whiteboard/link-whiteboard-or-block "Link whiteboard/page/block" + :whiteboard/align-left "Align left" + :whiteboard/align-center-horizontally "Align center horizontally" + :whiteboard/align-right "Align right" + :whiteboard/distribute-horizontally "Distribute horizontally" + :whiteboard/align-top "Align top" + :whiteboard/align-center-vertically "Align center vertically" + :whiteboard/align-bottom "Align bottom" + :whiteboard/distribute-vertically "Distribute vertically" + :whiteboard/pack-into-rectangle"Pack into rectangle" + :whiteboard/zoom-to-fit "Zoom to fit" + :whiteboard/ungroup "Ungroup" + :whiteboard/group "Group" + :whiteboard/cut "Cut" + :whiteboard/copy "Copy" + :whiteboard/paste "Paste" + :whiteboard/paste-as-link "Paste as link" + :whiteboard/export "Export" + :whiteboard/select-all "Select all" + :whiteboard/deselect-all "Deselect all" + :whiteboard/lock "Lock" + :whiteboard/unlock "Unlock" + :whiteboard/delete "Delete" + :whiteboard/flip-horizontally "Flip horizontally" + :whiteboard/flip-vertically "Flip vertically" + :whiteboard/move-to-front "Move to front" + :whiteboard/move-to-back "Move to back" + :whiteboard/dev-print-shape-props "(Dev) Print shape props" + :whiteboard/auto-resize "Auto resize" + :whiteboard/expand "Expand" + :whiteboard/collapse "Collapse" + :whiteboard/website-url "Website url" + :whiteboard/reload "Reload" + :whiteboard/open-website-url "Open website url" + :whiteboard/youtube-url "YouTube url" + :whiteboard/open-youtube-url "Open YouTube url" + :whiteboard/twitter-url "Twitter url" + :whiteboard/open-twitter-url "Open Twitter url" + :whiteboard/fill "Fill" + :whiteboard/stroke-type "Stroke type" + :whiteboard/arrow-head "Arrow head" + :whiteboard/bold "Bold" + :whiteboard/italic "Italic" + :whiteboard/undo "Undo" + :whiteboard/redo "Redo" + :whiteboard/zoom-in "Zoom in" + :whiteboard/zoom-out "Zoom out" + :whiteboard/select "Select" + :whiteboard/pan "Pan" + :whiteboard/add-block-or-page "Add block or page" + :whiteboard/draw "Draw" + :whiteboard/highlight "Highlight" + :whiteboard/eraser "Eraser" + :whiteboard/connector "Connector" + :whiteboard/text "Text" + :whiteboard/color "Color" + :whiteboard/select-custom-color "Select custom color" + :whiteboard/opacity "Opacity" + :whiteboard/extra-small "Extra Small" + :whiteboard/small "Small" + :whiteboard/medium "Medium" + :whiteboard/large "Large" + :whiteboard/extra-large "Extra Large" + :whiteboard/huge "Huge" + :whiteboard/scale-level "Scale level" + :whiteboard/rectangle "Rectangle" + :whiteboard/circle "Circle" + :whiteboard/triangle "Triangle" + :whiteboard/shape "Shape" + :whiteboard/open-page "Open page" + :whiteboard/open-page-in-sidebar "Open page in sidebar" + :whiteboard/remove-link "Remove link" + :whiteboard/link "Link" + :whiteboard/references "References" + :whiteboard/link-to-any-page-or-block "Link to any page or block" + :whiteboard/start-typing-to-search "Start typing to search..." + :whiteboard/new-block-colon "New block:" + :whiteboard/new-block-no-colon "New block" + :whiteboard/new-block "New block:" + :whiteboard/new-page "New page:" + :whiteboard/new-whiteboard "New whiteboard" + :whiteboard/search-only-blocks "Search only blocks" + :whiteboard/search-only-pages "Search only pages" + :whiteboard/cache-outdated "Cache is outdated. Please click the 'Re-index' button in the graph's dropdown menu." + :whiteboard/shape-quick-links "Shape Quick Links" :page-search "Search in the current page" :graph-search "Search graph" :home "Home" diff --git a/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx b/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx index 86bf68cb60..51f4df3df0 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ActionBar/ActionBar.tsx @@ -8,9 +8,13 @@ import { TablerIcon } from '../icons' import { Button } from '../Button' import { ZoomMenu } from '../ZoomMenu' import * as Separator from '@radix-ui/react-separator' +import { LogseqContext } from '../../lib/logseq-context' export const ActionBar = observer(function ActionBar(): JSX.Element { const app = useApp() + const { + handlers: { t }, + } = React.useContext(LogseqContext) const undo = React.useCallback(() => { app.api.undo() @@ -32,20 +36,20 @@ export const ActionBar = observer(function ActionBar(): JSX.Element {
{!app.readOnly && (
- -
)}
- - diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx index ce6f2197f1..d560f53840 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx @@ -92,13 +92,16 @@ function filterShapeByAction(type: ContextBarActionType) { const AutoResizingAction = observer(() => { const app = useApp() + const { + handlers: { t }, + } = React.useContext(LogseqContext) const shapes = filterShapeByAction('AutoResizing') const pressed = shapes.every(s => s.props.isAutoResizing) return ( s.props.type === 'logseq-portal')} className="tl-button" pressed={pressed} @@ -122,6 +125,9 @@ const AutoResizingAction = observer(() => { const LogseqPortalViewModeAction = observer(() => { const app = useApp() + const { + handlers: { t }, + } = React.useContext(LogseqContext) const shapes = filterShapeByAction('LogseqPortalViewMode') const collapsed = shapes.every(s => s.collapsed) @@ -131,7 +137,7 @@ const LogseqPortalViewModeAction = observer(() => { const tooltip = (
- {collapsed ? 'Expand' : 'Collapse'} + {collapsed ? t('whiteboard/expand') : t('whiteboard/collapse')} @@ -164,6 +170,9 @@ const ScaleLevelAction = observer(() => { const IFrameSourceAction = observer(() => { const app = useApp() + const { + handlers: { t }, + } = React.useContext(LogseqContext) const shape = filterShapeByAction('IFrameSource')[0] const handleChange = React.useCallback((e: React.ChangeEvent) => { @@ -177,16 +186,20 @@ const IFrameSourceAction = observer(() => { return ( - - @@ -195,6 +208,9 @@ const IFrameSourceAction = observer(() => { const YoutubeLinkAction = observer(() => { const app = useApp() + const { + handlers: { t }, + } = React.useContext(LogseqContext) const shape = filterShapeByAction('YoutubeLink')[0] const handleChange = React.useCallback((e: React.ChangeEvent) => { shape.onYoutubeLinkChange(e.target.value) @@ -204,13 +220,13 @@ const YoutubeLinkAction = observer(() => { return (
)}