diff --git a/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/HTMLCopyAndPaste.spec.mjs b/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/HTMLCopyAndPaste.spec.mjs
index cb0a9bed93a..e2543ec0e1e 100644
--- a/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/HTMLCopyAndPaste.spec.mjs
+++ b/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/HTMLCopyAndPaste.spec.mjs
@@ -208,8 +208,14 @@ test.describe('HTML CopyAndPaste', () => {
await assertHTML(
page,
html`
-
{
await assertHTML(
page,
html`
-
+
Text between HRs
-
+
`,
);
await assertSelection(page, {
@@ -266,7 +278,10 @@ test.describe('HTML CopyAndPaste', () => {
dir="ltr">
Hello
-
+
diff --git a/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/ListsHTMLCopyAndPaste.spec.mjs b/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/ListsHTMLCopyAndPaste.spec.mjs
index dbb58e82d3c..34cf35623ab 100644
--- a/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/ListsHTMLCopyAndPaste.spec.mjs
+++ b/packages/lexical-playground/__tests__/e2e/CopyAndPaste/html/ListsHTMLCopyAndPaste.spec.mjs
@@ -391,7 +391,10 @@ test.describe('HTML Lists CopyAndPaste', () => {
one
-
+
- {
page,
html`
-
+
`,
);
@@ -107,7 +110,10 @@ test.describe('HorizontalRule', () => {
dir="ltr">
Some text
-
+
@@ -135,7 +141,7 @@ test.describe('HorizontalRule', () => {
if (!isCollab) {
await assertHTML(
page,
- '
Some more text
',
+ '
Some more text
',
);
}
@@ -187,7 +193,10 @@ test.describe('HorizontalRule', () => {
dir="ltr">
Test
-
+
`,
);
@@ -248,7 +257,10 @@ test.describe('HorizontalRule', () => {
dir="ltr">
Te
-
+
@@ -278,7 +290,10 @@ test.describe('HorizontalRule', () => {
page,
html`
-
+
`,
);
@@ -305,7 +320,10 @@ test.describe('HorizontalRule', () => {
page,
html`
-
+
`,
);
@@ -326,9 +344,15 @@ test.describe('HorizontalRule', () => {
page,
html`
-
+
-
+
`,
);
@@ -359,7 +383,10 @@ test.describe('HorizontalRule', () => {
page,
html`
-
+
`,
);
@@ -380,7 +407,7 @@ test.describe('HorizontalRule', () => {
html`
`,
@@ -409,7 +436,7 @@ test.describe('HorizontalRule', () => {
page,
html`
`,
diff --git a/packages/lexical-playground/__tests__/e2e/Markdown.spec.mjs b/packages/lexical-playground/__tests__/e2e/Markdown.spec.mjs
index 61922e9cd8f..962e8933af1 100644
--- a/packages/lexical-playground/__tests__/e2e/Markdown.spec.mjs
+++ b/packages/lexical-playground/__tests__/e2e/Markdown.spec.mjs
@@ -150,7 +150,7 @@ test.describe('Markdown', () => {
},
{
expectation:
- '
',
+ '
',
importExpectation: '',
isBlockTest: true,
markdownImport: '',
@@ -159,7 +159,7 @@ test.describe('Markdown', () => {
},
{
expectation:
- '
',
+ '
',
importExpectation: '',
isBlockTest: true,
markdownImport: '',
@@ -493,14 +493,20 @@ test.describe('Markdown', () => {
},
{
html: html`
-
+
`,
text: '--- ',
},
{
html: html`
-
+
`,
text: '*** ',
@@ -1171,7 +1177,10 @@ const TYPED_MARKDOWN_HTML = html`
dir="ltr">
Quote
-
+
-
Horizontal Rules
-
+
Blockquotes
diff --git a/packages/lexical-playground/__tests__/e2e/Selection.spec.mjs b/packages/lexical-playground/__tests__/e2e/Selection.spec.mjs
index 3956e85420a..22a15388f5e 100644
--- a/packages/lexical-playground/__tests__/e2e/Selection.spec.mjs
+++ b/packages/lexical-playground/__tests__/e2e/Selection.spec.mjs
@@ -550,7 +550,7 @@ test.describe('Selection', () => {
Some text
{
const hrElem = editor.getElementByKey(nodeKey);
+ const isSelectedClassName = 'selected';
+
if (hrElem !== null) {
- hrElem.className = isSelected ? 'selected' : '';
+ if (isSelected) {
+ addClassNamesToElement(hrElem, isSelectedClassName);
+ } else {
+ removeClassNamesFromElement(hrElem, isSelectedClassName);
+ }
}
}, [editor, isSelected, nodeKey]);
@@ -136,8 +147,10 @@ export class HorizontalRuleNode extends DecoratorNode {
return {element: document.createElement('hr')};
}
- createDOM(): HTMLElement {
- return document.createElement('hr');
+ createDOM(config: EditorConfig): HTMLElement {
+ const element = document.createElement('hr');
+ addClassNamesToElement(element, config.theme.hr);
+ return element;
}
getTextContent(): string {
diff --git a/packages/lexical/src/LexicalEditor.ts b/packages/lexical/src/LexicalEditor.ts
index 7c03d00c790..92f59807206 100644
--- a/packages/lexical/src/LexicalEditor.ts
+++ b/packages/lexical/src/LexicalEditor.ts
@@ -104,6 +104,7 @@ export type EditorThemeClasses = {
h5?: EditorThemeClassName;
h6?: EditorThemeClassName;
};
+ hr?: EditorThemeClassName;
image?: EditorThemeClassName;
link?: EditorThemeClassName;
list?: {