Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: copy not work when after copy tooltip text #3968\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
4 changes: 3 additions & 1 deletion packages/vtable/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<div id="chartContainer">
<div id="vTable" style="position: relative; height: 100%; width: 100%; overflow: hidden"></div>
</div>
<div id="article"></div>
<div id="article">
<div class="arco-card-header"><div class="arco-card-header-title"><p><span class="mr8">test test test</span><svg fill="none" stroke="currentColor" stroke-width="4" viewBox="0 0 48 48" aria-hidden="true" focusable="false" class="arco-icon arco-icon-question-circle"><path d="M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6s18 8.059 18 18Z"></path><path d="M24.006 31v4.008m0-6.008L24 28c0-3 3-4 4.78-6.402C30.558 19.195 28.288 15 23.987 15c-4.014 0-5.382 2.548-5.388 4.514v.465"></path></svg></p></div></div>
</div>
</div>
</div>
</body>
Expand Down
2 changes: 2 additions & 0 deletions packages/vtable/src/event/listener/table-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getCellMergeInfo } from '../../scenegraph/utils/get-cell-merge';
import type { CheckBox, CheckboxAttributes, Radio } from '@src/vrender';
import { handleWhell } from '../scroll';
import { fireMoveColEventListeners } from '../helper';
import { clearPageSelection } from '../../tools/env';
export function bindTableGroupListener(eventManager: EventManager) {
const table = eventManager.table;
const stateManager = table.stateManager;
Expand Down Expand Up @@ -395,6 +396,7 @@ export function bindTableGroupListener(eventManager: EventManager) {
event: e.nativeEvent
});
}
clearPageSelection();
// table.eventManager.isPointerDownOnTable = true;
// setTimeout(() => {
// table.eventManager.isPointerDownOnTable = false;
Expand Down
34 changes: 34 additions & 0 deletions packages/vtable/src/tools/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,37 @@ function defaultMode(): EnvMode {
}
return mode;
}
/**
* 清空页面上的所有文本选择,使用多种兼容性方法
*/
export function clearPageSelection(): void {
try {
const selection = window.getSelection();
if (selection) {
// 方法1: removeAllRanges() - 标准方法,最广泛支持
if (typeof selection.removeAllRanges === 'function') {
selection.removeAllRanges();
console.log('使用 removeAllRanges() 清空selection');
return;
}

// 方法2: empty() - IE 和一些旧浏览器
if (typeof (selection as any).empty === 'function') {
(selection as any).empty();
console.log('使用 empty() 清空selection');
return;
}

// 方法3: collapse() - 备用方法
if (typeof selection.collapse === 'function') {
selection.collapse(document.body, 0);
console.log('使用 collapse() 清空selection');
return;
}

console.warn('无法清空selection:不支持的浏览器');
}
} catch (error) {
console.warn('清空selection时出错:', error);
}
}
Loading