UNPKG

@atlaskit/editor-plugin-mentions

Version:

Mentions plugin for @atlaskit/editor-core

41 lines (40 loc) 1.32 kB
import { mention } from '@atlaskit/adf-schema'; import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view'; const isSSR = Boolean(process.env.REACT_SSR); /** * Wrapper for ADF mention node spec to augment toDOM implementation * with fallback UI for lazy node view rendering / window virtualization * @nodeSpecException:toDOM patch * @returns */ export const mentionNodeSpec = () => { if (isSSR) { return mention; } return { ...mention, toDOM: node => { // packages/elements/mention/src/components/Mention/index.tsx const mentionAttrs = { 'aria-busy': 'true', contenteditable: 'false', 'data-access-level': '', 'data-mention-id': node.attrs.id, 'data-prosemirror-content-type': 'node', 'data-prosemirror-node-inline': 'true', 'data-prosemirror-node-name': 'mention', style: convertToInlineCss({ display: 'inline', border: `1px solid transparent`, background: "var(--ds-background-neutral, #0515240F)", color: "var(--ds-text-subtle, #505258)", borderRadius: '20px', cursor: 'pointer', padding: '0 0.3em 2px 0.23em', wordBreak: 'break-word' }) }; return ['span', mentionAttrs, node.attrs.text]; } }; };