{"id":22317167,"url":"https://github.com/kjj6198/draft-utils","last_synced_at":"2026-04-13T01:37:03.880Z","repository":{"id":57216012,"uuid":"99295993","full_name":"kjj6198/draft-utils","owner":"kjj6198","description":"draft-js utils to simplify draftjs.","archived":false,"fork":false,"pushed_at":"2017-08-04T03:07:08.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T13:18:15.641Z","etag":null,"topics":["development","draft-js","draftjs-utils","react","utils"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kjj6198.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-04T02:48:58.000Z","updated_at":"2017-08-04T02:59:28.000Z","dependencies_parsed_at":"2022-08-26T13:31:50.065Z","dependency_job_id":null,"html_url":"https://github.com/kjj6198/draft-utils","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kjj6198/draft-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjj6198%2Fdraft-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjj6198%2Fdraft-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjj6198%2Fdraft-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjj6198%2Fdraft-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kjj6198","download_url":"https://codeload.github.com/kjj6198/draft-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjj6198%2Fdraft-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265246022,"owners_count":23734109,"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":["development","draft-js","draftjs-utils","react","utils"],"created_at":"2024-12-03T23:08:55.241Z","updated_at":"2026-04-13T01:36:58.845Z","avatar_url":"https://github.com/kjj6198.png","language":"JavaScript","readme":"**WARN: this repo is under development.**\n\n## Draft Utils\n\ndraft-js is awesome, and it provide some method to use.\n\n\n### What's problem?\n\nif we want to get text in ContentBlock, we need to do something like\n\n```javascript\neditorState\n    .getCurrentContent()\n    .getBlockForKey(selection.getStartKey())\n    .getText();\n```\n\nso this utils provide convienient way to use draftJS.\n\nFor example,\n\n```javascript\n  getContentBlockText(editorState) // do the some thing above.\n```\n\nAll you need to do is passing editorState, which is more reasonable.\n\n### API\n\n#### getSelectedEntity(editorState)\n\nget selected entity instance (not entity key!)\n @param  {EditorState} editorState\n @return {Entity}\n\n### createEntity(type, mutable, data)\n\nreturn a function(editorState) and create an entity.\n\n### setContentState(contentState, editorState)\n\nset contentState in provided editorState. useful when you use some method only return contentState.\n\n\n### applyEntity(contentState, selectionState, entityKey)\n\nreturn a function(editorState). apply an entity and set ContentState to provided EditorState.\n\n### setBlockType(contentState, selectionState, blockType)\n\nreturn a function(editorState). apply an blockType and set ContentState to provided EditorState.\n\n### getCurrentBlockType(editorState)\n\nreturn currentBlock type.\n\n### getSelectedText(editorState)\n\nget selected text with editorState.\n\n\n### toHTML(editorState)\n\nconvert editorState into HTML.\n\n### getPlainText(editorState)\n\nget plain text with editorState.\n\n\n### LICENSE\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjj6198%2Fdraft-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkjj6198%2Fdraft-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjj6198%2Fdraft-utils/lists"}