← All changes
|
modules/atomic-widgets/elements/atomic-paragraph/atomic-paragraph.php
+14
-62
4.2.0-beta2
→
3.31.4
View file →
| @@ -1,24 +1,20 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph; |
| 4 | 4 | |
| 5 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 5 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 6 | 6 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 8 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; | |
| 9 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 8 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; | |
| 9 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 10 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 11 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 12 | -use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type; | |
| 11 | +use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Array_Prop_Type; | |
| 13 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 14 | 13 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 15 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 16 | 15 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 17 | 16 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 18 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; | |
| 19 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control; | |
| 20 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 21 | 17 | |
| 22 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 23 | 19 | exit; |
| 24 | 20 | } |
| @@ -27,10 +23,8 @@ | ||
| 27 | 23 | use Has_Template; |
| 28 | 24 | |
| 29 | 25 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 30 | 26 | |
| 31 | - public static $widget_description = 'Display a paragraph with customizable tag, styles, and link options.'; | |
| 32 | - | |
| 33 | 27 | public static function get_element_type(): string { |
| 34 | 28 | return 'e-paragraph'; |
| 35 | 29 | } |
| 36 | 30 | |
| @@ -46,28 +40,21 @@ | ||
| 46 | 40 | return 'eicon-paragraph'; |
| 47 | 41 | } |
| 48 | 42 | |
| 49 | 43 | protected static function define_props_schema(): array { |
| 50 | - return [ | |
| 44 | + $props = [ | |
| 51 | 45 | 'classes' => Classes_Prop_Type::make() |
| 52 | 46 | ->default( [] ), |
| 53 | 47 | |
| 54 | - 'paragraph' => Html_V3_Prop_Type::make() | |
| 55 | - ->default( [ | |
| 56 | - 'content' => String_Prop_Type::generate( __( 'Type your paragraph here', 'elementor' ) ), | |
| 57 | - 'children' => [], | |
| 58 | - ] ) | |
| 59 | - ->description( 'The text content of the paragraph.' ) | |
| 60 | - ->alias( 'text', 'content' ), | |
| 48 | + 'paragraph' => String_Prop_Type::make() | |
| 49 | + ->default( __( 'Type your paragraph here', 'elementor' ) ), | |
| 61 | 50 | |
| 62 | - 'tag' => String_Prop_Type::make() | |
| 63 | - ->enum( [ 'p', 'span' ] ) | |
| 64 | - ->default( 'p' ), | |
| 65 | - | |
| 66 | 51 | 'link' => Link_Prop_Type::make(), |
| 67 | 52 | |
| 68 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 53 | + 'attributes' => Key_Value_Array_Prop_Type::make(), | |
| 69 | 54 | ]; |
| 55 | + | |
| 56 | + return $props; | |
| 70 | 57 | } |
| 71 | 58 | |
| 72 | 59 | protected function define_atomic_controls(): array { |
| 73 | 60 | return [ |
| @@ -72,44 +59,20 @@ | ||
| 72 | 59 | protected function define_atomic_controls(): array { |
| 73 | 60 | return [ |
| 74 | 61 | Section::make() |
| 75 | 62 | ->set_label( __( 'Content', 'elementor' ) ) |
| 76 | - ->set_id( 'content' ) | |
| 77 | 63 | ->set_items( [ |
| 78 | - Inline_Editing_Control::bind_to( 'paragraph' ) | |
| 79 | - ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) | |
| 80 | - ->set_label( __( 'Paragraph', 'elementor' ) ), | |
| 64 | + Textarea_Control::bind_to( 'paragraph' ) | |
| 65 | + ->set_label( __( 'Paragraph', 'elementor' ) ) | |
| 66 | + ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ), | |
| 81 | 67 | ] ), |
| 82 | - Section::make() | |
| 83 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 84 | - ->set_id( 'settings' ) | |
| 85 | - ->set_items( $this->get_settings_controls() ), | |
| 86 | 68 | ]; |
| 87 | 69 | } |
| 88 | 70 | |
| 89 | 71 | protected function get_settings_controls(): array { |
| 90 | 72 | return [ |
| 91 | - Select_Control::bind_to( 'tag' ) | |
| 92 | - ->set_options([ | |
| 93 | - [ | |
| 94 | - 'value' => 'p', | |
| 95 | - 'label' => 'p', | |
| 96 | - ], | |
| 97 | - [ | |
| 98 | - 'value' => 'span', | |
| 99 | - 'label' => 'span', | |
| 100 | - ], | |
| 101 | - ]) | |
| 102 | - ->set_label( __( 'Tag', 'elementor' ) ), | |
| 103 | 73 | Link_Control::bind_to( 'link' ) |
| 104 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 105 | - ->set_label( __( 'Link', 'elementor' ) ) | |
| 106 | - ->set_meta( [ | |
| 107 | - 'topDivider' => true, | |
| 108 | - ] ), | |
| 109 | - Text_Control::bind_to( '_cssid' ) | |
| 110 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 111 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 74 | + ->set_label( __( 'Link', 'elementor' ) ), | |
| 112 | 75 | ]; |
| 113 | 76 | } |
| 114 | 77 | |
| 115 | 78 | protected function define_base_styles(): array { |
| @@ -136,17 +99,6 @@ | ||
| 136 | 99 | protected function get_templates(): array { |
| 137 | 100 | return [ |
| 138 | 101 | 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 139 | 102 | ]; |
| 140 | - } | |
| 141 | - | |
| 142 | - public function render_markdown(): string { | |
| 143 | - $settings = $this->get_atomic_settings(); | |
| 144 | - $content = $settings['paragraph'] ?? ''; | |
| 145 | - | |
| 146 | - if ( empty( $content ) ) { | |
| 147 | - return ''; | |
| 148 | - } | |
| 149 | - | |
| 150 | - return \Elementor\Modules\MarkdownRender\Html_To_Markdown::convert( $content ); | |
| 151 | 103 | } |
| 152 | 104 | } |