Lexical: Only allow headings if supported by backend

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
environments/review-lexical-ujdd17/deployments/3354
marcin mikołajczak 2023-05-08 22:03:06 +02:00
rodzic eee7534f58
commit d1c26a22ba
2 zmienionych plików z 65 dodań i 60 usunięć

Wyświetl plik

@ -71,8 +71,7 @@ const ComposeEditor = React.forwardRef<string, IComposeEditor>(({
const [suggestionsHidden, setSuggestionsHidden] = useState(true);
const initialConfig: InitialConfigType = useMemo(function() {
return {
const initialConfig: InitialConfigType = useMemo(() => ({
namespace: 'ComposeForm',
onError: console.error,
nodes,
@ -118,8 +117,7 @@ const ComposeEditor = React.forwardRef<string, IComposeEditor>(({
}
};
}),
};
}, []);
}), []);
const [floatingAnchorElem, setFloatingAnchorElem] =
useState<HTMLDivElement | null>(null);

Wyświetl plik

@ -45,6 +45,7 @@ import * as React from 'react';
import { createPortal } from 'react-dom';
import { Icon } from 'soapbox/components/ui';
import { useInstance } from 'soapbox/hooks';
import { getDOMRangeRect } from '../utils/get-dom-range-rect';
import { getSelectedNode } from '../utils/get-selected-node';
@ -104,6 +105,8 @@ const BlockTypeDropdown = ({ editor, anchorElem, blockType, icon }: {
blockType: keyof typeof blockTypeToBlockName
icon: string
}) => {
const instance = useInstance();
const [showDropDown, setShowDropDown] = useState(false);
const formatParagraph = () => {
@ -205,6 +208,8 @@ const BlockTypeDropdown = ({ editor, anchorElem, blockType, icon }: {
active={blockType === 'paragraph'}
icon={blockTypeToIcon.paragraph}
/>
{instance.pleroma.getIn(['metadata', 'markup', 'allow_headings']) === true && (
<>
<ToolbarButton
onClick={() => formatHeading('h1')}
active={blockType === 'h1'}
@ -220,6 +225,8 @@ const BlockTypeDropdown = ({ editor, anchorElem, blockType, icon }: {
active={blockType === 'h3'}
icon={blockTypeToIcon.h3}
/>
</>
)}
<ToolbarButton
onClick={formatBulletList}
active={blockType === 'bullet'}