Thanks @nielslyngsoe I missed that config property !
This is a useful approach to solve our problem, I have just added some CSS styling in the component like so
CSS for < a > tag
a.edit {
display:block;
text-decoration: none;
color: inherit;
}
Full example
import { UmbBlockDataType } from "@umbraco-cms/backoffice/block";
import { UmbBlockEditorCustomViewConfiguration, UmbBlockEditorCustomViewElement } from "@umbraco-cms/backoffice/block-custom-view";
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
import { css, customElement, html, LitElement, property, unsafeHTML } from "@umbraco-cms/backoffice/external/lit";
import { BackofficeCssStyles } from "../../common/styles/backoffice-css-styles";
import { RTEData } from "../../common/types/rte";
interface ParagraphBlockContent extends UmbBlockDataType {
richText: RTEData;
}
@customElement('paragraph-block-view')
export class ParagraphBlockViewElement extends UmbElementMixin(LitElement) implements UmbBlockEditorCustomViewElement {
@property({attribute: false})
label?: string;
@property({attribute: false})
content?: ParagraphBlockContent;
@property({attribute: false})
settings?: UmbBlockDataType;
@property({ attribute: false })
config?: UmbBlockEditorCustomViewConfiguration;
render() {
return html`
<fieldset>
<legend>${this.label ?? 'Paragraph'}</legend>
<a href=${this.config?.editContentPath ?? ''} class="edit">
${unsafeHTML(this.content?.richText.markup)}
</a>
</fieldset>
`;
}
static styles = [
BackofficeCssStyles,
css `
a.edit {
display:block;
text-decoration: none;
color: inherit;
}
`
]
}
export default ParagraphBlockViewElement;
declare global {
interface HTMLElementTagNameMap {
'paragraph-block-view': ParagraphBlockViewElement;
}
}