feat(docs): auto-resize table column widths after document create/update#56
Closed
SoIomon wants to merge 2 commits intolarksuite:mainfrom
Closed
feat(docs): auto-resize table column widths after document create/update#56SoIomon wants to merge 2 commits intolarksuite:mainfrom
SoIomon wants to merge 2 commits intolarksuite:mainfrom
Conversation
After creating or updating a document via MCP, post-process all table blocks to calculate optimal column widths based on cell content. CJK and fullwidth characters count as 2 units, ASCII as 1. Column widths are clamped between 80px and 400px and normalized to fit within the 700px document container. Failures are non-fatal (degrade to equal width with a warning).
3 tasks
Author
|
实现有 bug,修复后重新提交 |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When creating or updating documents via
docs +createordocs +update, table columns are rendered with equal widths regardless of content. This PR adds automatic column width calculation based on cell content, similar to how spreadsheet applications auto-fit column widths.Changes
New file:
table_auto_width.go— Post-processing logic that:batch_updateAPI to apply computed widthsNew file:
table_auto_width_test.go— Unit tests for width calculation, wide character detection, and pixel width constraintsModified:
docs_create.go— CallsautoResizeTableColumns()after successful document creationModified:
docs_update.go— CallsautoResizeTableColumns()afteroverwrite/appendmode updatesDesign decisions
runtime.CallAPIconsistent withdoc_media_insert.goTest plan
go build ./...passesgo test ./shortcuts/doc/...passes