Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(lexical): collapse nested block paragraphs in single-line editors (#4067)

gbirmanfa490c877039
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 792dbea5fe..b3834af65f 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -629,7 +629,7 @@ export const SoupView = (props: SoupViewProps) => {
when={!isComponentListView('search')}
fallback={
<Layer depth={2}>
- <div class="grow ml-2">
+ <div class="grow ml-2 min-w-0 [contain:inline-size]">
<SoupSearchbar
variant="secondary"
placeholder="Search, @mention contacts"
diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/single-line/singleLinePlugin.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/single-line/singleLinePlugin.ts
index 8cfdf75d15..27ea5e63d5 100644
--- a/js/app/packages/core/component/LexicalMarkdown/plugins/single-line/singleLinePlugin.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/single-line/singleLinePlugin.ts
@@ -2,7 +2,13 @@
* @file A plugin to enforce a single line only.
*/
import { mergeRegister } from '@lexical/utils';
-import { type LexicalEditor, LineBreakNode, RootNode } from 'lexical';
+import {
+ $isRootNode,
+ type LexicalEditor,
+ LineBreakNode,
+ ParagraphNode,
+ RootNode,
+} from 'lexical';
export function singleLinePlugin() {
return (editor: LexicalEditor) => {
@@ -15,6 +21,19 @@ export function singleLinePlugin() {
editor.registerNodeTransform(LineBreakNode, (node) => {
node.remove();
+ }),
+
+ // Programmatic inserts (snippets, paste) can nest block paragraphs inside
+ // the single root paragraph, which the root-child check above doesn't
+ // catch. Unwrap them so a nested block's inline content collapses onto the
+ // one line instead of rendering as extra rows.
+ editor.registerNodeTransform(ParagraphNode, (node) => {
+ const parent = node.getParent();
+ if (!parent || $isRootNode(parent)) return;
+ for (const child of node.getChildren()) {
+ node.insertBefore(child);
+ }
+ node.remove();
})
);
};