set default value for holderId (#533)

resolves #496
This commit is contained in:
Taly 2018-11-24 17:52:26 +03:00 committed by GitHub
parent 8398f825a8
commit 953949e56f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "2.5.3",
"version": "2.5.4",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "build/codex-editor.js",
"types": "./types/index.d.ts",

View file

@ -101,13 +101,25 @@ export default class Core {
set configuration(config: EditorConfig|string) {
/**
* Process zero-configuration or with only holderId
* Make config object
*/
if (typeof config === 'string' || typeof config === 'undefined') {
this.config = {
holderId: config || 'codex-editor',
if (typeof config !== 'object') {
config = {
holderId: config,
};
} else {
this.config = config;
}
/**
* Place config into the class property
* @type {EditorConfig}
*/
this.config = config;
/**
* If holderId is empty then set a default value
*/
if (!this.config.holderId || typeof this.config.holderId !== 'string') {
this.config.holderId = 'codex-editor';
}
/**

View file

@ -6,7 +6,7 @@ export interface EditorConfig {
/**
* Element where Editor will be append
*/
holderId: string;
holderId?: string;
/**
* This Tool will be used as default