Closed RFSH closed 1 year ago
We had a discussion about this and the following is the list of tasks for this issue:
[ ] Come up with heuristics to transform the actual size to a font-size that is understandable by users.
P.S. The selection is missing from this and we should most probably do that as a separate task for all the drawing tools.
We need a functionality wherein the textarea should enable the users to write the text and should be converted into SVG text at the same position with respect to the image. Similarly, the users should be able to edit the text annotation by clicking on it and the SVG text should be replaced by a textarea. To achieve this functionality, I decided to use foreginObject to add HTML elements to the SVG itself.
Why foreignObject
?
I decided to go ahead with a foriegnObject
instead of adding a textarea to an overlay because adding it to the overlay would increase the complexity in terms of switching back and forth between textarea and SVG text, placing the textarea at the proper position in the overlay and the click/drag functionality not working properly if the textarea might get covered by another overlay.
The logic currently is that we would add a foreignObject
containing a div and append the textarea to this div. Adding a div as a wrapper would be helpful for the resizing and dragging functionality. This implementation works in the POC stage. We are able to append a textarea to the SVG and type the text as well.
Issues faced:
null
- reference.textarea
is not working. The draggable bottom right corner area is very small and it is almost impossible to reach it accurately. Same issue with the image size as above. I tried to find a way to increase the area of drag using styling, but the actual draggable area still remains the same.To enable resizable textarea, I am using transparent divs that can be dragged to increase/decrease the size of the div containing the textarea. 3 divs are being used:
Here is a working POC that I have created: CodePen
The issue that I'm currently facing is similar to the previous input issue. There are OpenSeadragon handlers defined to handle the click, drag, mouseup and mousedown functionality. These need to be disabled when either of the divs mentioned above are being used to resize the textarea and enabled again. The same would be the scenario for moving functionality. We will need to disable and enable the handlers dynamically. I'm working on this.
The latest changes in text-annotation-tool
branch include the new textbox
drawing tool. In this comment we will keep track of the missing features/bugs. We should not merge this branch with master until all the listed issues are resolved.
textbox
is getting ignored. If there are multiple textboxes in the same SVG, while importing (loading the page), the last textbox
does not render.
textbox
to p
is not preserving the spacing properly and text is moving a bit.Text
annotation class that override the functions in base.js
that are used in other annotations.textbox
to p
is not preserving newlines.ForeignObject
, the textbox stops moving.
As the title suggests, we want to allow users to draw text on the image. The following are what we need to investigate as part of this:
The most straightforward implementation is to popup an input box somewhere. That being said, we should investigate other methods first, as this is not an ideal/acceptable solution.We could display an input overlay on top of the SVG and, after drawing, transform it into an SVG(Not worth pursuing since it can be easily broken).We can show a box around an actual SVGtext
tag. The content changes based on user input, and we should display a blinking icon to mimic the browser's focus behavior.textarea
usingforeignObject
in the SVG. This way we're showing a fully functional text box to the users.