|
|
|
@ -89,6 +89,19 @@ const FONT_SIZE_OPTIONS = [
|
|
|
|
// ['48px', '48px'],
|
|
|
|
// ['48px', '48px'],
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const LINE_SPACING_OPTIONS = [
|
|
|
|
|
|
|
|
['1', '1'],
|
|
|
|
|
|
|
|
['1.25', '1.25'],
|
|
|
|
|
|
|
|
['1.5', '1.5'],
|
|
|
|
|
|
|
|
['2', '2'],
|
|
|
|
|
|
|
|
['2.5', '2.5'],
|
|
|
|
|
|
|
|
['3', '3'],
|
|
|
|
|
|
|
|
// ['3.5', '3.5'],
|
|
|
|
|
|
|
|
// ['4', '4'],
|
|
|
|
|
|
|
|
// ['4.5', '4.5'],
|
|
|
|
|
|
|
|
// ['5', '5'],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const ELEMENT_FORMAT_OPTIONS = {
|
|
|
|
const ELEMENT_FORMAT_OPTIONS = {
|
|
|
|
center: { icon: 'center-align', iconRTL: 'center-align', name: 'Center Align' },
|
|
|
|
center: { icon: 'center-align', iconRTL: 'center-align', name: 'Center Align' },
|
|
|
|
end: { icon: 'right-align', iconRTL: 'left-align', name: 'End Align' },
|
|
|
|
end: { icon: 'right-align', iconRTL: 'left-align', name: 'End Align' },
|
|
|
|
@ -534,6 +547,26 @@ function BlockOptionsDropdownList({ editor, blockType, toolbarRef, setShowBlockO
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const FontDropDownMapped = {
|
|
|
|
|
|
|
|
'font-family': {
|
|
|
|
|
|
|
|
buttonAriaLabel: 'Formatting options for font family',
|
|
|
|
|
|
|
|
IconClassName: 'icon icon2 block-type font-family',
|
|
|
|
|
|
|
|
options: FONT_FAMILY_OPTIONS,
|
|
|
|
|
|
|
|
styleName: 'fontFamily',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
'font-size': {
|
|
|
|
|
|
|
|
buttonAriaLabel: 'Formatting options for font size',
|
|
|
|
|
|
|
|
IconClassName: '',
|
|
|
|
|
|
|
|
options: FONT_SIZE_OPTIONS,
|
|
|
|
|
|
|
|
styleName: 'fontSize',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
'line-height': {
|
|
|
|
|
|
|
|
buttonAriaLabel: 'Formatting options for line spacing',
|
|
|
|
|
|
|
|
IconClassName: 'icon icon2 line-height',
|
|
|
|
|
|
|
|
options: LINE_SPACING_OPTIONS,
|
|
|
|
|
|
|
|
styleName: 'lineHeight',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
function FontDropDown({ editor, value, style, disabled = false }) {
|
|
|
|
function FontDropDown({ editor, value, style, disabled = false }) {
|
|
|
|
const handleClick = useCallback(
|
|
|
|
const handleClick = useCallback(
|
|
|
|
(option) => {
|
|
|
|
(option) => {
|
|
|
|
@ -549,26 +582,23 @@ function FontDropDown({ editor, value, style, disabled = false }) {
|
|
|
|
[editor, style]
|
|
|
|
[editor, style]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const buttonAriaLabel = style === 'font-family' ? 'Formatting options for font family' : 'Formatting options for font size';
|
|
|
|
const buttonIconClassName = FontDropDownMapped[style].IconClassName;
|
|
|
|
|
|
|
|
const buttonAriaLabel = FontDropDownMapped[style].buttonAriaLabel;
|
|
|
|
|
|
|
|
const dropdownOptions = FontDropDownMapped[style].options;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<DropDown
|
|
|
|
<DropDown disabled={disabled} buttonClassName={'toolbar-item ' + style} buttonLabel={value} buttonIconClassName={buttonIconClassName} buttonAriaLabel={buttonAriaLabel}>
|
|
|
|
disabled={disabled}
|
|
|
|
{dropdownOptions.map(([option, text]) => (
|
|
|
|
buttonClassName={'toolbar-item ' + style}
|
|
|
|
|
|
|
|
buttonLabel={value}
|
|
|
|
|
|
|
|
buttonIconClassName={style === 'font-family' ? 'icon block-type font-family' : ''}
|
|
|
|
|
|
|
|
buttonAriaLabel={buttonAriaLabel}>
|
|
|
|
|
|
|
|
{(style === 'font-family' ? FONT_FAMILY_OPTIONS : FONT_SIZE_OPTIONS).map(([option, text]) => (
|
|
|
|
|
|
|
|
<DropDownItem
|
|
|
|
<DropDownItem
|
|
|
|
className={`item font-m-${option.replace(/\s+/g, '_')} ${dropDownActiveClass(value === option)} ${style === 'font-size' ? 'fontsize-item' : ''}`}
|
|
|
|
className={`item font-m-${option.replace(/\s+/g, '_')} ${dropDownActiveClass(value === option)} ${style === 'font-size' ? 'fontsize-item' : ''}`}
|
|
|
|
style={{ fontFamily: style === 'font-family' ? option : undefined, fontSize: style === 'font-size' ? option : undefined }}
|
|
|
|
style={{ fontFamily: style === 'font-family' ? option : undefined, fontSize: style === 'font-size' ? option : undefined, }}
|
|
|
|
onClick={() => handleClick(option)}
|
|
|
|
onClick={() => handleClick(option)}
|
|
|
|
key={option}>
|
|
|
|
key={option}>
|
|
|
|
<span className='text'>{text}</span>
|
|
|
|
<span className='text'>{text}</span>
|
|
|
|
</DropDownItem>
|
|
|
|
</DropDownItem>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</DropDown>
|
|
|
|
</DropDown>
|
|
|
|
);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ElementFormatDropdown({ editor, value, isRTL, disabled = false }) {
|
|
|
|
function ElementFormatDropdown({ editor, value, isRTL, disabled = false }) {
|
|
|
|
@ -673,6 +703,7 @@ export default function ToolbarPlugin() {
|
|
|
|
const [fontColor, setFontColor] = useState('#000');
|
|
|
|
const [fontColor, setFontColor] = useState('#000');
|
|
|
|
const [bgColor, setBgColor] = useState('#fff');
|
|
|
|
const [bgColor, setBgColor] = useState('#fff');
|
|
|
|
const [elementFormat, setElementFormat] = useState('left');
|
|
|
|
const [elementFormat, setElementFormat] = useState('left');
|
|
|
|
|
|
|
|
const [lineSpacing, setLineSpacing] = useState('1.5');
|
|
|
|
|
|
|
|
|
|
|
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
|
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
|
|
const [isSmallWidthViewport, setIsSmallWidthViewport] = useState(false);
|
|
|
|
const [isSmallWidthViewport, setIsSmallWidthViewport] = useState(false);
|
|
|
|
@ -760,6 +791,9 @@ export default function ToolbarPlugin() {
|
|
|
|
setFontSize(
|
|
|
|
setFontSize(
|
|
|
|
$getSelectionStyleValueForProperty(selection, 'font-size', '16px'),
|
|
|
|
$getSelectionStyleValueForProperty(selection, 'font-size', '16px'),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
setLineSpacing(
|
|
|
|
|
|
|
|
$getSelectionStyleValueForProperty(selection, 'line-height', '1.5'),
|
|
|
|
|
|
|
|
);
|
|
|
|
let matchingParent;
|
|
|
|
let matchingParent;
|
|
|
|
if ($isLinkNode(parent)) {
|
|
|
|
if ($isLinkNode(parent)) {
|
|
|
|
// If node is a link, we need to fetch the parent paragraph node to set format
|
|
|
|
// If node is a link, we need to fetch the parent paragraph node to set format
|
|
|
|
@ -896,6 +930,12 @@ export default function ToolbarPlugin() {
|
|
|
|
value={fontSize}
|
|
|
|
value={fontSize}
|
|
|
|
editor={editor}
|
|
|
|
editor={editor}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
<FontDropDown
|
|
|
|
|
|
|
|
disabled={!isEditable}
|
|
|
|
|
|
|
|
style={'line-height'}
|
|
|
|
|
|
|
|
value={lineSpacing}
|
|
|
|
|
|
|
|
editor={editor}
|
|
|
|
|
|
|
|
/>
|
|
|
|
<Divider />
|
|
|
|
<Divider />
|
|
|
|
<button type='button'
|
|
|
|
<button type='button'
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
|