Module: TipTap::JsonRenderable

Included in:
Node
Defined in:
lib/tip_tap/json_renderable.rb

Instance Method Summary collapse

Instance Method Details

#include_empty_content_in_json?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/tip_tap/json_renderable.rb', line 7

def include_empty_content_in_json?
  true
end

#to_hObject

Generate a JSON object that is useable by the editor



12
13
14
15
16
17
# File 'lib/tip_tap/json_renderable.rb', line 12

def to_h
  json = {type: type_name}
  json = json.merge(content: content.map(&:to_h)) if should_include_content?
  json = json.merge(attrs: attrs.deep_symbolize_keys) if attrs.present?
  json
end