Include CommonJS type declarations in the package to please new TypeScript resolution settings.
Make sure the this
bindings in editor props defined as part of a plugin spec refers to the proper plugin type.
Make the SelectionRange
constructor public in the types.
Creating a TextSelection
with endpoints that don't point at inline positions now emits a warning. (It is technically an error, but crashing on it might be too disruptive for some existing setups.)
Include TypeScript type declarations.
Remove (broken, poorly conceptualized) schema
option to EditorState.reconfigure
.
When deleting a whole-document-selection causes default content to be generated, make sure the selection is moved to the start of the document.
Rename ES module files to use a .js extension, since Webpack gets confused by .mjs
The file referred to in the package's module
field now is compiled down to ES5.
Add a module
field to package json file.
Transaction.setSelection
now immediately checks whether the given selection points into the proper document, rather than silently accepting an invalid selection.
The insertText
method now collapses the selection to the end of the inserted text, even when given explicit start/end positions.
The "appendedTransaction"
meta property on appended transactions now points to the root transaction instead of at the transaction itself, which it accidentally did before.
Fixes a bug in the default implementation of Selection.getBookmark
.
EditorState.create
now accepts a storedMark
option to set the state's stored marks.
EditorState.toJSON
and fromJSON
persist the set of stored marks, when available.
Throw errors, rather than constructing invalid objects, when deserializing from invalid JSON data.
EditorState.toJSON
now accepts a string or number as argument to support the way JSON.stringify
can call it.
Fix issue where a character might be selected after overwriting across block nodes.
Make sure replaceSelectionWith
doesn't needlessly copy unmarked nodes.
Typing over marked text now properly makes the new text inherit the old text's marks.
Selection.atStart
, and atEnd
no longer take a second textOnly
parameter.
Selection.near
, atStart
, and atEnd
will now fall back to returning an AllSelection
when unable to find a valid selection. This removes the (undocumented) requirement that documents always contain a valid selection position (though you'll probably still want to maintain this for practical UI reasons).
Selection.near
no longer accepts a textOnly
parameter.
TextSelection.between
may now return a node selection when the document does not contain a valid cursor position.
Selection
objects now implement a content
method that returns their content. This is used to determine what ends up on the clipboard when the selection is copied or dragged.
Selections may now specify multiple ranges that they cover, to generalize to more types of selections. The Selection
superclass constructor takes an array of ranges as optional third argument.
Selections gained new methods replace
and replaceWith
to provide subclasses more control over how selections of that type respond to being deleted or overwritten.
Selections have a new method getBookmark
that custom selection classes can implement to allow the undo history to accurately store and restore them.
The new selection class AllSelection
can be used to select the entire document.
Fix an issue where ensureMarks
would fail to reset the marks to the empty set when turning off the last mark.
Selection.between
is now called TextSelection.between
, and only returns text selections.
The JSON representation of selections changed. fromJSON
will continue to understand the old representation, but if your own code touches the JSON data, you'll have to adjust it.
All Selection
objects now have $head
/$anchor
properties, so those can no longer be used to recognize text selections (use $cursor
or instanceof
).
It is now possible to write your own Selection
subclasses and set the editor selection to an instance of them (provided you implement all required methods and register them with Selection.jsonID
).
Text selections now have a $cursor
getter which returns a position only if this is a cursor selection.
The new Transaction.ensureMarks
method makes it easier to ensure given set of active marks without needlessly setting storedMarks
.
Plugin objects now store their spec under a spec
instead of an options
property. The options
property still works with a warning in this release.
Transaction.scrolledIntoView
no longer always returns true.
Selection.near
now takes a third textOnly
argument, as the docs already claimed.
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.
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.
Plugins now take a view
option that can be used to interact with the editor view.
Selection actions no longer scroll the new selection into view by default (they never were supposed to, but due to a bug they did). Add a scrollIntoView
property to the action to get this behavior.
Selection actions now have a time
field and an (optional) origin
field.
EditorTransform.replaceSelection
now takes a slice, no longer a node. The new replaceSelectionWith
method should be used to replace the selection with a node. Until the next release, calling it the old way will still work and emit a warning.
The documentation for applyAction
now actually reflects the arguments this method is given.
A state field's applyAction
method is now passed the previous state as 4th argument, so that it has access to the new doc and selection.
EditorTransform.replaceSelection
now accepts a slice (or, as before, as a node), and uses a revised algorithm, relying on the defining
node flag.
The TextSelection
and NodeSelection
classes now have a static create
convenience method for creating selections from unresolved positions.
Allow transform actions to be extended during dispatch using extendTransformAction
. Introduce sealed
flag to indicate when this is not safe.
A new utility function NodeSelection.isSelectable
can be used to test whether a node can be the target of a node selection.
The interace to
EditorState.toJSON
and
EditorState.fromJSON
has changed.
The way plugins declare their state
field has changed. Only one
state field per plugin is supported, and state fields no longer have
hard-coded names. Plugin.getState
is the
way to access plugin state now.
Plugin dependencies are no longer supported.
Plugin.reconfigure
is gone. Plugins are now always created
with new Plugin
.
Plugins no longer have a config
field.
Node selections are now properly dropped when mapped over a change that replaces their nodes.
Plugin keys can now be used to find plugins by identity.
Transform actions now have a
time
field containing the timestamp when the change was made.
New module inheriting the Selection
and
EditorTransform
abstraction, along with
the persistent state value that is now separate
from the display logic, and the plugin system.
Selection.findAtStart
/End
was renamed to
Selection.atStart
/End
,
and Selection.findNear
to
Selection.near
.