Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Add hover options to package.json #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
- `markuplint.enable`: Control whether markuplint is enabled for HTML files or not
- `markuplint.debug`: Enable debug mode
- `markuplint.defaultConfig`: It's the configuration specified if configuration files do not exist
- `markuplint.showAccessibility`: Enable the feature that **popup Accessibility Object**
- `markuplint.showAccessibility.ariaVersion`: Set `1.1` or `1.2` WAI-ARIA version; Default is `1.2`.
- `markuplint.hover.accessibility.enable`: Enable the feature that **popup Accessibility Object**
- `markuplint.hover.accessibility.ariaVersion`: Set `1.1` or `1.2` WAI-ARIA version; Default is `1.2`.

## Release Notes

Expand Down
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@
"markuplint:recommended"
]
}
},
"markuplint.hover.accessibility.enable": {
"type": "boolean",
"markdownDescription": "Enable the feature that **popup Accessibility Object**",
"default": true
},
"markuplint.hover.accessibility.ariaVersion": {
"type": "string",
"enum": [
"1.1",
"1.2"
],
"markdownDescription": "Set `1.1` or `1.2` WAI-ARIA version; Default is `1.2`.",
"default": "1.2"
}
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ export async function bootServer() {

connection.onHover(async (params) => {
const { langConfigs } = await initialized;
const showAccessibility = langConfigs['html']?.showAccessibility ?? true;
const accessibilityConfig = langConfigs['html']?.hover.accessibility ?? { enable: true, ariaVersion: '1.2' };

if (!showAccessibility) {
if (!accessibilityConfig.enable) {
return;
}

const ariaVersion = typeof showAccessibility === 'boolean' ? '1.2' : showAccessibility.ariaVersion;
const ariaVersion = accessibilityConfig.ariaVersion;

const node = v3.getNodeWithAccessibilityProps(params.textDocument, params.position, ariaVersion);

Expand All @@ -157,8 +157,8 @@ export async function bootServer() {

const props = node.exposed
? `${Object.entries(node.aria)
.map(([key, value]) => `- ${key}: ${value}`)
.join('\n')}`
.map(([key, value]) => `- ${key}: ${value}`)
.join('\n')}`
: '\n**No exposed to accessibility tree** (hidden element)';

return {
Expand Down
11 changes: 6 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export type Config = {
enable: boolean;
debug: boolean;
defaultConfig: MLConfig;
showAccessibility:
| boolean
| {
ariaVersion: ARIAVersion;
};
hover: {
accessibility: {
enable: boolean;
ariaVersion: ARIAVersion;
};
}
};

export type LangConfigs = Record<string, Config>;