From 563a6d0e08a0947450a83e443b27110ceea25cb2 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Tue, 7 Apr 2026 18:04:45 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20Fix=20drop=20cursor=20?= =?UTF-8?q?creating=20columns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When dropping content, the drop cursor was creating new columns. This fix ensures that the drop cursor behaves correctly and does not create unnecessary columns. --- CHANGELOG.md | 4 ++ .../components/xl-multi-column/index.ts | 45 ++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2091c3a0..fdf5c571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to - 🚸(frontend) allow opening "@page" links with ctrl/command/middle-mouse click - ✅ E2E - Any instance friendly #2142 +### Fixed + +- 🐛(frontend) Fix drop cursor creating columns #2185 + ## [v4.8.5] - 2026-04-03 ### Added diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/xl-multi-column/index.ts b/src/frontend/apps/impress/src/features/docs/doc-editor/components/xl-multi-column/index.ts index 301c34dd..584deb9e 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/xl-multi-column/index.ts +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/xl-multi-column/index.ts @@ -3,13 +3,54 @@ * This is to ensure that the XL modules are only loaded when * the application is not published as MIT. */ +import type { + BlockNoteSchema, + BlockSchema, + InlineContentSchema, + StyleSchema, +} from '@blocknote/core'; import * as XLMultiColumn from '@blocknote/xl-multi-column'; +/** + * Custom withMultiColumn that strips the MultiColumnDropHandlerExtension + * from ColumnBlock. + * This prevents dragging a block onto another block from + * automatically creating a multi-column layout. + * @param schema + * @returns + */ +const withMultiColumnNoDropHandler = < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema, +>( + schema: BlockNoteSchema, +) => { + const ColumnBlockNoDropHandler = { + ...XLMultiColumn.ColumnBlock, + extensions: [], + }; + + return schema.extend({ + blockSpecs: { + column: ColumnBlockNoDropHandler, + columnList: XLMultiColumn.ColumnListBlock, + }, + }); +}; + let modulesXL = undefined; if (process.env.NEXT_PUBLIC_PUBLISH_AS_MIT === 'false') { - modulesXL = XLMultiColumn; + modulesXL = { + ...XLMultiColumn, + withMultiColumn: withMultiColumnNoDropHandler, + }; } -type ModulesXL = typeof XLMultiColumn | undefined; +type ModulesXL = + | (Omit & { + withMultiColumn: typeof withMultiColumnNoDropHandler; + }) + | undefined; export default modulesXL as ModulesXL;