T-N58P-md-engine-slash-and-heading-completion
State: closed/done · Impact: high · Complexity: medium
Typing / at the start of a line should offer the command catalogue, and `Location | Role today |
|---|---|
packages/ts/obsidian-editor/src/autocomplete.ts | wikilinkCompletionSource (note titles after [[), tagCompletionSource, obsidianCompletion() = autocompletion({ override, icons: false }) |
packages/ts/obsidian-editor/src/theme.ts | --obsmd-* colours for marks; no tooltip rules |
solutions/determined/experiences/notes/app/assets/notes.css | Host-side .cm-tooltip-autocomplete rules in --d-* tokens |
packages/ts/obsidian-editor/src/outline.ts#extractOutline | Headings of the current document |
packages/ts/obsidian-editor/src/types.ts#EditorIndexProvider | searchNotes, searchTags, resolveLink, assetUrl; no heading search |
packages/ts/obsidian-editor/test/autocomplete.test.ts | Wikilink and tag source tests |
packages/ts/obsidian-editor/test/helpers.ts#stubProvider | Two-note stub provider |
The catalogue, runCommand and chordLabel come from [[T-EXQ7-md-engine-command-catalogue; the
plugin roster from T-4TE2-md-engine-plugin-contract.
Proposed
Section titled “Proposed”packages/ts/obsidian-editor/src/plugins/slash.ts — the slash plugin contributes
slashCompletionSource: active when the line text before the cursor matches ^\s*/(\w*)$ and the
position is not in code; options are the compiled commands with slash !== false and group in
heading, list, block, insert, sectioned by group, boosted by slash.keywords matches;
apply deletes the /query token then calls runCommand(view, id).
ObsidianEditorOptions gains renderIcon?: (name: string) => HTMLElement | null and
EditorIndexProvider gains searchHeadings?(path: string, query: string): Promise<OutlineEntry[]>.
obsidianCompletion() becomes autocompletion({ override: compiled.completions, icons: false, optionClass: () => 'cm-completion-option', addToOptions: [icon at position 20 via renderIcon, keyboard hint at position 80 via chordLabel] }).
Heading completion: after Target.
The theme module gains tooltip rules: .cm-tooltip.cm-tooltip-autocomplete background
--obsmd-chrome-bg, border --obsmd-chrome-border, radius --obsmd-chrome-radius, selected row
--obsmd-chrome-hover-bg, .cm-completionDetail and section labels --obsmd-chrome-fg,
.cm-completion-icon, .cm-completion-kbd.
Approach
Section titled “Approach”- Write
packages/ts/obsidian-editor/test/plugins/slash.plugin.test.ts: source returnsnullmid-line and inside a fence; returns grouped options at a line start;applyremoves the/heatoken and runsheading.2(real view under the existing DOM setup); a command withslash: falseis absent. - Extend
packages/ts/obsidian-editor/test/autocomplete.test.ts:[[#and “Self`). - Extend
stubProviderwithsearchHeadings;bun test,tsc --noEmit.
Files to touch
Section titled “Files to touch”| Location | Kind | Change |
|---|---|---|
packages/ts/obsidian-editor/src/plugins/slash.ts | new | slash plugin and slashCompletionSource |
packages/ts/obsidian-editor/src/plugins/index.ts | new | Created by T-4TE2-md-engine-plugin-contract; slash added to BUILTIN_PLUGINS |
packages/ts/obsidian-editor/src/autocomplete.ts | modify | Heading completion; addToOptions icon and kbd renderers |
packages/ts/obsidian-editor/src/types.ts | modify | renderIcon?, searchHeadings? |
packages/ts/obsidian-editor/src/theme.ts | modify | Tooltip rules on --obsmd-chrome-* |
packages/ts/obsidian-editor/src/extensions.ts | modify | Completion built from compiled sources |
packages/ts/obsidian-editor/src/index.ts | modify | Export slashCompletionSource |
packages/ts/obsidian-editor/test/plugins/slash.plugin.test.ts | new | Slash source tests |
packages/ts/obsidian-editor/test/autocomplete.test.ts | modify | Heading completion cases |
packages/ts/obsidian-editor/test/helpers.ts | modify | searchHeadings on the stub provider |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1:
bun test packages/ts/obsidian-editorpasses with the slash suite and the extended autocomplete suite. - AC-2: the slash source returns
nullforfoo /(mid-line) and for/inside a fenced code block, and returns options for/at a line start. - AC-3: applying the
heading.2option from/healeaves the line as##with no/hearemaining. - AC-4: every catalogue command with
slash !== falseand a group inheading,list,block,insertappears exactly once in the slash options (asserted againstCATALOGUE). - AC-5:
[[Alpha#invokesprovider.searchHeadings('notes/alpha.md', '')on the stub and lists its answers;[[#listsextractOutline(state)entries. - AC-6:
grep -n "cm-tooltip-autocomplete"overpackages/ts/obsidian-editor/src/theme.tsmatches, and every colour in those rules is avar(--obsmd-chrome-*, …)reference. - AC-7: with
renderIconset, each rendered option contains a.cm-completion-iconchild; without it, none (happy-dom test).
Out of scope
Section titled “Out of scope”--d-*tooltip styling in the chrome layer (T-8ZHI-md-ui-overlays-bubble-link-table).^block-idcompletion after “Note`).
Dependencies
Section titled “Dependencies”- T-EXQ7-md-engine-command-catalogue for the catalogue,
runCommand,chordLabel. - D-4QGN: the dialect’s
Noteform is what heading completion produces.
Discovery context
Section titled “Discovery context”Member of milestone M-931L; engine step E5 of decision D-K3EM-markdown-editor-chrome-and-plugin-environment.
Depends on
Section titled “Depends on”T-EXQ7-md-engine-command-catalogue