mod/edit/set/all/editor.rb in card-1.98.3 vs mod/edit/set/all/editor.rb in card-1.99.0
- old
+ new
@@ -4,44 +4,57 @@
Self::InputOptions.add_to_basket :options, "text area"
Self::InputOptions.add_to_basket :options, "text field"
format :html do
- def editor
- (c = card.rule(:input)) && c.gsub(/[\[\]]/, "").tr(" ", "_")
+ def input_type
+ voo.input_type.present? ? voo.input_type : input_type_from_rule
end
- def editor_method editor_type
- "#{editor_type}_input"
+ def input_type_from_rule
+ card.rule(:input_type)&.gsub(/[\[\]]/, "")&.tr(" ", "_")
end
- def editor_defined_by_card
- return unless (editor_card = Card[editor])
+ def input_method input_type
+ "#{input_type}_input"
+ end
- nest editor_card, view: :core
+ # core view of card is input
+ def input_defined_by_card
+ with_card input_type do |input_card|
+ nest input_card, view: :core
+ end
end
- view :editor, unknown: true do
- try(editor_method(editor)) ||
- editor_defined_by_card ||
- send(editor_method(default_editor))
+ # move somewhere more accessible?
+ def with_card mark
+ return nil unless (card = Card[mark])
+
+ yield card
+ rescue Card::Error::CodenameNotFound
+ nil
end
- def default_editor
+ view :input, unknown: true do
+ try(input_method(input_type)) ||
+ input_defined_by_card ||
+ send(input_method(default_input_type))
+ end
+
+ def default_input_type
:rich_text
end
# overridden by mods that provide rich text editors
def rich_text_input
- default_editor = Cardio.config.rich_text_editor || :tinymce
- send "#{default_editor}_editor_input"
+ send "#{Cardio.config.rich_text_editor || :tinymce}_editor_input"
end
def text_area_input
text_area :content, rows: 5, class: "d0-card-content",
"data-card-type-code" => card.type_code
end
def text_field_input
- text_field :content, class: "d0-card-content"
+ text_field :content, class: classy("d0-card-content")
end
end