Custom menu in really basic setup

Hi! I’m trying to create a really basic setup of ProseMirror with my custom menu. I think I’ve got a grasp around adding my custom scheme but I can’t get the menu items of my custom menu to show. Below is my setup with a “buildMenuItems” function that should return an array of a single item. That won’t show though. What am I missing?

var prosemirror = require( "prosemirror" );
var schema 		= require( "./schema" ).schema;
var menu 		= require( "prosemirror/dist/menu" );
var basic 		= require( "prosemirror/dist/schema-basic" );

var { toggleMarkItem, icons } = require( "prosemirror/dist/menu/menu" );

function buildMenuItems( schema ) {
	var r = {};

	for( var name in schema.marks ) {
		var mark = schema.marks[name];

		if( mark instanceof basic.StrongMark ) r.toggleStrong = toggleMarkItem( mark, { title: "Toggle strong style", icon: icons.strong } );
	}

	return [r.toggleStrong];
}

var editor = window.editor = new prosemirror.ProseMirror( {
	place: document.body,
	schema: schema,
	doc: schema.parseDOM( document.querySelector( "#editor" ) ),
	plugins: [
		menu.menuBar.config( {
			content: buildMenuItems( schema )
		} )
	]
} );

Does returning [[r.toggleStrong]] help? The menu content is supposed to be an array of arrays, where the inner arrays represent the groups of items between which separators will be shown.

1 Like

Ah, thanks! Such simple mistake :slight_smile: