diff --git a/app/components/ClickablePadding.ts b/app/components/ClickablePadding.ts index f6d681b2a..bfbd31298 100644 --- a/app/components/ClickablePadding.ts +++ b/app/components/ClickablePadding.ts @@ -1,6 +1,9 @@ import styled from "styled-components"; -const ClickablePadding = styled.div<{ grow?: boolean; minHeight?: string }>` +const ClickablePadding = styled.div<{ + grow?: boolean; + minHeight?: React.CSSProperties["paddingBottom"]; +}>` min-height: ${(props) => props.minHeight || "50vh"}; flex-grow: 100; cursor: text; diff --git a/app/components/Editor.tsx b/app/components/Editor.tsx index af0917678..b0e8235dd 100644 --- a/app/components/Editor.tsx +++ b/app/components/Editor.tsx @@ -47,7 +47,7 @@ export type Props = Optional< onHeadingsChange?: (headings: Heading[]) => void; onSynced?: () => Promise; onPublish?: (event: React.MouseEvent) => any; - bottomPadding?: string; + editorStyle?: React.CSSProperties; }; function Editor(props: Props, ref: React.RefObject | null) { @@ -340,12 +340,12 @@ function Editor(props: Props, ref: React.RefObject | null) { placeholder={props.placeholder || ""} defaultValue={props.defaultValue || ""} /> - {props.bottomPadding && !props.readOnly && ( + {props.editorStyle?.paddingBottom && !props.readOnly && ( )} {activeLinkElement && !shareId && ( diff --git a/app/editor/index.tsx b/app/editor/index.tsx index e3ed3ce68..f8965cee1 100644 --- a/app/editor/index.tsx +++ b/app/editor/index.tsx @@ -127,8 +127,10 @@ export type Props = { /** Callback when a toast message is triggered (eg "link copied") */ onShowToast: (message: string) => void; className?: string; - /** Optional style overrides */ + /** Optional style overrides for the container*/ style?: React.CSSProperties; + /** Optional style overrides for the contenteeditable */ + editorStyle?: React.CSSProperties; }; type State = { @@ -759,6 +761,7 @@ export class Editor extends React.PureComponent< readOnly={readOnly} readOnlyWriteCheckboxes={readOnlyWriteCheckboxes} focusedCommentId={this.props.focusedCommentId} + editorStyle={this.props.editorStyle} ref={this.elementRef} /> {!readOnly && this.view && ( diff --git a/app/scenes/Document/components/Editor.tsx b/app/scenes/Document/components/Editor.tsx index 810b15dec..02b18c96f 100644 --- a/app/scenes/Document/components/Editor.tsx +++ b/app/scenes/Document/components/Editor.tsx @@ -25,7 +25,7 @@ import EditableTitle from "./EditableTitle"; const extensions = withComments(richExtensions); -type Props = Omit & { +type Props = Omit & { onChangeTitle: (text: string) => void; id: string; document: Document; @@ -189,12 +189,18 @@ function DocumentEditor(props: Props, ref: React.RefObject) { : undefined } onDeleteCommentMark={ - team?.getPreference(TeamPreference.Commenting) + team?.getPreference(TeamPreference.Commenting) && can.comment ? handleRemoveComment : undefined } extensions={extensions} - bottomPadding={`calc(50vh - ${childRef.current?.offsetHeight || 0}px)`} + editorStyle={{ + padding: "0 60px", + margin: "0 -60px", + paddingBottom: `calc(50vh - ${ + childRef.current?.offsetHeight || 0 + }px)`, + }} {...rest} />
{children}
diff --git a/shared/editor/components/Styles.ts b/shared/editor/components/Styles.ts index fdcfd4e50..0d11d4f17 100644 --- a/shared/editor/components/Styles.ts +++ b/shared/editor/components/Styles.ts @@ -7,6 +7,7 @@ export type Props = { rtl: boolean; readOnly?: boolean; readOnlyWriteCheckboxes?: boolean; + editorStyle?: React.CSSProperties; grow?: boolean; theme: DefaultTheme; }; @@ -143,6 +144,8 @@ width: 100%; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ + padding: ${props.editorStyle?.padding ?? "initial"}; + margin: ${props.editorStyle?.margin ?? "initial"}; & > .ProseMirror-yjs-cursor { display: none;