- Introduced `currentPageMeta` method to encapsulate access to the current page's metadata. - Updated references to page metadata throughout the codebase to use the new method, improving code readability and maintainability. - Adjusted related components in the UI and linting logic to utilize the new method for consistency.
23 lines
753 B
TypeScript
23 lines
753 B
TypeScript
import { type Diagnostic, linter } from "@codemirror/lint";
|
|
import type { Client } from "../client.ts";
|
|
import { parse } from "../markdown_parser/parse_tree.ts";
|
|
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
|
|
import type { LintEvent } from "@silverbulletmd/silverbullet/type/client";
|
|
|
|
export function plugLinter(client: Client) {
|
|
return linter(async (view): Promise<Diagnostic[]> => {
|
|
const text = view.state.sliceDoc();
|
|
const tree = parse(
|
|
extendedMarkdownLanguage,
|
|
text,
|
|
);
|
|
const results = (await client.dispatchAppEvent("editor:lint", {
|
|
name: client.currentName(),
|
|
pageMeta: client.currentPageMeta(),
|
|
tree,
|
|
text,
|
|
} as LintEvent)).flat();
|
|
return results;
|
|
});
|
|
}
|