← All changes
|
modules/atomic-widgets/elements/atomic-paragraph/atomic-paragraph.php
+11
-60
4.3.0-beta2
→
3.32.3
View file →
| @@ -1,17 +1,15 @@ | ||
| 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; | |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 8 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; | |
| 9 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 11 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 12 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 13 | -use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type; | |
| 14 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 15 | 13 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 16 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 17 | 15 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| @@ -16,10 +14,8 @@ | ||
| 16 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 17 | 15 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 18 | 16 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 19 | 17 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 20 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control; | |
| 21 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 22 | 18 | |
| 23 | 19 | if ( ! defined( 'ABSPATH' ) ) { |
| 24 | 20 | exit; |
| 25 | 21 | } |
| @@ -28,10 +24,8 @@ | ||
| 28 | 24 | use Has_Template; |
| 29 | 25 | |
| 30 | 26 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 31 | 27 | |
| 32 | - public static $widget_description = 'Display a paragraph with customizable tag, styles, and link options.'; | |
| 33 | - | |
| 34 | 28 | public static function get_element_type(): string { |
| 35 | 29 | return 'e-paragraph'; |
| 36 | 30 | } |
| 37 | 31 | |
| @@ -46,37 +40,22 @@ | ||
| 46 | 40 | public function get_icon() { |
| 47 | 41 | return 'eicon-paragraph'; |
| 48 | 42 | } |
| 49 | 43 | |
| 50 | - public static function html_tag_follows_link(): bool { | |
| 51 | - return false; | |
| 52 | - } | |
| 53 | - | |
| 54 | - public static function get_computed_html_tag( array $settings ): string { | |
| 55 | - return Html_Tag_Computer::compute( $settings, 'p', [ | |
| 56 | - Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(), | |
| 57 | - ] ); | |
| 58 | - } | |
| 59 | - | |
| 60 | 44 | protected static function define_props_schema(): array { |
| 61 | - return [ | |
| 45 | + $props = [ | |
| 62 | 46 | 'classes' => Classes_Prop_Type::make() |
| 63 | 47 | ->default( [] ), |
| 64 | 48 | |
| 65 | - 'paragraph' => Escaped_Html_Prop_Type::make() | |
| 66 | - ->default( __( 'Type your paragraph here', 'elementor' ) ) | |
| 67 | - ->description( 'The text content of the paragraph.' ) | |
| 68 | - ->alias( 'text', 'content' ), | |
| 49 | + 'paragraph' => String_Prop_Type::make() | |
| 50 | + ->default( __( 'Type your paragraph here', 'elementor' ) ), | |
| 69 | 51 | |
| 70 | - 'tag' => String_Prop_Type::make() | |
| 71 | - ->enum( [ 'p', 'span' ] ) | |
| 72 | - ->default( 'p' ) | |
| 73 | - ->description( 'The HTML tag for the paragraph element. One of: p or span. Do not use heading or div tags.' ), | |
| 74 | - | |
| 75 | 52 | 'link' => Link_Prop_Type::make(), |
| 76 | 53 | |
| 77 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 54 | + 'attributes' => Attributes_Prop_Type::make(), | |
| 78 | 55 | ]; |
| 56 | + | |
| 57 | + return $props; | |
| 79 | 58 | } |
| 80 | 59 | |
| 81 | 60 | protected function define_atomic_controls(): array { |
| 82 | 61 | return [ |
| @@ -81,11 +60,10 @@ | ||
| 81 | 60 | protected function define_atomic_controls(): array { |
| 82 | 61 | return [ |
| 83 | 62 | Section::make() |
| 84 | 63 | ->set_label( __( 'Content', 'elementor' ) ) |
| 85 | - ->set_id( 'content' ) | |
| 86 | 64 | ->set_items( [ |
| 87 | - Inline_Editing_Control::bind_to( 'paragraph' ) | |
| 65 | + Textarea_Control::bind_to( 'paragraph' ) | |
| 88 | 66 | ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) |
| 89 | 67 | ->set_label( __( 'Paragraph', 'elementor' ) ), |
| 90 | 68 | ] ), |
| 91 | 69 | Section::make() |
| @@ -96,26 +74,10 @@ | ||
| 96 | 74 | } |
| 97 | 75 | |
| 98 | 76 | protected function get_settings_controls(): array { |
| 99 | 77 | return [ |
| 100 | - Select_Control::bind_to( 'tag' ) | |
| 101 | - ->set_options([ | |
| 102 | - [ | |
| 103 | - 'value' => 'p', | |
| 104 | - 'label' => 'p', | |
| 105 | - ], | |
| 106 | - [ | |
| 107 | - 'value' => 'span', | |
| 108 | - 'label' => 'span', | |
| 109 | - ], | |
| 110 | - ]) | |
| 111 | - ->set_label( __( 'Tag', 'elementor' ) ), | |
| 112 | 78 | Link_Control::bind_to( 'link' ) |
| 113 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 114 | - ->set_label( __( 'Link', 'elementor' ) ) | |
| 115 | - ->set_meta( [ | |
| 116 | - 'topDivider' => true, | |
| 117 | - ] ), | |
| 79 | + ->set_label( __( 'Link', 'elementor' ) ), | |
| 118 | 80 | Text_Control::bind_to( '_cssid' ) |
| 119 | 81 | ->set_label( __( 'ID', 'elementor' ) ) |
| 120 | 82 | ->set_meta( $this->get_css_id_control_meta() ), |
| 121 | 83 | ]; |
| @@ -145,17 +107,6 @@ | ||
| 145 | 107 | protected function get_templates(): array { |
| 146 | 108 | return [ |
| 147 | 109 | 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 148 | 110 | ]; |
| 149 | - } | |
| 150 | - | |
| 151 | - public function render_markdown(): string { | |
| 152 | - $settings = $this->get_atomic_settings(); | |
| 153 | - $content = $settings['paragraph'] ?? ''; | |
| 154 | - | |
| 155 | - if ( empty( $content ) ) { | |
| 156 | - return ''; | |
| 157 | - } | |
| 158 | - | |
| 159 | - return \Elementor\Modules\MarkdownRender\Html_To_Markdown::convert( $content ); | |
| 160 | 111 | } |
| 161 | 112 | } |