excalidraw / excalidraw

Virtual whiteboard for sketching hand-drawn like diagrams
https://excalidraw.com
MIT License
81.61k stars 7.54k forks source link

Link the text inside a shape to the shape #1010

Open pshihn opened 4 years ago

pshihn commented 4 years ago

It can get a bit annoying when trying to move a block but it doesn't move the text inside it. Not a big issue, but I have forgotten to rubber-band (or command click) to move them together way too many times now :(

(I think there's a separate issue about linking arrows to shapes which is related)

dwelle commented 4 years ago

Related to (and possibly blocked by) https://github.com/excalidraw/excalidraw/issues/294. Let's keep this open, but as for how to implement this, let's move there because it'll require more meta discussion.

ReneCode commented 4 years ago

What's about the idea to move also all elements that are completely inside the moving element. So any element will be moved when its surrounding element is moved.

That behaviour will not be limited to text inside box, but working for all element types.

moveTextWithBox

xixixao commented 4 years ago

I think this issue is nicely and more generically addressed by groups. @ReneCode give it a try (select multiple elements, cmd+option+g on mac).

ReneCode commented 4 years ago

@xixixao yes, you are right -looks better using group. Because on resize the text-element will be resized too.

May be thinking about an "automatic-grouping" approach would help to make the workflow smoother, like:

xixixao commented 4 years ago

Grouping text to the shape when the text is created (via double click or text tool) while the shape is selected might work. It should still not autogroup if the shape is not selected and I'm adding text inside of it.

(then again any of this could be too much magic and stirring away from "just whiteboard" approach)

ReneCode commented 4 years ago

I've tried out to make auto-grouping when the new text is inside an element. try here

It works fine - if you leave the size of the element. But on resizing the element the text is resized too. That results a bad looking result when in a diagram with several elements with text the text size is different.

may be this approach is not ideal.

xixixao commented 4 years ago

@ReneCode you need to double click the group and then only resize the rectangle (so I don't think this is a big problem).

I wonder how @vjeux likes this version.

dwelle commented 4 years ago

Using grouping to solve this case came across my mind as well, but @ReneCode has a valid point. As an interim solution maybe?

vjeux commented 4 years ago

I feel like it achieves the behavior we want: when you move the shape it moves the text around. Now there are some unfortunate side effects:

I feel like the downsides are greater than the wins. I feel like once the arrow linking is implemented, we can use the same link in order to move things around and it wouldn't have those drawbacks.

xixixao commented 4 years ago

@vjeux Do you imagine we'll allow binding text to rectangles? I think this runs into a problem if we also want to allow binding of arrows to text, see bottom of my initial PR comment: #1899 .

vjeux commented 4 years ago

Interesting. I didn't think you'd be able to bind arrows to text fwiw.

ttjmartinez commented 2 years ago

I like the way it is done in yED, when you drag some object into some other object , if you have pressed at the time release the button, becomes a component within , and from that time on they move together whenever moves. You can still move inside , but if you try to drag outside of , then needs to grow in order to keep containing it. In order to detach from , grab it, then press move it out of and release the button.

fqf2009 commented 2 years ago

Text actually has a border which is just transparent. It will show up when you move the end-point of a line over the text border. Actually the line will be attached to text border when you release the mouse at this moment. So, why not just add a style to text border to show it? This will be quite convenient and useful.

Frazer commented 10 months ago

Perhaps it could work just like when you make an arrow, that connects to a shape. As you get close, a drop zone appears, and if you drop there it is connected.