google-docs-add-on icon indicating copy to clipboard operation
google-docs-add-on copied to clipboard

Full support for text-styling attributes

Open georgeh opened this issue 8 years ago • 7 comments

  • [ ] FONT_SIZE
  • [x] ITALIC
  • [x] STRIKETHROUGH
  • [ ] FOREGROUND_COLOR
  • [x] BOLD
  • [x] LINK_URL
  • [x] UNDERLINE
  • [ ] FONT_FAMILY
  • [ ] BACKGROUND_COLOR

georgeh avatar Dec 09 '16 21:12 georgeh

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 avatar Mar 27 '17 13:03 formosattic

@formosattic that seems like a pretty straight-forward change, I'll get it teed up

georgeh avatar Mar 27 '17 14:03 georgeh

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?

juan-lb avatar Jan 25 '18 23:01 juan-lb

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.

georgeh avatar Jan 29 '18 18:01 georgeh

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.

juan-lb avatar Jan 30 '18 15:01 juan-lb

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)

georgeh avatar Jan 30 '18 15:01 georgeh

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.

juan-lb avatar Jan 30 '18 16:01 juan-lb