Class: Inkpen::Toolbar
- Inherits:
-
Object
- Object
- Inkpen::Toolbar
- Defined in:
- lib/inkpen/toolbar.rb
Overview
PORO representing toolbar configuration.
The Toolbar class configures the floating or fixed toolbar that appears when text is selected (floating) or at the top of the editor (fixed).
Constant Summary collapse
- FORMATTING_BUTTONS =
Text formatting buttons (bold, italic, strike, underline).
%i[bold italic strike underline].freeze
- BLOCK_BUTTONS =
Block-level formatting buttons.
%i[heading bullet_list ordered_list blockquote code_block].freeze
- INSERT_BUTTONS =
Content insertion buttons.
%i[link image table horizontal_rule].freeze
- PRESET_MINIMAL =
Minimal preset (bold, italic, link).
%i[bold italic link].freeze
- PRESET_STANDARD =
Standard preset with common formatting options.
(FORMATTING_BUTTONS + %i[link heading bullet_list ordered_list blockquote]).freeze
- PRESET_FULL =
Full preset with all available buttons.
(FORMATTING_BUTTONS + BLOCK_BUTTONS + INSERT_BUTTONS).freeze
Instance Attribute Summary collapse
-
#buttons ⇒ Array<Symbol>
readonly
List of toolbar buttons.
- #position ⇒ Object readonly
-
#style ⇒ Symbol
readonly
Toolbar display style (:floating, :fixed, :none).
Instance Method Summary collapse
-
#data_attributes ⇒ Hash
Generate data attributes for Stimulus controller.
-
#fixed? ⇒ Boolean
Check if toolbar uses fixed style.
-
#floating? ⇒ Boolean
Check if toolbar uses floating (bubble menu) style.
-
#hidden? ⇒ Boolean
Check if toolbar is hidden.
-
#initialize(style: :floating, buttons: nil, position: :top) ⇒ Toolbar
constructor
Initialize a new toolbar configuration.
Constructor Details
#initialize(style: :floating, buttons: nil, position: :top) ⇒ Toolbar
Initialize a new toolbar configuration.
81 82 83 84 85 |
# File 'lib/inkpen/toolbar.rb', line 81 def initialize(style: :floating, buttons: nil, position: :top) @style = style.to_sym @buttons = || @position = position.to_sym end |
Instance Attribute Details
#buttons ⇒ Array<Symbol> (readonly)
Returns list of toolbar buttons.
42 |
# File 'lib/inkpen/toolbar.rb', line 42 attr_reader :style, :buttons, :position |
#position ⇒ Object (readonly)
42 |
# File 'lib/inkpen/toolbar.rb', line 42 attr_reader :style, :buttons, :position |
#style ⇒ Symbol (readonly)
Returns toolbar display style (:floating, :fixed, :none).
42 43 44 |
# File 'lib/inkpen/toolbar.rb', line 42 def style @style end |
Instance Method Details
#data_attributes ⇒ Hash
Generate data attributes for Stimulus controller.
119 120 121 122 123 124 125 |
# File 'lib/inkpen/toolbar.rb', line 119 def data_attributes { "inkpen--toolbar-style-value" => style.to_s, "inkpen--toolbar-buttons-value" => .to_json, "inkpen--toolbar-position-value" => position.to_s } end |
#fixed? ⇒ Boolean
Check if toolbar uses fixed style.
101 102 103 |
# File 'lib/inkpen/toolbar.rb', line 101 def fixed? style == :fixed end |
#floating? ⇒ Boolean
Check if toolbar uses floating (bubble menu) style.
92 93 94 |
# File 'lib/inkpen/toolbar.rb', line 92 def floating? style == :floating end |
#hidden? ⇒ Boolean
Check if toolbar is hidden.
110 111 112 |
# File 'lib/inkpen/toolbar.rb', line 110 def hidden? style == :none end |