Skip to content

Commit

Permalink
TextNode support font-weight bold (#5852)
Browse files Browse the repository at this point in the history
  • Loading branch information
zurfyx authored Apr 11, 2024
1 parent b30f4c1 commit 70c785e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/lexical/src/nodes/LexicalTextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1090,17 +1090,18 @@ export class TextNode extends LexicalNode {
function convertSpanElement(domNode: Node): DOMConversionOutput {
// domNode is a <span> since we matched it by nodeName
const span = domNode as HTMLSpanElement;
const style = span.style;
const fontWeight = style.fontWeight;
// Google Docs uses span tags + font-weight for bold text
const hasBoldFontWeight = span.style.fontWeight === '700';
const hasBoldFontWeight = fontWeight === '700' || fontWeight === 'bold';
// Google Docs uses span tags + text-decoration: line-through for strikethrough text
const hasLinethroughTextDecoration =
span.style.textDecoration === 'line-through';
const hasLinethroughTextDecoration = style.textDecoration === 'line-through';
// Google Docs uses span tags + font-style for italic text
const hasItalicFontStyle = span.style.fontStyle === 'italic';
const hasItalicFontStyle = style.fontStyle === 'italic';
// Google Docs uses span tags + text-decoration: underline for underline text
const hasUnderlineTextDecoration = span.style.textDecoration === 'underline';
const hasUnderlineTextDecoration = style.textDecoration === 'underline';
// Google Docs uses span tags + vertical-align to specify subscript and superscript
const verticalAlign = span.style.verticalAlign;
const verticalAlign = style.verticalAlign;

return {
forChild: (lexicalNode) => {
Expand Down

0 comments on commit 70c785e

Please sign in to comment.