Class: Coradoc::Mirror::Node
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Coradoc::Mirror::Node
- Defined in:
- lib/coradoc/mirror/node.rb,
lib/coradoc/mirror/node.rb,
lib/coradoc/mirror/node.rb
Overview
ProseMirror-compatible document node.
Wire format:
{ "type": "paragraph", "attrs": {...}, "content": [...], "marks": [...] }
All built-in Node subclasses live below in this file so the TYPE_TO_CLASS registry can see every PM_TYPE at load time. Adding a new node type = adding one subclass (+ optional Attrs sub-model) and letting the registry walker pick it up (OCP).
The TYPE_TO_CLASS and POLYMORPHIC constants are declared up-front
(empty) because subclass key_value blocks reference them at class
load time. The table is populated and frozen after every subclass
is defined at the bottom of this file.
Defined Under Namespace
Classes: Abstract, Admonition, Bibliography, BibliographyEntry, Blockquote, BulletList, Caption, CodeBlock, DefinitionDescription, DefinitionList, DefinitionTerm, Document, Example, Figure, FootnoteEntry, FootnoteMarker, Footnotes, Frontmatter, FrontmatterEntry, FrontmatterValue, GenericBlock, HardBreak, Header, HorizontalRule, Image, Include, ListItem, LiteralBlock, OpenBlock, OrderedList, Paragraph, Partintro, PassBlock, Preamble, RawInline, Section, Sections, Sidebar, SoftBreak, StemBlock, Table, TableBody, TableCell, TableHead, TableRow, Text, ThematicBreak, Toc, TocEntry, Verse
Constant Summary collapse
- PM_TYPE =
'node'- TYPE_TO_CLASS =
{}
- POLYMORPHIC =
{ attribute: 'type', class_map: TYPE_TO_CLASS }.freeze
Instance Method Summary collapse
Instance Method Details
#text_content ⇒ Object
46 47 48 49 50 |
# File 'lib/coradoc/mirror/node.rb', line 46 def text_content return '' unless content content.select { |c| c.is_a?(Node) }.map(&:text_content).join end |