silverbullet/web/cm_plugins/clean.ts

49 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-02-29 22:23:05 +08:00
import type { ClickEvent } from "../../plug-api/types.ts";
import type { Extension } from "@codemirror/state";
2023-07-14 22:56:20 +08:00
import type { Client } from "../client.ts";
import { blockquotePlugin } from "./block_quote.ts";
import { admonitionPlugin } from "./admonition.ts";
import { hideHeaderMarkPlugin, hideMarksPlugin } from "./hide_mark.ts";
import { cleanBlockPlugin } from "./block.ts";
import { linkPlugin } from "./link.ts";
import { listBulletPlugin } from "./list.ts";
import { tablePlugin } from "./table.ts";
import { taskListPlugin } from "./task.ts";
import { cleanWikiLinkPlugin } from "./wiki_link.ts";
2022-11-29 16:11:23 +08:00
import { cleanCommandLinkPlugin } from "./command_link.ts";
2022-12-22 23:20:05 +08:00
import { fencedCodePlugin } from "./fenced_code.ts";
import { frontmatterPlugin } from "./frontmatter.ts";
import { cleanEscapePlugin } from "./escapes.ts";
export function cleanModePlugins(client: Client) {
return [
linkPlugin(client),
blockquotePlugin(),
admonitionPlugin(client),
hideMarksPlugin(),
hideHeaderMarkPlugin(),
cleanBlockPlugin(),
2024-01-08 16:21:19 +08:00
frontmatterPlugin(),
fencedCodePlugin(client),
taskListPlugin({
// TODO: Move this logic elsewhere?
onCheckboxClick: (pos) => {
const clickEvent: ClickEvent = {
2024-01-24 21:44:39 +08:00
page: client.currentPage,
altKey: false,
ctrlKey: false,
metaKey: false,
pos: pos,
};
// Propagate click event from checkbox
client.dispatchAppEvent("page:click", clickEvent);
},
}),
listBulletPlugin(),
tablePlugin(client),
cleanWikiLinkPlugin(client),
cleanCommandLinkPlugin(client),
cleanEscapePlugin(),
] as Extension[];
}