Skip to content

Commit 50bd118

Browse files
authored
Make it possible to include a button CSS class in lint actions.
FEATURE: The new `markClass` option to actions makes it possible to style action buttons.
1 parent 0718a09 commit 50bd118

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lint.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface Diagnostic {
3939
export interface Action {
4040
/// The label to show to the user. Should be relatively short.
4141
name: string
42+
/// When given, add an extra CSS class to the action
43+
markClass?: string
4244
/// The function to call when the user activates this action. Is
4345
/// given the diagnostic's _current_ position, which may have
4446
/// changed since the creation of the diagnostic, due to editing.
@@ -452,9 +454,10 @@ function renderDiagnostic(view: EditorView, diagnostic: Diagnostic, inPanel: boo
452454
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
453455
elt("u", name.slice(keyIndex, keyIndex + 1)),
454456
name.slice(keyIndex + 1)]
457+
let markClass = action.markClass ? " " + action.markClass : ""
455458
return elt("button", {
456459
type: "button",
457-
class: "cm-diagnosticAction",
460+
class: "cm-diagnosticAction" + markClass,
458461
onclick: click,
459462
onmousedown: click,
460463
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`

0 commit comments

Comments
 (0)