Skip to content

Document의 동일 블록 내 offset 선택과 범위 확장을 반영한다 #723

Description

@developer-1px

Goal Anchor

  • Outcome: Document의 같은 블록 안에서도 selection.set이 요청한 offset과 범위 확장을 반영하여 직접 API 호출과 Document text control이 같은 선택 상태를 사용한다.
  • Done: 초기 offset 0에서 2로 이동, 같은 블록 내 양방향 extend와 collapse, 경계 보정이 공개 API와 실제 Document 입력 경로에서 확인된다. 선택만으로 document·기존 Undo/Redo 기록을 바꾸지 않고, 이어지는 편집의 Undo가 변경 전 offset/범위를 복원한다. 블록 단위 toggle·Copy의 기존 의미도 유지한다.
  • Don’t: Core API, 선택 shape, 명령 이름, 블록 단위 Copy/Cut/Paste 의미, 다른 editor의 선택 정책, History owner를 바꾸지 않는다. 새 editor/command registry나 Host-local 우회 구현을 만들지 않는다.

앞서 PR #722에서 기록한 동일 블록 offset 공백에 대해 사용자가 “계속해”로 후속 진행을 요청했다. #721/#722의 공통 적합성 설계는 유지하고 이 재현 가능한 구현 결함은 별도 변경으로 해결한다. Merge는 포함하지 않는다.

재현과 원인

const editor = createDocumentEditor({ blocks: [{ id: "a", text: "Alpha" }] });
editor.dispatch({ type: "selection.set", blockId: "a", offset: 2 });
// 현재: 성공이지만 anchor/focus offset은 0
// 기대: anchor/focus offset은 2

document.tsselectRangePoint에 block ID만 비교하는 함수를 전달한다. 이 함수가 RangeSelection의 point 동등성에도 쓰여서 같은 블록의 offset 변경이 이전 상태와 같다고 판정된다. 블록 toggle의 대상 동등성과 커서/range endpoint의 동등성을 구별해야 한다.

정본 owner는 json-document-editing/src/document.ts와 기존 Selection family다. Document Demo는 DocumentTextControlonCaretRange에서 같은 공개 selection.set을 호출하므로 Demo-local 계산으로 우회하지 않는다. 인접 Order/Tree/Sheet/Database의 같은 helper 사용도 비교해 수정 범위를 확인한다.

검증과 문서

  • Document editor 회귀: point 이동·extend·collapse·clamp, 동일 block toggle, 전체 블록 Copy, publication, 선택과 History의 독립성 및 복원
  • 기존 Editing·Selection·React 관련 테스트·타입 검사·빌드
  • 기존 Document Usage를 기존 Chrome 연결로 확인하고 해당 owner 문서·API reference·source 등록을 검증

#719 / PR #720의 세션 보완은 현재 main에 반영됐다. 그 변경을 새로 구현하지 않는다.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions