How to use the prosemirror-commands.wrapIn function in prosemirror-commands

To help you get started, we’ve selected a few prosemirror-commands examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProseMirror / website / example / menu / index.js View on Github external
}

// Create an icon for a heading at the given level
function heading(level) {
  return {
    command: setBlockType(schema.nodes.heading, {level}),
    dom: icon("H" + level, "heading")
  }
}

let menu = menuPlugin([
  {command: toggleMark(schema.marks.strong), dom: icon("B", "strong")},
  {command: toggleMark(schema.marks.em), dom: icon("i", "em")},
  {command: setBlockType(schema.nodes.paragraph), dom: icon("p", "paragraph")},
  heading(1), heading(2), heading(3),
  {command: wrapIn(schema.nodes.blockquote), dom: icon(">", "blockquote")}
])
// }

import {EditorState} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
import {baseKeymap} from "prosemirror-commands"
import {keymap} from "prosemirror-keymap"
import {DOMParser} from "prosemirror-model"

window.view = new EditorView(document.querySelector("#editor"), {
  state: EditorState.create({
    doc: DOMParser.fromSchema(schema).parse(document.querySelector("#content")),
    plugins: [keymap(baseKeymap), menu]
  })
})
github ProseMirror / prosemirror-menu / src / menu.js View on Github external
run(state, dispatch) {
      // FIXME if (options.attrs instanceof Function) options.attrs(state, attrs => wrapIn(nodeType, attrs)(state))
      return wrapIn(nodeType, options.attrs)(state, dispatch)
    },
    select(state) {
github pubpub / pubpub-editor / src / addons / HeaderMenu / headerMenuConfig.js View on Github external
function toggleWrap(type) {
		if (blockTypeIsActive(type)) {
			return lift(view.state, view.dispatch);
		}
		const wrapFunction = wrapIn(type);
		return wrapFunction(view.state, view.dispatch);
	}
	/* -------------- */
github pubpub / pubpub-editor / src / addons / FormattingMenu / formattingMenuConfig.js View on Github external
function toggleWrap(type) {
		if (blockTypeIsActive(type)) {
			return lift(view.state, view.dispatch);
		}
		const wrapFunction = wrapIn(type);
		return wrapFunction(view.state, view.dispatch);
	}
	/* -------------- */
github cosmocode / dokuwiki-plugin-prosemirror / script / plugins / Menu / MenuItems / BlockquoteMenuItemDispatcher.js View on Github external
static getMenuItem(schema) {
        if (!this.isAvailable(schema)) {
            console.log(schema);
            throw new Error('Blockquote is not available in schema!');
        }
        return new MenuItem({
            command: wrapIn(schema.nodes.blockquote),
            icon: svgIcon('format-quote-close'),
            label: LANG.plugins.prosemirror['label:blockquote'],
        });
    }
}
github cosmocode / dokuwiki-plugin-prosemirror / script / plugins / Menu / menu.js View on Github external
});

const paragraphMenuItem = new MenuItem({
    command: setBlockType(schema.nodes.paragraph),
    icon: svgIcon('format-paragraph'),
    label: 'Paragraph',
});

const codeBlockMenuItem = new MenuItem({
    command: setBlockTypeNoAttrCheck(schema.nodes.code_block),
    icon: svgIcon('code-braces'),
    label: 'Code Block',
});

const blockquoteMenuItem = new MenuItem({
    command: wrapIn(schema.nodes.blockquote),
    icon: svgIcon('format-quote-close'),
    label: 'Blockquote',
});

const pluginBlockMenuItem = new MenuItem({
    command: setBlockType(schema.nodes.dwplugin_block),
    icon: svgIcon('puzzle'),
    label: 'Plugin block',
});

const pluginInlineMenuItem = new MenuItem({
    command: (state, dispatch) => {
        const { $from } = state.selection;

        const index = $from.index();
        if (!$from.parent.canReplaceWith(index, index, schema.nodes.dwplugin_inline)) {
github tinacms / tinacms / packages / @tinacms / fields / src / Wysiwyg / state / plugins / Menu / FormattingDropdown.tsx View on Github external
blockQuote = () =>
    wrapIn(this.props.view.state.schema.nodes.blockquote)(
      this.props.view.state,
      this.props.view.dispatch
    )
  lift = () => lift(this.props.view.state, this.props.view.dispatch)
github scrumpy / tiptap / packages / tiptap-commands / src / commands / toggleWrap.js View on Github external
return (state, dispatch, view) => {
    const isActive = nodeIsActive(state, type)

    if (isActive) {
      return lift(state, dispatch)
    }

    return wrapIn(type)(state, dispatch, view)
  }
}
github tinacms / tinacms / packages / tinacms / fields / src / Wysiwyg / state / plugins / inline-menu / Menu.tsx View on Github external
function wrapInBlockquote(state: EditorState, dispatch: any) {
  return wrapIn(state.schema.nodes.blockquote)(state, dispatch)
}
function makeCodeBlock(state: EditorState, dispatch: any) {
github ifiokjr / remirror / @remirror / core / src / commands / toggle-wrap.ts View on Github external
export const toggleWrap = (type: NodeType, attrs?: Attrs): CommandFunction => (state, dispatch) => {
  const isActive = nodeActive(state, type);

  if (isActive) {
    return lift(state, dispatch);
  }
  return wrapIn(type, attrs)(state, dispatch);
};