{"id":13907061,"url":"https://github.com/withspectrum/draft-js-code-editor-plugin","last_synced_at":"2026-01-14T21:32:15.550Z","repository":{"id":57215919,"uuid":"104659746","full_name":"withspectrum/draft-js-code-editor-plugin","owner":"withspectrum","description":"Add IDE-like behaviours to code blocks in your DraftJS editors","archived":true,"fork":false,"pushed_at":"2020-06-06T10:27:06.000Z","size":208,"stargazers_count":38,"open_issues_count":5,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-31T01:19:27.733Z","etag":null,"topics":["code","draft-js","draft-js-plugins","draftjs","editor"],"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/withspectrum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-24T16:38:53.000Z","updated_at":"2025-04-17T19:06:39.000Z","dependencies_parsed_at":"2022-08-26T13:31:47.440Z","dependency_job_id":null,"html_url":"https://github.com/withspectrum/draft-js-code-editor-plugin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/withspectrum/draft-js-code-editor-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdraft-js-code-editor-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdraft-js-code-editor-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdraft-js-code-editor-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdraft-js-code-editor-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/withspectrum","download_url":"https://codeload.github.com/withspectrum/draft-js-code-editor-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdraft-js-code-editor-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28435122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["code","draft-js","draft-js-plugins","draftjs","editor"],"created_at":"2024-08-06T23:01:47.074Z","updated_at":"2026-01-14T21:32:15.533Z","avatar_url":"https://github.com/withspectrum.png","language":"JavaScript","readme":"# `draft-js-code-editor-plugin`\n\nAdd IDE-like behaviours to code blocks in your DraftJS editor. Meant to be used with [`draft-js-plugins`](https://github.com/draft-js-plugins/draft-js-plugins).\n\n\u003e Note: If you're not using `draft-js-plugins` you can also use the lower-level [`draft-js-code`](https://github.com/SamyPesse/draft-js-code) library. \n\n## Functionality\n\n- Insert indentation on \u003ckbd\u003etab\u003c/kbd\u003e\n- Preserve indentation of current line when pressing \u003ckbd\u003eenter\u003c/kbd\u003e\n- Remove indentation correctly with \u003ckbd\u003ebackspace\u003c/kbd\u003e\n- More to come!\n\n## Usage\n\nFirst, install the plugin:\n\n```sh\nnpm install --save draft-js-code-editor-plugin\n```\n\nThen pass it to the `plugins` prop of the `draft-js-plugins` editor:\n\n```JS\nimport React, { Component  } from 'react';\nimport Editor from 'draft-js-plugins-editor';\nimport createCodeEditorPlugin from 'draft-js-code-editor-plugin';\nimport { EditorState  } from 'draft-js';\n\nexport default class DemoEditor extends Component {\n  state = {\n    editorState: EditorState.createEmpty(),\n    plugins: [createCodeEditorPlugin()]      \n  };\n\n  onChange = (editorState) =\u003e {\n    this.setState({\n      editorState,          \n    });\n  };\n\n  render() {\n    return (\n      \u003cEditor\n        editorState={this.state.editorState}\n        onChange={this.onChange}\n        plugins={this.state.plugins}\n      /\u003e\n    );  \n  }\n}\n```\n\n### Add code block syntax highlighting\n\nUsing the [`draft-js-prism-plugin`](https://github.com/withspectrum/draft-js-prism-plugin) you can easily add syntax highlighting support to your code blocks!\n\n```JS\n// Install prismjs and draft-js-prism-plugin\nimport Prism from 'prismjs';\nimport createPrismPlugin from 'draft-js-prism-plugin';\n\nclass Editor extends Component {\n  state = {\n    plugins: [\n    // Add the Prism plugin to the plugins array \n      createPrismPlugin({\n        prism: Prism\n      }),\n      createCodeEditorPlugin()\n    ]\n  };\n}\n```\n\n## License\n\nLicensed under the MIT License, Copyright ©️ 2017 Space Program Inc. See [LICENSE.md](LICENSE.md) for more information.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithspectrum%2Fdraft-js-code-editor-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwithspectrum%2Fdraft-js-code-editor-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithspectrum%2Fdraft-js-code-editor-plugin/lists"}