generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dataview rendering method for FormValue
- Loading branch information
1 parent
57f2c1b
commit 86839ce
Showing
4 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
import { Notice } from "obsidian"; | ||
import { ModalFormError } from "./ModalFormError"; | ||
|
||
|
||
export function log_notice(title: string, msg: string | DocumentFragment, titleClass?: string, bodyClass?: string): void { | ||
export function log_notice( | ||
title: string, | ||
msg: string | DocumentFragment, | ||
titleClass?: string, | ||
bodyClass?: string, | ||
): void { | ||
const notice = new Notice("", 15000); | ||
const el = notice.noticeEl; | ||
el.empty(); | ||
const head = el.createEl('h6', { text: title, cls: titleClass }) | ||
head.setCssStyles({ marginTop: '0px' }) | ||
const body = el.createEl('div', { text: msg, cls: bodyClass }) | ||
const head = el.createEl("h6", { text: title, cls: titleClass }); | ||
head.setCssStyles({ marginTop: "0px" }); | ||
const body = el.createEl("div", { text: msg, cls: bodyClass }); | ||
el.append(head, body); | ||
} | ||
|
||
export function log_update(msg: string): void { | ||
log_notice('Modal form update', msg) | ||
log_notice("Modal form update", msg); | ||
} | ||
|
||
export function log_error(e: Error | ModalFormError): void { | ||
if (e instanceof ModalFormError && e.console_msg) { | ||
log_notice('Modal from error: ', e.message + "\n" + e.console_msg, 'var(--text-error)') | ||
log_notice("Modal from error: ", e.message + "\n" + e.console_msg, "var(--text-error)"); | ||
console.error(`Modal form Error:`, e.message, "\n", e.console_msg); | ||
} else { | ||
log_notice('Modal from error', e.message) | ||
log_notice("Modal from error", e.message); | ||
} | ||
} | ||
|
||
/** | ||
* Convenience function to create a function that logs a notice with a title. | ||
* Use it to notify the user about important errors | ||
* @param title | ||
*/ | ||
export const notifyError = (title: string) => (msg: string) => log_notice(`🚨 ${title} 🚨`, msg, "notice-error"); |