← All changes
|
modules/atomic-widgets/elements/atomic-paragraph/atomic-paragraph.php
+15
-72
4.3.0-beta3
→
3.31.4
View file →
| @@ -1,25 +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; | |
| 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 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 13 | -use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type; | |
| 11 | +use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Array_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; |
| 18 | 16 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 19 | -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 | 17 | |
| 23 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 24 | 19 | exit; |
| 25 | 20 | } |
| @@ -28,10 +23,8 @@ | ||
| 28 | 23 | use Has_Template; |
| 29 | 24 | |
| 30 | 25 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 31 | 26 | |
| 32 | - public static $widget_description = 'Display a paragraph with customizable tag, styles, and link options.'; | |
| 33 | - | |
| 34 | 27 | public static function get_element_type(): string { |
| 35 | 28 | return 'e-paragraph'; |
| 36 | 29 | } |
| 37 | 30 | |
| @@ -39,9 +32,9 @@ | ||
| 39 | 32 | return esc_html__( 'Paragraph', 'elementor' ); |
| 40 | 33 | } |
| 41 | 34 | |
| 42 | 35 | public function get_keywords() { |
| 43 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'paragraph', 'text', 'content' ]; | |
| 36 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 44 | 37 | } |
| 45 | 38 | |
| 46 | 39 | public function get_icon() { |
| 47 | 40 | return 'eicon-paragraph'; |
| @@ -46,37 +39,22 @@ | ||
| 46 | 39 | public function get_icon() { |
| 47 | 40 | return 'eicon-paragraph'; |
| 48 | 41 | } |
| 49 | 42 | |
| 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 | 43 | protected static function define_props_schema(): array { |
| 61 | - return [ | |
| 44 | + $props = [ | |
| 62 | 45 | 'classes' => Classes_Prop_Type::make() |
| 63 | 46 | ->default( [] ), |
| 64 | 47 | |
| 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' ), | |
| 48 | + 'paragraph' => String_Prop_Type::make() | |
| 49 | + ->default( __( 'Type your paragraph here', 'elementor' ) ), | |
| 69 | 50 | |
| 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 | 51 | 'link' => Link_Prop_Type::make(), |
| 76 | 52 | |
| 77 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 53 | + 'attributes' => Key_Value_Array_Prop_Type::make(), | |
| 78 | 54 | ]; |
| 55 | + | |
| 56 | + return $props; | |
| 79 | 57 | } |
| 80 | 58 | |
| 81 | 59 | protected function define_atomic_controls(): array { |
| 82 | 60 | return [ |
| @@ -81,44 +59,20 @@ | ||
| 81 | 59 | protected function define_atomic_controls(): array { |
| 82 | 60 | return [ |
| 83 | 61 | Section::make() |
| 84 | 62 | ->set_label( __( 'Content', 'elementor' ) ) |
| 85 | - ->set_id( 'content' ) | |
| 86 | 63 | ->set_items( [ |
| 87 | - Inline_Editing_Control::bind_to( 'paragraph' ) | |
| 88 | - ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) | |
| 89 | - ->set_label( __( 'Paragraph', 'elementor' ) ), | |
| 64 | + Textarea_Control::bind_to( 'paragraph' ) | |
| 65 | + ->set_label( __( 'Paragraph', 'elementor' ) ) | |
| 66 | + ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ), | |
| 90 | 67 | ] ), |
| 91 | - Section::make() | |
| 92 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 93 | - ->set_id( 'settings' ) | |
| 94 | - ->set_items( $this->get_settings_controls() ), | |
| 95 | 68 | ]; |
| 96 | 69 | } |
| 97 | 70 | |
| 98 | 71 | protected function get_settings_controls(): array { |
| 99 | 72 | 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 | 73 | 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 | - ] ), | |
| 118 | - Text_Control::bind_to( '_cssid' ) | |
| 119 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 120 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 74 | + ->set_label( __( 'Link', 'elementor' ) ), | |
| 121 | 75 | ]; |
| 122 | 76 | } |
| 123 | 77 | |
| 124 | 78 | protected function define_base_styles(): array { |
| @@ -145,17 +99,6 @@ | ||
| 145 | 99 | protected function get_templates(): array { |
| 146 | 100 | return [ |
| 147 | 101 | 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 148 | 102 | ]; |
| 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 | 103 | } |
| 161 | 104 | } |