{"id":16382836,"url":"https://github.com/boojack/tiny-undo","last_synced_at":"2025-08-18T09:14:29.403Z","repository":{"id":65516630,"uuid":"430286843","full_name":"boojack/tiny-undo","owner":"boojack","description":"Manage the undo/redo state programmatically for plain-text input element.","archived":false,"fork":false,"pushed_at":"2021-11-24T03:14:28.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-19T22:43:59.986Z","etag":null,"topics":["undo-redo"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boojack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-21T06:02:03.000Z","updated_at":"2025-05-22T22:23:45.000Z","dependencies_parsed_at":"2023-01-26T22:25:12.881Z","dependency_job_id":null,"html_url":"https://github.com/boojack/tiny-undo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/boojack/tiny-undo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boojack%2Ftiny-undo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boojack%2Ftiny-undo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boojack%2Ftiny-undo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boojack%2Ftiny-undo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boojack","download_url":"https://codeload.github.com/boojack/tiny-undo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boojack%2Ftiny-undo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270969275,"owners_count":24677288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["undo-redo"],"created_at":"2024-10-11T04:06:36.695Z","updated_at":"2025-08-18T09:14:29.371Z","avatar_url":"https://github.com/boojack.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiny Undo\n\nManage the undo/redo state programmatically for plain-text input element.\n\n## What does it solved?\n\n- Programming-friendly undo/redo handler (just like VSCode's behavior);\n- Get/set the undo/redo state, and subscribe its changes;\n- Run undo/redo programmatically;\n\n## How to use it?\n\n1. Install package: `yarn add tiny-undo` or `npm install tiny-undo`\n2. A simple example in pure html\u0026javascript:\n\n   ```javascript\n   // 1. Get a textarea element instance\n   const textareaEl = document.querySelector(\"textarea\");\n   // 2. Create a TinyUndo instance with the element\n   const tinyUndo = new TinyUndo(textareaEl);\n   // 3. done 🎉\n   ```\n\n3. And use it in React:\n\n   ```typescript\n   // ...\n   const editorRef = useRef\u003cHTMLTextAreaElement\u003e(null);\n\n   useEffect(() =\u003e {\n     const tinyUndo = new TinyUndo(editorRef.current!);\n\n     tinyUndo.subscribe((actions, index) =\u003e {\n       // do anything you want right here\n     });\n\n     return () =\u003e {\n       tinyUndo.destroy();\n     };\n   }, []);\n   // ...\n   ```\n\n4. (Optional) With initial configuration:\n\n   ```typescript\n   /**\n    * Initalize the TinyUndo config\n    * @param initialValue: The initial value of the editor\n    * @param interval: The interval in milliseconds to merge actions\n    * @param maxSize: The maximum number of actions to keep\n    * @param initialActions: The initial actions to add to the editor\n    * @param initialIndex: The initial index of the initial actions\n    */\n   export interface TinyUndoConfig {\n     initialValue: string;\n     interval: number;\n     maxSize?: number;\n     initialActions?: InputAction[];\n     initialIndex?: number;\n   }\n\n   const config: TinyUndoConfig = {\n     initialValue: \"\",\n     interval: 500,\n   };\n   const tinyUndo = new TinyUndo(textareaEl, config);\n   // ...\n   ```\n\n## More Advanced Examples\n\n- **An undo/redo editor with persistent history in React**\n\n  Please imagine that you can undo/redo with the historical data **even if the browser has refreshed or restarted**, and just need to save the tinyUndo data in the localstorage that can be done.\n\n  **[👀 Preview](https://memos.justsven.top)** / [⌨️ Source code](https://github.com/boojack/insmemo-web/commit/82d6a8bb880fd9f0e333c871f8c63ac6b19eff7b)\n\n- **An undo/redo state visual editor in Vue**\n\n  Just a simple example which made with Vue.js to show how tiny-undo works.\n\n  **[👀 Preview](https://boojack.github.io/tiny-undo-editor/)** / [⌨️ Source code](https://github.com/boojack/tiny-undo-editor)\n\n## References\n\n- [kommitters/editorjs-undo](https://github.com/kommitters/editorjs-undo)\n- [inputType values of InputEvent](https://rawgit.com/w3c/input-events/v1/index.html#interface-InputEvent-Attributes)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboojack%2Ftiny-undo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboojack%2Ftiny-undo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboojack%2Ftiny-undo/lists"}