Integrate new features: Lasso Select Tool, Customizable Toolbar, and Force Compact Mode#181
Integrate new features: Lasso Select Tool, Customizable Toolbar, and Force Compact Mode#181imed-ghomari wants to merge 11 commits intotldraw:mainfrom
Conversation
…ustom Toolbar, Compact Mode, Stroke Options)
jon-dez
left a comment
There was a problem hiding this comment.
I added a bunch of comments. A few capabilities were removed from the latest release. This is a danger of using AI tooling without doing an in depth review of the changes. While I do not mind using AI tools for vibe coding, please be considerate that it may introduce changes that do not fully adhere to patterns found in the code base. Again, thanks for your PR. I hope that you can address the changes I requested so that your contributions could be part of a future release!
If you have any questions you can reply to this thread or email me (jon@jon-dez.com).
| const classes = []; | ||
| if (themeMode === "dark") classes.push('tl-theme__dark'); | ||
| else if (themeMode === "light") { } | ||
| else if (isObsidianThemeDark()) classes.push('tl-theme__dark'); | ||
|
|
||
| return classes.join(' '); |
| components={overridesUiComponents.current} | ||
| // Set this flag to false when a tldraw document is embed into markdown to prevent it from gaining focus when it is loaded. | ||
| autoFocus={false} | ||
| forceMobile={plugin.settings.tldrawOptions?.forceCompactMode} |
| // Inject stroke parameters into window for patched getPath | ||
| React.useEffect(() => { | ||
| (window as any).tldrawStrokeOptions = plugin.settings.tldrawOptions?.strokeParameters; | ||
| }, [plugin.settings.tldrawOptions?.strokeParameters]); |
There was a problem hiding this comment.
Refactor this useEffect hook into the useTldrawAppEffects hook and utilize the settings variable returned from the useUserPluginSettings in the dependency array. Also, could you go into more detail as to where the window.tldrawStrokeOptions comes from and why it is necessary?
| React.useEffect(() => { | ||
| if (!editor) return; | ||
|
|
||
| const pointingCanvasState = editor.getStateDescendant('select.pointing_canvas'); | ||
| if (!pointingCanvasState) return; | ||
|
|
||
| const originalOnEnter = pointingCanvasState.onEnter; | ||
|
|
||
| pointingCanvasState.onEnter = function (info) { | ||
| const selectedShapeIds = editor.getSelectedShapeIds(); | ||
| const selectionBounds = editor.getSelectionPageBounds(); | ||
|
|
||
| if (selectedShapeIds.length === 0 || (selectionBounds && !selectionBounds.containsPoint(info.point))) { | ||
| editor.setCurrentTool('lasso-select'); | ||
| return; | ||
| } | ||
|
|
||
| originalOnEnter?.call(this, info); | ||
| }; | ||
|
|
||
| return () => { | ||
| if (originalOnEnter) { | ||
| pointingCanvasState.onEnter = originalOnEnter; | ||
| } | ||
| }; | ||
| }, [editor]); | ||
|
|
There was a problem hiding this comment.
Refactor this useEffect hook into the LassoOverlays component in order to keep relevant code together.
src/components/TldrawApp.tsx
Outdated
| icons: { | ||
| ...plugin.getIconOverrides(), | ||
| ...iconAssetUrls, | ||
| ...iconAssetUrls, |
There was a problem hiding this comment.
This appears to be a duplicate line
| ...iconAssetUrls, |
There was a problem hiding this comment.
revert file changes are unnecessary
There was a problem hiding this comment.
Make sure you are not removing any capabilities...
There was a problem hiding this comment.
If toolbar tools are not defined by the user's settings, opt to using default toolbar content. Refer to https://tldraw.dev/examples/add-tool-to-toolbar
There was a problem hiding this comment.
tldraw 4, prefer to stay on the 3.15.3 for now
package.json
Outdated
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1", | ||
| "tldraw": "^3.15.3", | ||
| "tldraw": "^4.2.1", |
There was a problem hiding this comment.
Upgrade to latest version is currently postponed.
| "tldraw": "^4.2.1", | |
| "tldraw": "^3.15.3", |
There was a problem hiding this comment.
Restore this file; Upgrade to latest version is currently postponed.
There was a problem hiding this comment.
Restore this file; Upgrade to latest version is currently postponed.
There was a problem hiding this comment.
Restore this file; Upgrade to latest version is currently postponed.
|
Hi, sorry for the confusion, but I'm not able to implement these changes. The pull request was simply a reference for adding new features, as I was using them on the forked version of your plugin. I wouldn't even know if I’m following your instructions correctly or unintentionally breaking the code further. Feel free to close the pull request if you want. |
|
@imed-ghomari no problem, I'll keep this PR open in case anybody wants to jump in and work on this. |
…ween vertical and horizontal toolbar
…sso select, draw and erase tools for better visibility in focus mode
…roke limit setting fix
…x in tdlraw repo issue, and added ui for zoom speed setting

Overview
This PR introduces several feature enhancements designed to provide granular control over the Tldraw experience within Obsidian. These additions focus on UI flexibility, tool efficiency, and advanced shape configuration.
Key Features Added
Lasso Select Tool: (solves add lasso select tool #169)
Force Compact Mode:
forceMobileprop, which required the underlying update of thetldrawlibrary to version4.2.1.Customizable Toolbar:
Advanced Stroke & Shape Configurations:
Streamline,Smoothing, andThinningto tune the drawing experience for different input devices. (solves reduce line smoothing #89)Implementation Details
tldrawto4.2.1to support the aforementioned UI features (specificallyforceMobile).