This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/components/Editor/components/Paragraph.js

35 lines
760 B
JavaScript

// @flow
import React from 'react';
import { Document } from 'slate';
import type { Props } from '../types';
import Placeholder from './Placeholder';
export default function Link({
attributes,
editor,
node,
parent,
children,
readOnly,
}: Props) {
const parentIsDocument = parent instanceof Document;
const firstParagraph = parent && parent.nodes.get(1) === node;
const lastParagraph = parent && parent.nodes.last() === node;
const showPlaceholder =
!readOnly &&
parentIsDocument &&
firstParagraph &&
lastParagraph &&
!node.text;
return (
<p>
{children}
{showPlaceholder &&
<Placeholder contentEditable={false}>
{editor.props.bodyPlaceholder}
</Placeholder>}
</p>
);
}