-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: try to fix the blank page on mobile #48
- deprecate the namespace approach - the some APIs optional in order to force us to check before use
- Loading branch information
Showing
31 changed files
with
159 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { LangType } from 'tongwen-core'; | ||
import { Pref } from '../../preference/types/lastest'; | ||
import { BrowserActionOpt } from '../../preference/types/v2'; | ||
import { browserAction } from './browser-action'; | ||
import { browser } from '../browser'; | ||
|
||
const browserActionToBadge = (ba: BrowserActionOpt) => (ba === 'auto' ? 'A' : ba === LangType.s2t ? 'T' : 'S'); | ||
|
||
const color = '#C0C0C0'; | ||
|
||
export const setBadge = (pref: Pref) => { | ||
const text = browserActionToBadge(pref.general.browserAction); | ||
const setText = browserAction.setBadgeText({ text }); | ||
const setBg = browserAction.setBadgeBackgroundColor({ color }); | ||
const setText = browser.browserAction.setBadgeText({ text }); | ||
const setBg = browser.browserAction.setBadgeBackgroundColor({ color }); | ||
|
||
return Promise.all([setText, setBg]); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { PrefMenuGroup, PrefMenuGroupKeys, PrefMenuOptions } from '../../preference/types/v2'; | ||
import { menus } from './menus'; | ||
import type { browser } from '../browser'; | ||
import { ContextOnAll, ContextOnEditable } from './menus'; | ||
|
||
const hasEnabled = (options: PrefMenuOptions) => options.s2t || options.t2s; | ||
|
||
export function getSubMenuContexts(prefKey: PrefMenuGroupKeys): menus.ContextType[] { | ||
return prefKey === 'textarea' ? menus.ContextOnEditable : menus.ContextOnAll; | ||
export function getSubMenuContexts(prefKey: PrefMenuGroupKeys): browser.Menus.ContextType[] { | ||
return prefKey === 'textarea' ? ContextOnEditable : ContextOnAll; | ||
} | ||
|
||
export function getTopMenuContexts({ textarea, webpage }: PrefMenuGroup): menus.ContextType[] { | ||
export function getTopMenuContexts({ textarea, webpage }: PrefMenuGroup): browser.Menus.ContextType[] { | ||
const hasEditable = hasEnabled(textarea); | ||
const hasOther = hasEnabled(webpage); | ||
|
||
return hasEditable && hasOther | ||
? [...menus.ContextOnAll, ...menus.ContextOnEditable] | ||
? [...ContextOnAll, ...ContextOnEditable] | ||
: hasEditable | ||
? menus.ContextOnEditable | ||
? ContextOnEditable | ||
: hasOther | ||
? menus.ContextOnAll | ||
? ContextOnAll | ||
: []; | ||
} |
Oops, something went wrong.