Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sheet): cell related facade api #4032

Merged
merged 10 commits into from
Nov 19, 2024
Merged

fix(sheet): cell related facade api #4032

merged 10 commits into from
Nov 19, 2024

Conversation

Dushusir
Copy link
Member

@Dushusir Dushusir commented Nov 11, 2024

What's updated?

Facade API

    • onCellRender
    • refreshCanvas
    • onBeforeCellEdit
    • onAfterCellEdit

Docs
Write API documentation after the new documentation system is built

How to test?

Testing with Uniscript

  1. Test onCellRender and refreshCanvas

Case 1, fixed position rendering, adding rows will not affect the rendering position

// Fixed position rendering
univerAPI.getSheetHooks().onCellRender([{
    drawWith: (ctx, info, skeleton, spreadsheets)=>{
        const {row, col} = info;
        // Update to any cell location you want
        if(row === 1 && col === 1){
            const { primaryWithCoord } = info;
            const {startX, startY} = primaryWithCoord
            ctx.fillText('✅', startX, startY+10)
        }
    }
}])

// refresh canvas
univerAPI.getActiveWorkbook().getActiveSheet().refreshCanvas()

Case 2, rendering by markup, the mark position will change with the row and column, and the rendering position will also change accordingly

// Mark in advance
univerAPI.getActiveWorkbook().getActiveSheet().getRange('B2').setValue({custom:{key:'needCheck'}})
// Rendering by markup
univerAPI.getSheetHooks().onCellRender([{
    drawWith: (ctx, info, skeleton, spreadsheets)=>{
        const {row, col, data} = info;
        // Update to any cell location you want
        if(data?.custom?.key === 'needCheck'){
            const { primaryWithCoord } = info;
            const {startX, startY} = primaryWithCoord
            ctx.fillText('✅', startX, startY+10)
        }
    }
}])

// refresh canvas
univerAPI.getActiveWorkbook().getActiveSheet().refreshCanvas()
  1. Test onBeforeCellEdit
univerAPI.getSheetHooks().onBeforeCellEdit((params)=>{
    console.info('cell edit before',params)
})
  1. Test onAfterCellEdit
univerAPI.getSheetHooks().onAfterCellEdit((params)=>{
    console.info('cell edit after',params)
})

Pull Request Checklist

  • Related tickets or issues have been linked in the PR description (or missing issue).
  • Naming convention is followed (do please check it especially when you created new plugins, commands and resources).
  • Unit tests have been added for the changes (if applicable).
  • Breaking changes have been documented (or no breaking changes introduced in this PR).

Copy link

github-actions bot commented Nov 11, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

Copy link

github-actions bot commented Nov 11, 2024

Playwright test results

passed  19 passed
flaky  1 flaky

Details

stats  20 tests across 9 suites
duration  5 minutes, 50 seconds
commit  5efbcff
info  For more information, see full report

Flaky tests

chromium › memory/memory.spec.ts › memory

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 47.72727% with 23 lines in your changes missing coverage. Please review.

Project coverage is 33.32%. Comparing base (d882624) to head (5efbcff).
Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
packages/sheets-ui/src/facade/f-worksheet.ts 0.00% 12 Missing ⚠️
packages/sheets-ui/src/facade/f-sheet-hooks.ts 84.00% 4 Missing ⚠️
packages/sheets/src/facade/f-sheet-hooks.ts 0.00% 4 Missing ⚠️
packages/sheets-ui/src/facade/f-univer.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4032      +/-   ##
==========================================
+ Coverage   33.07%   33.32%   +0.25%     
==========================================
  Files        2438     2440       +2     
  Lines      126762   126792      +30     
  Branches    28357    28364       +7     
==========================================
+ Hits        41921    42250     +329     
+ Misses      84841    84542     -299     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@Dushusir Dushusir changed the title fix(sheet): cell render fix(sheet): cell related facade api Nov 11, 2024
@Dushusir Dushusir marked this pull request as ready for review November 13, 2024 08:08
@Dushusir Dushusir added the qa:untested This PR is ready to be tested label Nov 13, 2024
@Dushusir Dushusir requested a review from lumixraku November 13, 2024 08:09
Copy link
Member

@wzhudev wzhudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some usability details need to be addressed.

packages/sheets-ui/src/facade/f-worksheet.ts Outdated Show resolved Hide resolved
packages/sheets-ui/src/facade/f-worksheet.ts Outdated Show resolved Hide resolved
packages/sheets-ui/src/facade/f-sheet-hooks.ts Outdated Show resolved Hide resolved
@wzhudev wzhudev added the qa:verified This PR has already by verified by a QA and is considered good enough to be merge label Nov 14, 2024
@univer-bot univer-bot bot removed the qa:untested This PR is ready to be tested label Nov 14, 2024
@wzhudev
Copy link
Member

wzhudev commented Nov 14, 2024

I am marking this PR as verified because it only changes API.

@Dushusir Dushusir marked this pull request as draft November 14, 2024 06:00
@Dushusir Dushusir force-pushed the dushusir/feat-cell-hook branch 2 times, most recently from 73164fa to d50d2e6 Compare November 16, 2024 09:22
@Dushusir Dushusir marked this pull request as ready for review November 16, 2024 11:10
@Dushusir Dushusir requested a review from VicKun4937 as a code owner November 16, 2024 11:10
Copy link
Member

@wzhudev wzhudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

packages/sheets-ui/src/facade/f-worksheet.ts Outdated Show resolved Hide resolved
@Dushusir Dushusir force-pushed the dushusir/feat-cell-hook branch from 3beec64 to 771754e Compare November 18, 2024 07:24
packages/sheets/src/index.ts Outdated Show resolved Hide resolved
@Dushusir Dushusir requested a review from hexf00 November 18, 2024 09:01
@Dushusir Dushusir force-pushed the dushusir/feat-cell-hook branch from de65ea5 to 5efbcff Compare November 19, 2024 10:06
@Dushusir Dushusir merged commit 545dc82 into dev Nov 19, 2024
9 checks passed
@Dushusir Dushusir deleted the dushusir/feat-cell-hook branch November 19, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qa:verified This PR has already by verified by a QA and is considered good enough to be merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants