MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / createFileForView

Function createFileForView

src/bases/BasesViewBase.ts:501–527  ·  view source on GitHub ↗

* Override Bases "New" button to open TaskNotes creation modal instead of default file creation. * Called when user clicks the "New" button in the Bases toolbar. * * NOTE: This requires Obsidian API 1.10.2+ and Bases support for createFileForView. * As of the current implementation, Bases (s

(
		baseFileName?: string,
		frontmatterProcessor?: (frontmatter: Record<string, unknown>) => void
	)

Source from the content-addressed store, hash-verified

499 * @param frontmatterProcessor - Optional callback that Bases uses to set default frontmatter values
500 */
501 async createFileForView(
502 baseFileName?: string,
503 frontmatterProcessor?: (frontmatter: Record<string, unknown>) => void
504 ): Promise<void> {
505 const { TaskCreationModal } = await import("../modals/TaskCreationModal");
506 const app = this.app || this.plugin.app;
507 const taskCreationData = buildBasesTaskCreationDataForView({
508 config: this.config,
509 fieldMapper: this.plugin.fieldMapper,
510 taskTag: this.plugin.settings.taskTag,
511 userFields: this.plugin.settings.userFields || [],
512 currentFileLink: () => getBasesCurrentFileLinkDefault(app),
513 frontmatterProcessor,
514 });
515
516 // Open TaskNotes creation modal
517 // Use this.app if available (set by Bases), otherwise fall back to plugin.app
518 const modal = new TaskCreationModal(app, this.plugin, {
519 prePopulatedValues: taskCreationData,
520 onTaskCreated: (task: TaskInfo) => {
521 // Refresh the view after task creation so it appears immediately
522 this.refresh();
523 },
524 });
525
526 modal.open();
527 }
528
529 /**
530 * Get visible properties for rendering task cards.

Callers

nothing calls this directly

Calls 4

refreshMethod · 0.65
openMethod · 0.45

Tested by

no test coverage detected