zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.03k stars 217 forks source link

FR: Wrap text when using text tool #1040

Open ducosg opened 1 year ago

ducosg commented 1 year ago

Is your feature request related to a problem? Please describe. It would be awesome if the text could be wrapped inside the text box. This is possible with sticky notes but not with the regular text box. A long sentence can still be broken by lines using line breaks but it is not very convenient for placing text in diagrams or other figures. Also, when you try to make the text box bigger, the text inside doesn't rearrange itself (wrapping), it simply gets bigger or smaller, depending on how one moves the text box handlers.

Describe the solution you'd like I'd like to be able to wrap text inside a text box so if I reduce the width the box will automatically increase its height to accommodate all the text inside, and vice versa, without the need for line breaks. An extra feature will be the ability to control text padding inside these text boxes; and maybe, one day, wrap text to special forms or around special forms, say if you wanted to align text on the right side but following the curvature of a circle.

Thanks for considering this; I'm sure it will be a much-appreciated feature. Given that it is possible to do this with sticky notes, I thought that programmatically, that will not be too hard to implement.

zsviczian commented 1 year ago

I use this script for this purpose: https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Convert%20selected%20text%20elements%20to%20sticky%20notes.md

This converts a text element to a sticky note, Sticky notes wrap text. Once you run the script you will be able to set the default stroke color and background color of the sticky note to transparent, that way the sticky note will "look" like a text element, but will wrap text.

charleshan commented 7 months ago

Perhaps you could add customizable stroke width and we can set it as zero to make sticky notes with transparent borders?

zsviczian commented 7 months ago

Check the "Convert selected text to sticky note" script. That comes with a setting to set sticky note border and background to transparent. (note you need to run the script once for the settings to be installed into plugin settings.

image
charleshan commented 7 months ago

Thanks for the suggestion. This does remove a few clicks on desktop but it looks like this setting is not available on android. Even if it was, it would be a pain to use because shortcuts are not as well supported on mobile

zsviczian commented 7 months ago

It is available on Android, and iOS, and everywhere else. You can pin the script to the sidebar (long press on the script icon in the Obsidian Tools Panel), then you'll have it available at just the touch of a button.

zsviczian commented 7 months ago

What do you mean shortcuts are not well supported. I use this script for a long time now, use it on my phone, my tablet, my desktop... I find it super convenient. Works for me without an pain.

charleshan commented 7 months ago

Oh! I didn't know that you can pin scripts. That makes it super easy. I was thinking that since hotkeys are not available on mobile, I would have to click on the menu > Open command palette > type "script" > select the script. That's what I meant by pain 😅

However, "Settings for installed Scripts" doesn't seem to be on android. There's nothing after "Compatibility features".

zsviczian commented 7 months ago

It is there. As mentioned above, you need to run the script at least once for it to install itself in the settings.

charleshan commented 7 months ago

Got it. Thank you!

zsviczian commented 7 months ago

One more idea. You can try the scribble helper script. It was designed with iOS scribble in mind, but works very well on Android devices as well (even desktop). Double tap the screen to start adding text. You can choose to add the text as a sticky note or a normal text element. It also comes with settings. Plus you can add markdown links to your text while you type (well almost, need to press the insert link button).

On a phone the additional benefit is that the on screen keyboard does not cause UI issues in Excalidraw.

On Sat, Feb 24, 2024, 09:43 Charles Han @.***> wrote:

Got it. Thank you!

— Reply to this email directly, view it on GitHub https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1040#issuecomment-1962300680, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNRO6Q6EDJTB237ZLADOODYVGR33AVCNFSM6AAAAAAVKHFT52VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSGMYDANRYGA . You are receiving this because you commented.Message ID: @.***>

hperk commented 3 months ago

I think the better default behavior for text would be for it to wrap, or at least having the option to set the default behavior to wrap.

For me, having a long line reduces readability of that line and also other elements on the page that it may intersect. It also visually clutters the meaning I assign to the spatial positioning of text to other text and elements, which is the main advantage of a canvas for me.

Existing options are not ideal for myself: 1) Placing a line break to control the space a line of text occupies artificially breaks up thoughts I want to keep grouped as a single line. 2) The cognitive load of running "text to sticky" after every series of lines I want wrapped breaks me out of my flow. Call me sensitive i guess. 3) Running "text to sticky" as a mass operation on all elements after I am at a point to stop my flow is also not an ideal option, as I then have to remember the tweaks to the spatial relationships I wanted between elements that I could have easily made on the fly.

For me, the ideal solution would be to have all text entry wrap by default at a specified character count, and then be able to both adjust the text box size and reposition it via mouse as i go. This would result in the minimum cognitive overhead for myself and allow me to maintain flow.

zsviczian commented 3 months ago

Have you seen the recent updates to the text tool? Now you can drag the size of the text area when you create your new text element which will then be used to wrap text.

https://x.com/excalidraw/status/1795468201335075000

https://x.com/excalidraw/status/1795468204132762026

https://x.com/excalidraw/status/1790742796728426661

hperk commented 3 months ago

Lol, definitely did not. That completely addresses my need. Great addition.

hperk commented 3 months ago

So just fyi, works wonderfully on desktop. On mobile I can adjust the width when creating the textbox, but trying to resize it after creation does not seem to be possible.

Either way, thank you.