← All changes
|
modules/atomic-widgets/elements/atomic-paragraph/atomic-paragraph.php
+31
-9
4.0.9
→
4.3.1
View file →
| @@ -6,11 +6,12 @@ | ||
| 6 | 6 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 8 | 8 | use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; |
| 9 | 9 | use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; |
| 10 | +use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 10 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 11 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 12 | -use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type; | |
| 13 | +use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type; | |
| 13 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 14 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 15 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 16 | 17 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| @@ -38,9 +39,9 @@ | ||
| 38 | 39 | return esc_html__( 'Paragraph', 'elementor' ); |
| 39 | 40 | } |
| 40 | 41 | |
| 41 | 42 | public function get_keywords() { |
| 42 | - return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 43 | + return [ 'ato', 'atom', 'atoms', 'atomic', 'paragraph', 'text', 'content' ]; | |
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | public function get_icon() { |
| 46 | 47 | return 'eicon-paragraph'; |
| @@ -45,23 +46,32 @@ | ||
| 45 | 46 | public function get_icon() { |
| 46 | 47 | return 'eicon-paragraph'; |
| 47 | 48 | } |
| 48 | 49 | |
| 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 | + | |
| 49 | 60 | protected static function define_props_schema(): array { |
| 50 | 61 | return [ |
| 51 | 62 | 'classes' => Classes_Prop_Type::make() |
| 52 | 63 | ->default( [] ), |
| 53 | 64 | |
| 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.' ), | |
| 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' ), | |
| 60 | 69 | |
| 61 | 70 | 'tag' => String_Prop_Type::make() |
| 62 | 71 | ->enum( [ 'p', 'span' ] ) |
| 63 | - ->default( 'p' ), | |
| 72 | + ->default( 'p' ) | |
| 73 | + ->description( 'The HTML tag for the paragraph element. One of: p or span. Do not use heading or div tags.' ), | |
| 64 | 74 | |
| 65 | 75 | 'link' => Link_Prop_Type::make(), |
| 66 | 76 | |
| 67 | 77 | 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), |
| @@ -71,8 +81,9 @@ | ||
| 71 | 81 | protected function define_atomic_controls(): array { |
| 72 | 82 | return [ |
| 73 | 83 | Section::make() |
| 74 | 84 | ->set_label( __( 'Content', 'elementor' ) ) |
| 85 | + ->set_id( 'content' ) | |
| 75 | 86 | ->set_items( [ |
| 76 | 87 | Inline_Editing_Control::bind_to( 'paragraph' ) |
| 77 | 88 | ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) |
| 78 | 89 | ->set_label( __( 'Paragraph', 'elementor' ) ), |
| @@ -134,6 +145,17 @@ | ||
| 134 | 145 | protected function get_templates(): array { |
| 135 | 146 | return [ |
| 136 | 147 | 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 137 | 148 | ]; |
| 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 ); | |
| 138 | 160 | } |
| 139 | 161 | } |