Skip to content

Commit

Permalink
feat: support ignore list for / key
Browse files Browse the repository at this point in the history
  • Loading branch information
Quorafind committed Jan 10, 2023
1 parent 87c2b99 commit c8edbc6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "surfing",
"name": "Surfing",
"version": "0.8.10",
"version": "0.8.11",
"minAppVersion": "1.0.0",
"description": "Surf the Net in Obsidian.",
"author": "Boninall & Windily-cloud",
Expand All @@ -12,4 +12,4 @@
"爱发电": "https://afdian.net/a/boninall",
"支付宝": "https://cdn.jsdelivr.net/gh/Quorafind/.github@main/IMAGE/%E6%94%AF%E4%BB%98%E5%AE%9D%E4%BB%98%E6%AC%BE%E7%A0%81.jpg"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "surfing",
"version": "0.8.10",
"version": "0.8.11",
"description": "Use surfing to surf the net in Obsidian.",
"main": "main.js",
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions src/surfingPluginSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type SearchOptionInfo = { name: string, description: string, options?: Dr
export interface SurfingSettings {
defaultSearchEngine: string;
customSearchEngine: SearchEngine[];
ignoreList: string[];
alwaysShowCustomSearch: boolean;
showOtherSearchEngines: boolean;
showSearchBarInPage: boolean;
Expand Down Expand Up @@ -75,6 +76,7 @@ export const DEFAULT_SETTINGS: SurfingSettings = {
name: 'duckduckgo',
url: 'https://duckduckgo.com/?q=',
}],
ignoreList: ["notion", "craft"],
alwaysShowCustomSearch: false,
showOtherSearchEngines: false,
showSearchBarInPage: false,
Expand Down Expand Up @@ -485,6 +487,20 @@ export class SurfingSettingTab extends PluginSettingTab {

this.addSettingToMasterSettingsList(tabName, setting.settingEl, settingName);

settingName = t('Disable / to search when on these sites');
setting = new Setting(wbContainerEl)
.setName(settingName)
.addText((text) => {
text.setPlaceholder(DEFAULT_SETTINGS.ignoreList.join(","))
.setValue(this.plugin.settings.ignoreList.join(","))
.onChange(async (value) => {
this.plugin.settings.ignoreList = value.split(",");
this.applySettingsUpdate()
})
})

this.addSettingToMasterSettingsList(tabName, setting.settingEl, settingName);

settingName = t('Always Show Custom Engines');
setting = new Setting(wbContainerEl)
.setName(settingName)
Expand Down
10 changes: 6 additions & 4 deletions src/surfingView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,14 @@ export class SurfingView extends ItemView {

// TODO: Allow set hotkey in webview;
if (emulatedKeyboardEvent.key === '/') {
webContents.executeJavaScript(`
if (!this.plugin.settings.ignoreList.find((item: string) => this.currentUrl.contains(item))) {
webContents.executeJavaScript(`
document.activeElement instanceof HTMLInputElement
`, true).then((result: any) => {
if (!result) this.headerBar.focus();
});
return;
if (!result) this.headerBar.focus();
});
return;
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/translations/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ export default {
'Copy failed, you may focus on surfing view, click the title bar, and try again.': 'Copy failed, you may focus on surfing view, click the title bar, and try again.',
"Default Category (Use , to split)": "Default Category (Use , to split)",
"Send to ReadWise": "Send to ReadWise",
"Add a action in page haader to Send to ReadWise.": "Add a action in page haader to Send to ReadWise."
"Add a action in page haader to Send to ReadWise.": "Add a action in page haader to Send to ReadWise.",
'Disable / to search when on these sites': 'Disable / to search when on these sites',
};
1 change: 1 addition & 0 deletions src/translations/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ export default {
"Default Category (Use , to split)": "默认分类 (用,分层)",
"Send to ReadWise": "发送到 ReadWise",
"Add a action in page haader to Send to ReadWise.": "在页面标题栏中添加一个动作来发送到 ReadWise。",
'Disable / to search when on these sites': '当在这些网站中禁止按 / 来搜索的功能',
};
5 changes: 3 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
"0.8.7": "1.0.0",
"0.8.8": "1.0.0",
"0.8.9": "1.0.0",
"0.8.10": "1.0.0"
}
"0.8.10": "1.0.0",
"0.8.11": "1.0.0"
}

0 comments on commit c8edbc6

Please sign in to comment.