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

feat(facade): add sheet hooks, onCellPointerMove hook #2193

Merged
merged 1 commit into from
May 8, 2024

Conversation

Dushusir
Copy link
Member

@Dushusir Dushusir commented May 8, 2024

close #1176
close #1425

通过监听 HoverManagerService 的 currentCell 变化来抛出当前单元格信息,便于用户在外部做拖拽放置

如何测试?

  1. 打开uniscript
  2. 粘贴以下代码,运行
window.univerAPI.getSheetHooks().onCellPointerMove((cell) => {
  const { location, position } = cell
  window.univerAPI?.getActiveWorkbook()?.getActiveSheet()?.getRange(location.row, location.col)?.setBackgroundColor('red');
})
  1. 鼠标在sheet区域内移动,会将经过的单元格设置为红色背景

Copy link

codecov bot commented May 8, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 2 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (dev@94a86d3). Click here to learn what that means.

Files Patch % Lines
packages/facade/src/apis/facade.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             dev    #2193   +/-   ##
======================================
  Coverage       ?   30.91%           
======================================
  Files          ?     1209           
  Lines          ?    66690           
  Branches       ?    14094           
======================================
  Hits           ?    20620           
  Misses         ?    46070           
  Partials       ?        0           

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

Copy link

github-actions bot commented May 8, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

@Dushusir Dushusir marked this pull request as ready for review May 8, 2024 10:11
@univer-bot
Copy link

univer-bot bot commented May 8, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: feat(facade): add sheet hooks, onCellPointerMove hook

Title: feat(facade): add sheet hooks, onCellPointerMove hook


close #1176
close #1425

By listening to the currentCell changes of HoverManagerService, the current cell information is thrown out to facilitate users to drag and drop externally.

How to test?

  1. Turn on uniscript
  2. Paste the following code and run
window.univerAPI.getSheetHooks().onCellPointerMove((cell) => {
  const { location, position } = cell
  window.univerAPI?.getActiveWorkbook()?.getActiveSheet()?.getRange(location.row, location.col)?.setBackgroundColor('red');
})
  1. When the mouse moves within the sheet area, the cells it passes will be set to a red background.

@hexf00
Copy link
Member

hexf00 commented May 8, 2024

LGTM

@Dushusir Dushusir merged commit 476ffd3 into dev May 8, 2024
12 checks passed
@Dushusir Dushusir deleted the dushusir/facade-cell-hooks branch May 8, 2024 10:50
@HaiYangHuX
Copy link

HaiYangHuX commented May 11, 2024

div在拖拽的时候,钩子不会执行。 <button draggable

        title="拖拽"
      >
       拖拽
      </button> fUniverRef.current.getSheetHooks().onCellPointerMove((cell) => {
  const { location, position } = cell
  console.log('div拖拽')
  // fUniverRef.current?.getActiveWorkbook()?.getActiveSheet()?.getRange(location.row, location.col)?.setBackgroundColor('red');
})

@univer-bot
Copy link

univer-bot bot commented May 11, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

When the div is dragged, the hook will not be executed. <button draggable

        title="Drag and drop"
      >
       drag
      </button> fUniverRef.current.getSheetHooks().onCellPointerMove((cell) => {
  const { location, position } = cell
  console.log('div drag')
  // fUniverRef.current?.getActiveWorkbook()?.getActiveSheet()?.getRange(location.row, location.col)?.setBackgroundColor('red');
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants