mirror of
https://github.com/vale981/tridactyl
synced 2025-03-13 14:06:38 -04:00
Merge branch 'configdocs' of github.com:cmcaine/tridactyl into configdocs
This commit is contained in:
commit
56df3f97a6
7 changed files with 71 additions and 12 deletions
|
@ -1,5 +1,11 @@
|
|||
# Tridactyl changelog
|
||||
|
||||
## Release 1.11.2 / 2018-05-11
|
||||
|
||||
- Hotfix to prevent "config undefined" errors on browser start if no rc file was found
|
||||
- It was mysteriously only reproducible sometimes...
|
||||
- Make newtab changelog a bit wider
|
||||
|
||||
## Release 1.11.1 / 2018-05-11
|
||||
|
||||
- **Add "tridactylrc" support**
|
||||
|
|
|
@ -15,24 +15,42 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/** @hidden */
|
||||
const CONFIGNAME = "userconfig"
|
||||
/** @hidden */
|
||||
const WAITERS = []
|
||||
/** @hidden */
|
||||
let INITIALISED = false
|
||||
|
||||
/** @hidden */
|
||||
// make a naked object
|
||||
function o(object) {
|
||||
return Object.assign(Object.create(null), object)
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
// "Import" is a reserved word so this will have to do
|
||||
function schlepp(settings) {
|
||||
Object.assign(USERCONFIG, settings)
|
||||
}
|
||||
|
||||
// TODO: have list of possibilities for settings, e.g. hintmode: reverse | normal
|
||||
/** @hidden */
|
||||
let USERCONFIG = o({})
|
||||
const _DEFAULTS = {
|
||||
|
||||
/**
|
||||
* This is the default configuration that Tridactyl comes with.
|
||||
*
|
||||
* You can change anything here using `set key1.key2.key3 value` or specific things any of the various helper commands such as `bind` or `command`.
|
||||
*
|
||||
*/
|
||||
const default_config = {
|
||||
configversion: "0.0",
|
||||
|
||||
/**
|
||||
* nmaps contain all of the bindings for "normal mode".
|
||||
*
|
||||
* They consist of key sequences mapped to ex commands.
|
||||
*/
|
||||
nmaps: {
|
||||
"<F1>": "help",
|
||||
o: "fillcmdline open",
|
||||
|
@ -64,8 +82,6 @@ const _DEFAULTS = {
|
|||
gg: "scrollto 0",
|
||||
"<c-u>": "scrollpage -0.5",
|
||||
"<c-d>": "scrollpage 0.5",
|
||||
// Disabled while our find mode is bad
|
||||
/* "<c-f>": "scrollpage -1", */
|
||||
// "<c-b>": "scrollpage -1",
|
||||
$: "scrollto 100 x",
|
||||
// "0": "scrollto 0 x", // will get interpreted as a count
|
||||
|
@ -270,11 +286,14 @@ const _DEFAULTS = {
|
|||
|
||||
csp: "untouched", // change this to "clobber" to ruin the CSP of all sites and make Tridactyl run a bit better on some of them, e.g. raw.github*
|
||||
}
|
||||
const DEFAULTS = o(_DEFAULTS)
|
||||
|
||||
/** @hidden */
|
||||
const DEFAULTS = o(default_config)
|
||||
|
||||
/** Given an object and a target, extract the target if it exists, else return undefined
|
||||
|
||||
@param target path of properties as an array
|
||||
@hidden
|
||||
*/
|
||||
function getDeepProperty(obj, target) {
|
||||
if (obj !== undefined && target.length) {
|
||||
|
@ -289,6 +308,7 @@ function getDeepProperty(obj, target) {
|
|||
If the path is an empty array, replace the obj.
|
||||
|
||||
@param target path of properties as an array
|
||||
@hidden
|
||||
*/
|
||||
function setDeepProperty(obj, value, target) {
|
||||
if (target.length > 1) {
|
||||
|
@ -306,6 +326,7 @@ function setDeepProperty(obj, value, target) {
|
|||
|
||||
If the user has not specified a key, use the corresponding key from
|
||||
defaults, if one exists, else undefined.
|
||||
@hidden
|
||||
*/
|
||||
export function get(...target) {
|
||||
const user = getDeepProperty(USERCONFIG, target)
|
||||
|
@ -327,6 +348,7 @@ export function get(...target) {
|
|||
database first if it has not been at least once before.
|
||||
|
||||
This is useful if you are a content script and you've just been loaded.
|
||||
@hidden
|
||||
*/
|
||||
export async function getAsync(...target) {
|
||||
if (INITIALISED) {
|
||||
|
@ -344,6 +366,8 @@ export async function getAsync(...target) {
|
|||
set("nmaps", "o", "open")
|
||||
set("search", "default", "google")
|
||||
set("aucmd", "BufRead", "memrise.com", "open memrise.com")
|
||||
|
||||
@hidden
|
||||
*/
|
||||
export function set(...args) {
|
||||
if (args.length < 2) {
|
||||
|
@ -357,7 +381,8 @@ export function set(...args) {
|
|||
save()
|
||||
}
|
||||
|
||||
/** Delete the key at target if it exists */
|
||||
/** Delete the key at target if it exists
|
||||
* @hidden */
|
||||
export function unset(...target) {
|
||||
const parent = getDeepProperty(USERCONFIG, target.slice(0, -1))
|
||||
if (parent !== undefined) delete parent[target[target.length - 1]]
|
||||
|
@ -368,6 +393,8 @@ export function unset(...target) {
|
|||
|
||||
Config is not synchronised between different instances of this module until
|
||||
sometime after this happens.
|
||||
|
||||
@hidden
|
||||
*/
|
||||
export async function save(storage: "local" | "sync" = get("storageloc")) {
|
||||
// let storageobj = storage == "local" ? browser.storage.local : browser.storage.sync
|
||||
|
@ -386,6 +413,7 @@ export async function save(storage: "local" | "sync" = get("storageloc")) {
|
|||
a default setting
|
||||
|
||||
When adding updaters, don't forget to set("configversion", newversionnumber)!
|
||||
@hidden
|
||||
*/
|
||||
export async function update() {
|
||||
let updaters = {
|
||||
|
@ -423,6 +451,7 @@ export async function update() {
|
|||
/** Read all user configuration from storage API then notify any waiting asynchronous calls
|
||||
|
||||
asynchronous calls generated by getAsync.
|
||||
@hidden
|
||||
*/
|
||||
async function init() {
|
||||
let syncConfig = await browser.storage.sync.get(CONFIGNAME)
|
||||
|
|
|
@ -10,8 +10,9 @@ export async function source(filename = "auto") {
|
|||
} else {
|
||||
rctext = (await Native.read(filename)).content
|
||||
}
|
||||
|
||||
if (rctext === undefined) return false
|
||||
runRc(rctext)
|
||||
return true
|
||||
}
|
||||
|
||||
export async function runRc(rc: string) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Use `:help <excmd>` or scroll down to show [[help]] for a particular excmd.
|
||||
|
||||
The default keybinds can be found [here](/static/docs/modules/_config_.html#defaults) or all active binds can be seen with `:viewconfig nmaps`.
|
||||
The default keybinds can be found [here](/static/docs/modules/_config_.html#_defaults) or all active binds can be seen with `:viewconfig nmaps`.
|
||||
You can also view them with [[bind]]. Try `bind j`.
|
||||
|
||||
For more information, and FAQs, check out our [readme][4] on github.
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
You do not need to worry about types.
|
||||
|
||||
At the bottom of each function's help page, you can click on a link that will take you straight to that function's definition in our code. This is especially recommended for browsing the [config](/static/docs/modules/_config_.html#defaults) which is nigh-on unreadable on these pages.
|
||||
At the bottom of each function's help page, you can click on a link that will take you straight to that function's definition in our code.
|
||||
|
||||
|
||||
## Highlighted features:
|
||||
|
@ -324,7 +324,7 @@ export async function installnative() {
|
|||
//#background
|
||||
export async function source(...fileArr: string[]) {
|
||||
const file = fileArr.join(" ") || undefined
|
||||
if (await Native.nativegate("0.1.3")) rc.source(file)
|
||||
if (await Native.nativegate("0.1.3")) if (!await rc.source(file)) logger.error("Could not find RC file")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Tridactyl",
|
||||
"version": "1.11.1",
|
||||
"version": "1.11.2",
|
||||
"icons": {
|
||||
"64": "static/logo/Tridactyl_64px.png",
|
||||
"100": "static/logo/Tridactyl_100px.png",
|
||||
|
|
|
@ -58,7 +58,8 @@ export async function getrc(): Promise<string> {
|
|||
logger.info(`Successfully retrieved fs config:\n${res.content}`)
|
||||
return res.content
|
||||
} else {
|
||||
logger.error(`Error in retrieving config: ${res.error}`)
|
||||
// Have to make this a warning as async exceptions apparently don't get caught
|
||||
logger.info(`Error in retrieving config: ${res.error}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -931,6 +931,10 @@ ul.tsd-descriptions h4 {
|
|||
border: unset;
|
||||
}
|
||||
|
||||
.tsd-signature {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tsd-flag {
|
||||
font-size: unset;
|
||||
border-radius: 2px;
|
||||
|
@ -945,6 +949,24 @@ ul.tsd-descriptions h4 {
|
|||
border: none
|
||||
}
|
||||
|
||||
.tsd-panel {
|
||||
padding: 0px;
|
||||
padding-left: 3rem;
|
||||
}
|
||||
|
||||
.tsd-parent-kind-object-literal > .tsd-panel {
|
||||
margin: 0px;
|
||||
border-top-width: 0.5px
|
||||
}
|
||||
|
||||
.tsd-parent-kind-object-literal > .tsd-signature {
|
||||
margin: 0px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.tsd-signature-type {
|
||||
display: none
|
||||
}
|
||||
|
||||
|
||||
/* Other changes:
|
||||
|
|
Loading…
Add table
Reference in a new issue