Skip to content

feat(drive): support text-range (sub-block) comment anchors in +add-comment for docx #1807

Description

@zrwang

Summary

drive +add-comment --selection-with-ellipsis "<text>" locates the matched text but ultimately anchors the comment to the entire block. In the Feishu client, the comment highlight then covers the whole paragraph rather than only the selected words. Please support true text-range (划词) anchoring so the highlight covers just the matched text, the same as a comment made by hand in the client.

Steps to reproduce

  1. A docx document contains the paragraph: The quick brown fox jumps over the lazy dog.

  2. Run:

    lark-cli drive +add-comment \
      --doc "https://<tenant>.feishu.cn/wiki/<WIKI_TOKEN>" \
      --selection-with-ellipsis "brown fox" \
      --content '[{"type":"text","text":"test"}]'
  3. CLI output shows Locate-doc matched 1 block(s); using match #1 (<block_id>) and creates the comment with anchor_block_id=<block_id>, comment_mode: local.

Current behavior

The comment is anchored at block level, so the Feishu client highlights the whole paragraph.

Expected behavior

Only the text matched by --selection-with-ellipsis (brown fox) is highlighted — i.e. word-level 划词评论, matching what manual commenting in the client produces.

Root cause, as far as I can tell

The underlying OpenAPI drive.file.comments.create_v2 only accepts anchor.block_id for docx — the schema has no start/end offset or text-range fields. Reading comments back with need_relation=true likewise returns only positionInfo.blockID. So this likely requires an Open Platform API extension first; filing here because --selection-with-ellipsis already expresses text-level intent, and the CLI is the natural place to surface the capability once available (and perhaps to relay the need to the OpenAPI team).

Suggestions

  • When the API supports it, keep --selection-with-ellipsis as the locator and submit the precise text range so the highlight matches the selection.
  • Until then, consider noting in +add-comment --help and the skill docs that docx anchoring is block-level, so the whole-line highlight doesn't surprise users.

Environment

  • lark-cli v1.0.65
  • macOS (darwin)

Sent by Jerry's Claw

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain/coreCLI framework and core librariesdomain/docDocs domainenhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions