Skip to content

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 `LocationRole today
packages/ts/obsidian-editor/src/autocomplete.tswikilinkCompletionSource (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.cssHost-side .cm-tooltip-autocomplete rules in --d-* tokens
packages/ts/obsidian-editor/src/outline.ts#extractOutlineHeadings of the current document
packages/ts/obsidian-editor/src/types.ts#EditorIndexProvidersearchNotes, searchTags, resolveLink, assetUrl; no heading search
packages/ts/obsidian-editor/test/autocomplete.test.tsWikilink and tag source tests
packages/ts/obsidian-editor/test/helpers.ts#stubProviderTwo-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.

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.

  1. Write packages/ts/obsidian-editor/test/plugins/slash.plugin.test.ts: source returns null mid-line and inside a fence; returns grouped options at a line start; apply removes the /hea token and runs heading.2 (real view under the existing DOM setup); a command with slash: false is absent.
  2. Extend packages/ts/obsidian-editor/test/autocomplete.test.ts: [[# and “Self`).
  3. Extend stubProvider with searchHeadings; bun test, tsc --noEmit.
LocationKindChange
packages/ts/obsidian-editor/src/plugins/slash.tsnewslash plugin and slashCompletionSource
packages/ts/obsidian-editor/src/plugins/index.tsnewCreated by T-4TE2-md-engine-plugin-contract; slash added to BUILTIN_PLUGINS
packages/ts/obsidian-editor/src/autocomplete.tsmodifyHeading completion; addToOptions icon and kbd renderers
packages/ts/obsidian-editor/src/types.tsmodifyrenderIcon?, searchHeadings?
packages/ts/obsidian-editor/src/theme.tsmodifyTooltip rules on --obsmd-chrome-*
packages/ts/obsidian-editor/src/extensions.tsmodifyCompletion built from compiled sources
packages/ts/obsidian-editor/src/index.tsmodifyExport slashCompletionSource
packages/ts/obsidian-editor/test/plugins/slash.plugin.test.tsnewSlash source tests
packages/ts/obsidian-editor/test/autocomplete.test.tsmodifyHeading completion cases
packages/ts/obsidian-editor/test/helpers.tsmodifysearchHeadings on the stub provider
  • AC-1: bun test packages/ts/obsidian-editor passes with the slash suite and the extended autocomplete suite.
  • AC-2: the slash source returns null for foo / (mid-line) and for / inside a fenced code block, and returns options for / at a line start.
  • AC-3: applying the heading.2 option from /hea leaves the line as ## with no /hea remaining.
  • AC-4: every catalogue command with slash !== false and a group in heading, list, block, insert appears exactly once in the slash options (asserted against CATALOGUE).
  • AC-5: [[Alpha# invokes provider.searchHeadings('notes/alpha.md', '') on the stub and lists its answers; [[# lists extractOutline(state) entries.
  • AC-6: grep -n "cm-tooltip-autocomplete" over packages/ts/obsidian-editor/src/theme.ts matches, and every colour in those rules is a var(--obsmd-chrome-*, …) reference.
  • AC-7: with renderIcon set, each rendered option contains a .cm-completion-icon child; without it, none (happy-dom test).

Member of milestone M-931L; engine step E5 of decision D-K3EM-markdown-editor-chrome-and-plugin-environment.

T-EXQ7-md-engine-command-catalogue


← Back to Tasks