Skip to content

Commit 7dba00e

Browse files
authored
Merge pull request #72 from whale4113/feat/whale/image_sources
Failed to fetch image sources
2 parents 45aab1b + 90d757c commit 7dba00e

File tree

19 files changed

+154
-40
lines changed

19 files changed

+154
-40
lines changed

.changeset/forty-roses-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/lark': patch
3+
---
4+
5+
failed to fetch image sources (#69)

.changeset/lucky-squids-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@dolphin/chrome-extension': patch
3+
---
4+
5+
enable larkenterprise.com (#70)

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
},
55
"[json]": {
66
"editor.defaultFormatter": "esbenp.prettier-vscode"
7-
}
7+
},
8+
"biome.enabled": false
89
}

apps/chrome-extension/manifest.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"https://*.feishu.net/*",
2424
"https://*.larksuite.com/*",
2525
"https://*.feishu-pre.net/*",
26-
"https://*.larkoffice.com/*"
26+
"https://*.larkoffice.com/*",
27+
"https://*.larkenterprise.com/*"
2728
],
2829
"content_scripts": [
2930
{
@@ -32,7 +33,8 @@
3233
"https://*.feishu.net/*",
3334
"https://*.larksuite.com/*",
3435
"https://*.feishu-pre.net/*",
35-
"https://*.larkoffice.com/*"
36+
"https://*.larkoffice.com/*",
37+
"https://*.larkenterprise.com/*"
3638
],
3739
"js": ["bundles/content.js"],
3840
"run_at": "document_end"

apps/chrome-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@rollup/plugin-commonjs": "^25.0.8",
1818
"@rollup/plugin-json": "^6.1.0",
1919
"@rollup/plugin-node-resolve": "^15.3.0",
20+
"@rollup/plugin-replace": "^6.0.2",
2021
"@rollup/plugin-terser": "^0.4.4",
2122
"@rollup/plugin-typescript": "^11.1.6",
2223
"chrome-types": "0.1.321",

apps/chrome-extension/rollup.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import json from '@rollup/plugin-json'
55
import commonjs from '@rollup/plugin-commonjs'
66
import { babel } from '@rollup/plugin-babel'
77
import terser from '@rollup/plugin-terser'
8+
import replace from '@rollup/plugin-replace'
89
import { globSync } from 'glob'
910

1011
const isDev = process.env.BUILD === 'development'
@@ -33,6 +34,10 @@ const createSharedPlugins = (options = {}) => {
3334
}),
3435
commonjs(),
3536
json(),
37+
replace({
38+
preventAssignment: true,
39+
'import.meta.env.DEV': JSON.stringify(isDev),
40+
}),
3641
...(isDev ? [] : [terser()]),
3742
]
3843

apps/chrome-extension/src/background.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import { type Message } from './common/message'
22

3+
const sharedDocumentUrlPatterns: string[] = [
4+
'https://*.feishu.cn/*',
5+
'https://*.feishu.net/*',
6+
'https://*.larksuite.com/*',
7+
'https://*.feishu-pre.net/*',
8+
'https://*.larkoffice.com/*',
9+
'https://*.larkenterprise.com/*',
10+
]
11+
312
enum MenuItemId {
413
DOWNLOAD_DOCX_AS_MARKDOWN = 'download_docx_as_markdown',
514
COPY_DOCX_AS_MARKDOWN = 'copy_docx_as_markdown',
@@ -10,39 +19,21 @@ chrome.runtime.onInstalled.addListener(() => {
1019
chrome.contextMenus.create({
1120
id: MenuItemId.DOWNLOAD_DOCX_AS_MARKDOWN,
1221
title: chrome.i18n.getMessage('download_docx_as_markdown'),
13-
documentUrlPatterns: [
14-
'https://*.feishu.cn/*',
15-
'https://*.feishu.net/*',
16-
'https://*.larksuite.com/*',
17-
'https://*.feishu-pre.net/*',
18-
'https://*.larkoffice.com/*',
19-
],
22+
documentUrlPatterns: sharedDocumentUrlPatterns,
2023
contexts: ['page', 'editable'],
2124
})
2225

2326
chrome.contextMenus.create({
2427
id: MenuItemId.COPY_DOCX_AS_MARKDOWN,
2528
title: chrome.i18n.getMessage('copy_docx_as_markdown'),
26-
documentUrlPatterns: [
27-
'https://*.feishu.cn/*',
28-
'https://*.feishu.net/*',
29-
'https://*.larksuite.com/*',
30-
'https://*.feishu-pre.net/*',
31-
'https://*.larkoffice.com/*',
32-
],
29+
documentUrlPatterns: sharedDocumentUrlPatterns,
3330
contexts: ['page', 'editable'],
3431
})
3532

3633
chrome.contextMenus.create({
3734
id: MenuItemId.VIEW_DOCX_AS_MARKDOWN,
3835
title: chrome.i18n.getMessage('view_docx_as_markdown'),
39-
documentUrlPatterns: [
40-
'https://*.feishu.cn/*',
41-
'https://*.feishu.net/*',
42-
'https://*.larksuite.com/*',
43-
'https://*.feishu-pre.net/*',
44-
'https://*.larkoffice.com/*',
45-
],
36+
documentUrlPatterns: sharedDocumentUrlPatterns,
4637
contexts: ['page', 'editable'],
4738
})
4839
})

apps/chrome-extension/src/content.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isConsoleEventData } from '@dolphin/common/dev'
12
import { chunk } from 'es-toolkit/array'
23

34
const COMMENT_BUTTON_CLASS = '.docx-comment__first-comment-btn'
@@ -323,3 +324,13 @@ const urlChangeObserver: MutationObserver = new MutationObserver(() => {
323324
}
324325
})
325326
urlChangeObserver.observe(document.body, { childList: true })
327+
328+
if (import.meta.env.DEV) {
329+
window.addEventListener('message', event => {
330+
if (event.source !== window) return
331+
332+
if (isConsoleEventData(event.data)) {
333+
console.log('console:', ...event.data.payload)
334+
}
335+
})
336+
}

apps/chrome-extension/tsconfig.extension.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"extends": "@dolphin/typescript-config/app.json",
3+
"compilerOptions": {
4+
"types": ["@dolphin/common/env"]
5+
},
36
"include": [
47
"src/background.ts",
58
"src/content.ts",

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ export default tseslint.config(
1515
},
1616
},
1717
{
18-
files: ['**/rollup.config.js'],
18+
files: ['**/rollup.config.js', '**/rollup-config/*.js'],
1919
languageOptions: {
2020
globals: {
2121
...globals.node,
2222
},
2323
},
2424
},
2525
{
26-
ignores: ['**/dist/', '**/bundles/', '**/compiled/'],
26+
ignores: ['**/dist/', '**/bundles/', '**/compiled/', '**/*.d.ts'],
2727
},
2828
)

0 commit comments

Comments
 (0)