fix: Move references spacing directly below content (#1113)
* fix: Move references spacing directly below content * Child document -> Nested document
This commit is contained in:
@ -17,6 +17,7 @@ import embeds from '../../embeds';
|
|||||||
type Props = {
|
type Props = {
|
||||||
defaultValue?: string,
|
defaultValue?: string,
|
||||||
readOnly?: boolean,
|
readOnly?: boolean,
|
||||||
|
grow?: boolean,
|
||||||
disableEmbeds?: boolean,
|
disableEmbeds?: boolean,
|
||||||
forwardedRef: React.Ref<RichMarkdownEditor>,
|
forwardedRef: React.Ref<RichMarkdownEditor>,
|
||||||
ui: UiStore,
|
ui: UiStore,
|
||||||
@ -103,6 +104,7 @@ class Editor extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const StyledEditor = styled(RichMarkdownEditor)`
|
const StyledEditor = styled(RichMarkdownEditor)`
|
||||||
|
flex-grow: ${props => (props.grow ? 'initial' : '0')};
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
|
@ -188,9 +188,9 @@ class DocumentMenu extends React.Component<Props> {
|
|||||||
{can.update && (
|
{can.update && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={this.handleNewChild}
|
onClick={this.handleNewChild}
|
||||||
title="Create a new child document for the current document"
|
title="Create a nested document inside the current document"
|
||||||
>
|
>
|
||||||
New child document
|
New nested document
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
)}
|
)}
|
||||||
{can.update && (
|
{can.update && (
|
||||||
|
@ -49,7 +49,7 @@ class NewChildDocumentMenu extends React.Component<Props> {
|
|||||||
</span>
|
</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem onClick={this.handleNewChild}>
|
<DropdownMenuItem onClick={this.handleNewChild}>
|
||||||
New child document
|
New nested document
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
);
|
);
|
||||||
|
@ -52,6 +52,19 @@ export default class Document extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
get isOnlyTitle(): boolean {
|
||||||
|
const { title } = parseTitle(this.text);
|
||||||
|
|
||||||
|
// find and extract title
|
||||||
|
const trimmedBody = this.text
|
||||||
|
.trim()
|
||||||
|
.replace(/^#/, '')
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
return unescape(trimmedBody) === title;
|
||||||
|
}
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
get modifiedSinceViewed(): boolean {
|
get modifiedSinceViewed(): boolean {
|
||||||
return !!this.lastViewedAt && this.lastViewedAt < this.updatedAt;
|
return !!this.lastViewedAt && this.lastViewedAt < this.updatedAt;
|
||||||
|
@ -440,7 +440,11 @@ class DocumentScene extends React.Component<Props> {
|
|||||||
schema={schema}
|
schema={schema}
|
||||||
/>
|
/>
|
||||||
{!this.isEditing &&
|
{!this.isEditing &&
|
||||||
!isShare && <References document={document} />}
|
!isShare && (
|
||||||
|
<ReferencesWrapper isOnlyTitle={document.isOnlyTitle}>
|
||||||
|
<References document={document} />
|
||||||
|
</ReferencesWrapper>
|
||||||
|
)}
|
||||||
</MaxWidth>
|
</MaxWidth>
|
||||||
</Container>
|
</Container>
|
||||||
</Container>
|
</Container>
|
||||||
@ -450,6 +454,10 @@ class DocumentScene extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ReferencesWrapper = styled('div')`
|
||||||
|
margin-top: ${props => (props.isOnlyTitle ? -45 : 16)}px;
|
||||||
|
`;
|
||||||
|
|
||||||
const MaxWidth = styled(Flex)`
|
const MaxWidth = styled(Flex)`
|
||||||
${props =>
|
${props =>
|
||||||
props.archived && `* { color: ${props.theme.textSecondary} !important; } `};
|
props.archived && `* { color: ${props.theme.textSecondary} !important; } `};
|
||||||
|
@ -34,12 +34,10 @@ class DocumentEditor extends React.Component<Props> {
|
|||||||
<Editor
|
<Editor
|
||||||
ref={ref => (this.editor = ref)}
|
ref={ref => (this.editor = ref)}
|
||||||
plugins={plugins}
|
plugins={plugins}
|
||||||
|
grow={!readOnly}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
/>
|
/>
|
||||||
<ClickablePadding
|
{!readOnly && <ClickablePadding onClick={this.focusAtEnd} grow />}
|
||||||
onClick={!readOnly ? this.focusAtEnd : undefined}
|
|
||||||
grow
|
|
||||||
/>
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class References extends React.Component<Props> {
|
|||||||
<Tabs>
|
<Tabs>
|
||||||
{showChildren && (
|
{showChildren && (
|
||||||
<Tab to="#children" isActive={() => !isBacklinksTab}>
|
<Tab to="#children" isActive={() => !isBacklinksTab}>
|
||||||
Child documents
|
Nested documents
|
||||||
</Tab>
|
</Tab>
|
||||||
)}
|
)}
|
||||||
{showBacklinks && (
|
{showBacklinks && (
|
||||||
|
@ -51,7 +51,7 @@ class DocumentDelete extends React.Component<Props> {
|
|||||||
<HelpText>
|
<HelpText>
|
||||||
Are you sure about that? Deleting the{' '}
|
Are you sure about that? Deleting the{' '}
|
||||||
<strong>{document.title}</strong> document will delete all of its
|
<strong>{document.title}</strong> document will delete all of its
|
||||||
history, and any child documents.
|
history, and any nested documents.
|
||||||
</HelpText>
|
</HelpText>
|
||||||
{!document.isDraft &&
|
{!document.isDraft &&
|
||||||
!document.isArchived && (
|
!document.isArchived && (
|
||||||
|
@ -439,7 +439,7 @@ export default function Api() {
|
|||||||
|
|
||||||
<Method method="documents.archive" label="Archive a document">
|
<Method method="documents.archive" label="Archive a document">
|
||||||
<Description>
|
<Description>
|
||||||
Archive a document and all of its child documents, if any.
|
Archive a document and all of its nested documents, if any.
|
||||||
</Description>
|
</Description>
|
||||||
<Arguments>
|
<Arguments>
|
||||||
<Argument
|
<Argument
|
||||||
@ -452,7 +452,7 @@ export default function Api() {
|
|||||||
|
|
||||||
<Method method="documents.delete" label="Delete a document">
|
<Method method="documents.delete" label="Delete a document">
|
||||||
<Description>
|
<Description>
|
||||||
Permanantly delete a document and all of its child documents, if
|
Permanantly delete a document and all of its nested documents, if
|
||||||
any.
|
any.
|
||||||
</Description>
|
</Description>
|
||||||
<Arguments>
|
<Arguments>
|
||||||
|
Reference in New Issue
Block a user