Class: RenderEditorjs::DefaultRenderer
- Inherits:
-
Object
- Object
- RenderEditorjs::DefaultRenderer
- Defined in:
- lib/render_editorjs/default_renderer.rb
Overview
Built in renderer with healthy defaults
Constant Summary collapse
- SCHEMA =
YAML.safe_load("type: object\nadditionalProperties: false\nproperties:\n time:\n type: number\n blocks:\n type: array\n items:\n type: object\n version:\n type: string\nrequired:\n- time\n- blocks\n- version\n")
- DEFAULT_MAPPING =
{ "paragraph" => RenderEditorjs::Blocks::Paragraph.new, "header" => RenderEditorjs::Blocks::Header.new, "list" => RenderEditorjs::Blocks::List.new, "image" => RenderEditorjs::Blocks::Image.new }.freeze
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Instance Method Summary collapse
-
#initialize(custom_mapping = {}) ⇒ DefaultRenderer
constructor
A new instance of DefaultRenderer.
- #validator(content) ⇒ Object
Constructor Details
#initialize(custom_mapping = {}) ⇒ DefaultRenderer
Returns a new instance of DefaultRenderer.
33 34 35 |
# File 'lib/render_editorjs/default_renderer.rb', line 33 def initialize(custom_mapping = {}) @mapping = DEFAULT_MAPPING.merge(custom_mapping) end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
31 32 33 |
# File 'lib/render_editorjs/default_renderer.rb', line 31 def mapping @mapping end |
Instance Method Details
#validator(content) ⇒ Object
37 38 39 |
# File 'lib/render_editorjs/default_renderer.rb', line 37 def validator(content) RenderEditorjs::Validator.new(content, SCHEMA) end |