-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove table format #2225
Remove table format #2225
Conversation
@@ -8,14 +8,17 @@ const DARK_COLORS_LIGHTNESS = 20; | |||
const BRIGHT_COLORS_LIGHTNESS = 80; | |||
const White = '#ffffff'; | |||
const Black = '#000000'; | |||
const DEFAULT_COLORS = ['rgb(0,0,0', '#000000', '#ffffff', 'rgb(255, 255, 255)']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rgb(0,0,0) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need this?
It is possible user's default color is not black/white
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think DEFAULT_COLORS is a bad name. The DEFAULT_COLORS is not the user default color, but the colors that we use when we adapt the text color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are removing the background color, we also need remove this textColor that we added before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, how can we know if this color is added by the code when we add background color, or added by user's manual action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check the color override flag from cell metadata. If there is color override flag, background color is added from table cell shade feature, then text color on table cell is also added there. Otherwise, the text color may be from original table. In that case, should we still change the color?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in this change do you also need to clear that flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid matching text and background colors, I checked if they were equal and also equal to the adaptive text color. I tried metadata approach and it did not work, because it erased the text color when I did these steps:
- Add a header row
- Change the header text color
- Delete the header row
- The text color was gone.
if (block.blockType == 'Paragraph') { | ||
if ( | ||
block.segmentFormat?.textColor && | ||
DEFAULT_COLORS.indexOf(block.segmentFormat?.textColor) > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>=
0?
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this empty line
*/ | ||
function shouldRemoveColor(textColor: string, cellBackgroundColor: string) { | ||
if ( | ||
([White, 'rgb(255,255,255)'].indexOf(textColor) > -1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you are checking both text color and background color to be white (or black). Are you sure about that?
It only returns true when black on black, or white on white.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to consider other bright or dark colors
When toggle table header, remove the text color that was adapted to appear in the header background color.
![fixTableHeader](https://private-user-images.githubusercontent.com/87443959/285524566-4b61187f-ef4e-403a-9eee-b109f873a63c.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1Mjg0NjgsIm5iZiI6MTczOTUyODE2OCwicGF0aCI6Ii84NzQ0Mzk1OS8yODU1MjQ1NjYtNGI2MTE4N2YtZWY0ZS00MDNhLTllZWUtYjEwOWY4NzNhNjNjLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDEwMTYwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA5Zjg0NTY4ZGZlZGRlYTdlYTkwZmM1Mzc4ZGRmYjNhZjEzZWU0NTcyY2ExM2U0YzgwOTRmYWQ2OTZiZjZhMDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.q412-qKzcBkzRw0JXjDgOVqK1W8eNvrfChFp1_Q3pzQ)