How to use prosemirror-history - 10 common examples

To help you get started, we’ve selected a few prosemirror-history 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 cosmocode / dokuwiki-plugin-prosemirror / script / main.js View on Github external
window.Prosemirror.enableProsemirror = function enableProsemirror() {
    const schema = new Schema(getSpec());

    const mi = new MenuInitializer(schema);

    // PLUGIN ORDER IS IMPORTANT!
    const plugins = [
        mi.getMenuPlugin(),
        history(),
        getKeymapPlugin(schema),
        tableEditing(schema),
    ];

    const json = jQuery('#dw__editform').find('[name=prosemirror_json]').get(0);
    const view = new EditorView(document.querySelector('#prosemirror__editor'), {
        state: EditorState.create({
            doc: Node.fromJSON(schema, JSON.parse(json.value)),
            schema,
            plugins,
        }),
        dispatchTransaction(tr) {
            console.log('run');

            view.updateState(view.state.apply(tr));
github namiwang / fiber-note / app / javascript / controllers / note / editor.ts View on Github external
contentHolder: Element
  ) {
    let state = EditorState.create({
      doc: DOMParser.fromSchema(schema).parse(contentHolder),
      plugins: [
        buildInputRules(schema),
        // TODO keymap around enter -> new list item
        // https://discuss.prosemirror.net/t/lists-paragraph-inside-li-instead-of-new-list-item/455
        // TODO keymap around tab and shift-tab
        // TODO extract hints about available keys
        // https://github.com/prosemirror/prosemirror-example-setup/blob/master/src/keymap.js
        keymap(buildKeymap(schema)),
        keymap(baseKeymap),
        dropCursor(),
        gapCursor(),
        history(),
      ]
    })

    this.view = new EditorView(editorHolder, {
      state: state,
      dispatchTransaction(transaction) {
        let view = this

        transaction.before

        console.log(`transaction`)
        console.log(transaction.before)
        console.log(transaction.doc)

        let newState = view.state.apply(transaction)
        view.updateState(newState)
github pubpub / pubpub-editor / src / schema / setup / index.js View on Github external
function getBasePlugins(options) {
	const deps = [
		buildInputRules(options.schema),
		keymap(buildKeymap(options.schema, options.mapKeys)),
		keymap(baseKeymap),
		headerIdPlugin,
	];
	if (!options.isReadOnly) {
		/* It's not clear that the SelectPlugin is used by anything */
		// deps.push(SelectPlugin);
	}
	if (options.placeholder) { deps.push(generatePlaceholderPlugin(options.placeholder)); }
	if (options.history !== false) { deps.push(history()); }
	// deps.push(gapCursor());

	return deps;
}
github gamejolt / frontend-lib / components / content / content-editor / plugins / plugins.ts View on Github external
return new UpdateIncrementerPlugin(editorView, editor);
		},
	});
	const isEmptyPlugin = new Plugin({
		view(_editorView) {
			return new UpdateIsEmptyPlugin(editor);
		},
	});

	// Additional keyboard bindings
	const ourKeymap = getContentEditorKeymap(editor, schema);

	return [
		keymap(ourKeymap),
		keymap(baseKeymap),
		history(),
		incrementerPlugin,
		isEmptyPlugin,
		new UpdateAutolinkPlugin(editor.capabilities),
		createInputRules(editor.capabilities),
	];
}
github guardian / prosemirror-noting / test / helpers / prosemirror.js View on Github external
redo(n = 1) {
    for (let i = 0; i < n; i += 1) {
      redo(this.state, tr => this.apply(tr));
    }
    return this;
  }
github guardian / prosemirror-noting / test / helpers / prosemirror.js View on Github external
undo(n = 1) {
    for (let i = 0; i < n; i += 1) {
      undo(this.state, tr => this.apply(tr));
    }
    return this;
  }
github guardian / prosemirror-noting / pages / index.js View on Github external
})
    )
  })
});

const doc = DOMParser.fromSchema(mySchema).parse(
  document.querySelector("#content")
);

const onNoteCreate = note => {
  note.meta = Object.assign({}, note.meta, {
    createdAt: Date.now()
  });
};

const historyPlugin = history();
const {
  plugin: noterPlugin,
  toggleAllNotes,
  showAllNotes,
  toggleNote,
  setNoteMeta
} = buildNoter(mySchema.marks.note, doc, "noter", historyPlugin, {
  onNoteCreate,
  handleClick: note =>
    setNoteMeta(note.id, {
      hidden: !note.meta.hidden
    })
});

const {
  plugin: flagPlugin,
github scrumpy / tiptap / packages / tiptap-extensions / src / extensions / History.js View on Github external
get plugins() {
    return [
      history({
        depth: this.options.depth,
        newGroupDelay: this.options.newGroupDelay,
      }),
    ]
  }
github ProseMirror / prosemirror-example-setup / src / index.js View on Github external
export function exampleSetup(options) {
  let plugins = [
    buildInputRules(options.schema),
    keymap(buildKeymap(options.schema, options.mapKeys)),
    keymap(baseKeymap),
    dropCursor(),
    gapCursor()
  ]
  if (options.menuBar !== false)
    plugins.push(menuBar({floating: options.floatingMenu !== false,
                          content: options.menuContent || buildMenuItems(options.schema).fullMenu}))
  if (options.history !== false)
    plugins.push(history())

  return plugins.concat(new Plugin({
    props: {
      attributes: {class: "ProseMirror-example-setup-style"}
    }
  }))
}
github guardian / prosemirror-noting / pages / index.ts View on Github external
requestAnimationFrame(commenceTheSpinning);
};
commenceTheSpinning();

const mySchema = new Schema({
  nodes: addListNodes(schema.spec.nodes as any, "paragraph block*", "block"),
  marks: {
    ...marks,
    ...validationMarks
  }
});

const contentElement =
  document.querySelector("#content") || document.createElement("content");
const doc = DOMParser.fromSchema(mySchema).parse(contentElement);
const historyPlugin = history();
const editorElement = document.querySelector("#editor");

editorElement &&
  ((window as any).editor = new EditorView(editorElement, {
    state: EditorState.create({
      doc,
      plugins: [
        ...exampleSetup({
          schema: mySchema,
          history: false,
          menuContent: buildMenuItems(mySchema).fullMenu
        }),
        keymap({
          F6: validateDocument
        }),
        historyPlugin,

prosemirror-history

Undo history for ProseMirror

MIT
Latest version published 2 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages