Skip to content

feat(executor): add tab character to tab node conversion in text insert#2832

Merged
harbournick merged 6 commits intomainfrom
andrii/sd-2567-api-tabs-export
Apr 22, 2026
Merged

feat(executor): add tab character to tab node conversion in text insert#2832
harbournick merged 6 commits intomainfrom
andrii/sd-2567-api-tabs-export

Conversation

@andrii-harbour
Copy link
Copy Markdown
Contributor

No description provided.

@andrii-harbour andrii-harbour self-assigned this Apr 15, 2026
@linear
Copy link
Copy Markdown

linear Bot commented Apr 15, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4a3cd90a8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…ontent for tab nodes

- Introduced a new integration test for the `executeTextInsert` function to validate behavior when inserting text into nodes that disallow tab nodes, specifically for the `total-page-number` type.
- Updated the `executeTextInsert` function to check if the parent node allows tab nodes before creating them, ensuring that raw tab characters are preserved as text when necessary.
- Added a utility function `parentAllowsNode` to determine if a node type can be inserted based on the parent's content match.
@andrii-harbour andrii-harbour requested review from caio-pizzol and harbournick and removed request for harbournick April 20, 2026 22:18
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@caio-pizzol
Copy link
Copy Markdown
Contributor

caio-pizzol commented Apr 21, 2026

hey @andrii-harbour - review pass on this one, wanted to share a few concerns.

fixing tabs at the editor-data layer introduces two new problems:

  • marks get dropped on the tab. tabNodeType.create() is called without marks, so a tab between bold text exports without the formatting.
  • reading a tab back returns shorter text than what was written. once a real tab node exists, textBetween returns empty for it - breaks the no-op check at write-adapter.ts:98. fix isn't obvious.

scope is also narrow: doc.replace, untargeted doc.insert, and untargeted tracked inserts still emit raw \t. and there's a || true in the new test that makes the assertion always pass.

might be worth going export-side instead: when serializing a text run, if we see \t, emit <w:tab/>. ~20 lines, one place, covers every path at once, same pattern later fixes \n<w:br/>. no editor-layer changes - marks stay put, reads keep working.

happy to chat if there's context i'm missing.

@andrii-harbour
Copy link
Copy Markdown
Contributor Author

hey @andrii-harbour - review pass on this one, wanted to share a few concerns.

fixing tabs at the editor-data layer introduces two new problems:

  • marks get dropped on the tab. tabNodeType.create() is called without marks, so a tab between bold text exports without the formatting.
  • reading a tab back returns shorter text than what was written. once a real tab node exists, textBetween returns empty for it - breaks the no-op check at write-adapter.ts:98. fix isn't obvious.

scope is also narrow: doc.replace, untargeted doc.insert, and untargeted tracked inserts still emit raw \t. and there's a || true in the new test that makes the assertion always pass.

might be worth going export-side instead: when serializing a text run, if we see \t, emit <w:tab/>. ~20 lines, one place, covers every path at once, same pattern later fixes \n<w:br/>. no editor-layer changes - marks stay put, reads keep working.

happy to chat if there's context i'm missing.

hey @caio-pizzol ! Thnx for the review. I agree that going export-side would be easier fix, however I have one concern here. Doing that means we have different nodes/content while rendering the doc and while exporting the doc. That might not be the problem now, but in the long run with this approach our differences of actual data for document API and data for export would be too different.
would be glad to chat on this one, maybe I'm missing something.

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @andrii-harbour! you're right - the importer makes tab nodes on docx open anyway, so keeping the write path consistent is the cleaner call. scratch my export-side suggestion from before.

that said, the inline comments are still valid. the four things from my earlier pass haven't moved:

  • marks dropped on the tab node
  • || true in the new test
  • only insert is fixed - replace and the structural paths still write raw \t
  • reading a tab back gives \ufffc instead of \t

good to merge after that.

@andrii-harbour
Copy link
Copy Markdown
Contributor Author

@caio-pizzol deal. Agree on the comments. Working on the fixes now

…raction

- Introduced `buildTextWithTabs` and `textBetweenWithTabs` functions to manage tab characters, converting them to tab nodes during text insertion and ensuring they are correctly represented in document extraction.
- Updated existing commands (`insertHeadingAt`, `insertListItemAt`, `insertParagraphAt`) to utilize the new tab handling functions, enhancing text formatting capabilities.
- Modified tests to validate the new tab handling behavior, ensuring that tab characters are preserved and correctly processed in various scenarios.
- Added comprehensive tests for the new helper functions to ensure robust functionality across different document structures.

This update enhances the editor's ability to handle tab characters, improving the overall user experience when working with formatted text.
@andrii-harbour
Copy link
Copy Markdown
Contributor Author

@caio-pizzol made the fixes. A bit more than expected, but also fixed a few minor things along the way

Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harbournick harbournick enabled auto-merge (squash) April 22, 2026 00:48
@harbournick harbournick merged commit bc6e5bf into main Apr 22, 2026
44 checks passed
@harbournick harbournick deleted the andrii/sd-2567-api-tabs-export branch April 22, 2026 00:51
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.38

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.40

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc-cli v0.8.0-next.3

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc v1.28.0-next.3

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc-sdk v1.6.0-next.39

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in esign v2.4.0

The release is available on GitHub release

superdoc-bot Bot pushed a commit that referenced this pull request Apr 22, 2026
### Bug Fixes

- restore published config typings
- place cursor at clicked pos inside tracked change (#2855)
- wait for in-flight cleanup in dispose() (#2892)

### Changes

- Merge remote-tracking branch 'origin/main' into merge/main-into-stable-2026-04-22

### Features

- add tab character to tab node conversion in text insert (#2832)
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc-sdk v1.7.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc v1.28.0

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants