Skip to content

Commit

Permalink
fix(Mentions): SSR failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Carrotzpc committed Jul 29, 2024
1 parent c165ab7 commit 6af870a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Mentions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import type { EditorState } from 'lexical';
import { $getRoot, TextNode } from 'lexical';
import React, { useMemo } from 'react';

import { isBrowser } from '@/utils/tools';

import { CustomTextNode } from './plugins/custom-text/node';
import {
MentionNode,
Expand Down Expand Up @@ -97,6 +99,28 @@ export const Mentions: React.FC<MentionsProps> = ({
}, {} as MentionsOptionsMap);
}, [options]);

if (!isBrowser) {
return (
<div className={cx(styles.wrapper, wrapperClassname)}>
<div
className={cx(
{
[styles.root]: true,
[styles.filled]: variant === 'filled',
[styles.borderless]: variant === 'borderless',
[styles.disabled]: disabled,
},
className
)}
style={style || {}}
/>
<div className={styles.placeholder}>
{placeholder || `输入 ${triggers.join(' 或 ')} 插入引用`}
</div>
</div>
);
}

return (
<LexicalComposer initialConfig={{ ...initialConfig, editable }}>
<MentionsConfigProvider value={{ optionsMap }}>
Expand Down

0 comments on commit 6af870a

Please sign in to comment.