mirror of
https://github.com/codex-team/editor.js
synced 2026-03-18 08:29:52 +01:00
do not add block if tool is not exist (#278)
* do not add block if tool is not exist
* show warning
* add todo
* update warning message
* put message into variable
* Revert "put message into variable"
This reverts commit c1f63894d7.
* update comment
This commit is contained in:
parent
903093b4f3
commit
72c2240b4b
3 changed files with 27 additions and 7 deletions
|
|
@ -4851,7 +4851,7 @@ var Renderer = function (_Module) {
|
|||
|
||||
|
||||
_createClass(Renderer, [{
|
||||
key: "render",
|
||||
key: 'render',
|
||||
value: function render(items) {
|
||||
var _this2 = this;
|
||||
|
||||
|
|
@ -4883,13 +4883,23 @@ var Renderer = function (_Module) {
|
|||
*/
|
||||
|
||||
}, {
|
||||
key: "insertBlock",
|
||||
key: 'insertBlock',
|
||||
value: function insertBlock(item) {
|
||||
var tool = item.type,
|
||||
data = item.data,
|
||||
settings = item.settings;
|
||||
|
||||
this.Editor.BlockManager.insert(tool, data, settings);
|
||||
if (tool in this.Editor.Tools.available) {
|
||||
this.Editor.BlockManager.insert(tool, data, settings);
|
||||
} else {
|
||||
/**
|
||||
* @todo show warning notification message
|
||||
*
|
||||
* `${tool} blocks was skipped.`
|
||||
*/
|
||||
|
||||
_.log('Tool \xAB' + tool + '\xBB is not found. Check \'tools\' property at your initial CodeX Editor config.', 'warn');
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
@ -4898,9 +4908,9 @@ var Renderer = function (_Module) {
|
|||
return Renderer;
|
||||
}(Module);
|
||||
|
||||
Renderer.displayName = "Renderer";
|
||||
Renderer.displayName = 'Renderer';
|
||||
exports.default = Renderer;
|
||||
module.exports = exports["default"];
|
||||
module.exports = exports['default'];
|
||||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../__module.ts */ "./src/components/__module.ts"), __webpack_require__(/*! utils */ "./src/components/utils.js")))
|
||||
|
||||
/***/ }),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -71,7 +71,17 @@ export default class Renderer extends Module {
|
|||
data = item.data,
|
||||
settings = item.settings;
|
||||
|
||||
this.Editor.BlockManager.insert(tool, data, settings);
|
||||
if (tool in this.Editor.Tools.available) {
|
||||
this.Editor.BlockManager.insert(tool, data, settings);
|
||||
} else {
|
||||
/**
|
||||
* @todo show warning notification message
|
||||
*
|
||||
* `${tool} blocks was skipped.`
|
||||
*/
|
||||
|
||||
_.log(`Tool «${tool}» is not found. Check 'tools' property at your initial CodeX Editor config.`, 'warn');
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue