Skip to content
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

Table Cell Background Color #4306

Merged
merged 5 commits into from
Apr 17, 2023
Merged

Table Cell Background Color #4306

merged 5 commits into from
Apr 17, 2023

Conversation

zurfyx
Copy link
Member

@zurfyx zurfyx commented Apr 11, 2023

Screen.Recording.2023-04-11.at.4.21.52.PM.mov

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 11, 2023
@vercel
Copy link

vercel bot commented Apr 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2023 6:59pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2023 6:59pm

@github-actions
Copy link

github-actions bot commented Apr 11, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 26.94 KB (0%) 539 ms (0%) 251 ms (-9.72% 🔽) 790 ms
packages/lexical-rich-text/dist/LexicalRichText.js 37.8 KB (0%) 757 ms (0%) 256 ms (-9.41% 🔽) 1.1 s
packages/lexical-plain-text/dist/LexicalPlainText.js 37.78 KB (0%) 756 ms (0%) 326 ms (+4.43% 🔺) 1.1 s

<hr />
</>
)}
{mergeCellButton}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we no longer need to nil check the mergeCellButton?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering a nullish component in React will not render it. It's a shorthand for foo != null ? foo : null

buttonLabel?: string;
title?: string;
stopCloseOnClickSelf?: boolean;
color: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be appropriate to define a new type for hex colour strings, making it a bit more semantically obvious when they're used as API parameters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of type are you thinking of? Sort of like constant for colors? I didn't change the API in this case, the ColorPicker was already present but in any case we can propose it as a good-first-issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the JS equivalent of this Swift code:

public typealias HexColor = String

Just to give a bit more semantics of what the string should be.

</div>
<MoveWrapper
className="color-picker-saturation"
style={{backgroundColor: `hsl(${selfColor.hsv.h}, 100%, 50%)`}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've done this logic (modify an HSV colour to have 100% sat, 50% lightness) a few times; maybe factor into its own function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't write this file, just moved the files around. Sorry if the blame is confusing

$isRangeSelection(selection) ||
DEPRECATED_$isGridSelection(selection)
) {
const [cell] = DEPRECATED_$getNodeTriplet(selection.anchor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there isn't a non-deprecated alternative here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to kill GridSelection eventually by moving it into the Table package itself. That's why it remains as deprecated while still actively using it

@@ -248,6 +270,10 @@ export function convertTableCellNodeElement(
);
tableCellNode.__colSpan = domNode_.colSpan;
tableCellNode.__rowSpan = domNode_.rowSpan;
const backgroundColor = domNode_.style.backgroundColor;
if (backgroundColor !== '') {
tableCellNode.__backgroundColor = backgroundColor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're going to have the same problem here that all other nodes implementing styling like this do. If the editor you paste into doesn't support this feature, then the user will have no option to remove it. Even if you paste into another Lexical editor, you may end up using HTML because of a namespace mismatch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - will follow up with a solution similar to #4343

@@ -215,21 +221,22 @@ export class TableSelection {
this.gridSelection = selection;
this.isHighlightingCells = true;
this.disableHighlightStyle();
$updateDOMForSelection(this.grid, this.gridSelection);
$updateDOMForSelection(this.editor, this.grid, this.gridSelection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it just be 'editor'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants