mirror of https://github.com/fantasticit/think.git
improve get fontSize
This commit is contained in:
parent
210adf583b
commit
5a1a5c7c1a
|
@ -9,9 +9,14 @@ export const FONT_SIZES = [12, 13, 14, 15, 16, 19, 22, 24, 29, 32, 40, 48];
|
||||||
|
|
||||||
export const FontSize: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const FontSize: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
const isTitleActive = useActive(editor, Title.name);
|
const isTitleActive = useActive(editor, Title.name);
|
||||||
const currentFontSize = useAttributes(editor, 'textStyle', { fontSize: '16px' }, (attrs) =>
|
const currentFontSize = useAttributes(editor, 'textStyle', { fontSize: '16px' }, (attrs) => {
|
||||||
attrs.fontSize.replace('px', '')
|
if (!attrs || !attrs.fontSize) return 16;
|
||||||
);
|
|
||||||
|
const matches = attrs.fontSize.match(/\d+/);
|
||||||
|
|
||||||
|
if (!matches || !matches[0]) return 16;
|
||||||
|
return matches[0];
|
||||||
|
});
|
||||||
|
|
||||||
const toggle = useCallback(
|
const toggle = useCallback(
|
||||||
(val) => {
|
(val) => {
|
||||||
|
|
Loading…
Reference in New Issue