Integrate a font-size change from the playground to the Toolbarplugin
Change the font-size, $getSelectionStyleValueForProperty(selection, 'font-size', '16px') do not return the correct value of the actual font-size, but the font-size is changed correctly, so I just can not update the toolbar ui correctly
Link to code example:
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
import { useCallback, useEffect, useRef, useState } from "react";
import {
SELECTION_CHANGE_COMMAND,
FORMAT_TEXT_COMMAND,
$getSelection,
$isRangeSelection,
$createParagraphNode,
COMMAND_PRIORITY_CRITICAL,
} from "lexical";
import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
import {
$wrapNodes,
$isAtNodeEnd,
$getSelectionStyleValueForProperty,
$patchStyleText
} from "@lexical/selection";
import { $getNearestNodeOfType, mergeRegister, $findMatchingParent } from "@lexical/utils";
import {
INSERT_ORDERED_LIST_COMMAND,
INSERT_UNORDERED_LIST_COMMAND,
REMOVE_LIST_COMMAND,
$isListNode,
ListNode
} from "@lexical/list";
import { createPortal } from "react-dom";
import {
$createHeadingNode,
$createQuoteNode,
$isHeadingNode
} from "@lexical/rich-text";
import {
$createCodeNode,
$isCodeNode,
getDefaultCodeLanguage,
getCodeLanguages
} from "@lexical/code";
import DropDown, { DropDownItem } from "@/Components/DropDown";
import ColorPicker from "@/Components/ColorPicker";
Try to remove every words inside and start typing in different font size. Then, click on the words. The font size UI do not change according to actual font size of the words.
This problem happens in 0.8.0 version of lexical but not in 0.6.0 version
Lexical version: 0.8.0
Steps To Reproduce
Link to code example:
@changneng Can you provide a CodeSandbox for your issue and provide some more context around what you're trying to achieve? It's a little unclear.
https://codesandbox.io/s/cocky-grass-5pzg0b
Try to remove every words inside and start typing in different font size. Then, click on the words. The font size UI do not change according to actual font size of the words. This problem happens in 0.8.0 version of lexical but not in 0.6.0 version
This is because $getSelectionStyleValueForProperty(selection, 'font-size', '16px') do not return the correct font-size of the selection.