google-docs-add-on
google-docs-add-on copied to clipboard
Full support for text-styling attributes
- [ ] FONT_SIZE
- [x] ITALIC
- [x] STRIKETHROUGH
- [ ] FOREGROUND_COLOR
- [x] BOLD
- [x] LINK_URL
- [x] UNDERLINE
- [ ] FONT_FAMILY
- [ ] BACKGROUND_COLOR
Update: fixed in https://github.com/Automattic/google-docs-add-on/pull/66
Could we add Justify formatting to this list?
I've just tested it, and the Justify formatting isn't sticking when getting saved to WordPress.com.
Since Justify is now removed from the WordPress.com toolbar, this could an alternative for users who prefer to have this formatting option easily accessible.
@formosattic that seems like a pretty straight-forward change, I'll get it teed up
Hi @georgeh, this is a great job! Thanks for sharing. I have a doubt: the support for text-styling is only for paragraph level, isn't it? If I have a single bold word in a paragraph, when the paragraph go to WP, this style is missing. Am I correct?
Hi @juan-lb - the add-on should support mid-paragraph bold text. If that's not working for you, please let us know and we'll investigate.
Thanks @georgeh, I've followed the code and couldn't find the place where the mid-paragraph style is catched. I'll have to check again :-) Thanks again.
I'm glad to hear the code is readable enough to follow! What happens is that in /server/doc-service/text.js, chunkTextByAttribute() breaks up the text by finding all the style changes with getTextAttributeIndices(). That breaks up a paragraph into chunks of text.
Then in /server/doc-service/tags.js, changedTags() generates open/close tags based on what style properties changed. The BOLD attribute matches the simpleTagMap property at the top, so it generates the <b> tag.
(As an aside, it uses <b> instead of <strong> because we don't have any semantic information, we just know that the user wanted it to appear bold)
The code is great! Now I see it clearly, I not knew the getTextAttributeIndices() function.
You are so kind for take the time to explain me :-)
Thanks again.