Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom CSS class and Prosemirror drop-down for sidebar style #490

Open
cyface opened this issue Jan 24, 2025 · 0 comments
Open

Add custom CSS class and Prosemirror drop-down for sidebar style #490

cyface opened this issue Jan 24, 2025 · 0 comments

Comments

@cyface
Copy link
Collaborator

cyface commented Jan 24, 2025

Something like:

Hooks.on("getProseMirrorMenuDropDowns", (menu, items) => {
  const wrapIn = ProseMirror.commands.wrapIn;
  if ("format" in items) {
    items.format.entries.push({
      action: "custom",
      title: "Custom Styles",
      children: [
        {
          action: "highlight",
          title: "Highlight Text",
          node: menu.schema.nodes.paragraph,
          attrs: { class: "sidebar" },
          cmd: () => {
            menu._toggleBlock(menu.schema.nodes.paragraph, wrapIn, {
              attrs: { _preserve: { class: "sidebar" } },
            });
            return true;
          },
        },
        // Add more styles as needed
      ],
    });
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant