Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upblocks.insert API does not pass config parameter to Tool #1230
Comments
|
@karpovsystems What is the purpose of sending the |
In my case, it would determine whether the block was created by the user or programmatically.
I'm not quite clear what you mean, but it's possible to send the class Test {
constructor ({config}) {
console.log(config.foo); // bar
}
render () {
return document.createElement('div');
}
}
const editor = new EditorJS({
tools: {
test: {
class: Test,
config: {foo: 'bar'} // passing config data
}
},
data: {
blocks: [{
type: 'test'
}]
}
});If you are facing the same issue try |
|
@karpovsystems Can you explain a proper use case? |
|
@karpovsystems I know these tools require the |
|
Let's say you have a button, clicking on which should add Header and Image blocks. |
|
Agree with @ranemihir. The In the attached PR the So if there is only use case of determining whether the block was created by API or not, we can find more logical solution. @karpovsystems Can you describe why exactly you need to know whether the block was created by API or by Editor core? Also, there is a little issue:
|
I worked on a spoiler tool. It appends two blocks: spoiler start & spoiler end. Blocks between start & end are spoiler content. I don't mind removing |
|
@karpovsystems I can't think of a practical use case of the tool. This needs more discussion. |
|
@karpovsystems I think spoiler feature as a container of blocks would be a great idea. For exemple you edit an html page and you want to edit the title of html page. This does not belong to the visble part of the page as it is its attributes generally stored in the head of html .For now I lay out this as an extra paragraph that can be easily wrongly mixed on block move with content of the page on edit.This is because blocks have not move constraints for now. Of course I can decide to have separate inline editor for each group of blocks to prevent this but this bring multiple editorjs complexity management! If you check the tools, the first invisible spoiler that serves as container is stub. |


Describe a bug:
blocks.insertAPI does not passconfigparameter to ToolSteps to reproduce:
Expected behavior:
Config is passed to Tool constructor
Editor.js 2.18.0
Code sample