mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-11-29 10:47:56 +08:00
fix: code block disables continuous input of characters (#12)
This commit is contained in:
@@ -69,7 +69,7 @@ function MermaidChat ({ node }: {
|
||||
const isDark = useContext(ThemeModeContext)?.isDark;
|
||||
const [error, setError] = React.useState<string | null>(null);
|
||||
|
||||
const updateMermaid = useCallback(async () => {
|
||||
const updateMermaid = useCallback(async (diagram: string) => {
|
||||
const sanitizedDiagram = sanitizeDiagram(diagram);
|
||||
const theme = isDark ? darkTheme : lightTheme;
|
||||
|
||||
@@ -91,17 +91,23 @@ function MermaidChat ({ node }: {
|
||||
// @ts-ignore
|
||||
setError(e.message);
|
||||
}
|
||||
}, [diagram, id, isDark]);
|
||||
}, [id, isDark]);
|
||||
|
||||
const deboucenUpdateMermaid = useMemo(() => {
|
||||
return debounce(updateMermaid, 1000);
|
||||
}, [updateMermaid]);
|
||||
|
||||
useEffect(() => {
|
||||
void deboucenUpdateMermaid();
|
||||
}, [deboucenUpdateMermaid]);
|
||||
if (!diagram.trim()) {
|
||||
setError(null);
|
||||
setInnerHtml('');
|
||||
return;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
void deboucenUpdateMermaid(diagram);
|
||||
}, [deboucenUpdateMermaid, diagram]);
|
||||
|
||||
if (error && diagram) {
|
||||
return (
|
||||
<div
|
||||
contentEditable={false}
|
||||
@@ -121,7 +127,6 @@ function MermaidChat ({ node }: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
placeContent: 'center',
|
||||
minHeight: '250px',
|
||||
}}
|
||||
contentEditable={false}
|
||||
ref={ref}
|
||||
|
||||
@@ -331,7 +331,6 @@ const rules: Rule[] = [
|
||||
match: /--/,
|
||||
format: SpecialSymbol.EM_DASH,
|
||||
transform: (editor) => {
|
||||
|
||||
editor.delete({
|
||||
unit: 'character',
|
||||
reverse: true,
|
||||
@@ -422,6 +421,9 @@ export const applyMarkdown = (editor: YjsEditor, insertText: string): boolean =>
|
||||
}
|
||||
|
||||
} else if (rule.type === 'symbol') {
|
||||
const block = getBlockEntry(editor)[0];
|
||||
|
||||
if (block.type === BlockType.CodeBlock) return false;
|
||||
const path = selection.anchor.path;
|
||||
const text = editor.string({
|
||||
anchor: {
|
||||
|
||||
Reference in New Issue
Block a user