Implement a TextEditor class that supports INSERT, DELETE, UNDO, and REDO operations. The editor should maintain a history of operations using a stack-based approach.
Examples
const editor =newTextEditor();editor.insert('Hello',0);// text = 'Hello'editor.insert(' World',5);// text = 'Hello World'editor.delete(5,6);// text = 'Hello'editor.undo();// text = 'Hello World'editor.undo();// text = 'Hello'editor.redo();// text = 'Hello World'
Constraints
Position must be valid (0 <= position <= text.length)
Delete length must be valid (position + length <= text.length)