Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Block Custom Views #2065

Merged
merged 25 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cb6d4f6
sort imports
nielslyngsoe Jun 28, 2024
80e3339
implementation of custom views for block editors
nielslyngsoe Jun 28, 2024
b2c4af5
extension slot fine tuning
nielslyngsoe Jun 28, 2024
fa263c7
Block Editor Custom View specific conditionals
nielslyngsoe Jul 1, 2024
ccb4c6b
implement all custom view props
nielslyngsoe Jul 1, 2024
342d888
remove UmbBlockViewUrlsPropType
nielslyngsoe Jul 1, 2024
06611cc
out comment test
nielslyngsoe Jul 1, 2024
67746b4
custom view test element
nielslyngsoe Jul 1, 2024
71f9e25
do not render slot in extension-with-api-slot
nielslyngsoe Jul 1, 2024
fbeb7b7
sort import
nielslyngsoe Jul 1, 2024
9a0f4f6
Merge branch 'main' into v14/feature/block-custom-views
nielslyngsoe Jul 1, 2024
e570c97
Merge branch 'main' into v14/feature/block-custom-views
nielslyngsoe Jul 3, 2024
5965e79
stylesheet update condition
nielslyngsoe Jul 3, 2024
b5748fb
Merge branch 'main' into v14/feature/block-custom-views
nielslyngsoe Jul 3, 2024
cfa40df
Merge branch 'main' into v14/feature/block-custom-views
iOvergaard Jul 3, 2024
b1f0d6d
Merge branch 'main' into v14/feature/block-custom-views
nielslyngsoe Jul 4, 2024
b827d97
run prettier
iOvergaard Jul 4, 2024
3e5b720
Merge remote-tracking branch 'origin' into v14/feature/block-custom-v…
iOvergaard Jul 4, 2024
a20d592
fix: import as type
iOvergaard Jul 4, 2024
146d4b5
Merge branch 'main' into v14/feature/block-custom-views
iOvergaard Jul 5, 2024
10a08bc
chore: run eslint fix
iOvergaard Jul 5, 2024
735fb35
Merge branch 'main' into v14/feature/block-custom-views
iOvergaard Jul 5, 2024
b98f666
Merge branch 'main' into v14/feature/block-custom-views
iOvergaard Jul 5, 2024
1e2d89e
Merge branch 'main' into v14/feature/block-custom-views
nielslyngsoe Jul 5, 2024
4d1bcc9
remove .contentUdi
nielslyngsoe Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export abstract class UmbBaseExtensionsInitializer<
#onChange?: (permittedManifests: Array<MyPermittedControllerType>) => void;
protected _extensions: Array<ControllerType> = [];
#permittedExts: Array<MyPermittedControllerType> = [];
#exposedPermittedExts: Array<MyPermittedControllerType> = [];
#exposedPermittedExts?: Array<MyPermittedControllerType>;
#changeDebounce?: number;

asPromise(): Promise<void> {
Expand Down Expand Up @@ -90,6 +90,12 @@ export abstract class UmbBaseExtensionsInitializer<
return;
}

// If we get no manifests and we have not exposed any extensions yet, then we should notify to let the listener know that we have our first response. [NL]
if (manifests.length === 0 && this.#exposedPermittedExts === undefined) {
this.#exposedPermittedExts = [];
this.#onChange?.(this.#exposedPermittedExts);
}

// Clean up extensions that are no longer.
this._extensions = this._extensions.filter((extension) => {
if (!manifests.find((manifest) => manifest.alias === extension.alias)) {
Expand All @@ -114,6 +120,7 @@ export abstract class UmbBaseExtensionsInitializer<

protected _extensionChanged = (isPermitted: boolean, controller: ControllerType) => {
let hasChanged = false;

// This might be called after this is destroyed, so we need to check if the _permittedExts is still available:
const existingIndex = this.#permittedExts?.indexOf(controller as unknown as MyPermittedControllerType);
if (isPermitted) {
Expand Down Expand Up @@ -149,7 +156,7 @@ export abstract class UmbBaseExtensionsInitializer<
// if so, look up the extension it overwrites, and remove it from the list. and check that for if it overwrites another extension and so on.
if (extCtrl.overwrites.length > 0) {
extCtrl.overwrites.forEach((overwrite) => {
this.#removeOverwrittenExtensions(this.#exposedPermittedExts, overwrite);
this.#removeOverwrittenExtensions(this.#exposedPermittedExts!, overwrite);
});
}
});
Expand Down Expand Up @@ -193,16 +200,16 @@ export abstract class UmbBaseExtensionsInitializer<
// The this.#extensionRegistry is an indication of wether this is already destroyed.
if (!this.#extensionRegistry) return;

const oldPermittedExtsLength = this.#exposedPermittedExts.length;
const oldPermittedExtsLength = this.#exposedPermittedExts?.length ?? 0;
(this._extensions as any) = undefined;
(this.#permittedExts as any) = undefined;
this.#exposedPermittedExts.length = 0;
this.#exposedPermittedExts = undefined;
if (this.#changeDebounce) {
cancelAnimationFrame(this.#changeDebounce);
this.#changeDebounce = undefined;
}
if (oldPermittedExtsLength > 0) {
this.#onChange?.(this.#exposedPermittedExts);
this.#onChange?.([]);
}
this.#promiseResolvers.length = 0;
this.#filter = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UmbBlockGridInlinePropertyDatasetContext } from './block-grid-inline-pr
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { css, customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit';
import type { UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type';
import type { UmbBlockViewUrlsPropType } from '@umbraco-cms/backoffice/block';
import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/extension-registry';
import '../block-grid-areas-container/index.js';
import '../ref-grid-block/index.js';

Expand All @@ -17,7 +17,7 @@ export class UmbBlockGridBlockInlineElement extends UmbLitElement {
label?: string;

@property({ attribute: false })
urls?: UmbBlockViewUrlsPropType;
config?: UmbBlockEditorCustomViewConfiguration;

@state()
_inlineProperty: UmbPropertyTypeModel | undefined;
Expand All @@ -39,7 +39,7 @@ export class UmbBlockGridBlockInlineElement extends UmbLitElement {
}

override render() {
return html`<umb-ref-grid-block standalone .name=${this.label ?? ''} href=${this.urls?.editContent ?? ''}>
return html`<umb-ref-grid-block standalone .name=${this.label ?? ''} href=${this.config?.editContentPath ?? ''}>
<umb-property-type-based-property
.property=${this._inlineProperty}
slot="areas"></umb-property-type-based-property>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { UMB_BLOCK_GRID_ENTRY_CONTEXT } from '../../context/block-grid-entry.context-token.js';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { css, customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit';
import type { UmbBlockDataType, UmbBlockViewUrlsPropType } from '@umbraco-cms/backoffice/block';
import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/extension-registry';
import type { UmbBlockDataType } from '@umbraco-cms/backoffice/block';

import '@umbraco-cms/backoffice/ufm';
import '../block-grid-areas-container/index.js';
Expand All @@ -17,7 +18,7 @@ export class UmbBlockGridBlockElement extends UmbLitElement {
label?: string;

@property({ attribute: false })
urls?: UmbBlockViewUrlsPropType;
config?: UmbBlockEditorCustomViewConfiguration;

@state()
_content?: UmbBlockDataType;
Expand All @@ -37,7 +38,7 @@ export class UmbBlockGridBlockElement extends UmbLitElement {
}

override render() {
return html`<umb-ref-grid-block standalone href=${this.urls?.editContent ?? ''}>
return html`<umb-ref-grid-block standalone href=${this.config?.editContentPath ?? ''}>
<umb-ufm-render inline .markdown=${this.label} .value=${this._content}></umb-ufm-render>
<umb-block-grid-areas-container slot="areas"></umb-block-grid-areas-container>
</umb-ref-grid-block>`;
Expand Down
Loading
Loading