code-syntax-addon / code-syntax

Syntax Highlighting Add-on for Google Apps
MIT License
16 stars 4 forks source link

Colorize removes the text box "Text fitting" attribute #19

Open clementlize opened 1 year ago

clementlize commented 1 year ago

Hi, thank you for this extension. I am facing an issue which is not critical but a bit annoying.

In Slides, when I create a text box, I always set the "text fitting" option to "Resize shape to fit text". But whenever I am applying styles from the extension, this properties gets back to "Do not autofit" (which seems to be the default one).

Would it be possible to keep the existing setting when colorizing? If I have time I'll try to open a MR, but if you want/can do it before I do, don't hesitate 😄

Thank you!

image

floitsch commented 1 year ago

I will try to have a look at some point, but so far I have no idea where this is happening. My guess is, it's somewhere in the boxShape function: https://github.com/code-syntax-addon/code-syntax/blob/master/slides/syntax.ts#L232. However, there is no explicit call to disabling the autofit functionality.

That said, apparently autofit can also be disabled implicitly. For example setContentAlignment disables it: https://developers.google.com/apps-script/reference/slides/shape#setcontentalignmentcontentalignment

It would be interesting to figure out which call in there is the culprit. If you want to help, maybe try to find a small repro (in a different script to make things easier). Just take the main shape and apply the modifications that code-syntax applies. After that we can try to find a work-around. So far I don't see any way of enabling the Autofit functionality once it's gone. Might be that we are out of luck...

Relevant issues: https://issuetracker.google.com/issues/191389037 https://issuetracker.google.com/issues/199176586

clementlize commented 1 year ago

Thanks for the answer. I took a look at the issues on issuetracker, and it seems that the API indeed is not giving us any magic function to work with. I'm not very familiar with the Slides environment but I'll definitely try to give it a look when I'll have a bit of time :)