UndoManager
修改笔记/笔记本数据时,应使用 undoGrouping(actionName, topicid, block) 包裹修改逻辑,以便支持撤销并在块执行后刷新界面。通过 UndoManager.sharedInstance() 获取(类型为 JSBUndoManager)。
类成员 (Class members)
Section titled “类成员 (Class members)”sharedInstance
Section titled “sharedInstance”获取全局 UndoManager。
static sharedInstance(): JSBUndoManagerReturn Value:
JSBUndoManager: 单例对象。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”undoGrouping
Section titled “undoGrouping”在指定笔记本下执行 block,作为一次可撤销操作;执行后界面会刷新。
undoGrouping(actionName: string, topicid: string, block: () => void): voidParameters:
| Name | Type | Description |
|---|---|---|
actionName | string | 操作名称(显示在撤销菜单中)。 |
topicid | string | 笔记本 ID (inNotebook)。 |
block | () => void | 执行修改逻辑的回调函数。 |
执行撤销。
undo(): void执行重做。
redo(): voidcanUndo
Section titled “canUndo”是否可撤销。
canUndo(): booleancanRedo
Section titled “canRedo”是否可重做。
canRedo(): booleanclearAll
Section titled “clearAll”清空撤销栈。
clearAll(): void修改笔记标题时,先取笔记本 ID(如 note.notebookId),再在 block 内修改 note.noteTitle,块外可调用 Application.sharedInstance().refreshAfterDBChanged(topicid)(若需)。