RubyGems Navigation menu

draftjs_exporter 0.0.1

# Draft.js Exporter [![Circle CI](https://circleci.com/gh/ignitionworks/draftjs_exporter/tree/master.svg?style=shield)](https://circleci.com/gh/ignitionworks/draftjs_exporter/tree/master) [![Code Climate](https://codeclimate.com/github/ignitionworks/draftjs_exporter/badges/gpa.svg)](https://codeclimate.com/github/ignitionworks/draftjs_exporter) [![Test Coverage](https://codeclimate.com/github/ignitionworks/draftjs_exporter/badges/coverage.svg)](https://codeclimate.com/github/ignitionworks/draftjs_exporter/coverage) [Draft.js](https://facebook.github.io/draft-js/) is a framework for building rich text editors. However, it does not support exporting documents at HTML. This gem is designed to take the raw `ContentState` (output of [`convertToRaw`](https://facebook.github.io/draft-js/docs/api-reference-data-conversion.html#converttoraw)) from Draft.js and convert it to HTML using Ruby. ## Usage ```ruby # Create configuration for entities and styles config = { entity_decorators: { 'LINK' => DraftjsExporter::Entities::Link.new }, block_map: { 'header-one' => { element: 'h1' }, 'unordered-list-item' => { element: 'li', wrapper: ['ul', { className: 'public-DraftStyleDefault-ul' }] }, 'unstyled' => { element: 'div' } }, style_map: { 'ITALIC' => { fontStyle: 'italic' } } } # New up the exporter exporter = DraftjsExporter::HTML.new(config) # Provide raw content state exporter.call({ entityMap: { '0' => { type: 'LINK', mutability: 'MUTABLE', data: { url: 'http://example.com' } } }, blocks: [ { key: '5s7g9', text: 'Header', type: 'header-one', depth: 0, inlineStyleRanges: [], entityRanges: [] }, { key: 'dem5p', text: 'some paragraph text', type: 'unstyled', depth: 0, inlineStyleRanges: [ { offset: 0, length: 4, style: 'ITALIC' } ], entityRanges: [ { offset: 5, length: 9, key: 0 } ] } ] }) # => "<h1>Header</h1><div>\n<span style=\"fontStyle: italic;\">some</span> <a href=\"http://example.com\">paragraph</a> text</div>" ``` ## Tests ```bash $ rspec ```

Gemfile:
=

安裝:
=

版本列表:

  1. 0.0.7 August 06, 2017 (9.5 KB)
  2. 0.0.6 August 04, 2016 (9.0 KB)
  3. 0.0.5 August 04, 2016 (9.0 KB)
  4. 0.0.4 June 21, 2016 (9.0 KB)
  5. 0.0.3 June 21, 2016 (9.0 KB)
  6. 0.0.1 June 21, 2016 (9.5 KB)
顯示所有版本(共 7)

Runtime 相依性套件 (1):

nokogiri >= 1.6.0, ~> 1.6

Development 相依性套件 (4):

codeclimate-test-reporter >= 0.5.0, ~> 0.5
rspec >= 3.4.0, ~> 3.4
rubocop >= 0.40.0, ~> 0.40
simplecov >= 0.11.0, ~> 0.11

擁有者:

作者:

  • Theo Cushion

SHA 256 總和檢查碼:

=

總下載次數 360,792

這個版本 2,026

版本发布:

授權:

MIT

Ruby 版本需求: >= 2.1.0

相關連結: