Skip to content

Commit 4e4fc05

Browse files
authored
fix(super-editor): structural text.rewrite for multi-block replacements (#2733)
* fix(super-editor): create paragraph nodes for multi-block text.rewrite on range targets * fix(super-editor): split replacement text on paragraph breaks for multi-paragraph rewrites * Revert "fix(super-editor): split replacement text on paragraph breaks for multi-paragraph rewrites" This reverts commit 429b207. * Revert "fix(super-editor): create paragraph nodes for multi-block text.rewrite on range targets" This reverts commit 1284c55. * fix(super-editor): implement structural text.rewrite for multi-block replacements - Added support for replacing entire textblocks with multiple paragraphs when the replacement text normalizes to multiple blocks. - Enhanced the `executeTextRewrite` function to handle structural rewrites and maintain paragraph attributes. - Introduced utility functions to manage text range and paragraph node creation for improved text handling during rewrites. * docs(system-prompt): add clarification on document structure and paragraph identification * fix(super-editor): address PR review β€” shared identity helper, position-based textblock check * fix(super-editor): preserve multi-block tracked rewrites
1 parent a995731 commit 4e4fc05

File tree

9 files changed

+1463
-106
lines changed

9 files changed

+1463
-106
lines changed

β€Žexamples/collaboration/ai-node-sdk/Makefileβ€Ž

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: install dev dev-local dev-server dev-client link-local-sdk rebuild-local-sdk restore-npm-sdk kill clean help
1+
.PHONY: install dev dev-local dev-server dev-client build-local-artifacts link-local-sdk rebuild-local-sdk restore-npm-sdk kill clean help
22

33
# ─── Config ───────────────────────────────────────────────────────────────────
44

@@ -82,7 +82,7 @@ dev: check-env kill restore-npm-sdk ## Start with npm SDK (default)
8282
"cd server && npm run dev" \
8383
"cd client && $(PNPM) run dev"
8484

85-
dev-local: check-env kill link-local-sdk ## Start with local SDK (built from monorepo)
85+
dev-local: check-env kill link-local-sdk ## Start with local SDK (always rebuilds local artifacts)
8686
@echo ""
8787
@echo " Server β†’ http://localhost:8090 + ws://localhost:8081 (local SDK)"
8888
@echo " Client β†’ http://localhost:5173"
@@ -109,25 +109,32 @@ restore-npm-sdk: ## Restore SDK from npm if currently symlinked
109109

110110
# ─── Local SDK ────────────────────────────────────────────────────────────────
111111

112-
link-local-sdk: ## Build and link local SuperDoc SDK + CLI
112+
build-local-artifacts: ## Rebuild local editor, SDK, and CLI artifacts used by dev-local
113+
@echo "Rebuilding local SuperDoc artifacts..."
114+
@echo " Building @superdoc/super-editor..."
115+
@cd $(ROOT) && $(PNPM) --filter @superdoc/super-editor run build
116+
@echo " Building superdoc..."
117+
@cd $(ROOT) && $(PNPM) --filter superdoc run build:es
118+
@echo " Building @superdoc-dev/react..."
119+
@cd $(ROOT) && $(PNPM) --filter @superdoc-dev/react run build
120+
@echo " Building @superdoc-dev/sdk..."
121+
@cd $(ROOT) && $(PNPM) --filter @superdoc-dev/sdk run build
122+
@echo " Building CLI binary..."
123+
@cd $(ROOT) && $(PNPM) --filter @superdoc-dev/cli run build:native:host
124+
@echo "βœ“ Local artifacts rebuilt"
125+
126+
link-local-sdk: build-local-artifacts ## Build and link local SuperDoc SDK + CLI
113127
@echo "Linking local SuperDoc SDK ($(CLI_TARGET))..."
114-
@# 1. Build CLI native binary if not already built
115-
@if [ ! -f $(CLI_ARTIFACT) ]; then \
116-
echo " Building CLI binary..."; \
117-
cd $(ROOT) && $(PNPM) --filter @superdoc-dev/cli run build:native:host; \
118-
else \
119-
echo " CLI binary found"; \
120-
fi
121-
@# 2. Ensure server node_modules exists
128+
@# 1. Ensure server node_modules exists
122129
@if [ ! -d server/node_modules ]; then \
123130
echo " Installing server deps first..."; \
124131
cd server && npm install; \
125132
fi
126-
@# 3. Replace npm SDK with symlink to workspace source
133+
@# 2. Replace npm SDK with symlink to workspace source
127134
@rm -rf server/node_modules/@superdoc-dev/sdk
128135
@ln -sf $(SDK_SRC) server/node_modules/@superdoc-dev/sdk
129136
@echo " βœ“ Linked SDK β†’ $(SDK_SRC)"
130-
@# 4. Place CLI binary where the workspace SDK can find it via require.resolve
137+
@# 3. Place CLI binary where the workspace SDK can find it via require.resolve
131138
@# Node follows the symlink real path, so the binary must be in the
132139
@# workspace SDK's own node_modules, not the server's.
133140
@mkdir -p $(SDK_SRC)/node_modules/$(CLI_PKG)/bin
@@ -136,13 +143,7 @@ link-local-sdk: ## Build and link local SuperDoc SDK + CLI
136143
@echo " βœ“ Linked CLI binary"
137144
@echo "βœ“ Local SDK ready"
138145

139-
rebuild-local-sdk: ## Rebuild CLI binary and re-link
140-
@echo "Rebuilding CLI binary..."
141-
@cd $(ROOT) && $(PNPM) --filter @superdoc-dev/cli run build:native:host
142-
@mkdir -p $(SDK_SRC)/node_modules/$(CLI_PKG)/bin
143-
@cp $(CLI_ARTIFACT) $(SDK_SRC)/node_modules/$(CLI_PKG)/bin/$(CLI_BINARY)
144-
@chmod +x $(SDK_SRC)/node_modules/$(CLI_PKG)/bin/$(CLI_BINARY)
145-
@echo "βœ“ CLI binary updated"
146+
rebuild-local-sdk: link-local-sdk ## Rebuild local artifacts and refresh links
146147

147148
# ─── Cleanup ──────────────────────────────────────────────────────────────────
148149

β€Žpackages/sdk/langs/browser/src/intent-dispatch.tsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export function dispatchIntentTool(
5454
return execute('doc.format.paragraph.setIndentation', rest);
5555
case 'set_spacing':
5656
return execute('doc.format.paragraph.setSpacing', rest);
57+
case 'set_flow_options':
58+
return execute('doc.format.paragraph.setFlowOptions', rest);
5759
case 'set_direction':
5860
return execute('doc.format.paragraph.setDirection', rest);
5961
default:
@@ -67,6 +69,8 @@ export function dispatchIntentTool(
6769
return execute('doc.create.paragraph', rest);
6870
case 'heading':
6971
return execute('doc.create.heading', rest);
72+
case 'table':
73+
return execute('doc.create.table', rest);
7074
default:
7175
throw new Error(`Unknown action for superdoc_create: ${action}`);
7276
}

0 commit comments

Comments
Β (0)