Fix missing holderId (#407)

* set default holderid

* 2.0.2

* pack bundle
This commit is contained in:
Taly 2018-08-05 16:09:30 +03:00 committed by GitHub
parent a7ebbae7fd
commit 15599d032d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View file

@ -1342,7 +1342,7 @@
/*!**********************!*\
!*** ./src/codex.js ***!
\**********************/
/*! no static exports found */function(e,o,t){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();t(/*! babel-core/register */"./node_modules/babel-core/register.js"),t(/*! babel-polyfill */"./node_modules/babel-polyfill/lib/index.js"),t(/*! components/polyfills */"./src/components/polyfills.ts");var s=function(e){return e&&e.__esModule?e:{default:e}}(t(/*! ./components/core */"./src/components/core.js"));var r=function(){function e(o){var t=this;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e);var n=o.onReady;n=n&&"function"==typeof n?n:function(){},o.onReady=function(){};var r=new s.default(o);this.isReady=r.isReady.then(function(){t.exportAPI(r),n()})}return n(e,null,[{key:"version",get:function(){return"2.0.1"}}]),n(e,[{key:"exportAPI",value:function(e){var o=this;["configuration"].forEach(function(t){o[t]=e[t]}),this.destroy=function(){for(var t in e.moduleInstances.Listeners.removeAll(),e.moduleInstances.UI.destroy(),e=null,o)delete o[t];Object.setPrototypeOf(o,null)},Object.setPrototypeOf(this,e.moduleInstances.API.methods),delete this.exportAPI}}]),e}();r.displayName="CodexEditor",o.default=r,e.exports=o.default},"./src/components/__module.ts":
/*! no static exports found */function(e,o,t){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();t(/*! babel-core/register */"./node_modules/babel-core/register.js"),t(/*! babel-polyfill */"./node_modules/babel-polyfill/lib/index.js"),t(/*! components/polyfills */"./src/components/polyfills.ts");var s=function(e){return e&&e.__esModule?e:{default:e}}(t(/*! ./components/core */"./src/components/core.js"));var r=function(){function e(o){var t=this;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e);var n=o.onReady;n=n&&"function"==typeof n?n:function(){},o.onReady=function(){};var r=new s.default(o);this.isReady=r.isReady.then(function(){t.exportAPI(r),n()})}return n(e,null,[{key:"version",get:function(){return"2.0.2"}}]),n(e,[{key:"exportAPI",value:function(e){var o=this;["configuration"].forEach(function(t){o[t]=e[t]}),this.destroy=function(){for(var t in e.moduleInstances.Listeners.removeAll(),e.moduleInstances.UI.destroy(),e=null,o)delete o[t];Object.setPrototypeOf(o,null)},Object.setPrototypeOf(this,e.moduleInstances.API.methods),delete this.exportAPI}}]),e}();r.displayName="CodexEditor",o.default=r,e.exports=o.default},"./src/components/__module.ts":
/*!************************************!*\
!*** ./src/components/__module.ts ***!
\************************************/
@ -1366,7 +1366,7 @@
/*!********************************!*\
!*** ./src/components/core.js ***!
\********************************/
/*! no static exports found */function(e,o,t){"use strict";(function(n,s){Object.defineProperty(o,"__esModule",{value:!0});var r=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();function i(e){return function(){var o=e.apply(this,arguments);return new Promise(function(e,t){return function n(s,r){try{var i=o[s](r),u=i.value}catch(e){return void t(e)}if(!i.done)return Promise.resolve(u).then(function(e){n("next",e)},function(e){n("throw",e)});e(u)}("next")})}}var u=["api-blocks.ts","api-caret.ts","api-events.ts","api-listener.ts","api-sanitizer.ts","api-saver.ts","api-selection.ts","api-styles.ts","api-toolbar.ts","api.ts","block-events.ts","blockManager.js","caret.js","events.js","listeners.js","paste.ts","renderer.js","sanitizer.js","saver.js","shortcuts.ts","toolbar-blockSettings.js","toolbar-inline.ts","toolbar-toolbox.js","toolbar.js","tools.js","ui.js"].map(function(e){return t("./src/components/modules sync [^_](api-blocks.ts|api-caret.ts|api-events.ts|api-listener.ts|api-sanitizer.ts|api-saver.ts|api-selection.ts|api-styles.ts|api-toolbar.ts|api.ts|block-events.ts|blockManager.js|caret.js|events.js|listeners.js|paste.ts|renderer.js|sanitizer.js|saver.js|shortcuts.ts|toolbar-blockSettings.js|toolbar-inline.ts|toolbar-toolbox.js|toolbar.js|tools.js|ui.js)$")("./"+e)}),l=function(){function e(o){var t=this;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e),this.config={},this.moduleInstances={};var s=void 0,r=void 0;this.isReady=new Promise(function(e,o){s=e,r=o}),Promise.resolve().then(function(){t.configuration=o}).then(function(){return t.validate()}).then(function(){return t.init()}).then(function(){return t.start()}).then(function(){n.log("I'm ready! (ノ◕ヮ◕)ノ*:・゚✧"),setTimeout(function(){t.config.onReady.call(),s()},500)}).catch(function(e){n.log("CodeX Editor does not ready because of "+e,"error"),r(e)})}return r(e,[{key:"validate",value:function(){if(!this.config.holderId)return Promise.reject("«holderId» param must being not empty");if(!s.get(this.config.holderId))return Promise.reject("element with ID «"+this.config.holderId+"» is missing. Pass correct holder's ID.");for(var e in this.config.tools){var o=this.config.tools[e];if(!n.isFunction(o)&&!n.isFunction(o.class))return Promise.reject("Tool «"+e+"» must be a constructor function or an object with that function in the «class» property")}}},{key:"init",value:function(){this.constructModules(),this.configureModules()}},{key:"constructModules",value:function(){var e=this;u.forEach(function(o){try{e.moduleInstances[o.displayName]=new o({config:e.configuration})}catch(e){console.log("Module %o skipped because %o",o,e)}})}},{key:"configureModules",value:function(){for(var e in this.moduleInstances)this.moduleInstances[e].state=this.getModulesDiff(e)}},{key:"getModulesDiff",value:function(e){var o={};for(var t in this.moduleInstances)t!==e&&(o[t]=this.moduleInstances[t]);return o}},{key:"start",value:function(){var e=i(regeneratorRuntime.mark(function e(){var o,t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=["Tools","UI","BlockManager","Paste"],e.next=3,o.reduce(function(e,o){return e.then(i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.log("Preparing "+o+" module","time"),e.prev=1,e.next=4,t.moduleInstances[o].prepare();case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.log("Module "+o+" was skipped because of %o","warn",e.t0);case 9:n.log("Preparing "+o+" module","timeEnd");case 10:case"end":return e.stop()}},e,t,[[1,6]])})))},Promise.resolve());case 3:return e.abrupt("return",this.moduleInstances.Renderer.render(this.config.data.blocks));case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"configuration",set:function(e){"string"!=typeof e&&void 0!==e||(e={holderId:e||"codex-editor"}),this.config.initialBlock=e.initialBlock||"paragraph";var o={type:this.config.initialBlock,data:{}};this.config.holderId=e.holderId,this.config.placeholder=e.placeholder||"write your story...",this.config.sanitizer=e.sanitizer||{p:!0,b:!0,a:!0},this.config.hideToolbar=!!e.hideToolbar&&e.hideToolbar,this.config.tools=e.tools||{},this.config.data=e.data||{},this.config.onReady=e.onReady||function(){},n.isEmpty(this.config.data)?(this.config.data={},this.config.data.blocks=[o]):this.config.data.blocks&&0!==this.config.data.blocks.length||(this.config.data.blocks=[o])},get:function(){return this.config}}]),e}();l.displayName="Core",o.default=l,e.exports=o.default}).call(this,t(/*! utils */"./src/components/utils.ts"),t(/*! dom */"./src/components/dom.ts"))},"./src/components/dom.ts":
/*! no static exports found */function(e,o,t){"use strict";(function(n,s){Object.defineProperty(o,"__esModule",{value:!0});var r=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();function i(e){return function(){var o=e.apply(this,arguments);return new Promise(function(e,t){return function n(s,r){try{var i=o[s](r),u=i.value}catch(e){return void t(e)}if(!i.done)return Promise.resolve(u).then(function(e){n("next",e)},function(e){n("throw",e)});e(u)}("next")})}}var u=["api-blocks.ts","api-caret.ts","api-events.ts","api-listener.ts","api-sanitizer.ts","api-saver.ts","api-selection.ts","api-styles.ts","api-toolbar.ts","api.ts","block-events.ts","blockManager.js","caret.js","events.js","listeners.js","paste.ts","renderer.js","sanitizer.js","saver.js","shortcuts.ts","toolbar-blockSettings.js","toolbar-inline.ts","toolbar-toolbox.js","toolbar.js","tools.js","ui.js"].map(function(e){return t("./src/components/modules sync [^_](api-blocks.ts|api-caret.ts|api-events.ts|api-listener.ts|api-sanitizer.ts|api-saver.ts|api-selection.ts|api-styles.ts|api-toolbar.ts|api.ts|block-events.ts|blockManager.js|caret.js|events.js|listeners.js|paste.ts|renderer.js|sanitizer.js|saver.js|shortcuts.ts|toolbar-blockSettings.js|toolbar-inline.ts|toolbar-toolbox.js|toolbar.js|tools.js|ui.js)$")("./"+e)}),l=function(){function e(o){var t=this;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e),this.config={},this.moduleInstances={};var s=void 0,r=void 0;this.isReady=new Promise(function(e,o){s=e,r=o}),Promise.resolve().then(function(){t.configuration=o}).then(function(){return t.validate()}).then(function(){return t.init()}).then(function(){return t.start()}).then(function(){n.log("I'm ready! (ノ◕ヮ◕)ノ*:・゚✧"),setTimeout(function(){t.config.onReady.call(),s()},500)}).catch(function(e){n.log("CodeX Editor does not ready because of "+e,"error"),r(e)})}return r(e,[{key:"validate",value:function(){if(!this.config.holderId)return Promise.reject("«holderId» param must being not empty");if(!s.get(this.config.holderId))return Promise.reject("element with ID «"+this.config.holderId+"» is missing. Pass correct holder's ID.");for(var e in this.config.tools){var o=this.config.tools[e];if(!n.isFunction(o)&&!n.isFunction(o.class))return Promise.reject("Tool «"+e+"» must be a constructor function or an object with that function in the «class» property")}}},{key:"init",value:function(){this.constructModules(),this.configureModules()}},{key:"constructModules",value:function(){var e=this;u.forEach(function(o){try{e.moduleInstances[o.displayName]=new o({config:e.configuration})}catch(e){console.log("Module %o skipped because %o",o,e)}})}},{key:"configureModules",value:function(){for(var e in this.moduleInstances)this.moduleInstances[e].state=this.getModulesDiff(e)}},{key:"getModulesDiff",value:function(e){var o={};for(var t in this.moduleInstances)t!==e&&(o[t]=this.moduleInstances[t]);return o}},{key:"start",value:function(){var e=i(regeneratorRuntime.mark(function e(){var o,t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=["Tools","UI","BlockManager","Paste"],e.next=3,o.reduce(function(e,o){return e.then(i(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.log("Preparing "+o+" module","time"),e.prev=1,e.next=4,t.moduleInstances[o].prepare();case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.log("Module "+o+" was skipped because of %o","warn",e.t0);case 9:n.log("Preparing "+o+" module","timeEnd");case 10:case"end":return e.stop()}},e,t,[[1,6]])})))},Promise.resolve());case 3:return e.abrupt("return",this.moduleInstances.Renderer.render(this.config.data.blocks));case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"configuration",set:function(e){"string"!=typeof e&&void 0!==e||(e={holderId:e}),this.config.initialBlock=e.initialBlock||"paragraph";var o={type:this.config.initialBlock,data:{}};this.config.holderId=e.holderId||"codex-editor",this.config.placeholder=e.placeholder||"write your story...",this.config.sanitizer=e.sanitizer||{p:!0,b:!0,a:!0},this.config.hideToolbar=!!e.hideToolbar&&e.hideToolbar,this.config.tools=e.tools||{},this.config.data=e.data||{},this.config.onReady=e.onReady||function(){},n.isEmpty(this.config.data)?(this.config.data={},this.config.data.blocks=[o]):this.config.data.blocks&&0!==this.config.data.blocks.length||(this.config.data.blocks=[o])},get:function(){return this.config}}]),e}();l.displayName="Core",o.default=l,e.exports=o.default}).call(this,t(/*! utils */"./src/components/utils.ts"),t(/*! dom */"./src/components/dom.ts"))},"./src/components/dom.ts":
/*!*******************************!*\
!*** ./src/components/dom.ts ***!
\*******************************/
@ -1466,7 +1466,7 @@
/*!*****************************************!*\
!*** ./src/components/modules/saver.js ***!
\*****************************************/
/*! no static exports found */function(e,o,t){"use strict";(function(t){Object.defineProperty(o,"__esModule",{value:!0});var n=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();var s=function(e){function o(e){var t=e.config;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o);var n=function(e,o){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!o||"object"!=typeof o&&"function"!=typeof o?e:o}(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,{config:t}));return n.output=null,n.blocksData=[],n}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function, not "+typeof o);e.prototype=Object.create(o&&o.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o&&(Object.setPrototypeOf?Object.setPrototypeOf(e,o):e.__proto__=o)}(o,t),n(o,[{key:"save",value:function(){var e=this,o=[];return this.Editor.BlockManager.blocks.forEach(function(e){o.push(e.data)}),Promise.all(o).then(function(o){return e.makeOutput(o)}).then(function(e){return e})}},{key:"makeOutput",value:function(e){var o=[],t=0;return console.groupCollapsed("[CodexEditor saving]:"),e.forEach(function(e){console.log("«"+e.tool+"» saving info",e),t+=e.time,o.push({type:e.tool,data:e.data})}),console.log("Total",t),console.groupEnd(),{time:+new Date,blocks:o,version:"2.0.1"}}}]),o}();s.displayName="Saver",o.default=s,e.exports=o.default}).call(this,t(/*! ./../__module.ts */"./src/components/__module.ts"))},"./src/components/modules/shortcuts.ts":
/*! no static exports found */function(e,o,t){"use strict";(function(t){Object.defineProperty(o,"__esModule",{value:!0});var n=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();var s=function(e){function o(e){var t=e.config;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o);var n=function(e,o){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!o||"object"!=typeof o&&"function"!=typeof o?e:o}(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,{config:t}));return n.output=null,n.blocksData=[],n}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function, not "+typeof o);e.prototype=Object.create(o&&o.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o&&(Object.setPrototypeOf?Object.setPrototypeOf(e,o):e.__proto__=o)}(o,t),n(o,[{key:"save",value:function(){var e=this,o=[];return this.Editor.BlockManager.blocks.forEach(function(e){o.push(e.data)}),Promise.all(o).then(function(o){return e.makeOutput(o)}).then(function(e){return e})}},{key:"makeOutput",value:function(e){var o=[],t=0;return console.groupCollapsed("[CodexEditor saving]:"),e.forEach(function(e){console.log("«"+e.tool+"» saving info",e),t+=e.time,o.push({type:e.tool,data:e.data})}),console.log("Total",t),console.groupEnd(),{time:+new Date,blocks:o,version:"2.0.2"}}}]),o}();s.displayName="Saver",o.default=s,e.exports=o.default}).call(this,t(/*! ./../__module.ts */"./src/components/__module.ts"))},"./src/components/modules/shortcuts.ts":
/*!*********************************************!*\
!*** ./src/components/modules/shortcuts.ts ***!
\*********************************************/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "2.0.1",
"version": "2.0.2",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "build/codex-editor.js",
"scripts": {

View file

@ -92,7 +92,7 @@ export default class Core {
*/
if (typeof config === 'string' || typeof config === 'undefined') {
config = {
holderId: config || 'codex-editor'
holderId: config
};
}
@ -111,7 +111,7 @@ export default class Core {
data : {}
};
this.config.holderId = config.holderId;
this.config.holderId = config.holderId || 'codex-editor';
this.config.placeholder = config.placeholder || 'write your story...';
this.config.sanitizer = config.sanitizer || {
p: true,