Open tomdyqin opened 20 hours ago
// plate/packages/autoformat/src/lib/withAutoformat.ts
editor.insertText = (text) => {
if (!isCollapsed(editor.selection)) return insertText(text);
if (getCodeLineEntry(editor)) return insertText(text); // I'm not sure if adding this processing here is too much
for (const rule of getOptions().rules!) {
const { insertTrigger, mode = 'text', query } = rule;
if (query && !query(editor as any, { ...rule, text })) continue;
const autoformatter: Record<typeof mode, any> = {
block: autoformatBlock,
mark: autoformatMark,
text: autoformatText,
};
if (
autoformatter[mode]?.(editor, {
...(rule as any),
text,
})
) {
return insertTrigger && insertText(text);
}
}
insertText(text);
};
Description
Autoformat should not take effect within code blocks
Reproduction URL
No response
Reproduction steps
Plate version
39.2.15
Slate React version
0.110.3
Screenshots
No response
Logs
No response
Browsers
No response