Skip to content

Comments

Integrate new features: Lasso Select Tool, Customizable Toolbar, and Force Compact Mode#181

Open
imed-ghomari wants to merge 11 commits intotldraw:mainfrom
imed-ghomari:main
Open

Integrate new features: Lasso Select Tool, Customizable Toolbar, and Force Compact Mode#181
imed-ghomari wants to merge 11 commits intotldraw:mainfrom
imed-ghomari:main

Conversation

@imed-ghomari
Copy link

@imed-ghomari imed-ghomari commented Dec 29, 2025

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

  1. Lasso Select Tool: (solves add lasso select tool #169)

    • Integrated a dedicated LassoSelectTool for free-form selection.
    • Smart Activation: The tool is automatically engaged when clicking/dragging on an empty canvas area, significantly speeding up selection workflows.
    • Includes visual SVG selection overlays for precise real-time feedback.
  2. Force Compact Mode:

    • Introduces a setting to force the mobile-optimized layout on desktop devices, ideal for sidebars or narrow note views.
    • Technical Note: This utilizes the native forceMobile prop, which required the underlying update of the tldraw library to version 4.2.1.
  3. Customizable Toolbar:

    • Adds a "Toolbar Customization" section in settings.
    • Users can now selectively enable/disable and reorder tools to create a personalized, clutter-free workspace tailored to their specific use cases.
  4. Advanced Stroke & Shape Configurations:

    • Customizable Presets: Define exact thicknesses for S, M, L, and XL stroke sizes.
    • Persistent Defaults: Set the default size and style (draw, solid, dashed, dotted) for all newly created shapes.
    • Drawing Parameters: Exposed settings for Streamline, Smoothing, and Thinning to tune the drawing experience for different input devices. (solves reduce line smoothing #89)

Implementation Details

  • Updated tldraw to 4.2.1 to support the aforementioned UI features (specifically forceMobile).
  • Refactored TldrawApp.tsx to handle dynamic tool ordering and custom component overlays.
  • Modernized the settings tab for better categorization of editor and pointer options.
  • Ensured full backward compatibility with all existing tldraw documents.

I'm not a developer; I vibe-coded and tested the changes manually. Feel free to reject them if they're not suitable.

…ustom Toolbar, Compact Mode, Stroke Options)
@jon-dez
Copy link
Collaborator

jon-dez commented Dec 29, 2025

Thanks for the PR! While I review the changes, there are a few things I want to address.

First, I've noticed that you updated tldraw to 4.2.1. The reason this plugin hasn't updated to a newer version yet is because the last time I checked the 4.0.0 version of tldraw introduced changes to its license which caused the "tldraw" watermark to disappear and be replaced with a message:

image

I don't want to update to version 4.0.0+ just yet due to this since I don't have a license key yet. I did apply for a hobby license and have talked to the tldraw team about it so I hope to have an updated version within the coming month. Within the same point but addressing the tldraw 4.2.1 patch file; I've forked the tldraw repo and added a few changes that fixed some bugs when using tldraw inside Obsidian, I don't know if you used my fork to generate the patches.

Second, I notice the description mentions refactoring the TldrawApp.tsx file for dynamic tool ordering and custom component overlays. I think this could have been implemented without having to touch that file, but I'll double check the changes to be sure. I'll provide comments suggesting on how it could be done if it touching that file could be avoided.

Give me a bit to review the code and add more comments. Again thanks for showing interest on resolving outstanding issues!

Copy link
Collaborator

@jon-dez jon-dez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines +323 to +328
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(' ');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary modification

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}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tldraw 4 feature

Comment on lines +257 to +260
// Inject stroke parameters into window for patched getPath
React.useEffect(() => {
(window as any).tldrawStrokeOptions = plugin.settings.tldrawOptions?.strokeParameters;
}, [plugin.settings.tldrawOptions?.strokeParameters]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines +230 to +256
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]);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this useEffect hook into the LassoOverlays component in order to keep relevant code together.

icons: {
...plugin.getIconOverrides(),
...iconAssetUrls,
...iconAssetUrls,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be a duplicate line

Suggested change
...iconAssetUrls,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert file changes are unnecessary

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you are not removing any capabilities...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade to latest version is currently postponed.

Suggested change
"tldraw": "^4.2.1",
"tldraw": "^3.15.3",

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore this file; Upgrade to latest version is currently postponed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore this file; Upgrade to latest version is currently postponed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore this file; Upgrade to latest version is currently postponed.

@imed-ghomari
Copy link
Author

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.

@jon-dez
Copy link
Collaborator

jon-dez commented Jan 4, 2026

@imed-ghomari no problem, I'll keep this PR open in case anybody wants to jump in and work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants