How wd21th/selectorjs works
Selector Js is a VS Code extension that turns selected HTML into JavaScript DOM-query code, then copies the generated text to the clipboard. Users invoke commands from the command palette; selector commands parse the selection, generate declarations, and report completion. The README also documents selector variants (including nested details and events) and JavaScript createElement completion. The source index identifies relationships among the command and utility modules, but several command implementations were not excerpted, so their internal details are represented at subsystem level.
Main entry points: index.js Command registry · build-html-tree.js HTML tree builder · query-selector-all.command.js All selectors · query-selector-with-details.command.js Nested details selector
Components 22
VS Code Extension
- Extension activation
extension.js - Command registry
src/commands/index.js
Command Workflows
- Editor selection
src/utils/get-selection.js - Single selector
src/commands/query-selector.command.js - All selectors
src/commands/query-selector-all.command.js - Select by attribute
src/commands/query-selector-by.command.js - Select all by attribute
src/commands/query-selector-all-by.command.js - Nested details selector
src/commands/query-selector-with-details.command.js - Selector with event
src/commands/query-selector-with-event.command.js - Create element completion
src/commands/create-element.command.js
HTML Utilities
- HTML tree builder
src/utils/build-html-tree.js - HTML element models
src/classes.js - Attribute parsing
src/utils/get-attributes.js - Single query builder
src/utils/query-selector.js - Multiple query builder
src/utils/query-selector-all.js - Variable name helpers
src/utils/check-class-var-name.js - ID variable helper
src/utils/check-id-var-name.js - Button selector helper
src/utils/button-correct.js - Button-all helper
src/utils/button-all-correct.js - HTML and text patterns
src/regex.js
Other components
- VS Code user
- System clipboard
Connections 40
- VS Code user → Extension activation: invokes commands
README.md - Extension activation → Command registry: loads registry
extension.js - Command registry → Single selector: registers command
src/commands/index.js - Command registry → All selectors: registers command
src/commands/index.js - Command registry → Select by attribute: registers command
src/commands/index.js - Command registry → Select all by attribute: registers command
src/commands/index.js - Command registry → Nested details selector: registers command
src/commands/index.js - Command registry → Selector with event: registers command
src/commands/index.js - Command registry → Create element completion: registers command
src/commands/index.js - Single selector → Editor selection: reads selection
src/commands/query-selector.command.js - Single selector → HTML tree builder: builds HTML tree
src/commands/query-selector.command.js - Single selector → Single query builder: generates declarations
src/commands/query-selector.command.js - All selectors → Editor selection: reads selection
src/commands/query-selector-all.command.js - All selectors → HTML tree builder: builds HTML tree
src/commands/query-selector-all.command.js - All selectors → Multiple query builder: generates declarations
src/commands/query-selector-all.command.js - All selectors → Button selector helper: formats buttons
src/commands/query-selector-all.command.js - Select by attribute → Editor selection: reads selection
src/commands/query-selector-by.command.js - Select by attribute → HTML tree builder: builds HTML tree
src/commands/query-selector-by.command.js - Select all by attribute → Editor selection: reads selection
src/commands/query-selector-all-by.command.js - Select all by attribute → HTML tree builder: builds HTML tree
src/commands/query-selector-all-by.command.js - Nested details selector → Editor selection: reads selection
src/commands/query-selector-with-details.command.js - Nested details selector → HTML tree builder: builds HTML tree
src/commands/query-selector-with-details.command.js - Nested details selector → ID variable helper: names IDs
src/commands/query-selector-with-details.command.js - Nested details selector → Variable name helpers: names classes
src/commands/query-selector-with-details.command.js - HTML tree builder → HTML element models: creates elements
src/utils/build-html-tree.js - HTML tree builder → Attribute parsing: reads attributes
src/utils/build-html-tree.js - HTML tree builder → HTML and text patterns: uses patterns
src/utils/build-html-tree.js - Single query builder → ID variable helper: names IDs
src/utils/query-selector.js - Single query builder → Variable name helpers: names classes
src/utils/query-selector.js - Multiple query builder → ID variable helper: names attributes
src/utils/query-selector-all.js - Multiple query builder → Variable name helpers: names classes
src/utils/query-selector-all.js - Button selector helper → ID variable helper: names IDs
src/utils/button-correct.js - Button-all helper → ID variable helper: names IDs
src/utils/button-all-correct.js - Single selector → System clipboard: copies generated text
- All selectors → System clipboard: copies generated text
src/commands/query-selector-all.command.js - Select by attribute → System clipboard: copies generated text
src/commands/query-selector-by.command.js - Select all by attribute → System clipboard: copies generated text
src/commands/query-selector-all-by.command.js - Nested details selector → System clipboard: copies generated text
src/commands/query-selector-with-details.command.js - Selector with event → System clipboard: copies generated text
- Create element completion → System clipboard: copies generated text