# Align undo redo \<input /\> when use pinyin scenario

**URL:** <https://discuss.prosemirror.net/t/align-undo-redo-input-when-use-pinyin-scenario/4764>\
**Category:** Show\
**Created:** [July 20, 2022, 11:10am UTC](https://discuss.prosemirror.net/t/align-undo-redo-input-when-use-pinyin-scenario/4764 "2022-07-20T11:10:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matrixbirds](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/matrixbirds/32/2958_2.png) [@Matrixbirds](https://discuss.prosemirror.net/u/Matrixbirds)\
**Post date:** [July 20, 2022, 11:10am UTC](https://discuss.prosemirror.net/t/align-undo-redo-input-when-use-pinyin-scenario/4764/1 "2022-07-20T11:10:13Z")

</div>

Hi folks I m new tiptap user. I m using tiptap2 and @tiptap/extensions-history plugin. and want to implement undo redo behaviour like native html element `<input />` when handle ime scenario.

You can see the current behaviour in @tiptap/extensions-history ![history-issue_](https://discuss.prosemirror.net/uploads/secondsite/original/2X/1/1fefd07fa55980734c65f678089e58fb70b40b0e.gif)

Here is `<input />` element’s default behaviour in [cn.bing.com](http://cn.bing.com) ![tiptap_](https://discuss.prosemirror.net/uploads/secondsite/original/2X/1/107583086e6dae6b4b74927597fdff2e78efe3ee.gif)

During debugging the callstack. I found input method scenario, the inputed character with ime will be created by transaction, prosemirror will use prosemirror-history plugin to handle inputing and producing the undo redo stack, the editor history will contain the inputed character. I m try to align the undo & redo behaviour like pure `<input />`, like [cn.bing.com](http://cn.bing.com) search ux.

I m want to observe `editor.view.composing` state. When the prosemirror-history meet the input method event, it will overwrite the original transaction behaviour and stash all transactions until composition end event fired, then dispatch the final transactions.

I don’t know how to align `<input />` undo redo ime scenario behaviour with prosemirror.

---

<div class="post-metadata">

**Author:** ![Matrixbirds](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/matrixbirds/32/2958_2.png) [@Matrixbirds](https://discuss.prosemirror.net/u/Matrixbirds)\
**Post date:** [July 20, 2022, 12:10pm UTC](https://discuss.prosemirror.net/t/align-undo-redo-input-when-use-pinyin-scenario/4764/2 "2022-07-20T12:10:30Z")

</div>

I m try to use `closeHistory` to align undo unit with every composition end fired. but the history steps are included all inputed character during trigger from composition start to composition end.

---

<div class="post-metadata">

**Author:** ![evanshe](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/evanshe/32/3324_2.png) [@evanshe](https://discuss.prosemirror.net/u/evanshe)\
**Post date:** [October 26, 2023, 1:16am UTC](https://discuss.prosemirror.net/t/align-undo-redo-input-when-use-pinyin-scenario/4764/3 "2023-10-26T01:16:38Z")

</div>

貌似这个方案有用

Try it with this soultion below:

> [@Incorrect undo behaviour for Chineses Characters \[Need Help\] Thx very much!](https://discuss.prosemirror.net/t/incorrect-undo-behaviour-for-chineses-characters-need-help-thx-very-much/4910/2):
>
> I find the workaround solution to fix. Here is the code. let composingStart = false; let compositionStartTime = NaN; // define customize history plugin, new Plugin({ key: new PluginKey('CustomizeHistory'), props: { // overwrite handleTextInput merge composition events in single historyState by set same transaction time handleTextInput: (view, chFrom, chTo, text) =\> { if (view.composing) { if (composingStart === false) { composingStart = true; compo…
