viliusle / miniPaint

online image editor
http://viliusle.github.io/miniPaint/
Other
2.74k stars 634 forks source link

[Feature Request] Text Tool Improvements #185

Open Giwayume opened 3 years ago

Giwayume commented 3 years ago

This is the tool that during my initial impression of miniPaint seeemed to be the most difficult to work with. I'd like to make it work more similar to programs like Photoshop & GIMP, namely:

This is a big wishlist, but just getting inline editing working would be a great start.

Giwayume commented 3 years ago

@viliusle just a heads up, implementing inline editing is going to be significantly more lines of code than the current text editor.

viliusle commented 3 years ago

It would not be easy to implement full feature text editor (editing on actual canvas for no differences between canvas, text parsing for extra features like bolding part of text, selection, all keyboard buttons support and so on and so on). So lets not build powerful text editor inside image editor?

But it should no be too hard to implement simple inline editor, where we render cursor position on screen, allow to navigate using left, right, top, bottom, and render everything on any keyboard button. After that more features can be added. I had this idea before, but added too low priority for it and was forgotten.

Or find some good library for it - but i am not sure it exists for rendering on canvas.

store uploaded fonts in JSON file?

allowing only google fonts and saving it could be simple, small and effective.

Giwayume commented 3 years ago

There is no pre-existing library so far as I know, which is why I've already done most of the work for creating a canvas text editor before in a personal project.

I'm just telling you up front to expect a PR that's a lot more code than what's currently there.

Giwayume commented 3 years ago

I also wanted to mention in terms of keeping the application lightweight, don't need to worry so much about how much code is contained in each feature, but rather when you load each feature.

https://webpack.js.org/guides/code-splitting/

Code splitting (dynamic imports) lets you organize the code into individual files that can be fetched from the network as needed, instead of building everything into one file and loading it all at once. This would be especially helpful for everything under the js/modules folder.

viliusle commented 3 years ago

if additional code gives benefit to user, i am ok :)

Giwayume commented 3 years ago

@viliusle there doesn't appear to be a way to differentiate when the canvas is rendered for image export vs for editing, right?

The problem I'm having is the text cursor/selection is showing up when saving the image as jpg or whatever.

I see this.Base_layers.convert_layers_to_canvas(); being called during save, but I'm not seeing any sort of flag being set on the config or anywhere that says not to render "editor" stuff. Is that correct that this doesn't exist and I'd have to add it?

viliusle commented 3 years ago

if you need to render for preview only, use can use: var ctx = document.getElementById('canvas_minipaint').getContext("2d"); It will be visible on main canvas. When user does "save as" action, everything is render on temp canvas which is converted to temp file for download.

Giwayume commented 3 years ago

Huh, I was expecting more of an API-centric way of differentiating but that works too.

Giwayume commented 3 years ago

Problem with that method is getting a new context forces everything to draw on top of the old context, so the layering is off.

Edit: Nevermind it was drawing on top because the mini preview renders after the same time as the main canvas, which drew on top of the already drawn main canvas.

viliusle commented 3 years ago

There is a ctx link on Base_layers_class class. It can be taken and used,

Other way is to add extra parameter (is_preview, true|null by default, false on file save ) to: (i can do this tomorrow)

Giwayume commented 3 years ago

I have a good chunk of this working, but I've been a bit busy and still have things left to do to make it a minimum viable product in terms of replacing the current functionality without losing anything.

Giwayume commented 3 years ago

I'm getting so close ;_;

image

Giwayume commented 3 years ago

@viliusle I'm thinking of restyling the selection box a little bit, the main problem is the resize handles cover up the corners & edges of the layer which makes it both difficult to see and work with smaller layers, especially if you're trying to select text starting from the edge of the layer. Only problem I can see with moving the handles outside is when you have a layer that reaches the edges of the canvas you can't grab the handles, so perhaps that will be a special case where they show inside the selection.

Another problem is the green outline is difficult to see especially if you have a large canvas and you're zoomed out. So I'm thinking of displaying it as an even thickness independent of the zoom level and possibly changing the color based on the background.

viliusle commented 3 years ago

Can you add borders feature to initial comment? I just got this suggestion by email, and i agree that it can be used in many cases.

We should implement it one day,

Another suggestion: could you add text with borders? This is commonly used to build flow charts etc.

Giwayume commented 3 years ago

could you add text with borders? This is commonly used to build flow charts etc.

My thought here (for making flow charts) would be a combination of multiple features.

  1. Rectangle & circle tools would allow for stroke & fill color to be controlled simultaneously (like it is on text tool)
  2. Add layer grouping #112
  3. Add snapping controls for grouped layers, so a text layer + rectangle for example could resize together.

We could add border/background feature to text layers, but at that point it pretty much replaces the rectangle tool...

viliusle commented 3 years ago

Right now it is possible to draw simple charts (using rectangle, text and line objects), but missing some shapes, arrow not snapping and of course editing is complicated (missing grouping or even line auto-snap to center of rectangle.)

I will do small improvements first, after that we will see. (more shapes, fill feature for shapes, snap while creating new shape).

viliusle commented 2 years ago

Users are asking for few changes:

* - it would also require to update old JSN import (I can do it)

Giwayume commented 2 years ago

I'd tend to agree with having the alignment on the top bar since it's easier to find there. Only thing is unlike all of the other options, it is a global setting and doesn't work on the selected text.

I don't really agree with the renaming, what's there is industry standard. For example, using "color" as a shortcut for "fill color" makes the term ambiguous as to whether it's impacting the fill or the stroke.

Even photopea uses this terminology image

Giwayume commented 2 years ago

Also it takes 10 seconds to figure out what these settings do if you don't already know the terminology.

viliusle commented 2 years ago

ok, let's leave naming as it is.

MMF3775 commented 2 years ago

can you solve problem #339 in text editor?