Block: open-interaction only available when Content is Editable (#20833)

Only interactive-open area when editable
This commit is contained in:
Niels Lyngsø
2025-12-02 11:57:17 +01:00
committed by GitHub
parent 1cdc15efda
commit c885922a64
3 changed files with 24 additions and 22 deletions

View File

@@ -34,7 +34,8 @@ export class UmbBlockGridBlockElement extends UmbLitElement {
return html` return html`
<umb-ref-grid-block <umb-ref-grid-block
standalone standalone
href=${(this.config?.showContentEdit ? this.config?.editContentPath : undefined) ?? ''}> .readonly=${!(this.config?.showContentEdit ?? false)}
.href=${this.config?.showContentEdit ? this.config?.editContentPath : undefined}>
<umb-icon slot="icon" .name=${this.icon}></umb-icon> <umb-icon slot="icon" .name=${this.icon}></umb-icon>
<umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render> <umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render>
${when( ${when(
@@ -58,6 +59,10 @@ export class UmbBlockGridBlockElement extends UmbLitElement {
margin: var(--uui-size-2); margin: var(--uui-size-2);
} }
umb-ufm-render {
user-select: none;
}
uui-tag { uui-tag {
margin-left: 0.5em; margin-left: 0.5em;
margin-bottom: -0.3em; margin-bottom: -0.3em;

View File

@@ -32,7 +32,10 @@ export class UmbRefListBlockElement extends UmbLitElement {
override render() { override render() {
const blockValue = { ...this.content, $settings: this.settings, $index: this.index }; const blockValue = { ...this.content, $settings: this.settings, $index: this.index };
return html` return html`
<uui-ref-node standalone href=${(this.config?.showContentEdit ? this.config?.editContentPath : undefined) ?? ''}> <uui-ref-node
standalone
.readonly=${!(this.config?.showContentEdit ?? false)}
.href=${this.config?.showContentEdit ? this.config?.editContentPath : undefined}>
<umb-icon slot="icon" .name=${this.icon}></umb-icon> <umb-icon slot="icon" .name=${this.icon}></umb-icon>
<umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render> <umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render>
${when( ${when(
@@ -57,6 +60,11 @@ export class UmbRefListBlockElement extends UmbLitElement {
margin-top: -0.3em; margin-top: -0.3em;
vertical-align: text-top; vertical-align: text-top;
} }
umb-ufm-render {
user-select: none;
}
:host([unpublished]) umb-icon, :host([unpublished]) umb-icon,
:host([unpublished]) umb-ufm-render { :host([unpublished]) umb-ufm-render {
opacity: 0.6; opacity: 0.6;

View File

@@ -1,6 +1,5 @@
import { css, customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit'; import { css, customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UMB_BLOCK_ENTRY_CONTEXT } from '@umbraco-cms/backoffice/block';
import type { UmbBlockDataType } from '@umbraco-cms/backoffice/block'; import type { UmbBlockDataType } from '@umbraco-cms/backoffice/block';
import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/block-custom-view'; import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/block-custom-view';
@@ -28,30 +27,16 @@ export class UmbRefRteBlockElement extends UmbLitElement {
@property({ attribute: false }) @property({ attribute: false })
settings?: UmbBlockDataType; settings?: UmbBlockDataType;
@state()
private _workspaceEditPath?: string;
@property({ attribute: false }) @property({ attribute: false })
config?: UmbBlockEditorCustomViewConfiguration; config?: UmbBlockEditorCustomViewConfiguration;
constructor() {
super();
this.consumeContext(UMB_BLOCK_ENTRY_CONTEXT, (context) => {
this.observe(
context?.workspaceEditContentPath,
(workspaceEditPath) => {
this._workspaceEditPath = workspaceEditPath;
},
'observeWorkspaceEditPath',
);
});
}
override render() { override render() {
const blockValue = { ...this.content, $settings: this.settings, $index: this.index }; const blockValue = { ...this.content, $settings: this.settings, $index: this.index };
return html` return html`
<uui-ref-node standalone href=${(this.config?.showContentEdit ? this._workspaceEditPath : undefined) ?? ''}> <uui-ref-node
standalone
.readonly=${!(this.config?.showContentEdit ?? false)}
.href=${this.config?.showContentEdit ? this.config?.editContentPath : undefined}>
<div class="selection-background" aria-hidden="true">&emsp;</div> <div class="selection-background" aria-hidden="true">&emsp;</div>
<umb-icon slot="icon" .name=${this.icon}></umb-icon> <umb-icon slot="icon" .name=${this.icon}></umb-icon>
<umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render> <umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render>
@@ -84,6 +69,10 @@ export class UmbRefRteBlockElement extends UmbLitElement {
z-index: 0; z-index: 0;
} }
umb-ufm-render {
user-select: none;
}
umb-icon, umb-icon,
umb-ufm-render { umb-ufm-render {
z-index: 1; z-index: 1;