{"id":13758283,"url":"https://github.com/ignitionworks/draftjs_exporter","last_synced_at":"2025-05-10T07:30:48.594Z","repository":{"id":62557478,"uuid":"61576481","full_name":"ignitionworks/draftjs_exporter","owner":"ignitionworks","description":"Export Draft.js content state into HTML.","archived":false,"fork":false,"pushed_at":"2019-04-11T16:50:08.000Z","size":22,"stargazers_count":16,"open_issues_count":2,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T18:15:39.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/ignitionworks.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":"2016-06-20T20:01:48.000Z","updated_at":"2022-03-17T06:12:56.000Z","dependencies_parsed_at":"2022-11-03T06:30:26.918Z","dependency_job_id":null,"html_url":"https://github.com/ignitionworks/draftjs_exporter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignitionworks%2Fdraftjs_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignitionworks%2Fdraftjs_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignitionworks%2Fdraftjs_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignitionworks%2Fdraftjs_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ignitionworks","download_url":"https://codeload.github.com/ignitionworks/draftjs_exporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253354755,"owners_count":21895451,"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.404Z","updated_at":"2025-05-10T07:30:48.349Z","avatar_url":"https://github.com/ignitionworks.png","language":"Ruby","funding_links":[],"categories":["Common Utilities"],"sub_categories":[],"readme":"# Draft.js Exporter\n\n[![Circle CI](https://circleci.com/gh/ignitionworks/draftjs_exporter/tree/master.svg?style=shield)](https://circleci.com/gh/ignitionworks/draftjs_exporter/tree/master)\n[![Code Climate](https://codeclimate.com/github/ignitionworks/draftjs_exporter/badges/gpa.svg)](https://codeclimate.com/github/ignitionworks/draftjs_exporter)\n[![Test Coverage](https://codeclimate.com/github/ignitionworks/draftjs_exporter/badges/coverage.svg)](https://codeclimate.com/github/ignitionworks/draftjs_exporter/coverage)\n\n[Draft.js](https://facebook.github.io/draft-js/) is a framework for\nbuilding rich text editors. However, it does not support exporting\ndocuments at HTML. This gem is designed to take the raw `ContentState`\n(output of [`convertToRaw`](https://facebook.github.io/draft-js/docs/api-reference-data-conversion.html#converttoraw))\nfrom Draft.js and convert it to HTML using Ruby.\n\n## Usage\n\n```ruby\n# Create configuration for entities and styles\nconfig = {\n  entity_decorators: {\n    'LINK' =\u003e DraftjsExporter::Entities::Link.new(className: 'link')\n  },\n  block_map: {\n    'header-one' =\u003e { element: 'h1' },\n    'unordered-list-item' =\u003e {\n      element: 'li',\n      wrapper: ['ul', { className: 'public-DraftStyleDefault-ul' }]\n    },\n    'unstyled' =\u003e { element: 'div' }\n  },\n  style_map: {\n    'ITALIC' =\u003e { fontStyle: 'italic' }\n  }\n}\n\n# New up the exporter\nexporter = DraftjsExporter::HTML.new(config)\n\n# Provide raw content state\nexporter.call({\n  entityMap: {\n    '0' =\u003e {\n      type: 'LINK',\n      mutability: 'MUTABLE',\n      data: {\n        url: 'http://example.com'\n      }\n    }\n  },\n  blocks: [\n    {\n      key: '5s7g9',\n      text: 'Header',\n      type: 'header-one',\n      depth: 0,\n      inlineStyleRanges: [],\n      entityRanges: []\n    },\n    {\n      key: 'dem5p',\n      text: 'some paragraph text',\n      type: 'unstyled',\n      depth: 0,\n      inlineStyleRanges: [\n        {\n          offset: 0,\n          length: 4,\n          style: 'ITALIC'\n        }\n      ],\n      entityRanges: [\n        {\n          offset: 5,\n          length: 9,\n          key: 0\n        }\n      ]\n    }\n  ]\n})\n# =\u003e \"\u003ch1\u003eHeader\u003c/h1\u003e\u003cdiv\u003e\\n\u003cspan style=\\\"font-style: italic;\\\"\u003esome\u003c/span\u003e \u003ca href=\\\"http://example.com\\\" class=\\\"link\\\"\u003eparagraph\u003c/a\u003e text\u003c/div\u003e\"\n```\n\n## Tests\n\n```bash\n$ rspec\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignitionworks%2Fdraftjs_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignitionworks%2Fdraftjs_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignitionworks%2Fdraftjs_exporter/lists"}