Class: EditorJs::Blocks::CodeBlock

Inherits:
Base
  • Object
show all
Defined in:
lib/editor_js/blocks/code_block.rb

Overview

code block

Constant Summary

Constants inherited from Base

Base::InvalidBlockDataError, Base::InvalidBlockTypeError

Instance Attribute Summary

Attributes inherited from Base

#output_buffer, #raw

Instance Method Summary collapse

Methods inherited from Base

#css_name, #data, #decode_html, inherited, #initialize, load, #output, registry, #sanitize!, #type, type, #valid?

Constructor Details

This class inherits a constructor from EditorJs::Blocks::Base

Instance Method Details

#plainObject



25
26
27
# File 'lib/editor_js/blocks/code_block.rb', line 25

def plain
  data['code'].strip
end

#render(_options = {}) ⇒ Object



19
20
21
22
23
# File 'lib/editor_js/blocks/code_block.rb', line 19

def render(_options = {})
   :code, class: css_name do
    data['code']
  end
end

#schemaObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/editor_js/blocks/code_block.rb', line 7

def schema
  YAML.safe_load(<<~YAML)
    type: object
    additionalProperties: false
    properties:
      code:
        type: string
    required:
    - code
  YAML
end