Skip to content
2 changes: 2 additions & 0 deletions src/plugins/common/react/ReactPlainText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const ReactPlainText = memo<ReactPlainTextProps>(
onCompositionEnd,
onContextMenu,
onTextChange,
spellCheck,
}) => {
const isChat = variant === 'chat';
const {
Expand Down Expand Up @@ -243,6 +244,7 @@ const ReactPlainText = memo<ReactPlainTextProps>(
onContextMenu={handleContextMenu}
onFocus={handleFocus}
ref={editorContainerRef}
spellCheck={spellCheck}
/>
<Placeholder lineEmptyPlaceholder={lineEmptyPlaceholder} style={style}>
{placeholder}
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/common/react/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export interface ReactPlainTextProps {
* @default true
*/
pasteVSCodeAsCodeBlock?: boolean;
/**
* Controls the spellCheck attribute on the contentEditable div.
* Setting to false also suppresses Safari/WebKit inline predictive text (Apple Intelligence).
* Consumers that don't want spellcheck (e.g. chat input) should pass spellCheck={false} explicitly.
*/
spellCheck?: boolean;
style?: CSSProperties;
theme?: CommonPluginOptions['theme'] & {
fontSize?: number;
Expand Down
74 changes: 74 additions & 0 deletions src/react/Editor/demos/spellCheck.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Editor, useEditor } from '@lobehub/editor/react';
import { createStaticStyles } from 'antd-style';
import { type FC } from 'react';

const styles = createStaticStyles(({ css }) => ({
container: css`
display: flex;
gap: 16px;
padding: 16px;
`,
editor: css`
min-height: 120px;
padding: 12px;
border: 1px solid #d9d9d9;
border-radius: 6px;
`,
label: css`
margin-bottom: 8px;
font-size: 12px;
font-weight: 500;
opacity: 0.6;
`,
wrapper: css`
flex: 1;
`,
}));

const SpellCheckOn: FC = () => {
const editor = useEditor();
return (
<div className={styles.wrapper}>
<div className={styles.label}>{'spellCheck={true}'} (browser default)</div>
<Editor
autoFocus
className={styles.editor}
content={''}
editor={editor}
placeholder={'Type here β€” browser spellcheck & Safari predictive text active...'}
spellCheck={true}
type={'text'}
variant={'chat'}
/>
</div>
);
};

const SpellCheckOff: FC = () => {
const editor = useEditor();
return (
<div className={styles.wrapper}>
<div className={styles.label}>{'spellCheck={false}'} (recommended for chat input)</div>
<Editor
className={styles.editor}
content={''}
editor={editor}
placeholder={'Type here β€” spellcheck & Safari predictive text suppressed...'}
spellCheck={false}
type={'text'}
variant={'chat'}
/>
</div>
);
};

const Demo: FC = () => {
return (
<div className={styles.container}>
<SpellCheckOn />
<SpellCheckOff />
</div>
);
};

export default Demo;
9 changes: 9 additions & 0 deletions src/react/Editor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ Force all pasted content to be inserted as plain text, stripping any rich text f

<code src="./demos/pasteAsPlainText.tsx" nopadding iframe></code>


## spellCheck β€” Suppress Safari Inline Predictive Text

Setting `spellCheck={false}` on the editor disables OS-level spellcheck and suppresses
Safari/WebKit inline predictive text (Apple Intelligence). This is recommended for chat
input surfaces where the editor provides its own autocomplete.

<code src="./demos/spellCheck.tsx" nopadding></code>

## APIs

### Editor
Expand Down
Loading