This repository was archived by the owner on Jan 30, 2026. It is now read-only.
Closed
Conversation
Co-authored-by: caiopizzol <caiopizzol@gmail.com>
|
Cursor Agent can help with this pull request. Just |
SD-548 Use numeric IDs for fields (XML/Word compatibility)
SummaryRemove ID generation from template-builder and let SuperDoc library handle it automatically using its proper Tasks
NotesCurrent problem (src/index.tsx): const fieldId = `field_${Date.now()}`; // ❌ Template builder generates string ID
editor.commands.insertStructuredContentInline?.({
attrs: {
id: fieldId, // ❌ Passes ID to SuperDoc, bypassing auto-generation
alias: field.alias,SuperDoc already handles this (structured-content-commands.js): const attrs = {
...options.attrs,
id: options.attrs?.id || generateRandomSigned32BitIntStrId(), // ✅ Auto-generates if not provided
tag: 'inline_text_sdt',
alias: options.attrs?.alias || 'Structured content',
};The fix - just delete the ID code: // DELETE: const fieldId = `field_${Date.now()}`;
editor.commands.insertStructuredContentInline?.({
attrs: {
// DELETE: id: fieldId,
alias: field.alias,
tag: field.category,
},
text: field.defaultValue || field.alias,
});Why this is better:
After the fix: SuperDoc will automatically generate proper numeric IDs for all new fields Testing: Create fields → export to .docx → open in Microsoft Word → verify SDT tags work correctly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove manual field ID generation in
template-builderto leverage SuperDoc's automatic numeric ID creation for Word compatibility, and update related types.The
template-builderpreviously generated string IDs (field_${Date.now()}) which bypassed SuperDoc's internal mechanism for generating proper signed 32-bit integer IDs, leading to potential compatibility issues with Microsoft Word. This change delegates ID generation entirely to SuperDoc and updates theTemplateFieldinterface and related functions to acceptstring | numberfor IDs. After field insertion, the component now refreshes its state by re-reading fields from the editor to capture the SuperDoc-generated ID.Linear Issue: SD-548