Add upload image menu item to insert menu

I tried to add an upload image menu item to insert menu with following code

import {Image} from 'prosemirror/dist/model';
Image.register('command', 'upload', {
  label: 'Upload Image',
  run(pm) {
    console.log('upload image');
  }
};
Image.register('insertMenu', 'main', {label: 'Upload', command: 'upload'});

but it didn’t appear on insert menu, is there something I did wrong?

Thanks!

Just syntax errors: colon after run(pm) and missing ) at end. Should be:

import {Image} from 'prosemirror/dist/model';
Image.register('command', 'upload', {
  label: 'Upload Image',
  run(pm) {
    console.log('upload image');
  }
});
Image.register('insertMenu', 'main', {label: 'Upload', command: 'upload'});

@peteb Thanks, just an error when I type code at here, the problem remains.

It works for me. If I insert this (with the missing parenthesis) at the top of, for example, demo/demo.js in the distribution, it replaces the ‘Image’ entry in the insert menu with an ‘Upload’ entry that logs to the console when chosen.

Are you using the git version of ProseMirror or the latest npm release? (You’re using features that only exist on git at the moment, so you need the git code.)

Thanks, I should’ve have checked that if git version works.