"addBlock failed: adding this block type is not supported"
P
Pollyruhnke
started a topic
about 1 month ago
Here, when we convert content, I want to erase the old block and add in a new one at the same coordinates. I'm just texting it right now, obviously, but I keep getting a "addBlock failed: adding this block type is not supported" and, when I include editor?.erase(originalBlock), a "can't delete root block" error. I'm wondering why this is occuring.
fun convertContent(content: ContentSelection? = null) {
val conversionState = editor?.getSupportedTargetConversionStates(content)
if (!conversionState.isNullOrEmpty()) {
editor?.convert(content, conversionState.first())
if(content != null) {
var originalBlock = content as ContentBlock;
var transform = editor?.renderer?.viewTransform;
var topLeft = transform?.apply(originalBlock.box.x, originalBlock.box.y);
var x = topLeft?.x;
var y = topLeft?.y;
// editor?.erase(originalBlock);
editor?.waitForIdle();
if (x != null && y != null) {
editor?.addBlock(x, y, "Text", MimeType.TEXT, "myscript")?.also(ContentBlock::close)
Pollyruhnke
Here, when we convert content, I want to erase the old block and add in a new one at the same coordinates. I'm just texting it right now, obviously, but I keep getting a "addBlock failed: adding this block type is not supported" and, when I include editor?.erase(originalBlock), a "can't delete root block" error. I'm wondering why this is occuring.
fun convertContent(content: ContentSelection? = null) {
val conversionState = editor?.getSupportedTargetConversionStates(content)
if (!conversionState.isNullOrEmpty()) {
editor?.convert(content, conversionState.first())
if(content != null) {
var originalBlock = content as ContentBlock;
var transform = editor?.renderer?.viewTransform;
var topLeft = transform?.apply(originalBlock.box.x, originalBlock.box.y);
var x = topLeft?.x;
var y = topLeft?.y;
// editor?.erase(originalBlock);
editor?.waitForIdle();
if (x != null && y != null) {
editor?.addBlock(x, y, "Text", MimeType.TEXT, "myscript")?.also(ContentBlock::close)
}
}
}
}