From 62c88503ba43c864f7fe981111a1f7577879916e Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 15 Apr 2025 13:53:42 -0400
Subject: fixing summary/elision text node to work better with lists or
 hierarchical text nodes.

---
 src/client/views/nodes/formattedText/SummaryView.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/client/views/nodes/formattedText/SummaryView.tsx')

diff --git a/src/client/views/nodes/formattedText/SummaryView.tsx b/src/client/views/nodes/formattedText/SummaryView.tsx
index 6dea891a0..eeb604b57 100644
--- a/src/client/views/nodes/formattedText/SummaryView.tsx
+++ b/src/client/views/nodes/formattedText/SummaryView.tsx
@@ -59,12 +59,15 @@ export class SummaryView {
         let endPos = start;
 
         const visited = new Set();
-        for (let i: number = start + 1; i < view.state.doc.nodeSize - 1; i++) {
+        const summarized = new Set();
+        const isSummary = (node: Node) => summarized.has(node) || node.marks.find(m => m.type === mtype || m.type === mtypeInc);
+        for (let i = start + 1; i < view.state.doc.nodeSize - 1; i++) {
             let skip = false;
             // eslint-disable-next-line no-loop-func
             view.state.doc.nodesBetween(start, i, (node: Node /* , pos: number, parent: Node, index: number */) => {
+                isSummary(node) && Array.from(node.children).forEach(child => summarized.add(child));
                 if (node.isLeaf && !visited.has(node) && !skip) {
-                    if (node.marks.find(m => m.type === mtype || m.type === mtypeInc)) {
+                    if (summarized.has(node) || isSummary(node)) {
                         visited.add(node);
                         endPos = i + node.nodeSize - 1;
                     } else skip = true;
-- 
cgit v1.2.3-70-g09d2

