How do I get the node name from a block editor view?

If it’s for a block that you are editing in the context of a content node, you need UMB_CONTENT_WORKSPACE_CONTEXT:

import { UMB_CONTENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/content';

this.consumeContext(UMB_CONTENT_WORKSPACE_CONTEXT, (context) => {
	//If you just want it one-time
	//This does not react to name changes
	const name = context.getName()

	//If you want to be kept up to date of changes, you need to
	//observe it!
	this.observe(context.name(), (name) => {
		//This is called every time the name changes
	});
}
1 Like