Skip to content

The open alternative to Salesforce, designed for AI.

Restore pre-TipTap note editor spacing (#29109)

neo773a6e934e00072
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditor.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditor.tsx
index 027e05f58fc..df1d8d5f617 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditor.tsx
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditor.tsx
@@ -56,7 +56,8 @@ const StyledEditorContainer = styled.div<{
height: 100%;
line-height: var(--editor-line-height);
overflow-wrap: anywhere;
- padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
+ padding: var(--editor-padding);
+ white-space: pre-wrap;
p.is-editor-empty:first-of-type:not([data-placeholder=''])::before {
${FORM_FIELD_PLACEHOLDER_STYLES}
@@ -175,6 +176,14 @@ const StyledEditorContainer = styled.div<{
display: none;
}
+ .toggle-block[data-open='false'] > .toggle-block-content > :first-child {
+ margin-bottom: 0;
+ }
+
+ .toggle-block-content > p:first-child {
+ padding-block: max(0px, (var(--editor-toggle-row-height) - 1lh) / 2);
+ }
+
.toggle-block-add-button {
background: none;
border: none;
@@ -218,6 +227,7 @@ const StyledEditorContainer = styled.div<{
& > :is(ul, ol) {
--editor-parent-list-offset: var(--editor-list-item-offset);
+ margin-top: var(--editor-nested-list-spacing);
}
}
@@ -247,7 +257,7 @@ const StyledEditorContainer = styled.div<{
border-radius: ${themeCssVariables.border.radius.md};
margin: 0 0 var(--editor-block-spacing);
overflow-x: auto;
- padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[3]};
+ padding: var(--editor-code-block-padding);
code {
background-color: transparent;
@@ -269,6 +279,13 @@ const StyledEditorContainer = styled.div<{
user-select: none;
}
+ & > label > input {
+ height: var(--editor-task-checkbox-height);
+ margin: var(--editor-task-checkbox-margin);
+ vertical-align: var(--editor-task-checkbox-vertical-align);
+ width: var(--editor-task-checkbox-width);
+ }
+
& > div {
flex: 1 1 auto;
min-width: 0;
@@ -276,6 +293,11 @@ const StyledEditorContainer = styled.div<{
& > div > p {
margin: 0;
+ min-height: var(--editor-task-checkbox-height);
+ }
+
+ & > div > :is(ul, ol) {
+ margin-top: var(--editor-nested-list-spacing);
}
}
@@ -288,8 +310,7 @@ const StyledEditorContainer = styled.div<{
.tableWrapper {
margin: 0 0 var(--editor-block-spacing);
overflow-x: auto;
- padding: 0 ${themeCssVariables.spacing[4]} ${themeCssVariables.spacing[4]}
- 0;
+ padding: var(--editor-table-wrapper-padding);
}
table {
@@ -302,7 +323,7 @@ const StyledEditorContainer = styled.div<{
border: 1px solid ${themeCssVariables.border.color.medium};
box-sizing: border-box;
min-width: 1em;
- padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
+ padding: var(--editor-table-cell-padding);
position: relative;
vertical-align: top;
@@ -405,6 +426,13 @@ const StyledEditorContainer = styled.div<{
border-left: none;
border-right: none;
border-top: 1px solid ${themeCssVariables.border.color.medium};
+ margin: var(--editor-divider-spacing) 0;
+
+ & + .block-divider {
+ margin-top: calc(
+ 2 * var(--editor-divider-spacing) - var(--editor-block-spacing)
+ );
+ }
&.ProseMirror-selectednode {
box-shadow: 0 0 0 ${themeCssVariables.spacing[2]}
@@ -455,7 +483,7 @@ const StyledEditorContainer = styled.div<{
}
:is(h1, h2, h3, h4, h5, h6):first-child {
- margin-top: 0;
+ margin-top: var(--editor-heading-first-spacing-top);
}
:is(
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/ResizableImageView.tsx b/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/ResizableImageView.tsx
index d1440bc9d04..d1ce3d52f29 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/ResizableImageView.tsx
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/ResizableImageView.tsx
@@ -30,6 +30,7 @@ const StyledImageContainer = styled.div`
`;
const StyledImage = styled.img`
+ display: block;
height: auto;
max-width: 100%;
`;
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorProfile.ts b/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorProfile.ts
index e6083b30142..7c234c0361e 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorProfile.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorProfile.ts
@@ -4,7 +4,7 @@ import { type AnyExtension } from '@tiptap/core';
export type AdvancedTextEditorChrome = 'field' | 'document';
-export type AdvancedTextEditorVariant = 'app' | 'email';
+export type AdvancedTextEditorVariant = 'app' | 'email' | 'note' | 'widget';
export type AdvancedTextEditorProfile = {
chrome: AdvancedTextEditorChrome;
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorTypographyStyle.ts b/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorTypographyStyle.ts
index 01875d29bd7..ab454801e9f 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorTypographyStyle.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorTypographyStyle.ts
@@ -3,27 +3,105 @@ import { type CSSProperties } from 'react';
import { EMAIL_TYPOGRAPHY } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
+type AdvancedTextEditorSpacing = {
+ padding: string;
+ lineHeight: string;
+ blockSpacing: string;
+ headingLineHeight: string;
+ headingSpacingTop: string;
+ headingFirstSpacingTop: string;
+ headingSpacingBottom: string;
+ listIndent: string;
+ listItemSpacing: string;
+ nestedListSpacing: string;
+ quoteIndent: string;
+ codeBlockPadding: string;
+ dividerSpacing: string;
+ taskCheckboxMargin: string;
+ taskCheckboxWidth: string;
+ taskCheckboxHeight: string;
+ taskCheckboxVerticalAlign: string;
+ tableWrapperPadding: string;
+ tableCellPadding: string;
+ toggleRowHeight: string;
+};
+
+const DEFAULT_SPACING: AdvancedTextEditorSpacing = {
+ padding: `${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]}`,
+ lineHeight: EMAIL_TYPOGRAPHY.lineHeight,
+ blockSpacing: EMAIL_TYPOGRAPHY.blockSpacing,
+ headingLineHeight: EMAIL_TYPOGRAPHY.headingLineHeight,
+ headingSpacingTop: EMAIL_TYPOGRAPHY.headingSpacingTop,
+ headingFirstSpacingTop: '0',
+ headingSpacingBottom: EMAIL_TYPOGRAPHY.headingSpacingBottom,
+ listIndent: EMAIL_TYPOGRAPHY.listIndent,
+ listItemSpacing: EMAIL_TYPOGRAPHY.listItemSpacing,
+ nestedListSpacing: '0',
+ quoteIndent: EMAIL_TYPOGRAPHY.quoteIndent,
+ codeBlockPadding: `${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[3]}`,
+ dividerSpacing: '0.5em',
+ taskCheckboxMargin: '3px 3px 3px 4px',
+ taskCheckboxWidth: 'auto',
+ taskCheckboxHeight: 'auto',
+ taskCheckboxVerticalAlign: 'baseline',
+ tableWrapperPadding: `0 ${themeCssVariables.spacing[4]} ${themeCssVariables.spacing[4]} 0`,
+ tableCellPadding: `${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]}`,
+ toggleRowHeight: '0px',
+};
+
+const NOTE_SPACING: AdvancedTextEditorSpacing = {
+ padding: '3px 0',
+ lineHeight: '1.5',
+ blockSpacing: '6px',
+ headingLineHeight: '1.5',
+ headingSpacingTop: '21px',
+ headingFirstSpacingTop: '15px',
+ headingSpacingBottom: '6px',
+ listIndent: '24px',
+ listItemSpacing: '6px',
+ nestedListSpacing: '6px',
+ quoteIndent: '1em',
+ codeBlockPadding: '24px',
+ dividerSpacing: '12.5px',
+ taskCheckboxMargin: `0 0 0 ${themeCssVariables.spacing[1]}`,
+ taskCheckboxWidth: '12px',
+ taskCheckboxHeight: '24px',
+ taskCheckboxVerticalAlign: 'top',
+ tableWrapperPadding: '9px 22px 22px 9px',
+ tableCellPadding: '5px 10px',
+ toggleRowHeight: '24px',
+};
+
+const VARIANT_SPACING: Record<
+ AdvancedTextEditorVariant,
+ AdvancedTextEditorSpacing
+> = {
+ app: DEFAULT_SPACING,
+ email: DEFAULT_SPACING,
+ note: NOTE_SPACING,
+ widget: { ...NOTE_SPACING, lineHeight: '1.4', headingLineHeight: '1.4' },
+};
+
+const APP_TYPOGRAPHY = {
+ fontFamily: themeCssVariables.font.family,
+ fontSize: themeCssVariables.font.size.md,
+ accentColor: themeCssVariables.color.blue,
+ listMarkerColor: 'inherit',
+};
+
const VARIANT_TYPOGRAPHY: Record<
AdvancedTextEditorVariant,
- {
- fontFamily: string;
- fontSize: string;
- accentColor: string;
- listMarkerColor: string;
- }
+ typeof APP_TYPOGRAPHY
> = {
- app: {
- fontFamily: themeCssVariables.font.family,
- fontSize: themeCssVariables.font.size.md,
- accentColor: themeCssVariables.color.blue,
- listMarkerColor: 'inherit',
- },
+ app: APP_TYPOGRAPHY,
email: {
fontFamily: EMAIL_TYPOGRAPHY.fontFamily,
fontSize: EMAIL_TYPOGRAPHY.fontSize,
accentColor: EMAIL_TYPOGRAPHY.accentColor,
listMarkerColor: EMAIL_TYPOGRAPHY.accentColor,
},
+ note: APP_TYPOGRAPHY,
+ widget: APP_TYPOGRAPHY,
};
export const getAdvancedTextEditorTypographyStyle = (
@@ -31,24 +109,37 @@ export const getAdvancedTextEditorTypographyStyle = (
) => {
const { fontFamily, fontSize, accentColor, listMarkerColor } =
VARIANT_TYPOGRAPHY[variant];
+ const spacing = VARIANT_SPACING[variant];
return {
'--editor-font-family': fontFamily,
'--editor-font-size': fontSize,
'--editor-accent-color': accentColor,
'--editor-list-marker-color': listMarkerColor,
- '--editor-line-height': EMAIL_TYPOGRAPHY.lineHeight,
- '--editor-block-spacing': EMAIL_TYPOGRAPHY.blockSpacing,
+ '--editor-padding': spacing.padding,
+ '--editor-line-height': spacing.lineHeight,
+ '--editor-block-spacing': spacing.blockSpacing,
'--editor-heading-1-font-size': EMAIL_TYPOGRAPHY.headingFontSizes[1],
'--editor-heading-2-font-size': EMAIL_TYPOGRAPHY.headingFontSizes[2],
'--editor-heading-3-font-size': EMAIL_TYPOGRAPHY.headingFontSizes[3],
'--editor-heading-font-weight': EMAIL_TYPOGRAPHY.headingFontWeight,
- '--editor-heading-line-height': EMAIL_TYPOGRAPHY.headingLineHeight,
- '--editor-heading-spacing-top': EMAIL_TYPOGRAPHY.headingSpacingTop,
- '--editor-heading-spacing-bottom': EMAIL_TYPOGRAPHY.headingSpacingBottom,
- '--editor-list-indent': EMAIL_TYPOGRAPHY.listIndent,
- '--editor-list-item-spacing': EMAIL_TYPOGRAPHY.listItemSpacing,
+ '--editor-heading-line-height': spacing.headingLineHeight,
+ '--editor-heading-spacing-top': spacing.headingSpacingTop,
+ '--editor-heading-first-spacing-top': spacing.headingFirstSpacingTop,
+ '--editor-heading-spacing-bottom': spacing.headingSpacingBottom,
+ '--editor-list-indent': spacing.listIndent,
+ '--editor-list-item-spacing': spacing.listItemSpacing,
+ '--editor-nested-list-spacing': spacing.nestedListSpacing,
'--editor-quote-border-width': EMAIL_TYPOGRAPHY.quoteBorderWidth,
- '--editor-quote-indent': EMAIL_TYPOGRAPHY.quoteIndent,
+ '--editor-quote-indent': spacing.quoteIndent,
+ '--editor-code-block-padding': spacing.codeBlockPadding,
+ '--editor-divider-spacing': spacing.dividerSpacing,
+ '--editor-task-checkbox-margin': spacing.taskCheckboxMargin,
+ '--editor-task-checkbox-width': spacing.taskCheckboxWidth,
+ '--editor-task-checkbox-height': spacing.taskCheckboxHeight,
+ '--editor-task-checkbox-vertical-align': spacing.taskCheckboxVerticalAlign,
+ '--editor-table-wrapper-padding': spacing.tableWrapperPadding,
+ '--editor-table-cell-padding': spacing.tableCellPadding,
+ '--editor-toggle-row-height': spacing.toggleRowHeight,
} as CSSProperties;
};
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor.tsx
index 1c24cfef62b..447c735a9d6 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor.tsx
@@ -36,14 +36,12 @@ import { type Editor } from '@tiptap/core';
import { Key } from 'ts-key-enum';
import { isDefined } from 'twenty-shared/utils';
import { useToast } from 'twenty-ui/components/feedback';
-import { themeCssVariables } from 'twenty-ui/theme';
import { useDebouncedCallback } from 'use-debounce';
const StyledEditorContainer = styled.div`
box-sizing: border-box;
max-width: 100%;
min-width: 0;
- padding-left: ${themeCssVariables.spacing[8]};
position: relative;
width: 100%;
`;
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/constants/RichTextFieldEditorProfile.ts b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/constants/RichTextFieldEditorProfile.ts
index 159362ef53d..18f12ad74a5 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/constants/RichTextFieldEditorProfile.ts
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/constants/RichTextFieldEditorProfile.ts
@@ -5,7 +5,7 @@ import { MentionSuggestion } from '@/mention/extensions/MentionSuggestion';
export const RICH_TEXT_FIELD_EDITOR_PROFILE = {
chrome: 'document',
- variant: 'app',
+ variant: 'note',
minHeight: 400,
enableFullScreen: false,
parseLegacyDocument: parseLegacyMarkdownDocument,
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/standalone-rich-text/constants/StandaloneRichTextEditorProfile.ts b/packages/twenty-front/src/modules/page-layout/widgets/standalone-rich-text/constants/StandaloneRichTextEditorProfile.ts
index 55f3c75b2b1..b0884d1075c 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/standalone-rich-text/constants/StandaloneRichTextEditorProfile.ts
+++ b/packages/twenty-front/src/modules/page-layout/widgets/standalone-rich-text/constants/StandaloneRichTextEditorProfile.ts
@@ -4,7 +4,7 @@ import { parseLegacyMarkdownDocument } from '@/advanced-text-editor/utils/parseL
export const STANDALONE_RICH_TEXT_EDITOR_PROFILE = {
chrome: 'document',
- variant: 'app',
+ variant: 'widget',
minHeight: 0,
enableFullScreen: false,
parseLegacyDocument: parseLegacyMarkdownDocument,