本文整理匯總了TypeScript中Immutable.Stack.push方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Stack.push方法的具體用法?TypeScript Stack.push怎麽用?TypeScript Stack.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Immutable.Stack
的用法示例。
在下文中一共展示了Stack.push方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: push
/**
* 設置重做、撤銷棧
* @param baseState this.state.baseState
* @param contentState 當前設置的新內容State,newContentState
* @param isSetUndo 是否設置撤銷棧,線性調整在調整過程中不記錄堆棧,調整結束時手動記錄調整開始位置的狀態為撤銷棧
*/
static push(baseState: BaseState, contentState: ContentState, isSetUndo: boolean = true): BaseState {
if (baseState.getCurrentContent() === contentState) {
return baseState;
}
const currentContent: ContentState = baseState.getCurrentContent();
let tempContentState: ContentState = baseState.getTempContentState();
let undoStack: Stack<ContentState> = baseState.getUndoStack();
const redoStack: Stack<ContentState> = baseState.getRedoStack();
const newContent: ContentState = contentState;
if (newContent !== currentContent && isSetUndo === true) {
tempContentState = newContent;
undoStack = undoStack.push(currentContent);
}
const editorStateChanges: any = {
currentContent: newContent,
tempContentState,
undoStack,
redoStack
};
return BaseState.set(baseState, editorStateChanges);
}