* feat: add command to toggle clean mode * refactor: simplify wiki_link no-clean-mode logic * refactor: use more sensible clean-mode toggling logic * fix: fix clean-mode-off not lasting across reloads * refactor: move var declaration to where it's used * feat: add root data attribute for clean mode state This allows writing styles based on whether clean mode is currently enabled or disabled. * feat: reset clean-mode-off syntax color * feat: un-hide lua directives in clean-mode-off * style: format changes from 60379b1 * feat: rename 'Toggle Clean Mode' command 'Toggle Clean Mode' is now 'Toggle Markdown Syntax Rendering', and along with the change in semantics, now defaults to false. The associated variables have also been renamed. * docs: add MD syntax rendering command to docs
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
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 { 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";
|
|
import type { ClickEvent } from "@silverbulletmd/silverbullet/type/client";
|
|
|
|
export function cleanModePlugins(client: Client) {
|
|
const pluginsNeededEvenWhenRenderingSyntax = [
|
|
luaDirectivePlugin(client),
|
|
cleanWikiLinkPlugin(client),
|
|
];
|
|
|
|
if (client.ui.viewState.uiOptions.markdownSyntaxRendering) {
|
|
return pluginsNeededEvenWhenRenderingSyntax;
|
|
}
|
|
|
|
return [
|
|
...pluginsNeededEvenWhenRenderingSyntax,
|
|
linkPlugin(client),
|
|
blockquotePlugin(),
|
|
admonitionPlugin(),
|
|
hideMarksPlugin(),
|
|
hideHeaderMarkPlugin(),
|
|
cleanBlockPlugin(),
|
|
frontmatterPlugin(),
|
|
fencedCodePlugin(client),
|
|
taskListPlugin({
|
|
// TODO: Move this logic elsewhere?
|
|
onCheckboxClick: (pos) => {
|
|
const clickEvent: ClickEvent = {
|
|
page: client.currentName(),
|
|
altKey: false,
|
|
ctrlKey: false,
|
|
metaKey: false,
|
|
pos: pos,
|
|
};
|
|
// Propagate click event from checkbox
|
|
client.dispatchClickEvent(clickEvent);
|
|
},
|
|
}),
|
|
listBulletPlugin(),
|
|
tablePlugin(client),
|
|
cleanEscapePlugin(),
|
|
hashtagPlugin(),
|
|
] as Extension[];
|
|
}
|