Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【確認待ち】5.9で蛍光マーカー再編集が出来るように調整 #948

Merged
merged 3 commits into from
Jan 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions src/extensions/common/highlighter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import {
ColorPalette,
URLPopover,
} from '@wordpress/block-editor';
import { Icon } from '@wordpress/components';
import { ReactComponent as IconSVG } from './icon.svg';
import hex2rgba from '@vkblocks/utils/hex-to-rgba';
import { ReactComponent as Icon } from './icon.svg';

const name = 'vk-blocks/highlighter';
const alpha = 0.7;
Expand Down Expand Up @@ -59,12 +60,17 @@ const HighlighterEdit = (props) => {
const activeFormat = getActiveFormat(value, name);
heightlightColor = activeFormat.attributes.data;
}
const heightlightColorStyle = {
background: heightlightColor,
};
const iconStyle = {
width: '24px',
};
let iconStyle = {};
if (heightlightColor) {
const rgbaHeightlightColor = hex2rgba(
heightlightColor,
alpha
);
iconStyle = {
color: 'initial',
background: `linear-gradient(transparent 60%, ${rgbaHeightlightColor} 0)`,
};
}
const anchorRef = useAnchorRef({ ref: props.contentRef, value });
const [isAddingColor, setIsAddingColor] = useState(false);

Expand All @@ -90,18 +96,11 @@ const HighlighterEdit = (props) => {
}}
shortcutType={shortcutType}
shortcutCharacter={shortcutChar}
key={isActive ? 'text-color' : 'text-color-not-active'}
className="format-library-text-color-button"
name={isActive ? 'text-color' : undefined}
isActive={isActive}
icon={
<>
<Icon icon={Icon} style={iconStyle} />
{isActive && (
<span
className="format-library-text-color-button__indicator"
style={heightlightColorStyle}
/>
)}
<Icon icon={IconSVG} style={iconStyle} />
</>
}
/>
Expand Down