if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
* Elementor text editor widget.
* Elementor widget that displays a WYSIWYG text editor, just like the WordPress
class Widget_Text_Editor extends Widget_Base {
* Retrieve text editor widget name.
* @return string Widget name.
public function get_name() {
* Retrieve text editor widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'Text Editor', 'elementor' );
* Retrieve text editor widget icon.
* @return string Widget icon.
public function get_icon() {
* Retrieve the list of categories the text editor widget belongs to.
* Used to determine where to display the widget in the editor.
* @return array Widget categories.
public function get_categories() {
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'text', 'editor' ];
* Get style dependencies.
* Retrieve the list of style dependencies the widget requires.
* The 'widget-text-editor' style is required only when the drop cap is used.
* Therefor, style should not be loaded on the widget level, rather only on
* control level when the drop cap is active.
* Only in the Editor, these style should be loaded on the widget level.
* @return array Widget style dependencies.
public function get_style_depends(): array {
$style_dependencies = Plugin::$instance->editor->is_edit_mode() || Plugin::$instance->preview->is_preview_mode()
? [ 'widget-text-editor' ]
return $style_dependencies;
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Register text editor widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
protected function register_controls() {
$this->start_controls_section(
'label' => esc_html__( 'Text Editor', 'elementor' ),
'type' => Controls_Manager::WYSIWYG,
'default' => '<p>' . esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'elementor' ) . '</p>',
'label' => esc_html__( 'Drop Cap', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => esc_html__( 'Off', 'elementor' ),
'label_on' => esc_html__( 'On', 'elementor' ),
'prefix_class' => 'elementor-drop-cap-',
'frontend_available' => true,
'name' => 'widget-text-editor',
$this->add_responsive_control(
'label' => esc_html__( 'Columns', 'elementor' ),
'type' => Controls_Manager::SELECT,
'' => esc_html__( 'Default', 'elementor' ),
'1' => esc_html__( '1', 'elementor' ),
'2' => esc_html__( '2', 'elementor' ),
'3' => esc_html__( '3', 'elementor' ),
'4' => esc_html__( '4', 'elementor' ),
'5' => esc_html__( '5', 'elementor' ),
'6' => esc_html__( '6', 'elementor' ),
'7' => esc_html__( '7', 'elementor' ),
'8' => esc_html__( '8', 'elementor' ),
'9' => esc_html__( '9', 'elementor' ),
'10' => esc_html__( '10', 'elementor' ),
'{{WRAPPER}}' => 'columns: {{VALUE}};',
$this->add_responsive_control(
'label' => esc_html__( 'Columns Gap', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'{{WRAPPER}}' => 'column-gap: {{SIZE}}{{UNIT}};',
'name' => 'text_columns',
'name' => 'text_columns',
$this->end_controls_section();
$this->start_controls_section(
'label' => esc_html__( 'Text Editor', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
$this->add_responsive_control(
'label' => esc_html__( 'Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-text-align-left',
'title' => esc_html__( 'Center', 'elementor' ),
'icon' => 'eicon-text-align-center',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-text-align-right',
'title' => esc_html__( 'Justified', 'elementor' ),
'icon' => 'eicon-text-align-justify',
'classes' => 'elementor-control-start-end',
'selectors_dictionary' => [
'left' => is_rtl() ? 'end' : 'start',
'right' => is_rtl() ? 'start' : 'end',
'{{WRAPPER}}' => 'text-align: {{VALUE}};',
$this->add_group_control(
Group_Control_Typography::get_type(),
'default' => Global_Typography::TYPOGRAPHY_TEXT,
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
'selector' => '{{WRAPPER}}',
$this->add_responsive_control(
'label' => esc_html__( 'Paragraph Spacing', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
'{{WRAPPER}} p' => 'margin-block-end: {{SIZE}}{{UNIT}}',
'type' => Controls_Manager::DIVIDER,
$this->start_controls_tabs( 'link_colors' );
$this->start_controls_tab(
'label' => esc_html__( 'Normal', 'elementor' ),
'label' => esc_html__( 'Text Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}}' => 'color: {{VALUE}};',
'default' => Global_Colors::COLOR_TEXT,
'label' => esc_html__( 'Link Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}} a' => 'color: {{VALUE}};',
$this->end_controls_tab();
$this->start_controls_tab(
'label' => esc_html__( 'Hover', 'elementor' ),
'label' => esc_html__( 'Link Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}} a:hover, {{WRAPPER}} a:focus' => 'color: {{VALUE}};',
'link_hover_color_transition_duration',
'label' => esc_html__( 'Transition Duration', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 's', 'ms', 'custom' ],
'{{WRAPPER}} a' => 'transition-duration: {{SIZE}}{{UNIT}};',
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'label' => esc_html__( 'Drop Cap', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
'label' => esc_html__( 'View', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => esc_html__( 'Default', 'elementor' ),
'stacked' => esc_html__( 'Stacked', 'elementor' ),
'framed' => esc_html__( 'Framed', 'elementor' ),
'prefix_class' => 'elementor-drop-cap-view-',
'drop_cap_primary_color',
'label' => esc_html__( 'Primary Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}}.elementor-drop-cap-view-stacked .elementor-drop-cap' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-drop-cap-view-framed .elementor-drop-cap, {{WRAPPER}}.elementor-drop-cap-view-default .elementor-drop-cap' => 'color: {{VALUE}}; border-color: {{VALUE}};',
'default' => Global_Colors::COLOR_PRIMARY,
'drop_cap_secondary_color',
'label' => esc_html__( 'Secondary Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'{{WRAPPER}}.elementor-drop-cap-view-framed .elementor-drop-cap' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-drop-cap-view-stacked .elementor-drop-cap' => 'color: {{VALUE}};',
'drop_cap_view!' => 'default',
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
'name' => 'drop_cap_shadow',
'selector' => '{{WRAPPER}} .elementor-drop-cap',
'label' => esc_html__( 'Size', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
'{{WRAPPER}} .elementor-drop-cap' => 'padding: {{SIZE}}{{UNIT}};',
'drop_cap_view!' => 'default',