Skip to content

fix(open-knowledge): generalize clipboard open-depth guard (#2778)#734

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jul 21, 2026
Merged

fix(open-knowledge): generalize clipboard open-depth guard (#2778)#734
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Copybara-translated 1 Inkeep OSS change. Rebase-merge this PR so the prepared commit lands directly on public main.

* wip: claim clipboard open-depth guard generalization

* fix(open-knowledge): generalize clipboard open-depth guard beyond tables

A partial text selection inside any marker-bearing block (blockquote,
heading, list item, task item, code block, footnote definition) copied the
block's markdown syntax because sliceToDocJson discards slice open depths.
PR #2724 fixed the table-cell instance; this generalizes its strip loop
into stripEnclosingMarkerWrappers, keyed off the live selection: table
wrappers and textblocks peel unconditionally, other marker-bearing
wrappers peel only while the selection covers a strict subset of their
text, and a fully covered list item keeps its list carrier so the
list-sibling paste splice payload is preserved.

The text/html markdown tier now re-derives the original slice from the
selection (PM hands it a context-unwrapped fragment with the depths gone)
and applies the same strip, so partial selections stop dumping full block
elements into rich-paste targets. PM stamps data-pm-slice after we return,
and new round-trip tests prove OK to OK paste of stripped payloads stays
clean.

New test file pins the class: interior selections for every marker-bearing
block on text/plain (marks preserved), the html twin, whole-structure
stay-green copies, and the paste round trip.

* fix(open-knowledge): keep interior copy non-empty across multiple list items

The generalized open-depth guard peels the enclosing list from a text
selection that spans the interior of two or more list items, leaving a
fragment of bare listItems. listItem is not valid top-level doc content,
so sliceToDocJson failed to fill the doc and returned an empty clipboard
string, dropping the copied text entirely (worse than the original
leaked markers). Lift such children to their own block content in the
fill-failure path so the interior text survives without list markers,
matching the two-paragraph blockquote-span result.

Author: Nick Gomez <122398915+nick-inkeep@users.noreply.github.com>

* fix(open-knowledge): satisfy iterable-callback-return lint in lift helper

GitOrigin-RevId: 2a0652196f7912592458b8e63bd083ff9f83c1b1
@inkeep-oss-sync
inkeep-oss-sync Bot merged commit 170acef into main Jul 21, 2026
@inkeep-oss-sync
inkeep-oss-sync Bot deleted the copybara/sync branch July 21, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant