Skip to content

How to customize slash menu functionality? #8035

Answered by lawvs
freeseamew asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for reaching out. Here is an example of how to customize the SlashWidget. You can find more usage in defaultSlashMenuConfig.

import { PageEditorBlockSpecs } from "@blocksuite/blocks";
import { PageEditor } from "@blocksuite/presets";
import {
  AffineFormatBarWidget,
  PageEditorBlockSpecs,
} from "@blocksuite/blocks";

const editor = new PageEditor();
editor.pageSpecs = [...PageEditorBlockSpecs].map((spec) => {
  if (spec.schema.model.flavour === "affine:page") {
    spec = patchPageRootSpec(spec as BlockSpec<"affine:page", PageRootService>);
  }
  return spec;
});

function patchPageRootSpec(spec: BlockSpec<"affine:page", PageRootService>) {
  const setup = spec.setup;
  const ne…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by freeseamew
Comment options

You must be logged in to vote
1 reply
@raintoway
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants