feat(sheets): add facade range list api#6932
Open
hexf00 wants to merge 1 commit into
Open
Conversation
View Deployment
|
Playwright test resultsDetails
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #6932 +/- ##
==========================================
+ Coverage 60.60% 60.66% +0.05%
==========================================
Files 2580 2584 +4
Lines 148313 148499 +186
Branches 33447 33464 +17
==========================================
+ Hits 89888 90085 +197
+ Misses 58425 58414 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9cac6cc to
e323f29
Compare
e323f29 to
a0c63c5
Compare
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
FRangeListfacade support for applying the same operation to non-contiguous ranges.FWorksheet.getRangeList(a1Notations)andFWorkbook.getRangeList(a1Notations); unqualified A1 notations resolve against the caller sheet / active sheet, while sheet-qualified A1 notations may target another sheet.sheets-numfmt,sheets-data-validation, andsheets-note, so RangeList keeps Univer package boundaries while supporting number formats, data validations, checkboxes, and notes.Google Apps Script RangeList Alignment
Reference: Google Apps Script
RangeList/getRangeList(a1Notations)public reference. Google documents are licensed under CC BY 4.0 and sample code under Apache 2.0. This PR is an Apache 2.0 open-source implementation in Univer, using the public API surface as a migration-friendly compatibility reference while keeping Univer-style enums and package boundaries.Supported in this PR:
FWorksheet.getRangeList(a1Notations: string[])FWorkbook.getRangeList(a1Notations: string[])for the active sheetFRangeList.getRanges()activate()breakApart()check()/uncheck()via sheets-data-validation facade mixinclear()/clear(options)with Univer clear optionsclearContent()clearDataValidations()via sheets-data-validation facade mixinclearFormat()clearNote()via sheets-note facade mixininsertCheckboxes()overloads andremoveCheckboxes()via sheets-data-validation facade mixinsetBackground(color)/setBackgroundColor(color)setBackgroundRGB(red, green, blue)setBorder(type, style, color?)using UniverBorderType/BorderStyleTypessetDataValidation(rule)using Univer data validation builder APIsetFontColor(color)setFontFamily(fontFamily)setFontLine(fontLine)setFontSize(size)setFontStyle(fontStyle)setFontWeight(fontWeight)setFormula(formula)for A1 formulassetHorizontalAlignment(alignment)setNote(note)via sheets-note facade mixinsetNumberFormat(pattern)via sheets-numfmt facade mixinsetTextDirection(direction)using UniverTextDirectionsetTextRotation(rotation)setValue(value)setVerticalAlignment(alignment)setWrap(isWrapEnabled)setWrapStrategy(strategy)Follow-up TODOs from Google RangeList API surface:
setFormulaR1C1(formula)- Univer has R1C1 range parse/serialize utilities, but this API needs formula-string-level R1C1 reference conversion relative to each target cell before it can be exposed safely.setShowHyperlink(showHyperlink)- no direct Univer facade/display-flag equivalent identified in the current hyperlink facade surface.setVerticalText(isVertical)- no direct Univer sheets facade equivalent identified yet.trimWhitespace()- implement separately with explicit value/rich-text/formula semantics.Known differences from Google Apps Script:
getRangeList()currently documents and tests A1 notation. R1C1 formula support is intentionally not claimed in this PR.activate()throws for cross-sheet range lists because active selection is a single-sheet UI state. Other operations may dispatch across sheet-qualified ranges by grouping or delegating per range.setBorder()follows Univer's enum-basedFRange.setBorder(type, style, color?)API instead of Google Apps Script boolean-edge overloads.clear(options)follows Univer's currentIFacadeClearOptionsshape.check()/uncheck()write the existing checkbox rule's checked/unchecked value and throw if the target contains non-checkbox data validation or mixed checkbox values.removeCheckboxes()refuses to clear ranges that contain non-checkbox data validation, avoiding accidental deletion of unrelated validation rules.setNote()/clearNote()target the top-left cell of each range, matching the existing sheets-note facade note model.clearDataValidations(),setDataValidation(), checkbox methods, note methods, and number format methods are provided by package-specific facade mixins.Implementation Notes
FRange; they can be optimized later by extending the underlying command layer without changing the facade API.Tests
pnpm --filter @univerjs/sheets typecheckpnpm --filter @univerjs/sheets test src/facade/__tests__/f-range-list.spec.ts src/facade/__tests__/f-workbook.spec.tspnpm --filter @univerjs/sheets-numfmt typecheckpnpm --filter @univerjs/sheets-numfmt test src/facade/__tests__/f-range.spec.tspnpm --filter @univerjs/sheets-data-validation typecheckpnpm --filter @univerjs/sheets-data-validation test src/facade/__tests__/f-range.spec.tspnpm --filter @univerjs/sheets-note typecheckpnpm --filter @univerjs/sheets-note test src/facade/__tests__/sheets-note.facade.spec.tspnpm exec eslint packages/sheets/src/facade/f-range.ts packages/sheets/src/facade/f-range-list.ts packages/sheets/src/facade/f-workbook.ts packages/sheets/src/facade/f-worksheet.ts packages/sheets/src/facade/index.ts packages/sheets/src/facade/__tests__/f-range-list.spec.ts packages/sheets/src/facade/__tests__/f-workbook.spec.ts packages/sheets-numfmt/src/facade/f-range-list.ts packages/sheets-numfmt/src/facade/index.ts packages/sheets-numfmt/src/facade/__tests__/f-range.spec.ts packages/sheets-data-validation/src/facade/f-range-list.ts packages/sheets-data-validation/src/facade/index.ts packages/sheets-data-validation/src/facade/__tests__/f-range.spec.ts packages/sheets-note/src/facade/f-range.ts packages/sheets-note/src/facade/f-range-list.ts packages/sheets-note/src/facade/index.ts packages/sheets-note/src/facade/__tests__/sheets-note.facade.spec.tsgit diff --check