Class: ProseMirror::Mark
- Inherits:
-
Object
- Object
- ProseMirror::Mark
- Defined in:
- lib/prose_mirror/mark.rb
Overview
Represents a mark in a ProseMirror document Marks can be applied to nodes to indicate formatting or other attributes
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#eq(other) ⇒ Boolean
Check if this mark is equal to another mark Two marks are equal if they have the same type name.
-
#initialize(type, attrs = {}) ⇒ Mark
constructor
Create a new Mark.
-
#is_in_set(mark_array) ⇒ Boolean
Check if this mark is in the given set of marks.
Constructor Details
#initialize(type, attrs = {}) ⇒ Mark
Create a new Mark
10 11 12 13 |
# File 'lib/prose_mirror/mark.rb', line 10 def initialize(type, attrs = {}) @type = OpenStruct.new(name: type) @attrs = attrs end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
5 6 7 |
# File 'lib/prose_mirror/mark.rb', line 5 def attrs @attrs end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/prose_mirror/mark.rb', line 5 def type @type end |
Instance Method Details
#eq(other) ⇒ Boolean
Check if this mark is equal to another mark Two marks are equal if they have the same type name
19 20 21 |
# File 'lib/prose_mirror/mark.rb', line 19 def eq(other) @type.name == other.type.name end |
#is_in_set(mark_array) ⇒ Boolean
Check if this mark is in the given set of marks
26 27 28 |
# File 'lib/prose_mirror/mark.rb', line 26 def is_in_set(mark_array) mark_array.any? { |m| eq(m) } end |