# Alternative inputrules implementation: @handlewithcare/prosemirror-inputrules

**URL:** https://discuss.prosemirror.net/t/alternative-inputrules-implementation-handlewithcare-prosemirror-inputrules/8531
**Category:** Show
**Created:** [August 26, 2025, 9:37pm UTC](https://discuss.prosemirror.net/t/alternative-inputrules-implementation-handlewithcare-prosemirror-inputrules/8531 "2025-08-26T21:37:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![SMores](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/smores/32/3356_2.png) [@SMores](https://discuss.prosemirror.net/u/SMores)
#### Post date: [August 26, 2025, 9:37pm UTC](https://discuss.prosemirror.net/t/alternative-inputrules-implementation-handlewithcare-prosemirror-inputrules/8531/1 "2025-08-26T21:37:33Z")

</div>

Howdy! Recently I had the need for an inputrules plugin with slightly different behavior from the default, so I lightly forked `prosemirror-inputrules`. Maybe some other folks will also want this approach!

[@handlewithcare/prosemirror-inputrules](https://github.com/handlewithcarecollective/prosemirror-inputrules)

From the README:

## Differences from `prosemirror-inputrules`

The primary behavior difference from `prosemirror-inputrules` is that this library actually applies the text that triggers its rules before executing the rules. In the first example, we had the following rule:

```ts
new InputRule(/->\s/, "→ ");

```

Using `prosemirror-inputrules`, if a user typed `-` and then `>`, the editor history would look like:

```json
[
  {
    "from": 1,
    "to": 1,
    "text": "-"
  },
  {
    "from": 1,
    "to": 2,
    "text": "→"
  }
]

```

The plugin identifies that a user is _going_ to type `->`, and executes the input rule instead of applying the `>`. This means that an undo command, rather than undoing just the input rule, undoes the insertion of the `>` character, resulting in just `-` again.

By contrast, here’s the editor history after the same inputs using this library:

```json
[
  {
    "from": 1,
    "to": 1,
    "text": "-"
  },
  {
    "from": 2,
    "to": 2,
    "text": ">"
  },
  {
    "from": 1,
    "to": 3,
    "text": "→"
  }
]

```

Since this library actually applies the `>` character to the editor before executing the input rule, an undo command _only_ undoes the input rule, resulting in what the user initially typed (`->`).

Also, this library exports a `markTypeInputRule` builder that can be used for Markdown-style formatting (e.g. ` **text** ` becomes **text** ).
