function buildMenuItems(schema) {
  const mediaNodes = {
    image: schema.nodes.image,
    video: schema.nodes.video,
    audio: schema.nodes.audio
  };

  const items = {
    toggleStrong: markItem(schema.marks.strong, { title: libreviews.msg('toggle bold', { accessKey: 'b' }), icon: icons.strong }),
    toggleEm: markItem(schema.marks.em, { title: libreviews.msg('toggle italic', { accessKey: 'i' }), icon: icons.em }),
    toggleCode: markItem(schema.marks.code, { title: libreviews.msg('toggle code', { accessKey: '`' }), icon: icons.code }),
    toggleLink: linkItem(schema),
    upload: uploadModalItem(mediaNodes, schema),
    insertMedia: insertMediaItem(mediaNodes, schema),
    insertHorizontalRule: horizontalRuleItem(schema.nodes.horizontal_rule),
    wrapBulletList: wrapListItem(schema.nodes.bullet_list, {
      title: libreviews.msg('format as bullet list', { accessKey: '8' }),
      icon: icons.bulletList
    }),
    wrapOrderedList: wrapListItem(schema.nodes.ordered_list, {
      title: libreviews.msg('format as numbered list', { accessKey: '9' }),
      icon: icons.orderedList
    }),
    wrapBlockQuote: wrapItem(schema.nodes.blockquote, {
      title: libreviews.msg('format as quote', { accessKey: '>' }),
      icon: icons.blockquote
    }),
    makeParagraph: blockTypeItem(schema.nodes.paragraph, {
      title: libreviews.msg('format as paragraph help', { accessKey: '0' }),
      label: libreviews.msg('format as paragraph')
    }),
    makeCodeBlock: blockTypeItem(schema.nodes.code_block, {
      title: libreviews.msg('format as code block help'),
      label: libreviews.msg('format as code block')
    }),
    formatSpoilerWarning: wrapItem(schema.nodes.container_warning, {
      title: libreviews.msg('format as spoiler help'),
      label: libreviews.msg('format as spoiler'),
      attrs: { markup: 'spoiler', message: libreviews.msg('spoiler warning') }
    }),
    formatNSFWWarning: wrapItem(schema.nodes.container_warning, {
      title: libreviews.msg('format as nsfw help'),
      label: libreviews.msg('format as nsfw'),
      attrs: { markup: 'nsfw', message: libreviews.msg('nsfw warning') }
    }),
    formatCustomWarning: formatCustomWarningItem(schema.nodes.container_warning),
    makeHeading: headingItems(schema.nodes.heading),
    fullScreen: fullScreenItem(),
    undo: undoItem,
    redo: redoItem,
    joinUp: joinUpItem,
    lift: liftItem
  };

  const insertDropdown = new Dropdown([items.insertMedia, items.insertHorizontalRule], {
    label: libreviews.msg('insert'),
    title: libreviews.msg('insert help')
  });

  const headingSubmenu = new DropdownSubmenu([...items.makeHeading], { label: libreviews.msg('format as heading') });

  const typeDropdown = new Dropdown(
    [
      items.makeParagraph, items.makeCodeBlock, items.formatSpoilerWarning,
      items.formatNSFWWarning, items.formatCustomWarning, headingSubmenu
    ], {
      label: libreviews.msg('format block'),
      title: libreviews.msg('format block help')
    });

  // Create final menu structure. In the rendered menu, there is a separator
  // symbol between each array
  const menu = [
    [items.toggleStrong, items.toggleEm, items.toggleCode, items.toggleLink],
    [insertDropdown, items.upload],
    [typeDropdown, items.wrapBulletList, items.wrapOrderedList, items.wrapBlockQuote, items.joinUp, items.lift],
    [items.undo, items.redo],
    [items.fullScreen]
  ];

  // We expose the items object so it can be used to externally trigger a menu
  // function, e.g., via a keyboard shortcut
  return { menu, items };
}
/**
 * Build a menu for nodes and marks supported in the markdown schema.
 *
 * @param {Schema} schema
 *  the markdown schema
 * @returns {Object}
 *  the generated menu and all its items
 */
Build a menu for nodes and marks supported in the markdown schema.
@param {Schema} schema
the markdown schema
@returns {Object}
the generated menu and all its items
Build a menu for nodes and marks supported in the markdown schema . @param { Schema } schema the markdown schema @returns { Object } the generated menu and all its items
function buildMenuItems(schema) {
  const mediaNodes = {
    image: schema.nodes.image,
    video: schema.nodes.video,
    audio: schema.nodes.audio
  };
  const items = {
    toggleStrong: markItem(schema.marks.strong, { title: libreviews.msg('toggle bold', { accessKey: 'b' }), icon: icons.strong }),
    toggleEm: markItem(schema.marks.em, { title: libreviews.msg('toggle italic', { accessKey: 'i' }), icon: icons.em }),
    toggleCode: markItem(schema.marks.code, { title: libreviews.msg('toggle code', { accessKey: '`' }), icon: icons.code }),
    toggleLink: linkItem(schema),
    upload: uploadModalItem(mediaNodes, schema),
    insertMedia: insertMediaItem(mediaNodes, schema),
    insertHorizontalRule: horizontalRuleItem(schema.nodes.horizontal_rule),
    wrapBulletList: wrapListItem(schema.nodes.bullet_list, {
      title: libreviews.msg('format as bullet list', { accessKey: '8' }),
      icon: icons.bulletList
    }),
    wrapOrderedList: wrapListItem(schema.nodes.ordered_list, {
      title: libreviews.msg('format as numbered list', { accessKey: '9' }),
      icon: icons.orderedList
    }),
    wrapBlockQuote: wrapItem(schema.nodes.blockquote, {
      title: libreviews.msg('format as quote', { accessKey: '>' }),
      icon: icons.blockquote
    }),
    makeParagraph: blockTypeItem(schema.nodes.paragraph, {
      title: libreviews.msg('format as paragraph help', { accessKey: '0' }),
      label: libreviews.msg('format as paragraph')
    }),
    makeCodeBlock: blockTypeItem(schema.nodes.code_block, {
      title: libreviews.msg('format as code block help'),
      label: libreviews.msg('format as code block')
    }),
    formatSpoilerWarning: wrapItem(schema.nodes.container_warning, {
      title: libreviews.msg('format as spoiler help'),
      label: libreviews.msg('format as spoiler'),
      attrs: { markup: 'spoiler', message: libreviews.msg('spoiler warning') }
    }),
    formatNSFWWarning: wrapItem(schema.nodes.container_warning, {
      title: libreviews.msg('format as nsfw help'),
      label: libreviews.msg('format as nsfw'),
      attrs: { markup: 'nsfw', message: libreviews.msg('nsfw warning') }
    }),
    formatCustomWarning: formatCustomWarningItem(schema.nodes.container_warning),
    makeHeading: headingItems(schema.nodes.heading),
    fullScreen: fullScreenItem(),
    undo: undoItem,
    redo: redoItem,
    joinUp: joinUpItem,
    lift: liftItem
  };
  const insertDropdown = new Dropdown([items.insertMedia, items.insertHorizontalRule], {
    label: libreviews.msg('insert'),
    title: libreviews.msg('insert help')
  });
  const headingSubmenu = new DropdownSubmenu([...items.makeHeading], { label: libreviews.msg('format as heading') });
  const typeDropdown = new Dropdown(
    [
      items.makeParagraph, items.makeCodeBlock, items.formatSpoilerWarning,
      items.formatNSFWWarning, items.formatCustomWarning, headingSubmenu
    ], {
      label: libreviews.msg('format block'),
      title: libreviews.msg('format block help')
    });
  const menu = [
    [items.toggleStrong, items.toggleEm, items.toggleCode, items.toggleLink],
    [insertDropdown, items.upload],
    [typeDropdown, items.wrapBulletList, items.wrapOrderedList, items.wrapBlockQuote, items.joinUp, items.lift],
    [items.undo, items.redo],
    [items.fullScreen]
  ];
  return { menu, items };
}
function buildMenuItems ( schema ) { const mediaNodes = { image : schema . nodes . image , video : schema . nodes . video , audio : schema . nodes . audio } ; const items = { toggleStrong : markItem ( schema . marks . strong , { title : libreviews . msg ( 'toggle bold' , { accessKey : 'b' } ) , icon : icons . strong } ) , toggleEm : markItem ( schema . marks . em , { title : libreviews . msg ( 'toggle italic' , { accessKey : 'i' } ) , icon : icons . em } ) , toggleCode : markItem ( schema . marks . code , { title : libreviews . msg ( 'toggle code' , { accessKey : '`' } ) , icon : icons . code } ) , toggleLink : linkItem ( schema ) , upload : uploadModalItem ( mediaNodes , schema ) , insertMedia : insertMediaItem ( mediaNodes , schema ) , insertHorizontalRule : horizontalRuleItem ( schema . nodes . horizontal_rule ) , wrapBulletList : wrapListItem ( schema . nodes . bullet_list , { title : libreviews . msg ( 'format as bullet list' , { accessKey : '8' } ) , icon : icons . bulletList } ) , wrapOrderedList : wrapListItem ( schema . nodes . ordered_list , { title : libreviews . msg ( 'format as numbered list' , { accessKey : '9' } ) , icon : icons . orderedList } ) , wrapBlockQuote : wrapItem ( schema . nodes . blockquote , { title : libreviews . msg ( 'format as quote' , { accessKey : '>' } ) , icon : icons . blockquote } ) , makeParagraph : blockTypeItem ( schema . nodes . paragraph , { title : libreviews . msg ( 'format as paragraph help' , { accessKey : '0' } ) , label : libreviews . msg ( 'format as paragraph' ) } ) , makeCodeBlock : blockTypeItem ( schema . nodes . code_block , { title : libreviews . msg ( 'format as code block help' ) , label : libreviews . msg ( 'format as code block' ) } ) , formatSpoilerWarning : wrapItem ( schema . nodes . container_warning , { title : libreviews . msg ( 'format as spoiler help' ) , label : libreviews . msg ( 'format as spoiler' ) , attrs : { markup : 'spoiler' , message : libreviews . msg ( 'spoiler warning' ) } } ) , formatNSFWWarning : wrapItem ( schema . nodes . container_warning , { title : libreviews . msg ( 'format as nsfw help' ) , label : libreviews . msg ( 'format as nsfw' ) , attrs : { markup : 'nsfw' , message : libreviews . msg ( 'nsfw warning' ) } } ) , formatCustomWarning : formatCustomWarningItem ( schema . nodes . container_warning ) , makeHeading : headingItems ( schema . nodes . heading ) , fullScreen : fullScreenItem ( ) , undo : undoItem , redo : redoItem , joinUp : joinUpItem , lift : liftItem } ; const insertDropdown = new Dropdown ( [ items . insertMedia , items . insertHorizontalRule ] , { label : libreviews . msg ( 'insert' ) , title : libreviews . msg ( 'insert help' ) } ) ; const headingSubmenu = new DropdownSubmenu ( [ ... items . makeHeading ] , { label : libreviews . msg ( 'format as heading' ) } ) ; const typeDropdown = new Dropdown ( [ items . makeParagraph , items . makeCodeBlock , items . formatSpoilerWarning , items . formatNSFWWarning , items . formatCustomWarning , headingSubmenu ] , { label : libreviews . msg ( 'format block' ) , title : libreviews . msg ( 'format block help' ) } ) ; const menu = [ [ items . toggleStrong , items . toggleEm , items . toggleCode , items . toggleLink ] , [ insertDropdown , items . upload ] , [ typeDropdown , items . wrapBulletList , items . wrapOrderedList , items . wrapBlockQuote , items . joinUp , items . lift ] , [ items . undo , items . redo ] , [ items . fullScreen ] ] ; return { menu , items } ; }
Build a menu for nodes and marks supported in the markdown schema.
Build a menu for nodes and marks supported in the markdown schema .
// Create final menu structure. In the rendered menu, there is a separator // symbol between each array // We expose the items object so it can be used to externally trigger a menu // function, e.g., via a keyboard shortcut