Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit ad2f28d

Browse files
feat: detect underline and line-through
1 parent b9a3094 commit ad2f28d

File tree

1 file changed

+16
-8
lines changed
  • webcomponents/inline-editor/src/utils

1 file changed

+16
-8
lines changed

webcomponents/inline-editor/src/utils/utils.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export class DeckdeckgoInlineEditorUtils {
5555
return 'underline';
5656
}
5757

58-
if (element.style.textDecoration === 'underline') {
58+
if (element.style.textDecoration?.indexOf('underline') > -1 || element.style.textDecorationLine?.indexOf('underline') > -1) {
5959
return 'underline';
6060
}
6161

62-
if (element.style.textDecoration === 'initial') {
62+
if (element.style.textDecoration?.indexOf('initial') > -1 || element.style.textDecorationLine?.indexOf('initial') > -1) {
6363
return 'initial';
6464
}
6565

@@ -70,11 +70,15 @@ export class DeckdeckgoInlineEditorUtils {
7070
const children: HTMLCollection = element.children;
7171
if (children && children.length > 0) {
7272
const selectedChild: HTMLElement = Array.from(children).find((child: HTMLElement) => {
73-
return child.style.textDecorationLine === 'underline' || child.style.textDecorationLine === 'initial';
73+
return (
74+
child.style.textDecoration?.indexOf('underline') > -1 ||
75+
child.style.textDecorationLine?.indexOf('underline') > -1 ||
76+
child.style.textDecorationLine?.indexOf('initial') > -1
77+
);
7478
}) as HTMLElement;
7579

7680
if (selectedChild) {
77-
return selectedChild.style.fontStyle === 'underline' ? 'underline' : 'initial';
81+
return selectedChild.style.fontStyle?.indexOf('underline') > -1 ? 'underline' : 'initial';
7882
}
7983
}
8084

@@ -86,11 +90,11 @@ export class DeckdeckgoInlineEditorUtils {
8690
return 'strikethrough';
8791
}
8892

89-
if (element.style.textDecoration === 'line-through') {
93+
if (element.style.textDecoration?.indexOf('line-through') > -1 || element.style.textDecorationLine?.indexOf('line-through') > -1) {
9094
return 'strikethrough';
9195
}
9296

93-
if (element.style.textDecoration === 'initial') {
97+
if (element.style.textDecoration?.indexOf('initial') > -1 || element.style.textDecorationLine?.indexOf('initial') > -1) {
9498
return 'initial';
9599
}
96100

@@ -101,11 +105,15 @@ export class DeckdeckgoInlineEditorUtils {
101105
const children: HTMLCollection = element.children;
102106
if (children && children.length > 0) {
103107
const selectedChild: HTMLElement = Array.from(children).find((child: HTMLElement) => {
104-
return child.style.textDecoration === 'line-through' || child.style.textDecoration === 'initial';
108+
return (
109+
child.style.textDecoration?.indexOf('line-through') > -1 ||
110+
child.style.textDecorationLine?.indexOf('line-through') > -1 ||
111+
child.style.textDecorationLine?.indexOf('initial') > -1
112+
);
105113
}) as HTMLElement;
106114

107115
if (selectedChild) {
108-
return selectedChild.style.fontStyle === 'line-through' ? 'strikethrough' : 'initial';
116+
return selectedChild.style.fontStyle?.indexOf('line-through') > -1 ? 'strikethrough' : 'initial';
109117
}
110118
}
111119

0 commit comments

Comments
 (0)