Files
plainleaf/web/cm_plugins/clean.ts
T
TR StaakeandGitHub 2020e85a6f Update how tags are rendered to allow for custom styling (#1179)
* Updated how tags are rendered to allow for custom styling via space-styles

* Wrapped the existing span for a tag with an anchor element <a> to
improve ux for screen readers
* Added data-tag-name attribute to tags so that given a tag `#my-tag` it
will have the attribute `data-tag-name="my-tag"` added to the new `<a>`
element wrapper allowing for end users to target tags for styling with a
css selector such as `.sb-hashtag[data-tag-name="my-tag"]{...}`

* Updated Docs
2024-12-14 09:57:46 +01:00

53 lines
1.8 KiB
TypeScript

import type { ClickEvent } from "../../plug-api/types.ts";
import type { Extension } from "@codemirror/state";
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";
import { cleanCommandLinkPlugin } from "./command_link.ts";
import { fencedCodePlugin } from "./fenced_code.ts";
import { frontmatterPlugin } from "./frontmatter.ts";
import { cleanEscapePlugin } from "./escapes.ts";
import { luaDirectivePlugin } from "./lua_directive.ts";
import { hashtagPlugin } from "./hashtag.ts";
export function cleanModePlugins(client: Client) {
return [
linkPlugin(client),
blockquotePlugin(),
admonitionPlugin(),
hideMarksPlugin(),
hideHeaderMarkPlugin(),
cleanBlockPlugin(),
frontmatterPlugin(),
fencedCodePlugin(client),
taskListPlugin({
// TODO: Move this logic elsewhere?
onCheckboxClick: (pos) => {
const clickEvent: ClickEvent = {
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(),
luaDirectivePlugin(client),
hashtagPlugin(),
] as Extension[];
}