Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setValue 增加 clearStack 参数,添加 clearStack 方法 #488

Merged
merged 4 commits into from
Jun 18, 2020

Conversation

zTree
Copy link
Contributor

@zTree zTree commented Jun 12, 2020

我的场景:使用 setValue 更换文章,所以,必须要清空 undo 的栈

  • PR 请提交到开发分支上
  • 我们对编码风格有着较为严格的要求,请在阅读代码后模仿类似风格提交

@Vanessa219
Copy link
Owner

setValue 加一个参数用于清空历史栈,或者单独的提供一个接口会不会比较好一点?

@zTree
Copy link
Contributor Author

zTree commented Jun 15, 2020

@Vanessa219 那我给 setValue 后面增加一个 clearUndoStack 的参数,然后去调用各自 undo 的 init 方法 这样可行么?

另外,你说的单独提供一个接口是什么意思? 单独提供一个接口,根据逻辑去处理 所有 undo 的 stack?

你看我怎么调整比较好?

@Vanessa219
Copy link
Owner

Vanessa219 commented Jun 15, 2020

就是提供一个 API 叫 clearUndoStack/clearRedoStack 的,你试试会不会有问题,因为 addUndoStack 的时候我用了 debounced。多谢

@zTree
Copy link
Contributor Author

zTree commented Jun 15, 2020

@Vanessa219 我的思路如下:

  1. 分别给 Undo / IRUndo / WysiwygUndo 增加 clearStack 接口,用来清空 undoStack 和 redoStack;
  2. setValue 增加 clearUndoStack 参数,用来控制是否需要清空 stack;
    当 clearUndoStack = true 时,先 clearTimeout 清理 wysiwyg 内的 afterRenderTimeoutId;然后去清空 所有 undo 内的 stack。

如果可行,我就按照这个方案去修改啦

@Vanessa219
Copy link
Owner

幸苦了,应该没啥问题。setValue 不需要 clearRedoStack 么?

@zTree
Copy link
Contributor Author

zTree commented Jun 15, 2020

@Vanessa219 我是觉得 undo redo 都是成对儿的,清空 undo 肯定也要清空 redo 的,但是放在 setValue 的参数里面,只叫做 clearStack 貌似很难理解是 针对 undo 和 redo 的。 所以。。。我就没想着要 clearRedoStack。

你觉得呢?

@Vanessa219
Copy link
Owner

Vanessa219 commented Jun 15, 2020 via email

@zTree
Copy link
Contributor Author

zTree commented Jun 18, 2020

@Vanessa219 抱歉,最近比较忙,今天才来提交,你看一下吧。

你看看 setValue 对应的文档,有需要修改的,就改一下吧。

@zTree zTree changed the title 给 undo 提供 init 方法,用于 setValue 后,允许清空 undoStack & redoStack setValue 增加 clearUndoStack 参数,允许清空 undoStack & redoStack Jun 18, 2020
@Vanessa219 Vanessa219 merged commit 71e74b7 into Vanessa219:dev Jun 18, 2020
@Vanessa219 Vanessa219 changed the title setValue 增加 clearUndoStack 参数,允许清空 undoStack & redoStack setValue 增加 clearStack 参数,添加 clearStack 方法 Jun 18, 2020
@Vanessa219 Vanessa219 self-requested a review June 18, 2020 09:43
@Vanessa219 Vanessa219 added this to the 3.3 milestone Jun 18, 2020
Vanessa219 added a commit that referenced this pull request Jun 18, 2020
@zTree zTree deleted the clearUndo branch July 15, 2020 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants