(plugin: TaskNotesPlugin)
| 198 | } |
| 199 | |
| 200 | export function createInstantConvertField(plugin: TaskNotesPlugin) { |
| 201 | return ViewPlugin.fromClass( |
| 202 | class implements PluginValue { |
| 203 | decorations: DecorationSet; |
| 204 | private enabled: boolean; |
| 205 | |
| 206 | constructor(view: EditorView) { |
| 207 | this.enabled = Boolean(plugin?.settings?.enableInstantTaskConvert); |
| 208 | this.decorations = this.enabled |
| 209 | ? buildConvertButtonDecorations(view, plugin) |
| 210 | : Decoration.none; |
| 211 | } |
| 212 | |
| 213 | update(update: ViewUpdate): void { |
| 214 | const enabled = Boolean(plugin?.settings?.enableInstantTaskConvert); |
| 215 | |
| 216 | if (!enabled) { |
| 217 | this.enabled = false; |
| 218 | this.decorations = Decoration.none; |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | if (!this.enabled || update.docChanged || update.viewportChanged) { |
| 223 | this.enabled = true; |
| 224 | this.decorations = buildConvertButtonDecorations(update.view, plugin); |
| 225 | } |
| 226 | } |
| 227 | }, |
| 228 | { |
| 229 | decorations: (value) => value.decorations, |
| 230 | } |
| 231 | ); |
| 232 | } |
| 233 | |
| 234 | type ConvertButtonDocument = { |
| 235 | lines: number; |
no outgoing calls
no test coverage detected