diff --git a/public/images/icons/line-height.svg b/public/images/icons/line-height.svg
new file mode 100644
index 0000000..5d45061
--- /dev/null
+++ b/public/images/icons/line-height.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/LexicalEditor/plugins/ToolbarPlugin.jsx b/src/components/LexicalEditor/plugins/ToolbarPlugin.jsx
index c9a1cc4..e1469a3 100644
--- a/src/components/LexicalEditor/plugins/ToolbarPlugin.jsx
+++ b/src/components/LexicalEditor/plugins/ToolbarPlugin.jsx
@@ -89,6 +89,19 @@ const FONT_SIZE_OPTIONS = [
// ['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 = {
center: { icon: 'center-align', iconRTL: 'center-align', name: 'Center 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 }) {
const handleClick = useCallback(
(option) => {
@@ -549,26 +582,23 @@ function FontDropDown({ editor, value, style, disabled = false }) {
[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 (
-
- {(style === 'font-family' ? FONT_FAMILY_OPTIONS : FONT_SIZE_OPTIONS).map(([option, text]) => (
+
+ {dropdownOptions.map(([option, text]) => (
handleClick(option)}
key={option}>
{text}
))}
- );
+ )
}
function ElementFormatDropdown({ editor, value, isRTL, disabled = false }) {
@@ -673,6 +703,7 @@ export default function ToolbarPlugin() {
const [fontColor, setFontColor] = useState('#000');
const [bgColor, setBgColor] = useState('#fff');
const [elementFormat, setElementFormat] = useState('left');
+ const [lineSpacing, setLineSpacing] = useState('1.5');
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
const [isSmallWidthViewport, setIsSmallWidthViewport] = useState(false);
@@ -760,6 +791,9 @@ export default function ToolbarPlugin() {
setFontSize(
$getSelectionStyleValueForProperty(selection, 'font-size', '16px'),
);
+ setLineSpacing(
+ $getSelectionStyleValueForProperty(selection, 'line-height', '1.5'),
+ );
let matchingParent;
if ($isLinkNode(parent)) {
// 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}
editor={editor}
/>
+