# Check for specific transaction

**URL:** <https://discuss.prosemirror.net/t/check-for-specific-transaction/3953>\
**Category:** Uncategorized\
**Created:** [August 5, 2021, 8:19pm UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953 "2021-08-05T20:19:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwu78\_nike](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mwu78_nike/32/2281_2.png) [@mwu78\_nike](https://discuss.prosemirror.net/u/mwu78_nike)\
**Post date:** [August 5, 2021, 8:19pm UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/1 "2021-08-05T20:19:14Z")

</div>

I would like the editor view to perform a certain functionality but only if a certain transaction is enacted. Is that possible? In other words, I’m not sure how to specify the editor view to render specific widget decorations only when specific menu options are clicked.

---

<div class="post-metadata">

**Author:** ![Priestch](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/priestch/32/2010_2.png) [@Priestch](https://discuss.prosemirror.net/u/Priestch)\
**Post date:** [August 6, 2021, 2:42am UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/2 "2021-08-06T02:42:24Z")

</div>

@mwu78_nike You can use [appendTransaction](https://prosemirror.net/docs/ref/#state.PluginSpec.appendTransaction) to append a new transaction to add widget decorations when some specific transaction happpened.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 6, 2021, 8:37am UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/3 "2021-08-06T08:37:15Z")

</div>

This sounds more like you need a custom state field that is set to a different value by some custom transaction (use transaction metadata to signal the change), and decorations that are maintained differently based on the value of that state field.

---

<div class="post-metadata">

**Author:** ![mwu78\_nike](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mwu78_nike/32/2281_2.png) [@mwu78\_nike](https://discuss.prosemirror.net/u/mwu78_nike)\
**Post date:** [August 9, 2021, 8:52pm UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/4 "2021-08-09T20:52:55Z")

</div>

I’ve been following this [example](https://prosemirror.net/examples/upload/), but I’m a bit confused why the example doesn’t work a second time. When I try to upload an image a second time, the transaction doesn’t go through. Is this because of the state field you’re mentioning?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 10, 2021, 7:10am UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/5 "2021-08-10T07:10:29Z")

</div>

> [@mwu78\_nike](#):
>
> When I try to upload an image a second time, the transaction doesn’t go through.

That’s not happening for me—the example seems to work when I add multiple images in a row.

---

<div class="post-metadata">

**Author:** ![mwu78\_nike](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mwu78_nike/32/2281_2.png) [@mwu78\_nike](https://discuss.prosemirror.net/u/mwu78_nike)\
**Post date:** [August 10, 2021, 6:57pm UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/7 "2021-08-10T18:57:20Z")

</div>

The widget decorations are now working, but in the use case of an author going into the RTE, adding some text with widgets, saves the data, closes the space, and then opens the RTE again to load the saved data, would the widget decorations still load? Where the special characters have widgets, would these widgets still be there upon closing the RTE?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 10, 2021, 9:08pm UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/8 "2021-08-10T21:08:34Z")

</div>

If you wrote the plugin, you know how it works and should be able to answer that (i.e. it depends on where you got the data that determines what widgets to render)

---

<div class="post-metadata">

**Author:** ![mwu78\_nike](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mwu78_nike/32/2281_2.png) [@mwu78\_nike](https://discuss.prosemirror.net/u/mwu78_nike)\
**Post date:** [August 10, 2021, 11:05pm UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/9 "2021-08-10T23:05:10Z")

</div>

Okay, and is it possible for an undo action (command-Z) to apply to widget decorations as well? If a widget is “typed,” is there a way to command Z it without adding that functionality to a specific menubar button? (We do not have undo / redo buttons as part of the menubar.)

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 11, 2021, 5:31am UTC](https://discuss.prosemirror.net/t/check-for-specific-transaction/3953/10 "2021-08-11T05:31:06Z")

</div>

> [@mwu78\_nike](#):
>
> Okay, and is it possible for an undo action (command-Z) to apply to widget decorations as well?

No, the prosemirror-history package only manages the document, no other data.
