Skip to content

Commit 50c7d83

Browse files
author
User
committed
updated globalconfig
1 parent bdef300 commit 50c7d83

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

API.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const GlobalConfig = [
55
G_C.OPTION_MERGE_STRATEGIES,
66
G_C.DEVTOOLS,
77
G_C.ERROR_HANDLER,
8-
G_C.WARN_HANDLER
8+
G_C.WARN_HANDLER,
9+
G_C.IGNORED_ELEMENTS,
10+
G_C.KEY_CODES
911
]
1012

1113

globalconfig/globalconfig.js

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
const chalk = require('chalk')
2+
3+
colorComment = comment => chalk.gray(comment)
4+
5+
colorPrimitive = primitive => chalk.magentaBright(primitive)
6+
27
const SILENT = {
38
category: 'Global Config',
49
name: 'silent',
@@ -12,7 +17,7 @@ const OPTION_MERGE_STRATEGIES = {
1217
name: 'optionMergeStrategies',
1318
type: '{ [key: string]: Function }',
1419
default: '{}',
15-
usage: `Vue.config.optionMergeStrategies._my_option = ${chalk.magentaBright('function')} (parent, child, vm) {
20+
usage: `Vue.config.optionMergeStrategies._my_option = ${chalk.magentaBright('function')}(parent,child,vm){
1621
${chalk.magentaBright('return')} child + 1
1722
}
1823
${chalk.magentaBright('const')} Profile = Vue.extend({
@@ -21,8 +26,8 @@ const OPTION_MERGE_STRATEGIES = {
2126
// Profile.options._my_option = 2\n`,
2227
details: `Define custom merging strategies for options.
2328
The merge strategy receives the value of that option defined
24-
on the parent and child instances as the first and second arguments, respectively.
25-
The context Vue instance is passed as the third argument.`
29+
on the parent and child instances as the first and second arguments,
30+
respectively. The context Vue instance is passed as the third argument.`
2631
}
2732
const DEVTOOLS = {
2833
category: 'Global Config',
@@ -40,7 +45,7 @@ const ERROR_HANDLER = {
4045
name: 'errorHandler',
4146
type: 'Function',
4247
default: 'undefined',
43-
usage: `Vue.config.errorHandler = ${chalk.magentaBright('function')} (err, vm, info) {
48+
usage: `Vue.config.errorHandler = ${chalk.magentaBright('function')}(err,vm,info){
4449
// handle error
4550
// 'info' is a Vue-specific error info, e.g. which lifecycle hook
4651
// the error was found in. Only available in 2.2.0+
@@ -61,31 +66,40 @@ const WARN_HANDLER = {
6166
during development and is ignored in production.`
6267
}
6368

64-
/*const SILENT = {
69+
const IGNORED_ELEMENTS = {
6570
category: 'Global Config',
66-
name: '#silent',
67-
type: 'boolean',
68-
default: 'false',
69-
arguments: '',
70-
readOption: '',
71-
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
72-
details: 'Suppress all Vue logs and warnings',
73-
example: ''
71+
name: 'ignoredElements',
72+
type: 'Array<string>',
73+
usage: `Vue.config.ignoredElements = [
74+
'my-custom-web-component', 'another-web-component'
75+
]`,
76+
details: `Make Vue ignore custom elements defined outside of Vue
77+
(e.g., using the Web Components APIs). Otherwise, it will throw
78+
a warning about an ${chalk.magentaBright('Unknown custom element')}, assuming that you forgot to
79+
register a global component or misspelled a component name.`
7480
}
7581

76-
const SILENT = {
82+
const KEY_CODES = {
7783
category: 'Global Config',
78-
name: '#silent',
79-
type: 'boolean',
80-
default: 'false',
81-
arguments: '',
82-
readOption: '',
83-
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
84-
details: 'Suppress all Vue logs and warnings',
85-
example: ''
84+
name: 'keyCodes',
85+
type: '{ [key: string]: number | Array<number> }',
86+
default: '{}',
87+
usage: `Vue.config.keyCodes = {
88+
v: ${colorPrimitive('86')},
89+
f1: ${colorPrimitive('112')},
90+
${colorComment("// camelCase won't work")}
91+
mediaPlayPause: ${colorPrimitive('179')},
92+
${colorComment("// instead you can use kebab-case with double quotation marks")}
93+
${chalk.green('"media-play-pause"')}: ${colorPrimitive('179')},
94+
up: ${colorPrimitive('[38, 87]')}
95+
}
96+
${colorComment("// example")}
97+
${chalk.blue('<input type=')}${chalk.green('"text"')} ${chalk.blue('@keyup.media-play-pause=')}${chalk.green('"method"')}${chalk.blue('>')}
98+
`,
99+
details: 'Define custom key alias(es) for v-on.'
86100
}
87101

88-
const SILENT = {
102+
/*const SILENT = {
89103
category: 'Global Config',
90104
name: '#silent',
91105
type: 'boolean',
@@ -138,5 +152,7 @@ module.exports = {
138152
OPTION_MERGE_STRATEGIES,
139153
DEVTOOLS,
140154
ERROR_HANDLER,
141-
WARN_HANDLER
155+
WARN_HANDLER,
156+
IGNORED_ELEMENTS,
157+
KEY_CODES
142158
}

vue-help.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ V.command('warnHandler', 'Outputs').action(function(args, callback){
3636
const warnHandler = gc[4]
3737
this.log(LGC.logGlobalConfig(warnHandler))
3838
callback()
39+
})
40+
41+
V.command('ignoredElements', 'Outputs').action(function(args, callback){
42+
const ignoredElements = gc[5]
43+
this.log(LGC.logGlobalConfig(ignoredElements))
44+
callback()
45+
})
46+
47+
V.command('keyCodes', 'Outputs').action(function(args, callback){
48+
const keyCodes = gc[6]
49+
this.log(LGC.logGlobalConfig(keyCodes))
50+
callback()
3951
})

0 commit comments

Comments
 (0)