Gotcha! We currently only support adding textarea to a line.
The easiest way to achieve this is:
- Add a new menu option that appears when two blocks are selected.
- Clicking this menu option will create a new line with the two blocks as endpoints, including the chosen textarea.
For step 1, you can implement this by showing the 'logBlockClass' menu option only when the 'singleShapeSelected' action returns true."
client.registerAction("logBlockClass", () => {
const selection = viewport.getSelectedItems().pop();
if (!selection) return;
const page = viewport.getCurrentPage();
if (!page) return;
const blockWithSameId = page.blocks.get(selection.id);
console.log(blockWithSameId.getClassName());
});
client.registerAction("singleShapeSelected", () => {
const items = viewport.getSelectedItems();
return items.length === 1;
});
menu.addMenuItem({
label: "Log block class",
action: "logBlockClass",
menuType: MenuType.Context,
visibleAction: "singleShapeSelected",
});
For step 2, you can do this
client.registerAction('Create Line with textarea', async () => {
const page = await viewport.getCurrentPage();
if(page){
const line = page?.addLine({
endpoint1: {x:10, y:10},
endpoint2: {x:100, y:100},
})
line.addTextArea('Hello', {location:0.5,side:0})
}
});
You can also explore additional configurations for lines in LineProxy in lucid-extension-sdk library block comment documentation. Let me know if you have more questions!