Class: RicherText::JsonText

Inherits:
ApplicationRecord show all
Defined in:
app/models/richer_text/json_text.rb

Constant Summary collapse

DEFAULT_BODY =
{"type" => "doc", "content" => [{"type" => "paragraph", "attrs" => {"textAlign" => "left"}}]}

Instance Method Summary collapse

Instance Method Details

#mentioneesObject



26
27
28
29
30
# File 'app/models/richer_text/json_text.rb', line 26

def mentionees
  gids = mention_nodes.map(&:id).compact_blank

  GlobalID::Locator.locate_many(gids).uniq # Only return unique records
end

#to_editor_formatObject



14
15
16
# File 'app/models/richer_text/json_text.rb', line 14

def to_editor_format
  body
end

#to_plain_textObject



22
23
24
# File 'app/models/richer_text/json_text.rb', line 22

def to_plain_text
  RicherText.default_text_renderer.visit(document)
end

#to_sObject



18
19
20
# File 'app/models/richer_text/json_text.rb', line 18

def to_s
  RicherText.default_renderer.visit(document)
end