{"id":13758287,"url":"https://github.com/icelab/draft-js-ast-importer","last_synced_at":"2026-01-26T22:17:52.213Z","repository":{"id":51778100,"uuid":"59251823","full_name":"icelab/draft-js-ast-importer","owner":"icelab","description":"Allows you to import an abstract syntax tree (AST) output from the companion draft-js-ast-exporter.","archived":false,"fork":false,"pushed_at":"2022-12-04T04:08:45.000Z","size":187,"stargazers_count":13,"open_issues_count":5,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-16T00:13:11.738Z","etag":null,"topics":[],"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/icelab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-05-20T00:12:48.000Z","updated_at":"2020-12-30T03:18:17.000Z","dependencies_parsed_at":"2023-01-24T00:01:58.956Z","dependency_job_id":null,"html_url":"https://github.com/icelab/draft-js-ast-importer","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelab%2Fdraft-js-ast-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelab%2Fdraft-js-ast-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelab%2Fdraft-js-ast-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelab%2Fdraft-js-ast-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icelab","download_url":"https://codeload.github.com/icelab/draft-js-ast-importer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253379463,"owners_count":21899259,"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-08-03T13:00:24.493Z","updated_at":"2026-01-26T22:17:52.098Z","avatar_url":"https://github.com/icelab.png","language":"JavaScript","funding_links":[],"categories":["Common Utilities"],"sub_categories":[],"readme":"# Draft.js AST Importer\n\nAllows you to import the abstract syntax tree (AST) output from the companion [`draft-js-ast-exporter`](https://github.com/icelab/draft-js-ast-exporter). Together they form the full cycle of exporting content from a Draft.js editor instance and then re-importing it.\n\n## Why?\n\nDraft.js supports exporting its content JSON, but this format is a little awkward. Blocks of text are disconnected from their style and entity ranges, and the depth of blocks isn’t implicit. So when it comes to rendering that content in contexts outside a Draft.js editor, you need to have an understanding of how those ranges should be applied and how blocks fit together.\n\nThe AST generated by `draft-js-ast-exporter` mitigates this issue by joining common ranges together into marked `inline` or `entity` sections, and by allowing blocks to be nested within one another based on their depth.\n\n## Installation\n\n```\nnpm install --save draft-js-ast-importer\n```\n\n## Usage\n\n```js\nimport {Editor} from 'draft-js'\nimport importer from 'draft-js-ast-importer'\nimport yourDecorator from './decorator'\n\nclass Foo extends React.Component {\n  constructor(props) {\n    super(props)\n    const contentState = importer(ast)\n    this.state {\n      editorState: EditorState.createWithContent(contentState, yourDecorator)\n    }\n  },\n\n  onChange (editorState) {\n    this.setState({editorState})\n  },\n\n  render () {\n    const {editorState} = this.state\n    return (\n      \u003cEditor editorState={editorState} onChange={this.onChange}/\u003e\n    )\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficelab%2Fdraft-js-ast-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficelab%2Fdraft-js-ast-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficelab%2Fdraft-js-ast-importer/lists"}