Skip to content

Commit

Permalink
Merge pull request #41 from t-hamano/wp6.3
Browse files Browse the repository at this point in the history
Version 2.3.0 (Release for WP6.3)
  • Loading branch information
t-hamano authored Jul 21, 2023
2 parents bba547d + b7a7af0 commit a344657
Show file tree
Hide file tree
Showing 11 changed files with 7,964 additions and 8,054 deletions.
5 changes: 0 additions & 5 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ const config = {
printWidth: 100,
bracketSpacing: true,
parenSpacing: true,
// Set new property instead of jsxBracketSameLine
bracketSameLine: false,
}

// Remove deprecated property
delete config.jsxBracketSameLine

module.exports = config;
10 changes: 7 additions & 3 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"plugins": [ "." ],
"config": {
"WP_DEBUG": true,
"SCRIPT_DEBUG": true
"env": {
"tests": {
"config": {
"WP_DEBUG": true,
"SCRIPT_DEBUG": true
}
}
}
}
12 changes: 8 additions & 4 deletions inc/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ class Config {
array(
'color' => '#ffff66',
'thickness' => 40,
'opacity' => 80,
'opacity' => 70,
'type' => 'solid',
),
array(
'color' => '#ff7f7f',
'thickness' => 40,
'opacity' => 80,
'opacity' => 40,
'type' => 'solid',
),
array(
'color' => '#ffff66',
'thickness' => 100,
'opacity' => 80,
'opacity' => 70,
'type' => 'solid',
),
array(
'color' => '#ff7f7f',
'thickness' => 100,
'opacity' => 80,
'opacity' => 40,
'type' => 'solid',
),
);

Expand Down
53 changes: 35 additions & 18 deletions inc/class-enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public function enqueue_editor_scripts() {
wp_enqueue_style( RTEX_NAMESPACE );

$inline_css = $this->get_inline_css();
$inline_css .= '.rtex-dropdown-popover .components-dropdown-menu__menu-item{justify-content:left;}';
$inline_css .= '.rtex-dropdown-popover .components-dropdown-menu__menu-item{justify-content:left;height:auto;}';
$inline_css .= '.rtex-dropdown-popover .components-dropdown-menu__menu-item svg{margin-right:8px;}';

wp_add_inline_style( RTEX_NAMESPACE, $inline_css );

$asset = include( RTEX_PATH . '/build/index.asset.php' );
Expand All @@ -66,12 +67,7 @@ public function enqueue_option_scripts( $hook ) {
}

wp_enqueue_style( 'wp-color-picker' );

wp_enqueue_style( 'richtext-extension-option', RTEX_URL . '/build/style-index.css', array(), RTEX_VERSION );

$inline_css = $this->get_inline_css();
wp_add_inline_style( 'richtext-extension-option', $inline_css );

wp_enqueue_script( 'wp-color-picker' );
}

Expand All @@ -96,20 +92,41 @@ private function get_inline_css() {
// Generate highlighter style
for ( $i = 0; $i <= 3; $i++ ) {
if ( get_option( 'rtex_highlighter_active_' . $i, true ) ) {
$thickness = 100 - get_option( 'rtex_highlighter_thickness_' . $i, Config::$highlighter[ $i ]['thickness'] );
$color = get_option( 'rtex_highlighter_color_' . $i, Config::$highlighter[ $i ]['color'] );
$color_rgba = 'transparent';

// Generate linear-gradient value
if ( preg_match( '/^#[0-9a-fA-F]{6}$/', $color ) ) {
$r = hexdec( substr( $color, 1, 2 ) );
$g = hexdec( substr( $color, 3, 2 ) );
$b = hexdec( substr( $color, 5, 2 ) );
$opacity = get_option( 'rtex_highlighter_opacity_' . $i, Config::$highlighter[ $i ]['opacity'] ) / 100;
$color_rgba = "rgba(${r}, ${g}, ${b}, ${opacity})";
$css_selector = ".rtex-highlighter-${i}, #rtex-highlighter-preview-${i}";
$thickness = get_option( 'rtex_highlighter_thickness_' . $i, Config::$highlighter[ $i ]['thickness'] );
$color_hex = get_option( 'rtex_highlighter_color_' . $i, Config::$highlighter[ $i ]['color'] );
$type = get_option( 'rtex_highlighter_type_' . $i, Config::$highlighter[ $i ]['type'] );
$color = 'transparent';

// Generate rgba value
if ( preg_match( '/^#[0-9a-fA-F]{6}$/', $color_hex ) ) {
$opacity = get_option( 'rtex_highlighter_opacity_' . $i, Config::$highlighter[ $i ]['opacity'] ) / 100;
if ( 1 === $opacity ) {
$color = $color_hex;
} else {
$r = hexdec( substr( $color_hex, 1, 2 ) );
$g = hexdec( substr( $color_hex, 3, 2 ) );
$b = hexdec( substr( $color_hex, 5, 2 ) );
$color = "rgba(${r}, ${g}, ${b}, ${opacity})";
}
}

// Generate gradient value
if ( 'solid' === $type ) {
$thickness = 100 - $thickness;
if ( 0 === $thickness ) {
$background_value = $color;
} else {
$background_value = "linear-gradient(transparent ${thickness}%, ${color} ${thickness}%)";
}
} elseif ( 'stripe' === $type ) {
$background_value = "repeating-linear-gradient(-45deg, ${color} 0, ${color} 3px, transparent 3px, transparent 6px) no-repeat bottom/100% ${thickness}%";
} elseif ( 'stripe-thin' === $type ) {
$background_value = "repeating-linear-gradient(-45deg, ${color} 0, ${color} 2px, transparent 2px, transparent 4px) no-repeat bottom/100% ${thickness}%";
}

$css .= ".rtex-highlighter-${i}, #rtex-highlighter-preview-${i}{ background: linear-gradient(transparent ${thickness}%, ${color_rgba} ${thickness}%);}";
// Generate CSS
$css .= "$css_selector{background: $background_value;}";
}
}

Expand Down
Loading

0 comments on commit a344657

Please sign in to comment.