Release 0.17.0

Hi all. I’ve released version 0.17.0 of ProseMirror. I had the chance to do some work on real-world editors for customers in the past weeks, and that led to a number of bugfixes and tweaks to improve various small issues I ran into. But the main change in this release is the new transaction system.

You can see the relevant discussion here, but the short of it is that Redux-style actions, the way we had them, were a poor fit for the pluggable state representation in ProseMirror, and the system has moved to a more structured representation of state updates, which it calls a Transaction, and which is pretty much the old EditorTransform plus a few extra properties and methods to represent updates to other state fields, and to store custom metadata for use by plugins.

As always, you can find the new modules on NPM. Here are the release notes:

prosemirror-model 0.17.0 (2017-01-05)

Breaking changes

Node.marksAt was replaced with ResolvedPos.marks. It still works (with a warning) in this release, but will be removed in the next one.

prosemirror-state 0.17.0 (2017-01-05)

Breaking changes

The way state is updated was changed. Instead of applying an action (a raw object with a type property), it is now done by applying a Transaction.

The EditorTransform class was renamed Transaction, and extended to allow changing the set of stored marks and attaching custom metadata.

New features

Plugins now accept a filterTransaction option that can be used to filter out transactions as they come in.

Plugins also got an appendTransaction option making it possible to follow up transactions with another transaction.

prosemirror-view 0.17.0 (2017-01-05)

Breaking changes

The handleDOMEvent prop has been dropped in favor of the handleDOMEvents (plural) prop.

The onChange prop has been replaced by a dispatchTransaction prop (which takes a transaction instead of an action).

New features

Added support for a handleDOMEvents prop, which allows you to provide handler functions per DOM event, and works even for events that the editor doesn’t normally add a handler for.

Add view method dispatch, which provides a convenient way to dispatch transactions.

The dispatchTransaction (used to be onAction) prop is now optional, and will default to simply applying the transaction to the current view state.

Widget decorations now accept an option associative which can be used to configure on which side of content inserted at their position they end up.

Typing immediately after deleting text now preserves the marks of the deleted text.

Transactions that update the selection because of mouse or touch input now get a metadata property pointer with the value true.

prosemirror-commands 0.17.0 (2017-01-05)

Breaking changes

The dispatch function passed to commands is now passed a Transaction, not an action object.

3 Likes

Working on upgrade now. Quick feedback - not sure if I like the new handleDOMEvents object as I believe this hurts code reusability.

Changes:

handleDOMEvent(view, event) {
  // setup code goes here
  switch(event.type) {
   case 'dragend':
   case 'drop':
    // do something
    break;
  }
  return false;
}

To:

handleDOMEvents: {
  dragend(view, event) {
    // setup code goes here
    // do something
    return false
  },
  drop(view, event) {
    // setup code goes here
    // do something
    return false
  },
}

Hi,

It might be worth adding a small blurb on extendTransformAction being removed too.

Nice release, Thanks!

The reason for this change is that you couldn’t reliably add handlers for random events in the old system, since ProseMirror isn’t registering handlers for every possible event, and it couldn’t tell, if it just go a function, which events you are interested in. As such, the old interface was error prone and confusing, and I felt fixing that was worth the change.

Right. I considered that kind of implicit in the fact that actions are gone, but it’s probably worth pointing out that the isGeneric accessor kind of takes its place – if no metadata has been attached to a transaction, it can safely be extended with additional steps.