Skip to content

Commit

Permalink
Maintain text decoration styles on paste (#5938)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhankerism authored Apr 22, 2024
1 parent 490389d commit 2278d20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/lexical-table/src/LexicalTableCellNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,12 @@ export function convertTableCellNodeElement(
}

const style = domNode_.style;
const textDecoration = style.textDecoration.split(' ');
const hasBoldFontWeight =
style.fontWeight === '700' || style.fontWeight === 'bold';
const hasLinethroughTextDecoration = style.textDecoration === 'line-through';
const hasLinethroughTextDecoration = textDecoration.includes('line-through');
const hasItalicFontStyle = style.fontStyle === 'italic';
const hasUnderlineTextDecoration = style.textDecoration === 'underline';
const hasUnderlineTextDecoration = textDecoration.includes('underline');

return {
after: (childLexicalNodes) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/lexical/src/nodes/LexicalTextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,14 +1092,15 @@ function convertSpanElement(domNode: Node): DOMConversionOutput {
const span = domNode as HTMLSpanElement;
const style = span.style;
const fontWeight = style.fontWeight;
const textDecoration = style.textDecoration.split(' ');
// Google Docs uses span tags + font-weight for bold text
const hasBoldFontWeight = fontWeight === '700' || fontWeight === 'bold';
// Google Docs uses span tags + text-decoration: line-through for strikethrough text
const hasLinethroughTextDecoration = style.textDecoration === 'line-through';
const hasLinethroughTextDecoration = textDecoration.includes('line-through');
// Google Docs uses span tags + font-style for italic text
const hasItalicFontStyle = style.fontStyle === 'italic';
// Google Docs uses span tags + text-decoration: underline for underline text
const hasUnderlineTextDecoration = style.textDecoration === 'underline';
const hasUnderlineTextDecoration = textDecoration.includes('underline');
// Google Docs uses span tags + vertical-align to specify subscript and superscript
const verticalAlign = style.verticalAlign;

Expand Down

0 comments on commit 2278d20

Please sign in to comment.