Skip to content

The open alternative to Salesforce, designed for AI.

Restore pre-TipTap note editor block styles (#29113)

neo77395a4b2d156c2
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 df1d8d5f617..a82f0137dd6 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
@@ -10,7 +10,7 @@ import { FORM_FIELD_PLACEHOLDER_STYLES } from '@/ui/input/constants/FormFieldPla
import { styled } from '@linaria/react';
import { EditorContent } from '@tiptap/react';
import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { themeCssVariables, useThemeColorScheme } from 'twenty-ui/theme';
const StyledEditorContainer = styled.div<{
readonly?: boolean;
@@ -121,15 +121,15 @@ const StyledEditorContainer = styled.div<{
}
h4 {
- font-size: calc(var(--editor-font-size) * 1.15);
+ font-size: var(--editor-heading-4-font-size);
}
h5 {
- font-size: var(--editor-font-size);
+ font-size: var(--editor-heading-5-font-size);
}
h6 {
- font-size: calc(var(--editor-font-size) * 0.9);
+ font-size: var(--editor-heading-6-font-size);
}
.toggle-block {
@@ -144,16 +144,18 @@ const StyledEditorContainer = styled.div<{
background: none;
border: none;
border-radius: ${themeCssVariables.border.radius.sm};
- color: ${themeCssVariables.font.color.tertiary};
+ color: var(--editor-toggle-icon-color);
cursor: pointer;
display: inline-block;
line-height: var(--editor-line-height);
padding: 0;
&::before {
- border-bottom: ${themeCssVariables.spacing[1]} solid transparent;
- border-left: ${themeCssVariables.spacing['1.5']} solid currentColor;
- border-top: ${themeCssVariables.spacing[1]} solid transparent;
+ border-bottom: calc(var(--editor-toggle-icon-size) / 2) solid
+ transparent;
+ border-left: calc(var(--editor-toggle-icon-size) * 0.75) solid
+ currentColor;
+ border-top: calc(var(--editor-toggle-icon-size) / 2) solid transparent;
content: '';
display: inline-block;
transition: transform
@@ -229,12 +231,49 @@ const StyledEditorContainer = styled.div<{
--editor-parent-list-offset: var(--editor-list-item-offset);
margin-top: var(--editor-nested-list-spacing);
}
+
+ & :is(ul, ol) {
+ position: relative;
+
+ &::after {
+ border-left: 1px solid var(--editor-guide-color);
+ bottom: 0;
+ content: '';
+ left: calc(
+ ${themeCssVariables.spacing[1]} - var(--editor-list-indent)
+ );
+ position: absolute;
+ top: 0;
+ }
+ }
+ }
+
+ [data-indent] {
+ position: relative;
+
+ &::after {
+ background-image: repeating-linear-gradient(
+ to right,
+ transparent 0 ${themeCssVariables.spacing[1]},
+ var(--editor-guide-color) ${themeCssVariables.spacing[1]}
+ calc(${themeCssVariables.spacing[1]} + 1px),
+ transparent calc(${themeCssVariables.spacing[1]} + 1px)
+ var(--editor-list-indent)
+ );
+ bottom: 0;
+ content: '';
+ left: calc(-1 * var(--editor-indent) * var(--editor-list-indent));
+ position: absolute;
+ top: 0;
+ width: calc(var(--editor-indent) * var(--editor-list-indent));
+ }
}
blockquote {
border-left: var(--editor-quote-border-width) solid
var(--editor-accent-color);
- font-style: italic;
+ color: var(--editor-quote-color);
+ font-style: var(--editor-quote-font-style);
margin: 0 0 var(--editor-block-spacing);
padding-left: var(--editor-quote-indent);
}
@@ -253,14 +292,16 @@ const StyledEditorContainer = styled.div<{
}
pre {
- background-color: ${themeCssVariables.background.transparent.lighter};
+ background-color: var(--editor-code-block-background);
border-radius: ${themeCssVariables.border.radius.md};
+ color: var(--editor-code-block-color);
margin: 0 0 var(--editor-block-spacing);
overflow-x: auto;
padding: var(--editor-code-block-padding);
code {
background-color: transparent;
+ font-size: var(--editor-code-block-font-size);
padding: 0;
}
}
@@ -302,7 +343,7 @@ const StyledEditorContainer = styled.div<{
}
li[data-checked='true'] > div {
- color: ${themeCssVariables.font.color.tertiary};
+ color: var(--editor-task-checked-color);
text-decoration: line-through;
}
}
@@ -425,7 +466,7 @@ const StyledEditorContainer = styled.div<{
border-bottom: none;
border-left: none;
border-right: none;
- border-top: 1px solid ${themeCssVariables.border.color.medium};
+ border-top: 1px solid var(--editor-divider-color);
margin: var(--editor-divider-spacing) 0;
& + .block-divider {
@@ -536,6 +577,7 @@ export const AdvancedTextEditor = ({
minHeight,
variant,
}: AdvancedTextEditorProps) => {
+ const colorScheme = useThemeColorScheme();
const hasTextBubbleMenu = TEXT_BUBBLE_MENU_EXTENSION_NAMES.some(
(extensionName) => hasEditorExtension(editor, extensionName),
);
@@ -554,7 +596,7 @@ export const AdvancedTextEditor = ({
<StyledEditorContainer
readonly={readonly}
minHeight={minHeight}
- style={getAdvancedTextEditorTypographyStyle(variant)}
+ style={getAdvancedTextEditorTypographyStyle(variant, colorScheme)}
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
>
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/indent/Indent.ts b/packages/twenty-front/src/modules/advanced-text-editor/extensions/indent/Indent.ts
index d274024a2e1..bcc15b038b7 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/extensions/indent/Indent.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/indent/Indent.ts
@@ -86,7 +86,7 @@ export const Indent = Extension.create({
? {
'data-indent': indent,
style: doNotTranslate(
- `margin-left: calc(${indent} * var(--editor-list-indent))`,
+ `--editor-indent: ${indent}; margin-left: calc(var(--editor-indent) * var(--editor-list-indent))`,
),
}
: {};
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 ab454801e9f..10d61ae607a 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
@@ -82,46 +82,116 @@ const VARIANT_SPACING: Record<
widget: { ...NOTE_SPACING, lineHeight: '1.4', headingLineHeight: '1.4' },
};
-const APP_TYPOGRAPHY = {
+type AdvancedTextEditorTypography = {
+ fontFamily: string;
+ fontSize: string;
+ accentColor: string;
+ listMarkerColor: string;
+ headingFontSizes: Record<1 | 2 | 3 | 4 | 5 | 6, string>;
+ quoteColor: string;
+ quoteFontStyle: string;
+ codeBlockBackground: Record<'light' | 'dark', string>;
+ codeBlockColor: Record<'light' | 'dark', string>;
+ codeBlockFontSize: string;
+ dividerColor: string;
+ guideColor: string;
+ toggleIconColor: string;
+ toggleIconSize: string;
+ taskCheckedColor: string;
+};
+
+const APP_TYPOGRAPHY: AdvancedTextEditorTypography = {
fontFamily: themeCssVariables.font.family,
fontSize: themeCssVariables.font.size.md,
accentColor: themeCssVariables.color.blue,
listMarkerColor: 'inherit',
+ headingFontSizes: {
+ ...EMAIL_TYPOGRAPHY.headingFontSizes,
+ 4: 'calc(var(--editor-font-size) * 1.15)',
+ 5: 'var(--editor-font-size)',
+ 6: 'calc(var(--editor-font-size) * 0.9)',
+ },
+ quoteColor: 'inherit',
+ quoteFontStyle: 'italic',
+ codeBlockBackground: {
+ light: themeCssVariables.background.transparent.lighter,
+ dark: themeCssVariables.background.transparent.lighter,
+ },
+ codeBlockColor: { light: 'inherit', dark: 'inherit' },
+ codeBlockFontSize: '0.9em',
+ dividerColor: themeCssVariables.border.color.medium,
+ guideColor: 'transparent',
+ toggleIconColor: themeCssVariables.font.color.tertiary,
+ toggleIconSize: themeCssVariables.spacing[2],
+ taskCheckedColor: themeCssVariables.font.color.tertiary,
+};
+
+const NOTE_TYPOGRAPHY: AdvancedTextEditorTypography = {
+ ...APP_TYPOGRAPHY,
+ accentColor: themeCssVariables.font.color.secondary,
+ headingFontSizes: {
+ 1: '3em',
+ 2: '2em',
+ 3: '1.3em',
+ 4: '1em',
+ 5: '0.9em',
+ 6: '0.8em',
+ },
+ quoteColor: themeCssVariables.font.color.secondary,
+ quoteFontStyle: 'normal',
+ codeBlockBackground: {
+ light: themeCssVariables.background.primaryInverted,
+ dark: themeCssVariables.background.primary,
+ },
+ codeBlockColor: {
+ light: themeCssVariables.font.color.inverted,
+ dark: themeCssVariables.font.color.primary,
+ },
+ codeBlockFontSize: '1em',
+ dividerColor: themeCssVariables.font.color.secondary,
+ guideColor: themeCssVariables.border.color.strong,
+ toggleIconColor: themeCssVariables.font.color.primary,
+ toggleIconSize: '10.5px',
+ taskCheckedColor: 'inherit',
};
const VARIANT_TYPOGRAPHY: Record<
AdvancedTextEditorVariant,
- typeof APP_TYPOGRAPHY
+ AdvancedTextEditorTypography
> = {
app: APP_TYPOGRAPHY,
email: {
+ ...APP_TYPOGRAPHY,
fontFamily: EMAIL_TYPOGRAPHY.fontFamily,
fontSize: EMAIL_TYPOGRAPHY.fontSize,
accentColor: EMAIL_TYPOGRAPHY.accentColor,
listMarkerColor: EMAIL_TYPOGRAPHY.accentColor,
},
- note: APP_TYPOGRAPHY,
- widget: APP_TYPOGRAPHY,
+ note: NOTE_TYPOGRAPHY,
+ widget: NOTE_TYPOGRAPHY,
};
export const getAdvancedTextEditorTypographyStyle = (
variant: AdvancedTextEditorVariant,
+ colorScheme: 'light' | 'dark',
) => {
- const { fontFamily, fontSize, accentColor, listMarkerColor } =
- VARIANT_TYPOGRAPHY[variant];
+ const typography = 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-font-family': typography.fontFamily,
+ '--editor-font-size': typography.fontSize,
+ '--editor-accent-color': typography.accentColor,
+ '--editor-list-marker-color': typography.listMarkerColor,
'--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-1-font-size': typography.headingFontSizes[1],
+ '--editor-heading-2-font-size': typography.headingFontSizes[2],
+ '--editor-heading-3-font-size': typography.headingFontSizes[3],
+ '--editor-heading-4-font-size': typography.headingFontSizes[4],
+ '--editor-heading-5-font-size': typography.headingFontSizes[5],
+ '--editor-heading-6-font-size': typography.headingFontSizes[6],
'--editor-heading-font-weight': EMAIL_TYPOGRAPHY.headingFontWeight,
'--editor-heading-line-height': spacing.headingLineHeight,
'--editor-heading-spacing-top': spacing.headingSpacingTop,
@@ -132,12 +202,23 @@ export const getAdvancedTextEditorTypographyStyle = (
'--editor-nested-list-spacing': spacing.nestedListSpacing,
'--editor-quote-border-width': EMAIL_TYPOGRAPHY.quoteBorderWidth,
'--editor-quote-indent': spacing.quoteIndent,
+ '--editor-quote-color': typography.quoteColor,
+ '--editor-quote-font-style': typography.quoteFontStyle,
+ '--editor-code-block-background':
+ typography.codeBlockBackground[colorScheme],
+ '--editor-code-block-color': typography.codeBlockColor[colorScheme],
+ '--editor-code-block-font-size': typography.codeBlockFontSize,
+ '--editor-divider-color': typography.dividerColor,
+ '--editor-guide-color': typography.guideColor,
+ '--editor-toggle-icon-color': typography.toggleIconColor,
+ '--editor-toggle-icon-size': typography.toggleIconSize,
'--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-task-checked-color': typography.taskCheckedColor,
'--editor-table-wrapper-padding': spacing.tableWrapperPadding,
'--editor-table-cell-padding': spacing.tableCellPadding,
'--editor-toggle-row-height': spacing.toggleRowHeight,