Skip to content

The open alternative to Salesforce, designed for AI.

Drag and drop blocks in the campaign editor (#26812)

neo773efa17a3fa591
diff --git a/packages/twenty-emails/src/utils/email-renderer/nodes/heading.tsx b/packages/twenty-emails/src/utils/email-renderer/nodes/heading.tsx
index bae9569dc56..55e0ffca4dc 100644
--- a/packages/twenty-emails/src/utils/email-renderer/nodes/heading.tsx
+++ b/packages/twenty-emails/src/utils/email-renderer/nodes/heading.tsx
@@ -2,6 +2,7 @@ import { Heading } from 'react-email';
import { type JSONContent } from '@tiptap/core';
import { type ReactNode } from 'react';
import { mappedNodeContent } from 'src/utils/email-renderer/renderers/render-node';
+import { blockStyle } from 'src/utils/email-renderer/utils/block-style';
import { type InheritedTypography } from 'src/utils/email-renderer/utils/inherited-typography';
import { isDefined } from 'twenty-shared/utils';
@@ -34,7 +35,14 @@ export const heading = (
const { fontSize: _inheritedFontSize, ...inheritedWithoutSize } = inherited;
return (
- <Heading as={element} style={{ fontSize, ...inheritedWithoutSize }}>
+ <Heading
+ as={element}
+ style={{
+ fontSize,
+ ...inheritedWithoutSize,
+ ...blockStyle(node.attrs?.style),
+ }}
+ >
{content}
</Heading>
);
diff --git a/packages/twenty-emails/src/utils/email-renderer/nodes/paragraph.tsx b/packages/twenty-emails/src/utils/email-renderer/nodes/paragraph.tsx
index 86dcd61120e..3e5e8b2196b 100644
--- a/packages/twenty-emails/src/utils/email-renderer/nodes/paragraph.tsx
+++ b/packages/twenty-emails/src/utils/email-renderer/nodes/paragraph.tsx
@@ -2,6 +2,7 @@ import { Text } from 'react-email';
import { type JSONContent } from '@tiptap/core';
import { type ReactNode } from 'react';
import { mappedNodeContent } from 'src/utils/email-renderer/renderers/render-node';
+import { blockStyle } from 'src/utils/email-renderer/utils/block-style';
import { type InheritedTypography } from 'src/utils/email-renderer/utils/inherited-typography';
export const paragraph = (
@@ -12,7 +13,13 @@ export const paragraph = (
return (
<Text
- style={{ lineHeight: '1.5', margin: '0', padding: '0', ...inherited }}
+ style={{
+ lineHeight: '1.5',
+ margin: '0',
+ padding: '0',
+ ...inherited,
+ ...blockStyle(node.attrs?.style),
+ }}
>
{content.length === 0 ? <>&nbsp;</> : content}
</Text>
diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.json
index eb6a9879836..fafe7745b36 100644
--- a/packages/twenty-front/package.json
+++ b/packages/twenty-front/package.json
@@ -63,19 +63,24 @@
"@stripe/stripe-js": "^9.8.0",
"@tiptap/core": "3.30.5",
"@tiptap/extension-bold": "3.30.5",
+ "@tiptap/extension-collaboration": "3.30.5",
"@tiptap/extension-document": "3.30.5",
+ "@tiptap/extension-drag-handle": "3.30.5",
+ "@tiptap/extension-drag-handle-react": "3.30.5",
"@tiptap/extension-hard-break": "3.30.5",
"@tiptap/extension-heading": "3.30.5",
"@tiptap/extension-image": "3.30.5",
"@tiptap/extension-italic": "3.30.5",
"@tiptap/extension-link": "3.30.5",
"@tiptap/extension-list": "3.30.5",
+ "@tiptap/extension-node-range": "3.30.5",
"@tiptap/extension-paragraph": "3.30.5",
"@tiptap/extension-strike": "3.30.5",
"@tiptap/extension-text": "3.30.5",
"@tiptap/extension-underline": "3.30.5",
"@tiptap/extensions": "3.30.5",
"@tiptap/react": "3.30.5",
+ "@tiptap/y-tiptap": "^3.0.7",
"@xyflow/react": "^12.4.2",
"ai": "7.0.103",
"apollo-link-rest": "^0.10.0-rc.2",
diff --git a/packages/twenty-front/src/modules/activities/emails/components/CampaignBodyField.tsx b/packages/twenty-front/src/modules/activities/emails/components/CampaignBodyField.tsx
index 5daf1dafba0..51b70f5ea45 100644
--- a/packages/twenty-front/src/modules/activities/emails/components/CampaignBodyField.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/components/CampaignBodyField.tsx
@@ -1,18 +1,15 @@
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { type Editor } from '@tiptap/core';
-import { useCallback, useState } from 'react';
-import { isDefined } from 'twenty-shared/utils';
+import { useCallback } from 'react';
import { useCampaignBodyState } from '@/activities/emails/hooks/useCampaignBodyState';
-import { useCampaignEmailEditorVariables } from '@/activities/emails/hooks/useCampaignEmailEditorVariables';
import { EmailEditorCanvas } from '@/activities/emails/editor/components/EmailEditorCanvas';
import { CAMPAIGN_BODY_EDITOR_PROFILE } from '@/activities/emails/editor/constants/CampaignBodyEditorProfile';
import { useUploadEmailImage } from '@/activities/emails/hooks/useUploadEmailImage';
import { activeEmailEditorState } from '@/activities/emails/states/activeEmailEditorState';
import { type MessageCampaign } from '@/activities/emails/types/MessageCampaign';
import { FormAdvancedTextFieldInput } from '@/advanced-text-editor/components/FormAdvancedTextFieldInput';
-import { AdvancedTextEditorInsertRail } from '@/advanced-text-editor/components/AdvancedTextEditorInsertRail';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
const StyledContainer = styled.div`
@@ -20,7 +17,6 @@ const StyledContainer = styled.div`
flex: 1;
flex-direction: column;
min-height: 0;
- position: relative;
`;
type CampaignBodyFieldProps = {
@@ -39,14 +35,10 @@ export const CampaignBodyField = ({
});
const setActiveEmailEditor = useSetAtomState(activeEmailEditorState);
const { uploadEmailImage } = useUploadEmailImage();
- const { variables } = useCampaignEmailEditorVariables();
-
- const [bodyEditor, setBodyEditor] = useState<Editor | null>(null);
const handleEditorReady = useCallback(
(editor: Editor | null) => {
setActiveEmailEditor(editor);
- setBodyEditor(editor);
onEditorReady?.(editor);
},
[setActiveEmailEditor, onEditorReady],
@@ -64,13 +56,6 @@ export const CampaignBodyField = ({
onEditorReady={handleEditorReady}
onImageUpload={uploadEmailImage}
/>
- {isDefined(bodyEditor) && (
- <AdvancedTextEditorInsertRail
- editor={bodyEditor}
- onImageUpload={uploadEmailImage}
- variables={variables}
- />
- )}
</StyledContainer>
);
};
diff --git a/packages/twenty-front/src/modules/activities/emails/editor/components/EmailEditorCanvas.tsx b/packages/twenty-front/src/modules/activities/emails/editor/components/EmailEditorCanvas.tsx
index 505c4698af9..93b8d9301fc 100644
--- a/packages/twenty-front/src/modules/activities/emails/editor/components/EmailEditorCanvas.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/editor/components/EmailEditorCanvas.tsx
@@ -1,7 +1,10 @@
import { AdvancedTextEditor } from '@/advanced-text-editor/components/AdvancedTextEditor';
+import { AdvancedTextEditorBlockHandle } from '@/advanced-text-editor/components/AdvancedTextEditorBlockHandle';
+import { useOpenEmailBlockStyleInSidePanel } from '@/side-panel/hooks/useOpenEmailBlockStyleInSidePanel';
import { useLiveEditorState } from '@/advanced-text-editor/hooks/useLiveEditorState';
import { type AdvancedTextEditorComponentProps } from '@/advanced-text-editor/types/AdvancedTextEditorComponentProps';
import { styled } from '@linaria/react';
+import { type MouseEvent } from 'react';
import { CANVAS_THEME_DEFAULTS, resolveCanvasTheme } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -26,7 +29,9 @@ const StyledCanvasPage = styled.div`
.tiptap {
color: inherit;
- padding: 0;
+ margin-left: calc(-1 * ${themeCssVariables.spacing[10]});
+ padding: 0 0 0 ${themeCssVariables.spacing[10]};
+ width: calc(100% + ${themeCssVariables.spacing[10]});
}
`;
@@ -41,6 +46,19 @@ export const EmailEditorCanvas = ({
resolveCanvasTheme(currentEditor.state.doc.attrs.canvasTheme),
);
const canvasTheme = storedCanvasTheme ?? CANVAS_THEME_DEFAULTS;
+ const {
+ openEmailBlockStyleInSidePanel,
+ followEmailBlockSelectionInSidePanel,
+ } = useOpenEmailBlockStyleInSidePanel();
+
+ const handleCanvasClick = (event: MouseEvent<HTMLDivElement>) => {
+ if (
+ event.target instanceof Node &&
+ editor.view.dom.contains(event.target)
+ ) {
+ followEmailBlockSelectionInSidePanel(editor);
+ }
+ };
return (
<StyledCanvasBackdrop
@@ -50,6 +68,7 @@ export const EmailEditorCanvas = ({
}}
>
<StyledCanvasPage
+ onClick={handleCanvasClick}
style={{
backgroundColor: canvasTheme.bodyBackground || undefined,
border:
@@ -68,6 +87,10 @@ export const EmailEditorCanvas = ({
readonly={readonly}
minHeight={minHeight}
/>
+ <AdvancedTextEditorBlockHandle
+ editor={editor}
+ onOpenBlockSettings={openEmailBlockStyleInSidePanel}
+ />
</StyledCanvasPage>
</StyledCanvasBackdrop>
);
diff --git a/packages/twenty-front/src/modules/activities/emails/editor/constants/CampaignBodyEditorProfile.ts b/packages/twenty-front/src/modules/activities/emails/editor/constants/CampaignBodyEditorProfile.ts
index a6a30008112..20c291dae8f 100644
--- a/packages/twenty-front/src/modules/activities/emails/editor/constants/CampaignBodyEditorProfile.ts
+++ b/packages/twenty-front/src/modules/activities/emails/editor/constants/CampaignBodyEditorProfile.ts
@@ -1,5 +1,6 @@
import { EmailThemedDocument } from '@/activities/emails/editor/extensions/EmailThemedDocument';
import { CampaignVariableTag } from '@/activities/emails/editor/extensions/campaign-variables/CampaignVariableTag';
+import { BlockDragAndDrop } from '@/advanced-text-editor/extensions/BlockDragAndDrop';
import { ADVANCED_TEXT_EDITOR_BLOCK_EXTENSIONS } from '@/advanced-text-editor/constants/AdvancedTextEditorBlockExtensions';
import { type AdvancedTextEditorProfile } from '@/advanced-text-editor/types/AdvancedTextEditorProfile';
import { buildFullRichTextExtensions } from '@/advanced-text-editor/utils/buildFullRichTextExtensions';
@@ -13,5 +14,6 @@ export const CAMPAIGN_BODY_EDITOR_PROFILE = {
...buildFullRichTextExtensions(context),
CampaignVariableTag,
...ADVANCED_TEXT_EDITOR_BLOCK_EXTENSIONS,
+ BlockDragAndDrop,
],
} satisfies AdvancedTextEditorProfile;
diff --git a/packages/twenty-front/src/modules/activities/emails/editor/extensions/EmailThemedDocument.ts b/packages/twenty-front/src/modules/activities/emails/editor/extensions/EmailThemedDocument.ts
index 6d805c50224..0a15cd7b1de 100644
--- a/packages/twenty-front/src/modules/activities/emails/editor/extensions/EmailThemedDocument.ts
+++ b/packages/twenty-front/src/modules/activities/emails/editor/extensions/EmailThemedDocument.ts
@@ -1,4 +1,5 @@
import { Document } from '@tiptap/extension-document';
+import { Plugin, PluginKey } from '@tiptap/pm/state';
import {
EMAIL_DOCUMENT_SCHEMA_VERSION,
CANVAS_THEME_DEFAULTS,
@@ -15,4 +16,15 @@ export const EmailThemedDocument = Document.extend({
},
};
},
+
+ addProseMirrorPlugins() {
+ return [
+ new Plugin({
+ key: new PluginKey('emailCanvasLightColorScheme'),
+ props: {
+ attributes: { class: 'light' },
+ },
+ }),
+ ];
+ },
});
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 cec9efe9272..937f1e4aae6 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
@@ -22,9 +22,20 @@ const StyledEditorContainer = styled.div<{
flex-grow: 1;
height: 100%;
min-height: ${({ minHeight }) => minHeight}px;
+ position: relative;
width: 100%;
}
+ .drop-cursor {
+ background-color: ${themeCssVariables.color.blue};
+ border-radius: ${themeCssVariables.border.radius.pill};
+ transition-duration: calc(
+ ${themeCssVariables.animation.duration.fast} * 1s
+ );
+ transition-property: left, top, width, height;
+ transition-timing-function: ease-out;
+ }
+
.tiptap {
border: none !important;
box-sizing: border-box;
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorBlockHandle.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorBlockHandle.tsx
new file mode 100644
index 00000000000..2ea30720160
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorBlockHandle.tsx
@@ -0,0 +1,155 @@
+import { AdvancedTextEditorBlockHandleMenu } from '@/advanced-text-editor/components/AdvancedTextEditorBlockHandleMenu';
+import { AdvancedTextEditorDragPreview } from '@/advanced-text-editor/components/AdvancedTextEditorDragPreview';
+import { getAdvancedTextEditorBlockDisplay } from '@/advanced-text-editor/utils/getAdvancedTextEditorBlockDisplay';
+import { offset } from '@floating-ui/react';
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { type Editor } from '@tiptap/core';
+import {
+ DragHandle,
+ type DragHandleProps,
+} from '@tiptap/extension-drag-handle-react';
+import { type CSSProperties, useRef, useState } from 'react';
+import { createPortal } from 'react-dom';
+import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const DRAG_HANDLE_OPTIONS: Pick<
+ DragHandleProps,
+ 'nested' | 'computePositionConfig'
+> = {
+ nested: {
+ edgeDetection: 'none',
+ rules: [
+ {
+ id: 'excludeColumn',
+ evaluate: ({ node }) =>
+ node.type.name === TIPTAP_NODE_TYPES.COLUMN ? 1000 : 0,
+ },
+ ],
+ },
+ computePositionConfig: { middleware: [offset(8)] },
+};
+
+const StyledHandleSlot = styled.div`
+ align-items: center;
+ display: flex;
+ height: ${themeCssVariables.spacing[6]};
+ justify-content: center;
+ width: ${themeCssVariables.spacing[6]};
+`;
+
+const StyledBlockOutline = styled.div`
+ border-radius: ${themeCssVariables.border.radius.sm};
+ outline: 1px solid ${themeCssVariables.border.color.blue};
+ outline-offset: ${themeCssVariables.spacing[1]};
+ pointer-events: none;
+ position: absolute;
+`;
+
+type HoveredBlock = {
+ pos: number;
+ display: ReturnType<typeof getAdvancedTextEditorBlockDisplay>;
+ outline: CSSProperties;
+};
+
+type AdvancedTextEditorBlockHandleProps = {
+ editor: Editor;
+ onOpenBlockSettings?: () => void;
+};
+
+export const AdvancedTextEditorBlockHandle = ({
+ editor,
+ onOpenBlockSettings,
+}: AdvancedTextEditorBlockHandleProps) => {
+ const { i18n } = useLingui();
+ const dragPreviewRef = useRef<HTMLDivElement>(null);
+ const [hoveredBlock, setHoveredBlock] = useState<HoveredBlock | null>(null);
+ const outlineContainer = editor.view.dom.parentElement;
+
+ const handleNodeChange = ({ pos }: { pos: number }) => {
+ const blockElement = pos >= 0 ? editor.view.nodeDOM(pos) : null;
+
+ if (
+ !(blockElement instanceof HTMLElement) ||
+ !isDefined(outlineContainer)
+ ) {
+ setHoveredBlock(null);
+ return;
+ }
+
+ const blockRect = blockElement.getBoundingClientRect();
+ const containerRect = outlineContainer.getBoundingClientRect();
+
+ setHoveredBlock({
+ pos,
+ display: getAdvancedTextEditorBlockDisplay(editor.state.doc, pos),
+ outline: {
+ top: blockRect.top - containerRect.top,
+ left: blockRect.left - containerRect.left,
+ width: blockRect.width,
+ height: blockRect.height,
+ },
+ });
+ };
+
+ const handleMenuOpenChange = (isOpen: boolean) =>
+ editor.view.dispatch(editor.state.tr.setMeta('lockDragHandle', isOpen));
+
+ const replaceDragImageAfterDragHandle = () =>
+ document.addEventListener(
+ 'dragstart',
+ (event) => {
+ const dragPreview = dragPreviewRef.current;
+
+ if (isDefined(dragPreview)) {
+ event.dataTransfer?.setDragImage(
+ dragPreview,
+ 0,
+ dragPreview.offsetHeight / 2,
+ );
+ }
+ },
+ { once: true },
+ );
+
+ return (
+ <>
+ <DragHandle
+ editor={editor}
+ nested={DRAG_HANDLE_OPTIONS.nested}
+ computePositionConfig={DRAG_HANDLE_OPTIONS.computePositionConfig}
+ onNodeChange={handleNodeChange}
+ onElementDragStart={replaceDragImageAfterDragHandle}
+ onElementDragEnd={() => {
+ editor.view.dragging = null;
+ setHoveredBlock(null);
+ }}
+ >
+ <StyledHandleSlot>
+ {isDefined(hoveredBlock) && (
+ <>
+ <AdvancedTextEditorBlockHandleMenu
+ editor={editor}
+ blockPos={hoveredBlock.pos}
+ onOpenChange={handleMenuOpenChange}
+ onOpenBlockSettings={onOpenBlockSettings}
+ />
+ <AdvancedTextEditorDragPreview
+ ref={dragPreviewRef}
+ Icon={hoveredBlock.display.icon}
+ label={i18n._(hoveredBlock.display.title)}
+ />
+ </>
+ )}
+ </StyledHandleSlot>
+ </DragHandle>
+ {isDefined(hoveredBlock) &&
+ isDefined(outlineContainer) &&
+ createPortal(
+ <StyledBlockOutline style={hoveredBlock.outline} />,
+ outlineContainer,
+ )}
+ </>
+ );
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorBlockHandleMenu.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorBlockHandleMenu.tsx
new file mode 100644
index 00000000000..9031bfd59f2
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorBlockHandleMenu.tsx
@@ -0,0 +1,118 @@
+import { isAdvancedTextEditorBlockNodeType } from '@/advanced-text-editor/types/AdvancedTextEditorBlockCatalog';
+import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
+import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';
+import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
+import { useLingui } from '@lingui/react/macro';
+import { type Editor } from '@tiptap/core';
+import { useId } from 'react';
+import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
+import { Dropdown, LightIconButton } from 'twenty-ui/components';
+import {
+ IconAdjustments,
+ IconCopy,
+ IconGripVertical,
+ IconPlus,
+ IconTrash,
+} from 'twenty-ui/icon';
+
+type AdvancedTextEditorBlockHandleMenuProps = {
+ editor: Editor;
+ blockPos: number;
+ onOpenChange: (isOpen: boolean) => void;
+ onOpenBlockSettings?: () => void;
+};
+
+export const AdvancedTextEditorBlockHandleMenu = ({
+ editor,
+ blockPos,
+ onOpenChange,
+ onOpenBlockSettings,
+}: AdvancedTextEditorBlockHandleMenuProps) => {
+ const { t } = useLingui();
+ const instanceId = useId();
+ const blockNode = editor.state.doc.nodeAt(blockPos);
+
+ if (!isDefined(blockNode)) {
+ return null;
+ }
+
+ const blockEnd = blockPos + blockNode.nodeSize;
+ const hasBlockSettings =
+ isDefined(onOpenBlockSettings) &&
+ isAdvancedTextEditorBlockNodeType(blockNode.type.name);
+
+ const handleAddBlock = () =>
+ editor
+ .chain()
+ .insertContentAt(blockEnd, { type: TIPTAP_NODE_TYPES.PARAGRAPH })
+ .setTextSelection(blockEnd + 1)
+ .insertContent('/')
+ .focus(null, { scrollIntoView: false })
+ .run();
+
+ const handleDuplicate = () =>
+ editor.chain().insertContentAt(blockEnd, blockNode.toJSON()).run();
+
+ const handleOpenBlockSettings = () => {
+ editor.chain().setNodeSelection(blockPos).run();
+ onOpenBlockSettings?.();
+ };
+
+ const handleDelete = () =>
+ editor.chain().deleteRange({ from: blockPos, to: blockEnd }).run();
+
+ return (
+ <DropdownRoot
+ dropdownId={`advanced-text-editor-block-handle-${instanceId}`}
+ type="menu"
+ onOpenChange={onOpenChange}
+ >
+ <Dropdown.Trigger
+ render={
+ <LightIconButton
+ size="sm"
+ emphasis="subtle"
+ aria-label={t`Drag to move, click for options`}
+ >
+ <IconGripVertical />
+ </LightIconButton>
+ }
+ />
+ <DropdownContent
+ side="bottom"
+ align="start"
+ width={GenericDropdownContentWidth.Narrow}
+ >
+ <Dropdown.Section>
+ <Dropdown.ActionItem
+ startIcon={<IconPlus />}
+ onClick={handleAddBlock}
+ >
+ {t`Add block`}
+ </Dropdown.ActionItem>
+ <Dropdown.ActionItem
+ startIcon={<IconCopy />}
+ onClick={handleDuplicate}
+ >
+ {t`Duplicate`}
+ </Dropdown.ActionItem>
+ {hasBlockSettings && (
+ <Dropdown.ActionItem
+ startIcon={<IconAdjustments />}
+ onClick={handleOpenBlockSettings}
+ >
+ {t`Style`}
+ </Dropdown.ActionItem>
+ )}
+ <Dropdown.ActionItem
+ color="danger"
+ startIcon={<IconTrash />}
+ onClick={handleDelete}
+ >
+ {t`Delete`}
+ </Dropdown.ActionItem>
+ </Dropdown.Section>
+ </DropdownContent>
+ </DropdownRoot>
+ );
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorDragPreview.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorDragPreview.tsx
new file mode 100644
index 00000000000..0736e4c2ab9
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorDragPreview.tsx
@@ -0,0 +1,71 @@
+import { styled } from '@linaria/react';
+import { type Ref } from 'react';
+import { createPortal } from 'react-dom';
+import { type IconComponent, IconPlus } from 'twenty-ui/icon';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
+
+const StyledDragPreview = styled.div`
+ align-items: center;
+ backdrop-filter: ${themeCssVariables.blur.strong};
+ background-color: ${themeCssVariables.tooltip.background};
+ border-radius: ${themeCssVariables.border.radius.md};
+ color: ${themeCssVariables.tooltip.color};
+ display: inline-flex;
+ font-family: ${themeCssVariables.font.family};
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ gap: ${themeCssVariables.spacing[1]};
+ left: -10000px;
+ padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
+ pointer-events: none;
+ position: fixed;
+ top: 0;
+ white-space: nowrap;
+
+ &[data-insertion='true'] {
+ padding-left: ${themeCssVariables.spacing[1]};
+ }
+`;
+
+const StyledInsertionBadge = styled.span`
+ align-items: center;
+ background-color: ${themeCssVariables.color.blue};
+ border-radius: ${themeCssVariables.border.radius.rounded};
+ display: inline-flex;
+ height: 16px;
+ justify-content: center;
+ width: 16px;
+`;
+
+type AdvancedTextEditorDragPreviewProps = {
+ Icon: IconComponent;
+ label: string;
+ isInsertion?: boolean;
+ ref: Ref<HTMLDivElement>;
+};
+
+export const AdvancedTextEditorDragPreview = ({
+ Icon,
+ label,
+ isInsertion = false,
+ ref,
+}: AdvancedTextEditorDragPreviewProps) => {
+ const theme = useTheme();
+
+ return createPortal(
+ <StyledDragPreview
+ ref={ref}
+ aria-hidden
+ data-insertion={String(isInsertion)}
+ >
+ {isInsertion && (
+ <StyledInsertionBadge>
+ <IconPlus size={10} stroke={theme.icon.stroke.lg} />
+ </StyledInsertionBadge>
+ )}
+ <Icon size={theme.icon.size.sm} stroke={theme.icon.stroke.sm} />
+ {label}
+ </StyledDragPreview>,
+ document.body,
+ );
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorDraggableContent.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorDraggableContent.tsx
new file mode 100644
index 00000000000..7defaa7e632
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorDraggableContent.tsx
@@ -0,0 +1,68 @@
+import { AdvancedTextEditorDragPreview } from '@/advanced-text-editor/components/AdvancedTextEditorDragPreview';
+import { ADVANCED_TEXT_EDITOR_EXTERNAL_DRAG_MIME_TYPE } from '@/advanced-text-editor/constants/AdvancedTextEditorExternalDragMimeType';
+import { type Editor, type JSONContent } from '@tiptap/core';
+import { Fragment, Slice } from '@tiptap/pm/model';
+import { type DragEvent, type ReactNode, useRef } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { type IconComponent } from 'twenty-ui/icon';
+
+type AdvancedTextEditorDraggableContentProps = {
+ editor: Editor;
+ content: JSONContent;
+ Icon: IconComponent;
+ label: string;
+ children: ReactNode;
+};
+
+export const AdvancedTextEditorDraggableContent = ({
+ editor,
+ content,
+ Icon,
+ label,
+ children,
+}: AdvancedTextEditorDraggableContentProps) => {
+ const dragPreviewRef = useRef<HTMLDivElement>(null);
+
+ const handleDragStart = (event: DragEvent<HTMLDivElement>) => {
+ event.dataTransfer.setData(
+ ADVANCED_TEXT_EDITOR_EXTERNAL_DRAG_MIME_TYPE,
+ '',
+ );
+ event.dataTransfer.effectAllowed = 'copy';
+
+ if (isDefined(dragPreviewRef.current)) {
+ event.dataTransfer.setDragImage(
+ dragPreviewRef.current,
+ 0,
+ dragPreviewRef.current.offsetHeight / 2,
+ );
+ }
+
+ editor.view.dragging = {
+ slice: new Slice(
+ Fragment.from(editor.schema.nodeFromJSON(content)),
+ 0,
+ 0,
+ ),
+ move: false,
+ };
+ };
+
+ return (
+ <div
+ draggable
+ onDragStart={handleDragStart}
+ onDragEnd={() => {
+ editor.view.dragging = null;
+ }}
+ >
+ {children}
+ <AdvancedTextEditorDragPreview
+ ref={dragPreviewRef}
+ isInsertion
+ Icon={Icon}
+ label={label}
+ />
+ </div>
+ );
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorInsertRail.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorInsertRail.tsx
deleted file mode 100644
index dd9b63a7505..00000000000
--- a/packages/twenty-front/src/modules/advanced-text-editor/components/AdvancedTextEditorInsertRail.tsx
+++ /dev/null
@@ -1,340 +0,0 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
-import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
-import { styled } from '@linaria/react';
-import { useLingui } from '@lingui/react/macro';
-import { type Editor } from '@tiptap/core';
-import { useRef, useState } from 'react';
-import { EMAIL_IMAGE_MIME_TYPES } from 'twenty-shared/constants';
-import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
-import {
- IconH1,
- IconH2,
- IconH3,
- IconLayoutGrid,
- IconList,
- IconListNumbers,
- IconPhoto,
- IconTypography,
- IconVariable,
-} from 'twenty-ui/icon';
-import { Button } from 'twenty-ui/primitives/input';
-import { LightIconButton } from 'twenty-ui/components';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-import { ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES } from '@/advanced-text-editor/constants/AdvancedTextEditorBlockInsertionRecipes';
-import { type UploadedImage } from '@/advanced-text-editor/types/UploadedImage';
-import { hasEditorExtension } from '@/advanced-text-editor/utils/hasEditorExtension';
-import { TextInput } from '@/ui/input/components/TextInput';
-
-const StyledRail = styled.div`
- align-items: center;
- backdrop-filter: blur(20px);
- background-color: ${themeCssVariables.background.primary};
- border: 1px solid ${themeCssVariables.border.color.medium};
- border-radius: ${themeCssVariables.border.radius.pill};
- box-shadow:
- 0px 2px 4px 0px ${themeCssVariables.background.transparent.light},
- 0px 0px 4px 0px ${themeCssVariables.background.transparent.medium};
- corner-shape: round;
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[2]};
- padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[1]};
-`;
-
-const StyledRailContainer = styled.div`
- left: ${themeCssVariables.spacing[3]};
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- z-index: 1;
-`;
-
-const StyledPopover = styled.div`
- background-color: ${themeCssVariables.background.primary};
- border: 1px solid ${themeCssVariables.border.color.medium};
- border-radius: ${themeCssVariables.border.radius.md};
- box-shadow:
- 0px 2px 4px 0px ${themeCssVariables.background.transparent.light},
- 0px 0px 4px 0px ${themeCssVariables.background.transparent.medium};
- left: calc(100% + ${themeCssVariables.spacing[2]});
- max-height: 320px;
- min-width: 180px;
- overflow-y: auto;
- padding: ${themeCssVariables.spacing[1]};
- position: absolute;
- top: 0;
-`;
-
-const StyledImageForm = styled.div`
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[2]};
- padding: ${themeCssVariables.spacing[1]};
- width: 220px;
-`;
-
-const StyledVariableLiteral = styled.span`
- font-family: ${themeCssVariables.code.font.family};
- font-size: ${themeCssVariables.font.size.sm};
-`;
-
-const StyledImageHint = styled.div`
- color: ${themeCssVariables.font.color.tertiary};
- font-size: ${themeCssVariables.font.size.xs};
-`;
-
-type AdvancedTextEditorInsertRailProps = {
- editor: Editor;
- onImageUpload?: (file: File) => Promise<UploadedImage>;
- variables?: Array<{ label: string; value: string }>;
-};
-
-export const AdvancedTextEditorInsertRail = ({
- editor,
- onImageUpload,
- variables = [],
-}: AdvancedTextEditorInsertRailProps) => {
- const { i18n, t } = useLingui();
- const imageFileInputRef = useRef<HTMLInputElement>(null);
- const [isUploadingImage, setIsUploadingImage] = useState(false);
- const [openMenu, setOpenMenu] = useState<
- 'text' | 'image' | 'blocks' | 'variables' | null
- >(null);
- const [imageUrl, setImageUrl] = useState('');
-
- const hasVariables =
- variables.length > 0 && hasEditorExtension(editor, 'variableTag');
-
- const insertVariable = (value: string) => {
- editor.chain().focus().insertVariableTag(value).run();
- setOpenMenu(null);
- };
-
- const insertAtEnd = (content: object) => {
- editor
- .chain()
- .insertContentAt(editor.state.doc.content.size, content)
- .focus('end')
- .scrollIntoView()
- .run();
- setOpenMenu(null);
- };
-
- const listItemJson = () => ({
- type: TIPTAP_NODE_TYPES.LIST_ITEM,
- content: [{ type: TIPTAP_NODE_TYPES.PARAGRAPH }],
- });
-
- const textItems = [
- {
- Icon: IconTypography,
- label: t`Text`,
- content: { type: TIPTAP_NODE_TYPES.PARAGRAPH },
- },
- {
- Icon: IconH1,
- label: t`Title`,
- content: { type: TIPTAP_NODE_TYPES.HEADING, attrs: { level: 1 } },
- },
- {
- Icon: IconH2,
- label: t`Subtitle`,
- content: { type: TIPTAP_NODE_TYPES.HEADING, attrs: { level: 2 } },
- },
- {
- Icon: IconH3,
- label: t`Heading`,
- content: { type: TIPTAP_NODE_TYPES.HEADING, attrs: { level: 3 } },
- },
- {
- Icon: IconList,
- label: t`Bullet list`,
- content: {
- type: TIPTAP_NODE_TYPES.BULLET_LIST,
- content: [listItemJson()],
- },
- },
- {
- Icon: IconListNumbers,
- label: t`Numbered list`,
- content: {
- type: TIPTAP_NODE_TYPES.ORDERED_LIST,
- content: [listItemJson()],
- },
- },
- ];
-
- const handleFilePicked = async (file: File | undefined) => {
- if (!isDefined(file) || !isDefined(onImageUpload)) {
- return;
- }
-
- setIsUploadingImage(true);
-
- try {
- const uploadedImage = await onImageUpload(file);
-
- insertAtEnd({
- type: TIPTAP_NODE_TYPES.IMAGE,
- attrs: {
- fileId: uploadedImage.fileId ?? null,
- src: uploadedImage.url,
- },
- });
- } catch {
- } finally {
- setIsUploadingImage(false);
- }
- };
-
- const handleInsertImage = () => {
- if (imageUrl.trim() === '') {
- return;
- }
-
- insertAtEnd({
- type: TIPTAP_NODE_TYPES.IMAGE,
- attrs: { src: imageUrl.trim() },
- });
- setImageUrl('');
- };
-
- const blockItems = ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.map(
- ({ createContent, icon, id, title }) => ({
- id,
- Icon: icon,
- label: i18n._(title),
- content: createContent((message) => i18n._(message)),
- }),
- );
-
- return (
- <StyledRailContainer>
- <input
- ref={imageFileInputRef}
- type="file"
- accept={EMAIL_IMAGE_MIME_TYPES.join(',')}
- hidden
- onChange={(event) => {
- void handleFilePicked(event.target.files?.[0]);
- event.target.value = '';
- }}
- />
- <StyledRail>
- <LightIconButton
- size="md"
- emphasis={openMenu === 'text' ? 'standard' : 'subtle'}
- title={t`Text`}
- onClick={() => setOpenMenu(openMenu === 'text' ? null : 'text')}
- aria-label={t`Text`}
- >
- <IconTypography />
- </LightIconButton>
- <LightIconButton
- size="md"
- emphasis={openMenu === 'image' ? 'standard' : 'subtle'}
- title={isUploadingImage ? t`Uploading...` : t`Image`}
- disabled={isUploadingImage}
- onClick={() => {
- if (isDefined(onImageUpload)) {
- imageFileInputRef.current?.click();
- return;
- }
-
- setOpenMenu(openMenu === 'image' ? null : 'image');
- }}
- aria-label={isUploadingImage ? t`Uploading...` : t`Image`}
- >
- <IconPhoto />
- </LightIconButton>
- <LightIconButton
- size="md"
- emphasis={openMenu === 'blocks' ? 'standard' : 'subtle'}
- title={t`Blocks`}
- onClick={() => setOpenMenu(openMenu === 'blocks' ? null : 'blocks')}
- aria-label={t`Blocks`}
- >
- <IconLayoutGrid />
- </LightIconButton>
- {hasVariables && (
- <LightIconButton
- size="md"
- emphasis={openMenu === 'variables' ? 'standard' : 'subtle'}
- title={t`Variables`}
- onClick={() =>
- setOpenMenu(openMenu === 'variables' ? null : 'variables')
- }
- aria-label={t`Variables`}
- >
- <IconVariable />
- </LightIconButton>
- )}
- </StyledRail>
- {openMenu === 'variables' && (
- <StyledPopover>
- {variables.map(({ label, value }) => (
- <ListItem
- key={value}
- description={label}
- onClick={() => insertVariable(value)}
- >
- <StyledVariableLiteral>{value}</StyledVariableLiteral>
- </ListItem>
- ))}
- </StyledPopover>
- )}
- {openMenu === 'text' && (
- <StyledPopover>
- {textItems.map(({ Icon, label, content }) => (
- <ListItem
- key={label}
- startIcon={<SelectOptionIcon Icon={Icon} />}
- onClick={() => insertAtEnd(content)}
- >
- {label}
- </ListItem>
- ))}
- </StyledPopover>
- )}
- {openMenu === 'blocks' && (
- <StyledPopover>
- {blockItems.map(({ Icon, id, label, content }) => (
- <ListItem
- key={id}
- startIcon={<SelectOptionIcon Icon={Icon} />}
- onClick={() => insertAtEnd(content)}
- >
- {label}
- </ListItem>
- ))}
- </StyledPopover>
- )}
- {openMenu === 'image' && (
- <StyledPopover>
- <StyledImageForm>
- <TextInput
- value={imageUrl}
- onChange={setImageUrl}
- placeholder={t`Image URL`}
- fullWidth
- autoFocus
- onKeyDown={(event) => {
- if (event.key === 'Enter') {
- handleInsertImage();
- }
- }}
- />
- <StyledImageHint>
- {t`Paste a link to a hosted image`}
- </StyledImageHint>
- <Button
- size="sm"
- onClick={handleInsertImage}
- >{t`Insert image`}</Button>
- </StyledImageForm>
- </StyledPopover>
- )}
- </StyledRailContainer>
- );
-};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockCatalog.ts b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockCatalog.ts
index 38e65ce4409..34feef009b1 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockCatalog.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockCatalog.ts
@@ -3,6 +3,7 @@ import {
createParagraphBlockContent,
} from '@/advanced-text-editor/constants/AdvancedTextEditorBlockContent';
import { getAdvancedTextEditorContainerAppearanceSettings } from '@/advanced-text-editor/constants/getAdvancedTextEditorContainerAppearanceSettings';
+import { getAdvancedTextEditorTextBlockSettings } from '@/advanced-text-editor/constants/getAdvancedTextEditorTextBlockSettings';
import { getAdvancedTextEditorTypographySettings } from '@/advanced-text-editor/constants/getAdvancedTextEditorTypographySettings';
import { ButtonNode } from '@/advanced-text-editor/extensions/blocks/ButtonNode';
import { ColumnNode } from '@/advanced-text-editor/extensions/blocks/ColumnNode';
@@ -10,6 +11,7 @@ import { ColumnsNode } from '@/advanced-text-editor/extensions/blocks/ColumnsNod
import { DividerNode } from '@/advanced-text-editor/extensions/blocks/DividerNode';
import { HtmlNode } from '@/advanced-text-editor/extensions/blocks/HtmlNode';
import { SectionNode } from '@/advanced-text-editor/extensions/blocks/SectionNode';
+import { TextBlockStyle } from '@/advanced-text-editor/extensions/blocks/TextBlockStyle';
import {
type AdvancedTextEditorBlockDefinition,
type AdvancedTextEditorBlockNodeType,
@@ -21,11 +23,27 @@ import {
IconClick,
IconCode,
IconColumns,
+ IconH1,
IconMinus,
IconPhoto,
+ IconPilcrow,
} from 'twenty-ui/icon';
export const ADVANCED_TEXT_EDITOR_BLOCK_CATALOG = {
+ [TIPTAP_NODE_TYPES.PARAGRAPH]: {
+ label: msg`Text`,
+ icon: IconPilcrow,
+ extension: TextBlockStyle,
+ insertionRecipes: [],
+ settingsFields: getAdvancedTextEditorTextBlockSettings(),
+ },
+ [TIPTAP_NODE_TYPES.HEADING]: {
+ label: msg`Heading`,
+ icon: IconH1,
+ extension: null,
+ insertionRecipes: [],
+ settingsFields: getAdvancedTextEditorTextBlockSettings(),
+ },
[TIPTAP_NODE_TYPES.SECTION]: {
label: msg`Section`,
icon: IconBox,
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockContent.ts b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockContent.ts
index f3b42c735fb..8d7d7023321 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockContent.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorBlockContent.ts
@@ -5,6 +5,26 @@ export function createParagraphBlockContent(): JSONContent {
return { type: TIPTAP_NODE_TYPES.PARAGRAPH };
}
+export function createHeadingBlockContent(level: 1 | 2 | 3): JSONContent {
+ return { type: TIPTAP_NODE_TYPES.HEADING, attrs: { level } };
+}
+
+export function createListBlockContent(
+ listType:
+ | typeof TIPTAP_NODE_TYPES.BULLET_LIST
+ | typeof TIPTAP_NODE_TYPES.ORDERED_LIST,
+): JSONContent {
+ return {
+ type: listType,
+ content: [
+ {
+ type: TIPTAP_NODE_TYPES.LIST_ITEM,
+ content: [createParagraphBlockContent()],
+ },
+ ],
+ };
+}
+
export function createColumnBlockContent(): JSONContent {
return {
type: TIPTAP_NODE_TYPES.COLUMN,
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorCoreExtensions.ts b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorCoreExtensions.ts
index 5bf9300671b..ffc848be4a1 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorCoreExtensions.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorCoreExtensions.ts
@@ -23,5 +23,5 @@ export const buildAdvancedTextEditorCoreExtensions = ({
keepMarks: false,
}),
UndoRedo,
- Dropcursor,
+ Dropcursor.configure({ color: false, width: 2, class: 'drop-cursor' }),
];
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorExternalDragMimeType.ts b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorExternalDragMimeType.ts
new file mode 100644
index 00000000000..3d2b2f7f1be
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorExternalDragMimeType.ts
@@ -0,0 +1,2 @@
+export const ADVANCED_TEXT_EDITOR_EXTERNAL_DRAG_MIME_TYPE =
+ 'application/x-twenty-editor-content';
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorTextInsertionItems.ts b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorTextInsertionItems.ts
new file mode 100644
index 00000000000..460dd1c0a10
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/constants/AdvancedTextEditorTextInsertionItems.ts
@@ -0,0 +1,58 @@
+import {
+ createHeadingBlockContent,
+ createListBlockContent,
+ createParagraphBlockContent,
+} from '@/advanced-text-editor/constants/AdvancedTextEditorBlockContent';
+import { type AdvancedTextEditorBlockInsertionItem } from '@/advanced-text-editor/types/AdvancedTextEditorBlockCatalog';
+import { msg } from '@lingui/core/macro';
+import { TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
+import {
+ IconH1,
+ IconH2,
+ IconH3,
+ IconList,
+ IconListNumbers,
+ IconPilcrow,
+} from 'twenty-ui/icon';
+
+export const ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS: Pick<
+ AdvancedTextEditorBlockInsertionItem,
+ 'id' | 'title' | 'icon' | 'createContent'
+>[] = [
+ {
+ id: 'paragraph',
+ title: msg`Text`,
+ icon: IconPilcrow,
+ createContent: createParagraphBlockContent,
+ },
+ {
+ id: 'h1',
+ title: msg`Heading 1`,
+ icon: IconH1,
+ createContent: () => createHeadingBlockContent(1),
+ },
+ {
+ id: 'h2',
+ title: msg`Heading 2`,
+ icon: IconH2,
+ createContent: () => createHeadingBlockContent(2),
+ },
+ {
+ id: 'h3',
+ title: msg`Heading 3`,
+ icon: IconH3,
+ createContent: () => createHeadingBlockContent(3),
+ },
+ {
+ id: 'bulletList',
+ title: msg`Bullet List`,
+ icon: IconList,
+ createContent: () => createListBlockContent(TIPTAP_NODE_TYPES.BULLET_LIST),
+ },
+ {
+ id: 'orderedList',
+ title: msg`Ordered List`,
+ icon: IconListNumbers,
+ createContent: () => createListBlockContent(TIPTAP_NODE_TYPES.ORDERED_LIST),
+ },
+];
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/constants/getAdvancedTextEditorTextBlockSettings.ts b/packages/twenty-front/src/modules/advanced-text-editor/constants/getAdvancedTextEditorTextBlockSettings.ts
new file mode 100644
index 00000000000..139cd1e2498
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/constants/getAdvancedTextEditorTextBlockSettings.ts
@@ -0,0 +1,16 @@
+import { getAdvancedTextEditorTypographySettings } from '@/advanced-text-editor/constants/getAdvancedTextEditorTypographySettings';
+import { type AdvancedTextEditorBlockSetting } from '@/advanced-text-editor/types/AdvancedTextEditorBlockCatalog';
+import { msg } from '@lingui/core/macro';
+
+export function getAdvancedTextEditorTextBlockSettings() {
+ return [
+ ...getAdvancedTextEditorTypographySettings(),
+ {
+ label: msg`Padding`,
+ kind: 'style',
+ property: 'padding',
+ input: 'box',
+ placeholder: '0',
+ },
+ ] as const satisfies readonly AdvancedTextEditorBlockSetting[];
+}
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/BlockDragAndDrop.ts b/packages/twenty-front/src/modules/advanced-text-editor/extensions/BlockDragAndDrop.ts
new file mode 100644
index 00000000000..ea41fa66ca3
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/BlockDragAndDrop.ts
@@ -0,0 +1,34 @@
+import { ADVANCED_TEXT_EDITOR_EXTERNAL_DRAG_MIME_TYPE } from '@/advanced-text-editor/constants/AdvancedTextEditorExternalDragMimeType';
+import { Extension, isNodeSelection } from '@tiptap/core';
+import { Plugin, PluginKey, Selection } from '@tiptap/pm/state';
+
+export const BlockDragAndDrop = Extension.create({
+ name: 'blockDragAndDrop',
+
+ addProseMirrorPlugins() {
+ return [
+ new Plugin({
+ key: new PluginKey('blockDragAndDrop'),
+ appendTransaction: (transactions, _oldState, newState) => {
+ const isDrop = transactions.some(
+ (transaction) => transaction.getMeta('uiEvent') === 'drop',
+ );
+
+ if (!isDrop || !isNodeSelection(newState.selection)) {
+ return null;
+ }
+
+ return newState.tr.setSelection(
+ Selection.near(newState.doc.resolve(newState.selection.from + 1)),
+ );
+ },
+ props: {
+ dragCopies: (event) =>
+ event.dataTransfer?.types.includes(
+ ADVANCED_TEXT_EDITOR_EXTERNAL_DRAG_MIME_TYPE,
+ ) ?? false,
+ },
+ }),
+ ];
+ },
+});
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/blocks/TextBlockStyle.ts b/packages/twenty-front/src/modules/advanced-text-editor/extensions/blocks/TextBlockStyle.ts
new file mode 100644
index 00000000000..35d4d306582
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/blocks/TextBlockStyle.ts
@@ -0,0 +1,29 @@
+import { readBlockStyleAttribute } from '@/advanced-text-editor/extensions/blocks/readBlockStyleAttribute';
+import { inlineStyleToCss } from '@/advanced-text-editor/utils/inlineStyleToCss';
+import { Extension } from '@tiptap/core';
+import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
+
+export const TextBlockStyle = Extension.create({
+ name: 'textBlockStyle',
+
+ addGlobalAttributes() {
+ return [
+ {
+ types: [TIPTAP_NODE_TYPES.PARAGRAPH, TIPTAP_NODE_TYPES.HEADING],
+ attributes: {
+ style: {
+ default: null,
+ parseHTML: readBlockStyleAttribute,
+ renderHTML: (attributes) =>
+ isDefined(attributes.style)
+ ? {
+ style: inlineStyleToCss(attributes.style),
+ 'data-style': JSON.stringify(attributes.style),
+ }
+ : {},
+ },
+ },
+ },
+ ];
+ },
+});
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/UploadImagePlugin.ts b/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/UploadImagePlugin.ts
index 05e3fae4455..a5ee113e2c6 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/UploadImagePlugin.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/resizable-image/UploadImagePlugin.ts
@@ -1,9 +1,8 @@
import { type Editor } from '@tiptap/core';
-import { type Node } from '@tiptap/pm/model';
import { Plugin, PluginKey } from '@tiptap/pm/state';
-import { type EditorView } from '@tiptap/pm/view';
import { type UploadedImage } from '@/advanced-text-editor/types/UploadedImage';
+import { insertUploadingImage } from '@/advanced-text-editor/utils/insertUploadingImage';
export type UploadImagePluginProps = {
editor: Editor;
@@ -16,69 +15,6 @@ export const UploadImagePlugin = (options: UploadImagePluginProps) => {
const { editor, onImageUpload, allowedMimeTypes, onImageUploadError } =
options;
- const handleImageUpload = (view: EditorView, file: File, pos?: number) => {
- const placeholderSrc = URL.createObjectURL(file);
-
- const { tr, schema } = view.state;
- const imageNode = schema.nodes.image.create({
- src: placeholderSrc,
- alt: file.name,
- });
-
- editor.extensionStorage.uploadImage.placeholderImages.add(placeholderSrc);
-
- const resolvedPos =
- pos !== undefined
- ? view.state.doc.resolve(pos)
- : view.state.selection.$head;
-
- const transaction = tr.insert(resolvedPos.pos, imageNode);
- view.dispatch(transaction);
-
- onImageUpload?.(file)
- .then((uploadedImage) => {
- const updateTr = view.state.tr;
-
- const predicate = (node: Node) =>
- node.type.name === 'image' && node.attrs.src === placeholderSrc;
-
- view.state.doc.descendants((node, pos) => {
- if (predicate(node)) {
- updateTr.setNodeMarkup(pos, undefined, {
- ...node.attrs,
- fileId: uploadedImage.fileId ?? null,
- src: uploadedImage.url,
- });
- return false;
- }
- });
-
- view.dispatch(updateTr);
- })
- .catch((error: Error) => {
- const removeTr = view.state.tr;
- const predicate = (node: Node) =>
- node.type.name === 'image' && node.attrs.src === placeholderSrc;
-
- view.state.doc.descendants((node, pos) => {
- if (predicate(node)) {
- removeTr.delete(pos, pos + node.nodeSize);
- return false; // Stop traversal after finding the target
- }
- });
-
- view.dispatch(removeTr);
-
- onImageUploadError?.(error, file);
- })
- .finally(() => {
- editor.extensionStorage.uploadImage.placeholderImages.delete(
- placeholderSrc,
- );
- URL.revokeObjectURL(placeholderSrc);
- });
- };
-
return new Plugin({
key: new PluginKey('uploadImage'),
props: {
@@ -105,10 +41,18 @@ export const UploadImagePlugin = (options: UploadImagePluginProps) => {
event.preventDefault();
event.stopPropagation();
- images.forEach((file) => handleImageUpload(view, file, pos.pos));
+ images.forEach((file) =>
+ insertUploadingImage({
+ editor,
+ file,
+ pos: pos.pos,
+ onImageUpload,
+ onImageUploadError,
+ }),
+ );
return true;
},
- handlePaste: (view, event) => {
+ handlePaste: (_view, event) => {
if (!onImageUpload || !event.clipboardData?.files?.length) {
return false;
}
@@ -123,7 +67,14 @@ export const UploadImagePlugin = (options: UploadImagePluginProps) => {
event.preventDefault();
event.stopPropagation();
- images.forEach((file) => handleImageUpload(view, file));
+ images.forEach((file) =>
+ insertUploadingImage({
+ editor,
+ file,
+ onImageUpload,
+ onImageUploadError,
+ }),
+ );
return true;
},
},
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorBlockCatalog.ts b/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorBlockCatalog.ts
index 8fe8c320e5e..cd0d4dc9407 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorBlockCatalog.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/types/AdvancedTextEditorBlockCatalog.ts
@@ -4,6 +4,8 @@ import { TIPTAP_NODE_TYPES, type TipTapNodeType } from 'twenty-shared/utils';
import { type IconComponent } from 'twenty-ui/icon';
export const ADVANCED_TEXT_EDITOR_BLOCK_NODE_TYPES = [
+ TIPTAP_NODE_TYPES.PARAGRAPH,
+ TIPTAP_NODE_TYPES.HEADING,
TIPTAP_NODE_TYPES.SECTION,
TIPTAP_NODE_TYPES.COLUMNS,
TIPTAP_NODE_TYPES.COLUMN,
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/utils/__tests__/getBlockSelectionTarget.test.ts b/packages/twenty-front/src/modules/advanced-text-editor/utils/__tests__/getBlockSelectionTarget.test.ts
index 00d5b13203d..b9acdbf4def 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/utils/__tests__/getBlockSelectionTarget.test.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/utils/__tests__/getBlockSelectionTarget.test.ts
@@ -26,7 +26,7 @@ const createEditor = (content: object) =>
});
describe('getBlockSelectionTarget', () => {
- it('should return null when the cursor is in plain content', () => {
+ it('should target the paragraph holding the cursor', () => {
const editor = createEditor({
type: 'doc',
content: [
@@ -34,11 +34,11 @@ describe('getBlockSelectionTarget', () => {
],
});
- expect(getBlockSelectionTarget(editor)).toBeNull();
+ expect(getBlockSelectionTarget(editor)?.nodeType).toBe('paragraph');
editor.destroy();
});
- it('should target the section containing the cursor', () => {
+ it('should target a node-selected section', () => {
const editor = createEditor({
type: 'doc',
content: [
@@ -53,7 +53,7 @@ describe('getBlockSelectionTarget', () => {
});
editor.view.dispatch(
- editor.state.tr.setSelection(TextSelection.create(editor.state.doc, 3)),
+ editor.state.tr.setSelection(NodeSelection.create(editor.state.doc, 0)),
);
const target = getBlockSelectionTarget(editor);
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorBlockDisplay.ts b/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorBlockDisplay.ts
new file mode 100644
index 00000000000..20af12a4864
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/utils/getAdvancedTextEditorBlockDisplay.ts
@@ -0,0 +1,38 @@
+import { ADVANCED_TEXT_EDITOR_BLOCK_CATALOG } from '@/advanced-text-editor/constants/AdvancedTextEditorBlockCatalog';
+import { ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS } from '@/advanced-text-editor/constants/AdvancedTextEditorTextInsertionItems';
+import { isAdvancedTextEditorBlockNodeType } from '@/advanced-text-editor/types/AdvancedTextEditorBlockCatalog';
+import { type Node as ProseMirrorNode } from '@tiptap/pm/model';
+import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
+
+export const getAdvancedTextEditorBlockDisplay = (
+ doc: ProseMirrorNode,
+ pos: number,
+) => {
+ const $pos = doc.resolve(pos);
+ const node =
+ $pos.nodeAfter?.type.name === TIPTAP_NODE_TYPES.LIST_ITEM
+ ? $pos.parent
+ : $pos.nodeAfter;
+ const nodeTypeName = node?.type.name ?? TIPTAP_NODE_TYPES.PARAGRAPH;
+ const textItem = ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS.find((item) => {
+ const content = item.createContent(() => '');
+
+ return (
+ content.type === nodeTypeName &&
+ content.attrs?.level === node?.attrs.level
+ );
+ });
+
+ if (isDefined(textItem)) {
+ return textItem;
+ }
+
+ const { label, icon } =
+ ADVANCED_TEXT_EDITOR_BLOCK_CATALOG[
+ isAdvancedTextEditorBlockNodeType(nodeTypeName)
+ ? nodeTypeName
+ : TIPTAP_NODE_TYPES.PARAGRAPH
+ ];
+
+ return { title: label, icon };
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/utils/insertUploadingImage.ts b/packages/twenty-front/src/modules/advanced-text-editor/utils/insertUploadingImage.ts
new file mode 100644
index 00000000000..20f6568a135
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/utils/insertUploadingImage.ts
@@ -0,0 +1,82 @@
+import { type Editor } from '@tiptap/core';
+import { type Node } from '@tiptap/pm/model';
+
+import { type UploadedImage } from '@/advanced-text-editor/types/UploadedImage';
+
+type InsertUploadingImageArgs = {
+ editor: Editor;
+ file: File;
+ pos?: number;
+ onImageUpload: (file: File) => Promise<UploadedImage>;
+ onImageUploadError?: (error: Error, file: File) => void;
+};
+
+export const insertUploadingImage = ({
+ editor,
+ file,
+ pos,
+ onImageUpload,
+ onImageUploadError,
+}: InsertUploadingImageArgs) => {
+ const { view } = editor;
+ const placeholderSrc = URL.createObjectURL(file);
+
+ const { tr, schema } = view.state;
+ const imageNode = schema.nodes.image.create({
+ src: placeholderSrc,
+ alt: file.name,
+ });
+
+ editor.extensionStorage.uploadImage.placeholderImages.add(placeholderSrc);
+
+ const resolvedPos =
+ pos !== undefined
+ ? view.state.doc.resolve(pos)
+ : view.state.selection.$head;
+
+ const transaction = tr.insert(resolvedPos.pos, imageNode);
+ view.dispatch(transaction);
+
+ onImageUpload(file)
+ .then((uploadedImage) => {
+ const updateTr = view.state.tr;
+
+ const predicate = (node: Node) =>
+ node.type.name === 'image' && node.attrs.src === placeholderSrc;
+
+ view.state.doc.descendants((node, pos) => {
+ if (predicate(node)) {
+ updateTr.setNodeMarkup(pos, undefined, {
+ ...node.attrs,
+ fileId: uploadedImage.fileId ?? null,
+ src: uploadedImage.url,
+ });
+ return false;
+ }
+ });
+
+ view.dispatch(updateTr);
+ })
+ .catch((error: Error) => {
+ const removeTr = view.state.tr;
+ const predicate = (node: Node) =>
+ node.type.name === 'image' && node.attrs.src === placeholderSrc;
+
+ view.state.doc.descendants((node, pos) => {
+ if (predicate(node)) {
+ removeTr.delete(pos, pos + node.nodeSize);
+ return false; // Stop traversal after finding the target
+ }
+ });
+
+ view.dispatch(removeTr);
+
+ onImageUploadError?.(error, file);
+ })
+ .finally(() => {
+ editor.extensionStorage.uploadImage.placeholderImages.delete(
+ placeholderSrc,
+ );
+ URL.revokeObjectURL(placeholderSrc);
+ });
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/utils/isTextSelected.ts b/packages/twenty-front/src/modules/advanced-text-editor/utils/isTextSelected.ts
index eae922ff21f..190d019d37b 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/utils/isTextSelected.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/utils/isTextSelected.ts
@@ -1,4 +1,4 @@
-import { type Editor, isTextSelection } from '@tiptap/core';
+import { type Editor, isNodeSelection, isTextSelection } from '@tiptap/core';
type IsTextSelectedProps = {
editor: Editor;
@@ -19,7 +19,12 @@ export const isTextSelected = ({ editor }: IsTextSelectedProps) => {
const isEmptyTextBlock =
!doc.textBetween(from, to).length && isTextSelection(selection);
- if (empty || isEmptyTextBlock || !editor.isEditable) {
+ if (
+ empty ||
+ isEmptyTextBlock ||
+ isNodeSelection(selection) ||
+ !editor.isEditable
+ ) {
return false;
}
diff --git a/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx b/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx
index b5d3fe54f35..5a7f3bd6cb7 100644
--- a/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx
+++ b/packages/twenty-front/src/modules/side-panel/constants/SidePanelPagesConfig.tsx
@@ -5,6 +5,8 @@ import { SidePanelCoreWorkflowVersionPage } from '@/object-core/workflows/versio
import { SidePanelCoreWorkflowVersionsPage } from '@/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionsPage';
import { SidePanelRoutedPage } from '@/side-panel/routing/components/SidePanelRoutedPage';
import { SidePanelEmailBlockSettingsPage } from '@/side-panel/pages/email-block-settings/components/SidePanelEmailBlockSettingsPage';
+import { SidePanelEmailDesignPage } from '@/side-panel/pages/email-block-settings/components/SidePanelEmailDesignPage';
+import { SidePanelEmailPageStylePage } from '@/side-panel/pages/email-block-settings/components/SidePanelEmailPageStylePage';
import { SidePanelAskAiPage } from '@/side-panel/pages/ask-ai/components/SidePanelAskAiPage';
import { SidePanelComposeEmailPage } from '@/side-panel/pages/compose-email/components/SidePanelComposeEmailPage';
import { SidePanelComposeCalendarEventPage } from '@/side-panel/pages/compose-calendar-event/components/SidePanelComposeCalendarEventPage';
@@ -94,7 +96,9 @@ export const SIDE_PANEL_PAGES_CONFIG = new Map<
[SidePanelPages.SendCampaign, <SidePanelSendCampaignPage />],
[SidePanelPages.RecordCreationForm, <SidePanelRecordCreationFormPage />],
[SidePanelPages.SendCampaignTest, <SidePanelSendCampaignTestPage />],
- [SidePanelPages.EmailBlockSettings, <SidePanelEmailBlockSettingsPage />],
+ [SidePanelPages.EmailBlockSettings, <SidePanelEmailDesignPage />],
+ [SidePanelPages.EmailBlockStyle, <SidePanelEmailBlockSettingsPage />],
+ [SidePanelPages.EmailPageStyle, <SidePanelEmailPageStylePage />],
[SidePanelPages.RoutedPage, <SidePanelRoutedPage />],
[SidePanelPages.WorkflowCoreFilters, <SidePanelCoreWorkflowFiltersPage />],
[SidePanelPages.WorkflowVersions, <SidePanelCoreWorkflowVersionsPage />],
diff --git a/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockSettingsInSidePanel.ts b/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockSettingsInSidePanel.ts
index 486e4914a7f..2af32d887f8 100644
--- a/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockSettingsInSidePanel.ts
+++ b/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockSettingsInSidePanel.ts
@@ -12,9 +12,10 @@ export const useOpenEmailBlockSettingsInSidePanel = () => {
const openEmailBlockSettingsInSidePanel = useCallback(() => {
navigateSidePanelMenu({
page: SidePanelPages.EmailBlockSettings,
- pageTitle: t`Block Settings`,
+ pageTitle: t`Design`,
pageIcon: IconAdjustments,
pageId: v4(),
+ resetNavigationStack: true,
});
}, [navigateSidePanelMenu]);
diff --git a/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockStyleInSidePanel.ts b/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockStyleInSidePanel.ts
new file mode 100644
index 00000000000..0d35dd89a09
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/hooks/useOpenEmailBlockStyleInSidePanel.ts
@@ -0,0 +1,59 @@
+import { t } from '@lingui/core/macro';
+import { type Editor } from '@tiptap/core';
+import { useStore } from 'jotai';
+import { useCallback } from 'react';
+import { SidePanelPages } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
+import { IconAdjustments } from 'twenty-ui/icon';
+import { v4 } from 'uuid';
+
+import { getBlockSelectionTarget } from '@/advanced-text-editor/utils/getBlockSelectionTarget';
+import { useOpenEmailBlockSettingsInSidePanel } from '@/side-panel/hooks/useOpenEmailBlockSettingsInSidePanel';
+import { useSidePanelHistory } from '@/side-panel/hooks/useSidePanelHistory';
+import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
+import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';
+
+export const useOpenEmailBlockStyleInSidePanel = () => {
+ const store = useStore();
+ const { navigateSidePanelMenu } = useSidePanelMenu();
+ const { goBackFromSidePanel } = useSidePanelHistory();
+ const { openEmailBlockSettingsInSidePanel } =
+ useOpenEmailBlockSettingsInSidePanel();
+
+ const openEmailBlockStyleInSidePanel = useCallback(() => {
+ openEmailBlockSettingsInSidePanel();
+ navigateSidePanelMenu({
+ page: SidePanelPages.EmailBlockStyle,
+ pageTitle: t`Style`,
+ pageIcon: IconAdjustments,
+ pageId: v4(),
+ });
+ }, [navigateSidePanelMenu, openEmailBlockSettingsInSidePanel]);
+
+ const followEmailBlockSelectionInSidePanel = useCallback(
+ (editor: Editor) => {
+ const hasBlockTarget = isDefined(getBlockSelectionTarget(editor));
+
+ switch (store.get(sidePanelNavigationStackState.atom).at(-1)?.page) {
+ case SidePanelPages.EmailBlockSettings:
+ if (hasBlockTarget) {
+ openEmailBlockStyleInSidePanel();
+ }
+ return;
+ case SidePanelPages.EmailBlockStyle:
+ if (!hasBlockTarget) {
+ goBackFromSidePanel();
+ }
+ return;
+ default:
+ return;
+ }
+ },
+ [goBackFromSidePanel, openEmailBlockStyleInSidePanel, store],
+ );
+
+ return {
+ openEmailBlockStyleInSidePanel,
+ followEmailBlockSelectionInSidePanel,
+ };
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx
new file mode 100644
index 00000000000..6b3ae5eae6e
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx
@@ -0,0 +1,193 @@
+import { useLingui } from '@lingui/react/macro';
+import { isNonEmptyArray } from '@sniptt/guards';
+import { type Editor, type JSONContent } from '@tiptap/core';
+import { useRef } from 'react';
+import { EMAIL_IMAGE_MIME_TYPES } from 'twenty-shared/constants';
+import { SidePanelPages } from 'twenty-shared/types';
+import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
+import { MenuItem } from 'twenty-ui/components';
+import {
+ type IconComponent,
+ IconPaint,
+ IconPhoto,
+ IconVariable,
+} from 'twenty-ui/icon';
+import { themeCssVariables } from 'twenty-ui/theme';
+import { v4 } from 'uuid';
+
+import { useCampaignEmailEditorVariables } from '@/activities/emails/hooks/useCampaignEmailEditorVariables';
+import { useUploadEmailImage } from '@/activities/emails/hooks/useUploadEmailImage';
+import { ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES } from '@/advanced-text-editor/constants/AdvancedTextEditorBlockInsertionRecipes';
+import { ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS } from '@/advanced-text-editor/constants/AdvancedTextEditorTextInsertionItems';
+import { type AdvancedTextEditorBlockInsertionItem } from '@/advanced-text-editor/types/AdvancedTextEditorBlockCatalog';
+import { AdvancedTextEditorDraggableContent } from '@/advanced-text-editor/components/AdvancedTextEditorDraggableContent';
+import { insertUploadingImage } from '@/advanced-text-editor/utils/insertUploadingImage';
+import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
+import { SidePanelStepListContainer } from '@/workflow/workflow-steps/components/SidePanelWorkflowSelectStepContainer';
+import { SidePanelWorkflowSelectStepTitle } from '@/workflow/workflow-steps/components/SidePanelWorkflowSelectStepTitle';
+
+const LAYOUT_NODE_TYPES: string[] = [
+ TIPTAP_NODE_TYPES.SECTION,
+ TIPTAP_NODE_TYPES.COLUMNS,
+ TIPTAP_NODE_TYPES.DIVIDER,
+];
+
+type DraggableInsertItem = {
+ id: string;
+ Icon: IconComponent;
+ iconColor: string;
+ label: string;
+ content: JSONContent;
+};
+
+type EmailBlockInsertListProps = {
+ editor: Editor;
+};
+
+export const EmailBlockInsertList = ({ editor }: EmailBlockInsertListProps) => {
+ const { i18n, t } = useLingui();
+ const imageFileInputRef = useRef<HTMLInputElement>(null);
+ const { variables } = useCampaignEmailEditorVariables();
+ const { uploadEmailImage } = useUploadEmailImage();
+ const { navigateSidePanelMenu } = useSidePanelMenu();
+
+ const insertContent = (content: JSONContent) =>
+ editor.chain().focus().insertContent(content).scrollIntoView().run();
+
+ const handleImageFilePicked = (file: File | undefined) => {
+ if (isDefined(file)) {
+ insertUploadingImage({ editor, file, onImageUpload: uploadEmailImage });
+ }
+ };
+
+ const handleOpenPageStyle = () =>
+ navigateSidePanelMenu({
+ page: SidePanelPages.EmailPageStyle,
+ pageTitle: t`Page style`,
+ pageIcon: IconPaint,
+ pageId: v4(),
+ });
+
+ const renderDraggableItem = ({
+ id,
+ Icon,
+ iconColor,
+ label,
+ content,
+ }: DraggableInsertItem) => (
+ <AdvancedTextEditorDraggableContent
+ key={id}
+ editor={editor}
+ content={content}
+ Icon={Icon}
+ label={label}
+ >
+ <MenuItem
+ withIconContainer
+ LeftIcon={() => <Icon color={iconColor} size={16} />}
+ text={label}
+ onClick={() => insertContent(content)}
+ />
+ </AdvancedTextEditorDraggableContent>
+ );
+
+ const renderInsertionItems = (
+ items: Pick<
+ AdvancedTextEditorBlockInsertionItem,
+ 'id' | 'title' | 'icon' | 'createContent'
+ >[],
+ iconColor: string,
+ ) =>
+ items.map(({ id, title, icon, createContent }) =>
+ renderDraggableItem({
+ id,
+ Icon: icon,
+ iconColor,
+ label: i18n._(title),
+ content: createContent((message) => i18n._(message)),
+ }),
+ );
+
+ return (
+ <SidePanelStepListContainer>
+ <input
+ ref={imageFileInputRef}
+ type="file"
+ accept={EMAIL_IMAGE_MIME_TYPES.join(',')}
+ hidden
+ onChange={(event) => {
+ handleImageFilePicked(event.target.files?.[0]);
+ event.target.value = '';
+ }}
+ />
+ <SidePanelWorkflowSelectStepTitle>
+ {t`Text`}
+ </SidePanelWorkflowSelectStepTitle>
+ {renderInsertionItems(
+ ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS,
+ themeCssVariables.color.gray9,
+ )}
+
+ <SidePanelWorkflowSelectStepTitle>
+ {t`Layout`}
+ </SidePanelWorkflowSelectStepTitle>
+ {renderInsertionItems(
+ ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.filter(({ nodeType }) =>
+ LAYOUT_NODE_TYPES.includes(nodeType),
+ ),
+ themeCssVariables.color.green9,
+ )}
+
+ <SidePanelWorkflowSelectStepTitle>
+ {t`Content`}
+ </SidePanelWorkflowSelectStepTitle>
+ <MenuItem
+ withIconContainer
+ LeftIcon={() => (
+ <IconPhoto color={themeCssVariables.color.orange9} size={16} />
+ )}
+ text={t`Image`}
+ onClick={() => imageFileInputRef.current?.click()}
+ />
+ {renderInsertionItems(
+ ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.filter(
+ ({ nodeType }) => !LAYOUT_NODE_TYPES.includes(nodeType),
+ ),
+ themeCssVariables.color.orange9,
+ )}
+
+ {isNonEmptyArray(variables) && (
+ <>
+ <SidePanelWorkflowSelectStepTitle>
+ {t`Variables`}
+ </SidePanelWorkflowSelectStepTitle>
+ {variables.map(({ label, value }) =>
+ renderDraggableItem({
+ id: value,
+ Icon: IconVariable,
+ iconColor: themeCssVariables.color.blue9,
+ label,
+ content: {
+ type: TIPTAP_NODE_TYPES.VARIABLE_TAG,
+ attrs: { variable: value },
+ },
+ }),
+ )}
+ </>
+ )}
+
+ <SidePanelWorkflowSelectStepTitle>
+ {t`Page`}
+ </SidePanelWorkflowSelectStepTitle>
+ <MenuItem
+ withIconContainer
+ LeftIcon={() => (
+ <IconPaint color={themeCssVariables.color.purple9} size={16} />
+ )}
+ text={t`Page style`}
+ hasSubMenu
+ onClick={handleOpenPageStyle}
+ />
+ </SidePanelStepListContainer>
+ );
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailBlockSettingsPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailBlockSettingsPage.tsx
index 8bbbe4e8a38..3a548c4a38d 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailBlockSettingsPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailBlockSettingsPage.tsx
@@ -21,8 +21,9 @@ import {
EmailBoxSidesInput,
type CssBoxSides,
} from '@/side-panel/pages/email-block-settings/components/EmailBoxSidesInput';
-import { EmailPageStyleSection } from '@/side-panel/pages/email-block-settings/components/EmailPageStyleSection';
+import { StyledEmailSidePanelHint } from '@/side-panel/pages/email-block-settings/components/StyledEmailSidePanelHint';
import { getEffectiveSectionStyleValue } from '@/side-panel/pages/email-block-settings/utils/getEffectiveSectionStyleValue';
+import { useSidePanelHistory } from '@/side-panel/hooks/useSidePanelHistory';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
const StyledContainer = styled.div`
@@ -32,12 +33,6 @@ const StyledContainer = styled.div`
padding: ${themeCssVariables.spacing[4]};
`;
-const StyledHint = styled.div`
- color: ${themeCssVariables.font.color.tertiary};
- font-size: ${themeCssVariables.font.size.sm};
- padding: ${themeCssVariables.spacing[4]};
-`;
-
const StyledBlockHeader = styled.div`
align-items: center;
display: flex;
@@ -71,12 +66,15 @@ const BOX_FIELD_SIDE_PROPERTIES: Record<
const EmailBlockSettingsContent = ({ editor }: { editor: Editor }) => {
const { i18n, t } = useLingui();
+ const { goBackFromSidePanel } = useSidePanelHistory();
const target = useLiveEditorState(editor, (currentEditor) =>
getBlockSelectionTarget(currentEditor),
);
if (!isDefined(target)) {
- return <EmailPageStyleSection editor={editor} />;
+ return (
+ <StyledEmailSidePanelHint>{t`Select a block to edit its style.`}</StyledEmailSidePanelHint>
+ );
}
const blockDefinition = ADVANCED_TEXT_EDITOR_BLOCK_CATALOG[target.nodeType];
@@ -84,9 +82,21 @@ const EmailBlockSettingsContent = ({ editor }: { editor: Editor }) => {
const styles = getBlockStyle(target.attrs.style);
const canvasTheme = resolveCanvasTheme(editor.state.doc.attrs.canvasTheme);
+ const inheritsCanvasTypography = (property: string) => {
+ switch (target.nodeType) {
+ case TIPTAP_NODE_TYPES.SECTION:
+ case TIPTAP_NODE_TYPES.PARAGRAPH:
+ return true;
+ case TIPTAP_NODE_TYPES.HEADING:
+ return property !== 'fontSize';
+ default:
+ return false;
+ }
+ };
+
const displayedStyleValue = (property: string) =>
styles[property] ??
- (target.nodeType === TIPTAP_NODE_TYPES.SECTION
+ (inheritsCanvasTypography(property)
? getEffectiveSectionStyleValue(property, canvasTheme)
: '');
@@ -119,6 +129,7 @@ const EmailBlockSettingsContent = ({ editor }: { editor: Editor }) => {
return true;
})
.run();
+ goBackFromSidePanel();
};
const handleFieldChange = (
@@ -239,7 +250,7 @@ export const SidePanelEmailBlockSettingsPage = () => {
if (!isDefined(activeEmailEditor) || activeEmailEditor.isDestroyed) {
return (
- <StyledHint>{t`Open an email editor to edit block settings.`}</StyledHint>
+ <StyledEmailSidePanelHint>{t`Open an email editor to edit block settings.`}</StyledEmailSidePanelHint>
);
}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailDesignPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailDesignPage.tsx
new file mode 100644
index 00000000000..d8fe4ff6ada
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailDesignPage.tsx
@@ -0,0 +1,20 @@
+import { useLingui } from '@lingui/react/macro';
+import { isDefined } from 'twenty-shared/utils';
+
+import { activeEmailEditorState } from '@/activities/emails/states/activeEmailEditorState';
+import { EmailBlockInsertList } from '@/side-panel/pages/email-block-settings/components/EmailBlockInsertList';
+import { StyledEmailSidePanelHint } from '@/side-panel/pages/email-block-settings/components/StyledEmailSidePanelHint';
+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+
+export const SidePanelEmailDesignPage = () => {
+ const { t } = useLingui();
+ const activeEmailEditor = useAtomStateValue(activeEmailEditorState);
+
+ if (!isDefined(activeEmailEditor) || activeEmailEditor.isDestroyed) {
+ return (
+ <StyledEmailSidePanelHint>{t`Open an email editor to design it.`}</StyledEmailSidePanelHint>
+ );
+ }
+
+ return <EmailBlockInsertList editor={activeEmailEditor} />;
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailPageStylePage.tsx b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailPageStylePage.tsx
new file mode 100644
index 00000000000..0af7e656ae8
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/SidePanelEmailPageStylePage.tsx
@@ -0,0 +1,20 @@
+import { useLingui } from '@lingui/react/macro';
+import { isDefined } from 'twenty-shared/utils';
+
+import { activeEmailEditorState } from '@/activities/emails/states/activeEmailEditorState';
+import { EmailPageStyleSection } from '@/side-panel/pages/email-block-settings/components/EmailPageStyleSection';
+import { StyledEmailSidePanelHint } from '@/side-panel/pages/email-block-settings/components/StyledEmailSidePanelHint';
+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+
+export const SidePanelEmailPageStylePage = () => {
+ const { t } = useLingui();
+ const activeEmailEditor = useAtomStateValue(activeEmailEditorState);
+
+ if (!isDefined(activeEmailEditor) || activeEmailEditor.isDestroyed) {
+ return (
+ <StyledEmailSidePanelHint>{t`Open an email editor to edit the page style.`}</StyledEmailSidePanelHint>
+ );
+ }
+
+ return <EmailPageStyleSection editor={activeEmailEditor} />;
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/StyledEmailSidePanelHint.tsx b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/StyledEmailSidePanelHint.tsx
new file mode 100644
index 00000000000..04167e40d41
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/StyledEmailSidePanelHint.tsx
@@ -0,0 +1,8 @@
+import { styled } from '@linaria/react';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+export const StyledEmailSidePanelHint = styled.div`
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.sm};
+ padding: ${themeCssVariables.spacing[4]};
+`;
diff --git a/packages/twenty-server/src/engine/core-modules/email/utils/__tests__/compile-outbound-email-content.util.spec.ts b/packages/twenty-server/src/engine/core-modules/email/utils/__tests__/compile-outbound-email-content.util.spec.ts
index 36237127aad..014fa01235d 100644
--- a/packages/twenty-server/src/engine/core-modules/email/utils/__tests__/compile-outbound-email-content.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/email/utils/__tests__/compile-outbound-email-content.util.spec.ts
@@ -128,6 +128,30 @@ describe('compileOutboundEmailContent', () => {
expect(html).toContain('2px dashed #ff0000');
});
+ it('should apply text block styles to headings and paragraphs', async () => {
+ const html = await compileDocument({
+ type: 'doc',
+ content: [
+ {
+ type: 'heading',
+ attrs: { level: 2, style: { color: '#0000ff', fontSize: '40px' } },
+ content: [{ type: 'text', text: 'Styled heading' }],
+ },
+ {
+ type: 'paragraph',
+ attrs: { style: { textAlign: 'center', letterSpacing: '2px' } },
+ content: [{ type: 'text', text: 'Styled paragraph' }],
+ },
+ ],
+ });
+
+ expect(html).toContain('color:#0000ff');
+ expect(html).toContain('font-size:40px');
+ expect(html).not.toContain('font-size:24px');
+ expect(html).toContain('text-align:center');
+ expect(html).toContain('letter-spacing:2px');
+ });
+
it('should wrap themed documents in a styled page and centered container', async () => {
const html = await compileDocument({
type: 'doc',
diff --git a/packages/twenty-shared/src/types/SidePanelPages.ts b/packages/twenty-shared/src/types/SidePanelPages.ts
index e24d8012223..c83990fb0a4 100644
--- a/packages/twenty-shared/src/types/SidePanelPages.ts
+++ b/packages/twenty-shared/src/types/SidePanelPages.ts
@@ -38,6 +38,8 @@ export enum SidePanelPages {
WorkflowVersions = 'workflow-versions',
WorkflowVersion = 'workflow-version',
EmailBlockSettings = 'email-block-settings',
+ EmailPageStyle = 'email-page-style',
+ EmailBlockStyle = 'email-block-style',
SettingsMetadataTranslations = 'settings-metadata-translations',
RoutedPage = 'routed-page',
WorkflowCoreFilters = 'workflow-core-filters',
diff --git a/packages/twenty-shared/src/utils/tiptap/__tests__/email-document-schema.test.ts b/packages/twenty-shared/src/utils/tiptap/__tests__/email-document-schema.test.ts
index 025047a7c1d..1c9f371e578 100644
--- a/packages/twenty-shared/src/utils/tiptap/__tests__/email-document-schema.test.ts
+++ b/packages/twenty-shared/src/utils/tiptap/__tests__/email-document-schema.test.ts
@@ -192,6 +192,33 @@ describe('parseEmailDocument', () => {
expect(result.success).toBe(false);
});
+ it('should accept text block styles and unset styles', () => {
+ const result = parseEmailDocument({
+ type: 'doc',
+ content: [
+ {
+ type: 'heading',
+ attrs: { level: 1, style: { color: '#123456', textAlign: 'center' } },
+ content: [{ type: 'text', text: 'Hi' }],
+ },
+ { ...paragraph('Body'), attrs: { style: null } },
+ ],
+ });
+
+ expect(result.success).toBe(true);
+ });
+
+ it('should reject a text block style with non-css keys', () => {
+ const result = parseEmailDocument({
+ type: 'doc',
+ content: [
+ { ...paragraph('Body'), attrs: { style: { 'font-size': '12px' } } },
+ ],
+ });
+
+ expect(result.success).toBe(false);
+ });
+
it('should reject columns with fewer than two columns', () => {
const result = parseEmailDocument({
type: 'doc',
diff --git a/packages/twenty-shared/src/utils/tiptap/email-document-schema.ts b/packages/twenty-shared/src/utils/tiptap/email-document-schema.ts
index af04866dbe2..1b67e4988d9 100644
--- a/packages/twenty-shared/src/utils/tiptap/email-document-schema.ts
+++ b/packages/twenty-shared/src/utils/tiptap/email-document-schema.ts
@@ -53,7 +53,7 @@ const blockContentSchema = z.array(
const paragraphNodeSchema = z.looseObject({
type: z.literal(TIPTAP_NODE_TYPES.PARAGRAPH),
- attrs: z.looseObject({}).optional(),
+ attrs: z.looseObject({ style: styleAttributeSchema.nullable() }).optional(),
content: z.array(inlineNodeSchema).optional(),
});
@@ -61,6 +61,7 @@ const headingNodeSchema = z.looseObject({
type: z.literal(TIPTAP_NODE_TYPES.HEADING),
attrs: z.looseObject({
level: z.union([z.literal(1), z.literal(2), z.literal(3)]),
+ style: styleAttributeSchema.nullable(),
}),
content: z.array(inlineNodeSchema).optional(),
});
diff --git a/yarn.lock b/yarn.lock
index 6ea2f3e18a1..aae17690381 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6612,6 +6612,16 @@ __metadata:
languageName: node
linkType: hard
+"@floating-ui/dom@npm:^1.6.13, @floating-ui/dom@npm:^1.8.0":
+ version: 1.8.0
+ resolution: "@floating-ui/dom@npm:1.8.0"
+ dependencies:
+ "@floating-ui/core": "npm:^1.8.0"
+ "@floating-ui/utils": "npm:^0.2.12"
+ checksum: 10c0/c32b2de7a596b69cfffa909c7028825e14f6319be1b45da529f8943c89fe16b75a49c214e800c87ded3f172353d3b99163d50072f11410488e756961b7b629cc
+ languageName: node
+ linkType: hard
+
"@floating-ui/dom@npm:^1.7.4, @floating-ui/dom@npm:^1.7.6":
version: 1.7.6
resolution: "@floating-ui/dom@npm:1.7.6"
@@ -6632,16 +6642,6 @@ __metadata:
languageName: node
linkType: hard
-"@floating-ui/dom@npm:^1.8.0":
- version: 1.8.0
- resolution: "@floating-ui/dom@npm:1.8.0"
- dependencies:
- "@floating-ui/core": "npm:^1.8.0"
- "@floating-ui/utils": "npm:^0.2.12"
- checksum: 10c0/c32b2de7a596b69cfffa909c7028825e14f6319be1b45da529f8943c89fe16b75a49c214e800c87ded3f172353d3b99163d50072f11410488e756961b7b629cc
- languageName: node
- linkType: hard
-
"@floating-ui/react-dom@npm:^2.0.0, @floating-ui/react-dom@npm:^2.0.1":
version: 2.1.1
resolution: "@floating-ui/react-dom@npm:2.1.1"
@@ -19877,6 +19877,18 @@ __metadata:
languageName: node
linkType: hard
+"@tiptap/extension-collaboration@npm:3.30.5":
+ version: 3.30.5
+ resolution: "@tiptap/extension-collaboration@npm:3.30.5"
+ peerDependencies:
+ "@tiptap/core": 3.30.5
+ "@tiptap/pm": 3.30.5
+ "@tiptap/y-tiptap": ^3.0.7
+ yjs: ^13
+ checksum: 10c0/0c1c0d7d626841a0913f8b2c21dac0ed41d1bb1935cad2ad7cf18577d57d433ed32655cdea90bf85161dac5b55c8852952b0640cd90717b26dd638cdc702b680
+ languageName: node
+ linkType: hard
+
"@tiptap/extension-document@npm:3.30.5":
version: 3.30.5
resolution: "@tiptap/extension-document@npm:3.30.5"
@@ -19886,6 +19898,34 @@ __metadata:
languageName: node
linkType: hard
+"@tiptap/extension-drag-handle-react@npm:3.30.5":
+ version: 3.30.5
+ resolution: "@tiptap/extension-drag-handle-react@npm:3.30.5"
+ peerDependencies:
+ "@tiptap/extension-drag-handle": 3.30.5
+ "@tiptap/pm": 3.30.5
+ "@tiptap/react": 3.30.5
+ react: ^16.8 || ^17 || ^18 || ^19
+ react-dom: ^16.8 || ^17 || ^18 || ^19
+ checksum: 10c0/890134f6ef52ee3a69d1e77524f84ad212ad1ede8324498e62cc2b55ec2bb8329e04e2b84290449e096f13b2e26c2ea138a7af7b306cd66b757a609070af09cb
+ languageName: node
+ linkType: hard
+
+"@tiptap/extension-drag-handle@npm:3.30.5":
+ version: 3.30.5
+ resolution: "@tiptap/extension-drag-handle@npm:3.30.5"
+ dependencies:
+ "@floating-ui/dom": "npm:^1.6.13"
+ peerDependencies:
+ "@tiptap/core": 3.30.5
+ "@tiptap/extension-collaboration": 3.30.5
+ "@tiptap/extension-node-range": 3.30.5
+ "@tiptap/pm": 3.30.5
+ "@tiptap/y-tiptap": ^3.0.7
+ checksum: 10c0/2701246bf49977789b3046a01c81cecf7f08f06f686ccc270544e30c28413d871ae3a047e31bb02607798d65aafe9607ac2fc3ddf8196a4a5b56e5029b944819
+ languageName: node
+ linkType: hard
+
"@tiptap/extension-floating-menu@npm:^3.30.5, @tiptap/extension-floating-menu@npm:^3.31.3":
version: 3.31.3
resolution: "@tiptap/extension-floating-menu@npm:3.31.3"
@@ -19974,6 +20014,16 @@ __metadata:
languageName: node
linkType: hard
+"@tiptap/extension-node-range@npm:3.30.5":
+ version: 3.30.5
+ resolution: "@tiptap/extension-node-range@npm:3.30.5"
+ peerDependencies:
+ "@tiptap/core": 3.30.5
+ "@tiptap/pm": 3.30.5
+ checksum: 10c0/293e610f54a60c8e100ddc7c45c9f5f5d7c7b46dc80b818236dec711ce13aa64b8cc0fce8a11dc23dd4bffea0f67adb1fab9dd472af190732f1abcd6ef53d52a
+ languageName: node
+ linkType: hard
+
"@tiptap/extension-paragraph@npm:3.30.5":
version: 3.30.5
resolution: "@tiptap/extension-paragraph@npm:3.30.5"
@@ -20148,6 +20198,21 @@ __metadata:
languageName: node
linkType: hard
+"@tiptap/y-tiptap@npm:^3.0.7":
+ version: 3.0.9
+ resolution: "@tiptap/y-tiptap@npm:3.0.9"
+ dependencies:
+ lib0: "npm:^0.2.100"
+ peerDependencies:
+ prosemirror-model: ^1.7.1
+ prosemirror-state: ^1.2.3
+ prosemirror-view: ^1.9.10
+ y-protocols: ^1.0.1
+ yjs: ^13.5.38
+ checksum: 10c0/451330971bf0eb5ba1102b2dadc87ead84e9446b54e5ff736befcd9da5513db89fdd56a01fd3066b000de2305a6c95921e7ca0dd6041d3df040e1dbbe5d319fc
+ languageName: node
+ linkType: hard
+
"@tokenizer/inflate@npm:^0.4.1":
version: 0.4.1
resolution: "@tokenizer/inflate@npm:0.4.1"
@@ -37704,7 +37769,7 @@ __metadata:
languageName: node
linkType: hard
-"lib0@npm:^0.2.109":
+"lib0@npm:^0.2.100, lib0@npm:^0.2.109":
version: 0.2.117
resolution: "lib0@npm:0.2.117"
dependencies:
@@ -50449,13 +50514,17 @@ __metadata:
"@testing-library/react": "npm:^16.3.0"
"@tiptap/core": "npm:3.30.5"
"@tiptap/extension-bold": "npm:3.30.5"
+ "@tiptap/extension-collaboration": "npm:3.30.5"
"@tiptap/extension-document": "npm:3.30.5"
+ "@tiptap/extension-drag-handle": "npm:3.30.5"
+ "@tiptap/extension-drag-handle-react": "npm:3.30.5"
"@tiptap/extension-hard-break": "npm:3.30.5"
"@tiptap/extension-heading": "npm:3.30.5"
"@tiptap/extension-image": "npm:3.30.5"
"@tiptap/extension-italic": "npm:3.30.5"
"@tiptap/extension-link": "npm:3.30.5"
"@tiptap/extension-list": "npm:3.30.5"
+ "@tiptap/extension-node-range": "npm:3.30.5"
"@tiptap/extension-paragraph": "npm:3.30.5"
"@tiptap/extension-strike": "npm:3.30.5"
"@tiptap/extension-text": "npm:3.30.5"
@@ -50463,6 +50532,7 @@ __metadata:
"@tiptap/extensions": "npm:3.30.5"
"@tiptap/react": "npm:3.30.5"
"@tiptap/suggestion": "npm:3.30.5"
+ "@tiptap/y-tiptap": "npm:^3.0.7"
"@types/deep-equal": "npm:^1.0.1"
"@types/file-saver": "npm:^2.0.7"
"@types/jest": "npm:^30.0.0"