| 160 | } |
| 161 | |
| 162 | async executeWithFocusedProperty( |
| 163 | choice: IChoice, |
| 164 | focusedProperty: FrontmatterPropertyTarget | null, |
| 165 | triggerContext?: QuickAddTriggerContext | null, |
| 166 | ): Promise<void> { |
| 167 | const previousFocusedOverride = this.focusedPropertyOverride; |
| 168 | const previousTriggerOverride = this.triggerContextOverride; |
| 169 | this.focusedPropertyOverride = focusedProperty; |
| 170 | // `triggerContext` is `undefined` only when the caller didn't capture one; |
| 171 | // leave the override unset so the executor reads it live. A captured value |
| 172 | // (including `null` for "no active note at trigger time") IS injected. |
| 173 | this.triggerContextOverride = triggerContext; |
| 174 | try { |
| 175 | await this.execute(choice); |
| 176 | } finally { |
| 177 | this.focusedPropertyOverride = previousFocusedOverride; |
| 178 | this.triggerContextOverride = previousTriggerOverride; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Executes a Template or Capture choice and returns a structured |