Skip to content

Commit 1ad4cfc

Browse files
committed
fix: refactor effectiveLanguage initialization and enhance clipboard error handling
1 parent d7a91a1 commit 1ad4cfc

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

src/interactive-code.element.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ export class InteractiveCodeElement extends HTMLElement {
624624
blockCommentKeys: Set<string>,
625625
openBlockComments: Set<string>,
626626
lineNumber: number,
627-
effectiveLanguage: Language = this.language
627+
effectiveLanguage: Language
628628
): string {
629629
const indentMatch = line.match(/^(\s*)/);
630630
const indent = indentMatch ? indentMatch[1] : '';
@@ -666,7 +666,7 @@ export class InteractiveCodeElement extends HTMLElement {
666666
commentStyle: CommentStyle,
667667
blockCommentKeys: Set<string>,
668668
openBlockComments: Set<string>,
669-
effectiveLanguage: Language = this.language
669+
effectiveLanguage: Language
670670
): { processedContent: string; blockStartsOnLine: string[]; blockEndsOnLine: string[] } {
671671
let markerIndex = 0;
672672
const markers = new Map<string, string>();
@@ -856,19 +856,21 @@ export class InteractiveCodeElement extends HTMLElement {
856856
btn.setAttribute('aria-label', 'Copy code to clipboard');
857857
this._copyTimeout = null;
858858
}, 2000);
859+
}).catch(() => {
860+
// Clipboard access denied — fail silently
859861
});
860862
}
861863

862864
private highlightSyntax(text: string, language: Language): string {
863865
switch (language) {
864866
case 'html':
865867
return this.highlightHtml(text);
868+
case 'scss':
869+
return this.highlightScss(text);
866870
case 'typescript':
867871
return this.highlightTypeScript(text);
868872
case 'shell':
869873
return this.highlightShell(text);
870-
default:
871-
return this.highlightScss(text);
872874
}
873875
}
874876

@@ -1015,17 +1017,7 @@ export class InteractiveCodeElement extends HTMLElement {
10151017
white-space: pre;
10161018
}
10171019
1018-
.inline-control.disabled {
1019-
opacity: 0.5;
1020-
cursor: default;
1021-
}
1022-
1023-
.inline-control.disabled:hover {
1024-
background: transparent;
1025-
}
1026-
1027-
.line-disabled,
1028-
.block-content-disabled {
1020+
.line-disabled {
10291021
opacity: 0.3;
10301022
}
10311023
@@ -1068,10 +1060,15 @@ export class InteractiveCodeElement extends HTMLElement {
10681060
}
10691061
10701062
.inline-control.disabled {
1063+
opacity: 0.5;
10711064
text-decoration: none;
10721065
cursor: default;
10731066
}
10741067
1068+
.inline-control.disabled:hover {
1069+
background: transparent;
1070+
}
1071+
10751072
.line-toggle,
10761073
.block-toggle {
10771074
margin-right: 4px;

0 commit comments

Comments
 (0)