-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[lexical-playground] Fix: tabs do not show strikethrough #6811
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
Outdated
Show resolved
Hide resolved
packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
Outdated
Show resolved
Hide resolved
packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
Outdated
Show resolved
Hide resolved
packages/lexical-playground/src/themes/PlaygroundEditorTheme.css
Outdated
Show resolved
Hide resolved
i took another approach to fixing this.., i just jumped into it without thinking and was in an hurry to fix it... I had even forgotten both underline and strikethrough existed... the reason I used |
no need for them actually. 😅 silly me.. i was using |
Don't bother trying to replace the spaces, that will cause problems. I suggested a possible approach in my last comment, this workaround only needs to apply to tab nodes. If you add a class so they can be targeted you should be able to work around it for only those nodes and leave the other CSS alone so this fix doesn't break anything else. |
I tried soemthing... but it breaks something in the tests... but i think the strikethrough/underlining or both works, atleast from what i tested in the playground
|
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.
Not sure why that check failed, let's see if it happens again once the other issues are fixed. I can't review the functionality because it didn't deploy.
// Add method to get class name for styling | ||
getClassName(): string { | ||
const baseClass = 'PlaygroundEditorTheme__tabNode'; | ||
const formatClassNames = []; | ||
|
||
const underline = this.hasFormat('underline'); | ||
const strikethrough = this.hasFormat('strikethrough'); | ||
|
||
if (underline && strikethrough) { | ||
formatClassNames.push( | ||
'PlaygroundEditorTheme__textUnderlineStrikethrough', | ||
); | ||
} else if (strikethrough) { | ||
formatClassNames.push('PlaygroundEditorTheme__textStrikethrough'); | ||
} else if (underline) { | ||
formatClassNames.push('PlaygroundEditorTheme__textUnderline'); | ||
} | ||
|
||
return [baseClass, ...formatClassNames].join(' '); | ||
} | ||
|
||
createDOM(config: EditorConfig): HTMLElement { | ||
const dom = super.createDOM(config); | ||
dom.className = this.getClassName(); | ||
return dom; | ||
} | ||
|
||
updateDOM( | ||
prevNode: TabNode, | ||
dom: HTMLElement, | ||
config: EditorConfig, | ||
): boolean { | ||
const updated = super.updateDOM(prevNode, dom, config); | ||
if (updated) { | ||
dom.className = this.getClassName(); | ||
} | ||
return updated; | ||
} |
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.
This is far more work than it needs to be, the format classes are already assigned by the super implementation. You only need to add the class for TabNode in createDOM. This class should be defined in the theme, not hard-coded in this implementation.
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.
ok, thank you. will get to work on this. and make necessary adjustments.
so, only createDOM is needed in LexicalTabNode, but I noticed a number of tests are failing due to a new class name being introduced to lexical. And while testing, I dont think the pseudo element approach will ever work(but i may be wrong though) for example:
|
Yes, of course the tests that use tab node will have to change when a class is added. |
@etrepum I noticed something a while ago(totally unrelated) i dont know if its a bug.. sometimes when you press tab, it doesnt go to the next 4 spaces, it (folds the tab('4' spaces to '1' space), but when you do it again, it goes 4 spaces forward.. Why is that? is that the right behaviour |
i have a suggestion @etrepum instead of adding the artificial strikethroughs/underlines or both for affected tab nodes... what of a visual tab indicator like i have here in this screenshot? |
Regarding spacing with tabs - this is how they work. Tabs are not just wide spaces, they are variable width depending on how much space there is until the next horizontal tab stop. https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size As far as displaying them visually goes, that would be a different feature and is unrelated to this issue. Some people expect that the tab character would have text decoration in this particular scenario, as if it was part of the same span as the rest of the text, at least that's what something like Google Docs or Word (the app, not the web version) would do. I'm not aware of an HTML based editor that can display tabs with text decoration, so I don't have an example to point you towards, but this also isn't an issue that I've researched myself beyond reviewing this PR. |
Description
Made some changes to
.PlaygroundEditorTheme__textStrikethrough
to show strikethroughs on tabsCloses #6808
Before
After selecting the whole text, it shows the strikethrough is present
After
The slight change in css makes the strikethrough visible