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

[lexical-playground] Fix: tabs do not show strikethrough/underline #6811

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,30 @@
.PlaygroundEditorTheme__textUnderline {
text-decoration: underline;
}

.PlaygroundEditorTheme__textStrikethrough {
text-decoration: line-through;
}

.PlaygroundEditorTheme__textUnderlineStrikethrough {
text-decoration: underline line-through;
}

.PlaygroundEditorTheme__tabNode {
position: relative;
}

/* affected tabs
.PlaygroundEditorTheme__tabNode.PlaygroundEditorTheme__textUnderline {
}

.PlaygroundEditorTheme__tabNode.PlaygroundEditorTheme__textStrikethrough {
}

.PlaygroundEditorTheme__tabNode.PlaygroundEditorTheme__textUnderlineStrikethrough {
}

*/
.PlaygroundEditorTheme__textSubscript {
font-size: 0.8em;
vertical-align: sub !important;
Expand Down
7 changes: 7 additions & 0 deletions packages/lexical/src/nodes/LexicalTabNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {DOMConversionMap, NodeKey} from '../LexicalNode';
import invariant from 'shared/invariant';

import {IS_UNMERGEABLE} from '../LexicalConstants';
import {EditorConfig} from '../LexicalEditor';
import {LexicalNode} from '../LexicalNode';
import {$applyNodeReplacement} from '../LexicalUtils';
import {
Expand Down Expand Up @@ -47,6 +48,12 @@ export class TabNode extends TextNode {
return null;
}

createDOM(config: EditorConfig): HTMLElement {
const dom = super.createDOM(config);
dom.classList.add('PlaygroundEditorTheme__tabNode');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is not a playground-only node, this class needs to come from the theme and not be hardcoded.

Copy link
Contributor Author

@vantage-ola vantage-ola Nov 27, 2024

Choose a reason for hiding this comment

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

ok, what do you mean by 'come from the theme and not be hardcoded?'

Copy link
Collaborator

Choose a reason for hiding this comment

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

addClassNamesToElement(dom, config.theme.tab);

In addition you would need to modify the EditorThemeClasses type and add the property tab: 'PlaygroundEditorTheme__tabNode' to PlaygroundEditorTheme.ts

return dom;
}

static importJSON(serializedTabNode: SerializedTabNode): TabNode {
const node = $createTabNode();
node.setFormat(serializedTabNode.format);
Expand Down
Loading