{"id":21004644,"url":"https://github.com/flaque/use-slate-lifecycle","last_synced_at":"2025-05-15T01:33:04.617Z","repository":{"id":51700076,"uuid":"214284998","full_name":"Flaque/use-slate-lifecycle","owner":"Flaque","description":"Add \"onUserStartsTyping\" and \"onUserStopsTyping\" events to your slate-js editor","archived":false,"fork":false,"pushed_at":"2021-08-11T13:45:26.000Z","size":46,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T11:12:16.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Flaque.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":"2019-10-10T21:01:50.000Z","updated_at":"2023-03-14T23:10:16.000Z","dependencies_parsed_at":"2022-08-22T07:10:33.620Z","dependency_job_id":null,"html_url":"https://github.com/Flaque/use-slate-lifecycle","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flaque%2Fuse-slate-lifecycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flaque%2Fuse-slate-lifecycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flaque%2Fuse-slate-lifecycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flaque%2Fuse-slate-lifecycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flaque","download_url":"https://codeload.github.com/Flaque/use-slate-lifecycle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254256467,"owners_count":22040296,"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","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":[],"created_at":"2024-11-19T08:37:19.632Z","updated_at":"2025-05-15T01:33:04.299Z","avatar_url":"https://github.com/Flaque.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-slate-lifecycle \n\nAdd `onUserStartsTyping` and `onUserStopsTyping` events to your slate editor.\n\n## Install\n\n```\nyarn add use-slate-lifecycle\n```\n\n## Usage\n\n`use-slate-lifecycle` works by returning a function that needs to be called\nin your `onChange` function like this:\n\n```jsx\nconst [ withLifeCycle ] = useSlateLifecycle({\n  onUserStartsTyping: () =\u003e {},\n  onUserStopsTyping: () =\u003e {}\n});\n\n// ...\n\n\u003cEditor onChange={(change) =\u003e {\n    withLifeCycle(change)\n    // .. other stuff\n}}\u003e\n\n```\n\nFull example:\n\n```jsx\nimport { Editor } from \"slate-react\";\nimport useSlateLifecycle from \"use-slate-lifecycle\";\n\nfunction MyEditor = () =\u003e {\n  function onUserStartsTyping(change) {\n      console.log(\"starts typing\")\n  }\n\n  function onUserStopsTyping(change) {\n      console.log(\"stops typing\")\n  }\n\n  const [ withLifeCycle ] = useSlateLifecycle({\n    onUserStartsTyping,\n    onUserStopsTyping\n  });\n\n  function onChange(change) {\n      withLifeCycle(change)\n\n      // Do your regular updating\n  }\n\n  return (\n      \u003cEditor onChange={change} {/* ... */} /\u003e\n  )\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaque%2Fuse-slate-lifecycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflaque%2Fuse-slate-lifecycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaque%2Fuse-slate-lifecycle/lists"}