Skip to content

Commit

Permalink
feature: Theme class added to horizontal rule node
Browse files Browse the repository at this point in the history
  • Loading branch information
umaranis committed Aug 1, 2024
1 parent 8bab454 commit 879066b
Show file tree
Hide file tree
Showing 21 changed files with 530 additions and 186 deletions.
314 changes: 280 additions & 34 deletions demos/plaintext-editor/src/themes/PlaygroundEditorTheme.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions demos/plaintext-editor/src/themes/PlaygroundEditorTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const theme = {
h4: 'PlaygroundEditorTheme__h4',
h5: 'PlaygroundEditorTheme__h5',
},
hr: 'PlaygroundEditorTheme__hr',
image: 'editor-image',
link: 'PlaygroundEditorTheme__link',
list: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,14 @@ test.describe('HTML CopyAndPaste', () => {
await assertHTML(
page,
html`
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<div
class="PlaygroundEditorTheme__blockCursor"
contenteditable="false"
Expand All @@ -228,13 +234,19 @@ test.describe('HTML CopyAndPaste', () => {
await assertHTML(
page,
html`
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Text between HRs</span>
</p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
`,
);
await assertSelection(page, {
Expand Down Expand Up @@ -266,7 +278,10 @@ test.describe('HTML CopyAndPaste', () => {
dir="ltr">
<span data-lexical-text="true">Hello</span>
</p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,10 @@ test.describe('HTML Lists CopyAndPaste', () => {
<span data-lexical-text="true">one</span>
</li>
</ul>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
Expand Down
51 changes: 39 additions & 12 deletions demos/playground/src/__tests__/e2e/HorizontalRule.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ test.describe('HorizontalRule', () => {
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
Expand Down Expand Up @@ -108,7 +111,10 @@ test.describe('HorizontalRule', () => {
dir="ltr">
<span data-lexical-text="true">Some text</span>
</p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand Down Expand Up @@ -136,7 +142,7 @@ test.describe('HorizontalRule', () => {
if (!isCollab) {
await assertHTML(
page,
'<div class="PlaygroundEditorTheme__blockCursor" contenteditable="false" data-lexical-cursor="true"></div><hr class="" data-lexical-decorator="true" contenteditable="false"><p class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">Some more text</span></p>',
'<div class="PlaygroundEditorTheme__blockCursor" contenteditable="false" data-lexical-cursor="true"></div><hr class="PlaygroundEditorTheme__hr" data-lexical-decorator="true" contenteditable="false"><p class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr" dir="ltr"><span data-lexical-text="true">Some more text</span></p>',
);
}

Expand Down Expand Up @@ -188,7 +194,10 @@ test.describe('HorizontalRule', () => {
dir="ltr">
<span data-lexical-text="true">Test</span>
</p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
Expand Down Expand Up @@ -249,7 +258,10 @@ test.describe('HorizontalRule', () => {
dir="ltr">
<span data-lexical-text="true">Te</span>
</p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand Down Expand Up @@ -284,7 +296,10 @@ test.describe('HorizontalRule', () => {
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
Expand All @@ -311,7 +326,10 @@ test.describe('HorizontalRule', () => {
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
Expand All @@ -332,9 +350,15 @@ test.describe('HorizontalRule', () => {
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
Expand Down Expand Up @@ -365,7 +389,10 @@ test.describe('HorizontalRule', () => {
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
Expand All @@ -386,7 +413,7 @@ test.describe('HorizontalRule', () => {
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<hr
class="selected"
class="PlaygroundEditorTheme__hr selected"
contenteditable="false"
data-lexical-decorator="true" />
`,
Expand Down Expand Up @@ -415,7 +442,7 @@ test.describe('HorizontalRule', () => {
page,
html`
<hr
class="selected"
class="PlaygroundEditorTheme__hr selected"
contenteditable="false"
data-lexical-decorator="true" />
`,
Expand Down
24 changes: 18 additions & 6 deletions demos/playground/src/__tests__/e2e/Markdown.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ test.describe('Markdown', () => {
},
{
expectation:
'<hr class="" data-lexical-decorator="true" contenteditable="false" /><p class="PlaygroundEditorTheme__paragraph"><br></p>',
'<hr class="PlaygroundEditorTheme__hr" data-lexical-decorator="true" contenteditable="false" /><p class="PlaygroundEditorTheme__paragraph"><br></p>',
importExpectation: '',
isBlockTest: true,
markdownImport: '',
Expand All @@ -159,7 +159,7 @@ test.describe('Markdown', () => {
},
{
expectation:
'<hr class="" data-lexical-decorator="true" contenteditable="false" /><p class="PlaygroundEditorTheme__paragraph"><br></p>',
'<hr class="PlaygroundEditorTheme__hr" data-lexical-decorator="true" contenteditable="false" /><p class="PlaygroundEditorTheme__paragraph"><br></p>',
importExpectation: '',
isBlockTest: true,
markdownImport: '',
Expand Down Expand Up @@ -492,14 +492,20 @@ test.describe('Markdown', () => {
},
{
html: html`
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p><br /></p>
`,
text: '--- ',
},
{
html: html`
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<p><br /></p>
`,
text: '*** ',
Expand Down Expand Up @@ -1176,7 +1182,10 @@ const TYPED_MARKDOWN_HTML = html`
dir="ltr">
<span data-lexical-text="true">Quote</span>
</blockquote>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<ul class="PlaygroundEditorTheme__ul">
<li
value="1"
Expand Down Expand Up @@ -1390,7 +1399,10 @@ const IMPORTED_MARKDOWN_HTML = html`
<h3 class="PlaygroundEditorTheme__h3 PlaygroundEditorTheme__ltr" dir="ltr">
<span data-lexical-text="true">Horizontal Rules</span>
</h3>
<hr class="" contenteditable="false" data-lexical-decorator="true" />
<hr
class="PlaygroundEditorTheme__hr"
contenteditable="false"
data-lexical-decorator="true" />
<h3 class="PlaygroundEditorTheme__h3 PlaygroundEditorTheme__ltr" dir="ltr">
<span data-lexical-text="true">Blockquotes</span>
</h3>
Expand Down
2 changes: 1 addition & 1 deletion demos/playground/src/__tests__/e2e/Selection.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ test.describe('Selection', () => {
<span data-lexical-text="true">Some text</span>
</h1>
<hr
class="selected"
class="PlaygroundEditorTheme__hr selected"
contenteditable="false"
data-lexical-decorator="true" />
<h1
Expand Down
20 changes: 0 additions & 20 deletions demos/playground/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1626,26 +1626,6 @@ button.item.dropdown-item-active i {
opacity: 1;
}

hr {
padding: 2px 2px;
border: none;
margin: 1em 0;
cursor: pointer;
}

hr:after {
content: '';
display: block;
height: 2px;
background-color: #ccc;
line-height: 2px;
}

hr.selected {
outline: 2px solid rgb(60, 132, 244);
user-select: none;
}

.TableNode__contentEditable {
min-height: 20px;
border: 0px;
Expand Down
17 changes: 17 additions & 0 deletions demos/playground/src/themes/PlaygroundEditorTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,20 @@
.PlaygroundEditorTheme__autocomplete {
color: #ccc;
}
.PlaygroundEditorTheme__hr {
padding: 2px 2px;
border: none;
margin: 1em 0;
cursor: pointer;
}
.PlaygroundEditorTheme__hr:after {
content: '';
display: block;
height: 2px;
background-color: #ccc;
line-height: 2px;
}
.PlaygroundEditorTheme__hr.selected {
outline: 2px solid rgb(60, 132, 244);
user-select: none;
}
1 change: 1 addition & 0 deletions demos/playground/src/themes/PlaygroundEditorTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const theme: EditorThemeClasses = {
h5: 'PlaygroundEditorTheme__h5',
h6: 'PlaygroundEditorTheme__h6',
},
hr: 'PlaygroundEditorTheme__hr',
image: 'editor-image',
indent: 'PlaygroundEditorTheme__indent',
inlineImage: 'inline-editor-image',
Expand Down
30 changes: 8 additions & 22 deletions demos/richtext-editor/src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

body {
margin: 0;
font-family: system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular',
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'.SFNSText-Regular',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand Down Expand Up @@ -762,7 +766,9 @@ i.prettier-error {
z-index: 10;
display: block;
position: fixed;
box-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1),
box-shadow:
0 12px 28px 0 rgba(0, 0, 0, 0.2),
0 2px 4px 0 rgba(0, 0, 0, 0.1),
inset 0 0 0 1px rgba(255, 255, 255, 0.5);
border-radius: 8px;
min-height: 40px;
Expand Down Expand Up @@ -1649,26 +1655,6 @@ button.item.dropdown-item-active i {
opacity: 1;
}

hr {
padding: 2px 2px;
border: none;
margin: 1em 0;
cursor: pointer;
}

hr:after {
content: '';
display: block;
height: 2px;
background-color: #ccc;
line-height: 2px;
}

hr.selected {
outline: 2px solid rgb(60, 132, 244);
user-select: none;
}

.TableNode__contentEditable {
min-height: 20px;
border: 0px;
Expand Down
Loading

0 comments on commit 879066b

Please sign in to comment.