Skip to content

Commit 877b175

Browse files
committed
feat: qq sheet #113
1 parent 8097c65 commit 877b175

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

packages/copy/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "🔥🔥🔥文本选中复制🔥🔥🔥",
33
"namespace": "https://github.com/WindrunnerMax/TKScript",
4-
"version": "6.1.20",
4+
"version": "6.1.21",
55
"description": "解除网站不允许复制的限制,文本选中后点击复制按钮即可复制,主要用于 百度文库 道客巴巴 腾讯文档 豆丁网 无忧考网 学习啦 蓬勃范文 思否社区 力扣 知乎 语雀 等",
66
"author": "Czy",
77
"match": [
@@ -21,6 +21,7 @@
2121
"*://*.zhihu.com/*",
2222
"*://z.30edu.com.cn/*",
2323
"*://docs.qq.com/doc/*",
24+
"*://docs.qq.com/sheet/*",
2425
"*://boke112.com/post/*",
2526
"*://*.yuque.com/*",
2627
"*://www.commandlinux.com/*",

packages/copy/src/modules/docqq.ts

+39-4
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,61 @@ const website: Website = {
2020
const editor = unsafeWindow.pad.editor;
2121
if (editor.getCopyContent) {
2222
const content = editor.getCopyContent() || {};
23-
const plainText: string | undefined = content.plain;
24-
const htmlText: string | undefined = content.html;
23+
const plainText: string = content.plain || "";
24+
const htmlText: string = content.html || "";
2525
return {
2626
[TEXT_PLAIN]: plainText,
2727
[TEXT_HTML]: htmlText,
2828
};
2929
} else {
3030
editor._docEnv.copyable = true;
3131
editor.clipboardManager.copy();
32-
const plainText: string | undefined = editor.clipboardManager.customClipboard.plain;
33-
const htmlText: string | undefined = editor.clipboardManager.customClipboard.html;
32+
const plainText: string = editor.clipboardManager.customClipboard.plain || "";
33+
const htmlText: string = editor.clipboardManager.customClipboard.html || "";
3434
editor._docEnv.copyable = false;
3535
return {
3636
[TEXT_PLAIN]: plainText,
3737
[TEXT_HTML]: htmlText,
3838
};
3939
}
40+
} else if (
41+
unsafeWindow.SpreadsheetApp &&
42+
unsafeWindow.SpreadsheetApp.permissions &&
43+
unsafeWindow.SpreadsheetApp.permissions.sheetStatus &&
44+
unsafeWindow.SpreadsheetApp.permissions.sheetStatus.canCopy === false &&
45+
unsafeWindow.SpreadsheetApp.permissions.sheetStatus.canEdit &&
46+
unsafeWindow.SpreadsheetApp.permissions.sheetStatus.canEdit() === false
47+
) {
48+
utils.showButton();
49+
const SpreadsheetApp = unsafeWindow.SpreadsheetApp;
50+
const [selection] = SpreadsheetApp.view.getSelectionRanges();
51+
if (selection) {
52+
const text: string[] = [];
53+
const { startColIndex, startRowIndex, endColIndex, endRowIndex } = selection;
54+
for (let i = startRowIndex; i <= endRowIndex; i++) {
55+
for (let k = startColIndex; k <= endColIndex; k++) {
56+
const cell = SpreadsheetApp.workbook.activeSheet.getCellDataAtPosition(i, k);
57+
if (!cell) continue;
58+
text.push(" ", cell.value || "");
59+
}
60+
i !== endRowIndex && text.push("\n");
61+
}
62+
const str = text.join("");
63+
return /^\s*$/.test(str) ? "" : str;
64+
}
65+
return "";
4066
}
4167
return "";
4268
},
4369
};
4470

4571
export default website;
72+
73+
// Sheet
74+
// SpreadsheetApp.feature._copyPaste.copyPasteCache.onCopy({
75+
// selectGridRange: SpreadsheetApp.view.getSelectionRanges()[0],
76+
// copyType: 0,
77+
// app: SpreadsheetApp.feature.app,
78+
// isSelectAll: undefined,
79+
// });
80+
// SpreadsheetApp.sheetStatus.workbookStatus.status.setCanCopy(true);

0 commit comments

Comments
 (0)