diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.test.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.test.ts index 61445c9ab81e..571720619f55 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.test.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.test.ts @@ -5,6 +5,7 @@ import { UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS } from '../../../property-e import type { UmbBlockGridValueModel } from '../../../types.js'; import { UmbBlockToBlockGridClipboardPastePropertyValueTranslator } from './block-to-block-grid-paste-translator.js'; import type { UmbBlockClipboardEntryValueModel } from '@umbraco-cms/backoffice/block'; +import type { UmbBlockGridPropertyEditorConfig } from '../../../property-editors/block-grid-editor/types.js'; @customElement('test-controller-host') class UmbTestControllerHostElement extends UmbControllerHostElementMixin(HTMLElement) {} @@ -55,22 +56,26 @@ describe('UmbBlockToBlockGridClipboardPastePropertyValueTranslator', () => { settingsData: blockGridPropertyValue.settingsData, }; - const config1: Array<{ alias: string; value: [{ contentElementTypeKey: string }] }> = [ + const config1: UmbBlockGridPropertyEditorConfig = [ { alias: 'blocks', value: [ { + allowAtRoot: true, + allowInAreas: true, contentElementTypeKey: 'contentTypeKey', }, ], }, ]; - const config2: Array<{ alias: string; value: [{ contentElementTypeKey: string }] }> = [ + const config2: UmbBlockGridPropertyEditorConfig = [ { alias: 'blocks', value: [ { + allowAtRoot: true, + allowInAreas: true, contentElementTypeKey: 'contentTypeKey2', }, ], @@ -101,12 +106,12 @@ describe('UmbBlockToBlockGridClipboardPastePropertyValueTranslator', () => { describe('isCompatibleValue', () => { it('returns true if the value is compatible', async () => { - const result = await copyTranslator.isCompatibleValue(blockClipboardEntryValue, config1); + const result = await copyTranslator.isCompatibleValue(blockGridPropertyValue, config1); expect(result).to.be.true; }); it('returns false if the value is not compatible', async () => { - const result = await copyTranslator.isCompatibleValue(blockClipboardEntryValue, config2); + const result = await copyTranslator.isCompatibleValue(blockGridPropertyValue, config2); expect(result).to.be.false; }); }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.ts index 1f7cc20ba85b..67081389ce3f 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/block/paste/block-to-block-grid-paste-translator.ts @@ -1,5 +1,6 @@ import type { UmbBlockGridLayoutModel, UmbBlockGridValueModel } from '../../../types.js'; import { UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS } from '../../../constants.js'; +import type { UmbBlockGridPropertyEditorConfig } from '../../../property-editors/block-grid-editor/types.js'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbClipboardPastePropertyValueTranslator } from '@umbraco-cms/backoffice/clipboard'; import type { UmbBlockClipboardEntryValueModel, UmbBlockLayoutBaseModel } from '@umbraco-cms/backoffice/block'; @@ -44,19 +45,18 @@ export class UmbBlockToBlockGridClipboardPastePropertyValueTranslator /** * Determines if a block clipboard entry value is compatible with the Block Grid property editor. - * @param {UmbBlockClipboardEntryValueModel} value The block clipboard entry value. - * @param {*} config The Block Grid property editor configuration. + * @param {UmbBlockClipboardEntryValueModel} propertyValue The block clipboard entry value. + * @param {UmbBlockGridPropertyEditorConfig} config The Block Grid property editor configuration. * @returns {Promise} A promise that resolves with a boolean indicating if the value is compatible. * @memberof UmbBlockToBlockGridClipboardPastePropertyValueTranslator */ async isCompatibleValue( - value: UmbBlockClipboardEntryValueModel, - // TODO: Replace any with the correct type. - config: Array<{ alias: string; value: [{ contentElementTypeKey: string }] }>, + propertyValue: UmbBlockGridValueModel, + config: UmbBlockGridPropertyEditorConfig, ): Promise { const allowedBlockContentTypes = config.find((c) => c.alias === 'blocks')?.value.map((b) => b.contentElementTypeKey) ?? []; - const blockContentTypes = value.contentData.map((c) => c.contentTypeKey); + const blockContentTypes = propertyValue.contentData.map((c) => c.contentTypeKey); return blockContentTypes?.every((b) => allowedBlockContentTypes.includes(b)) ?? false; } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/grid-block/paste/grid-block-to-block-grid-paste-translator.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/grid-block/paste/grid-block-to-block-grid-paste-translator.ts index 150d71484334..2b3a2a0e089e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/grid-block/paste/grid-block-to-block-grid-paste-translator.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/grid-block/paste/grid-block-to-block-grid-paste-translator.ts @@ -1,3 +1,4 @@ +import type { UmbBlockGridPropertyEditorConfig } from '../../../property-editors/block-grid-editor/types.js'; import { UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS } from '../../../property-editors/constants.js'; import type { UmbBlockGridValueModel } from '../../../types.js'; import type { UmbGridBlockClipboardEntryValueModel } from '../../types.js'; @@ -35,20 +36,22 @@ export class UmbGridBlockToBlockGridClipboardPastePropertyValueTranslator /** * Checks if the clipboard entry value is compatible with the config. - * @param {UmbGridBlockClipboardEntryValueModel} value - The grid block clipboard entry value. + * @param {UmbGridBlockClipboardEntryValueModel} propertyValue - The grid block clipboard entry value. * @param {*} config - The Property Editor config. + * @param {(value, config) => Promise} filter - The filter function. * @returns {Promise} {Promise} * @memberof UmbGridBlockToBlockGridClipboardPastePropertyValueTranslator */ async isCompatibleValue( - value: UmbGridBlockClipboardEntryValueModel, - // TODO: Replace any with the correct type. - config: Array<{ alias: string; value: [{ contentElementTypeKey: string }] }>, + propertyValue: UmbBlockGridValueModel, + config: UmbBlockGridPropertyEditorConfig, + filter?: (propertyValue: UmbBlockGridValueModel, config: UmbBlockGridPropertyEditorConfig) => Promise, ): Promise { - const allowedBlockContentTypes = - config.find((c) => c.alias === 'blocks')?.value.map((b) => b.contentElementTypeKey) ?? []; - const blockContentTypes = value.contentData.map((c) => c.contentTypeKey); - return blockContentTypes?.every((b) => allowedBlockContentTypes.includes(b)) ?? false; + const blocksConfig = config.find((c) => c.alias === 'blocks'); + const allowedBlockContentTypes = blocksConfig?.value.map((b) => b.contentElementTypeKey) ?? []; + const blockContentTypes = propertyValue.contentData.map((c) => c.contentTypeKey); + const allContentTypesAllowed = blockContentTypes?.every((b) => allowedBlockContentTypes.includes(b)) ?? false; + return allContentTypesAllowed && (!filter || (await filter(propertyValue, config))); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/manifests.ts index 6546d9da1158..7fdabef3752d 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/clipboard/manifests.ts @@ -1,6 +1,7 @@ import { UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS } from '../property-editors/constants.js'; import { manifests as blockManifests } from './block/manifests.js'; import { manifests as gridBlockManifests } from './grid-block/manifests.js'; +import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry'; import { UMB_PROPERTY_HAS_VALUE_CONDITION_ALIAS, UMB_WRITABLE_PROPERTY_CONDITION_ALIAS, @@ -8,7 +9,7 @@ import { const forPropertyEditorUis = [UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS]; -export const manifests: Array = [ +export const manifests: Array = [ { type: 'propertyContext', kind: 'clipboard', @@ -31,18 +32,6 @@ export const manifests: Array = [ }, ], }, - { - type: 'propertyAction', - kind: 'pasteFromClipboard', - alias: 'Umb.PropertyAction.BlockGrid.Clipboard.Paste', - name: 'Block Grid Paste From Clipboard Property Action', - forPropertyEditorUis, - conditions: [ - { - alias: UMB_WRITABLE_PROPERTY_CONDITION_ALIAS, - }, - ], - }, ...blockManifests, ...gridBlockManifests, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts index bb1fe4cc3702..e410f894d07e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts @@ -14,6 +14,7 @@ import type { UmbBlockGridValueModel, } from '../types.js'; import { forEachBlockLayoutEntryOf } from '../utils/index.js'; +import type { UmbBlockGridPropertyEditorConfig } from '../property-editors/block-grid-editor/types.js'; import { UMB_BLOCK_GRID_MANAGER_CONTEXT } from './block-grid-manager.context-token.js'; import type { UmbBlockGridScalableContainerContext } from './block-grid-scale-manager/block-grid-scale-manager.controller.js'; import { @@ -170,7 +171,7 @@ export class UmbBlockGridEntriesContext // TODO: consider moving some of this logic to the clipboard property context const propertyContext = await this.getContext(UMB_PROPERTY_CONTEXT); - const config = propertyContext.getConfig(); + const config = propertyContext.getConfig() as UmbBlockGridPropertyEditorConfig; const valueResolver = new UmbClipboardPastePropertyValueTranslatorValueResolver(this); return { @@ -198,7 +199,8 @@ export class UmbBlockGridEntriesContext clipboardEntryDetail.values, UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS, ); - return pasteTranslator.isCompatibleValue(value, config); + + return pasteTranslator.isCompatibleValue(value, config, (value) => this.#clipboardEntriesFilter(value)); } return true; @@ -269,6 +271,21 @@ export class UmbBlockGridEntriesContext }); } + async #clipboardEntriesFilter(propertyValue: UmbBlockGridValueModel) { + const allowedElementTypeKeys = this.#retrieveAllowedElementTypes().map((x) => x.contentElementTypeKey); + + const rootContentKeys = propertyValue.layout['Umbraco.BlockGrid']?.map((block) => block.contentKey) ?? []; + const rootContentTypeKeys = propertyValue.contentData + .filter((content) => rootContentKeys.includes(content.key)) + .map((content) => content.contentTypeKey); + + const allContentTypesAllowed = rootContentTypeKeys.every((contentKey) => + allowedElementTypeKeys.includes(contentKey), + ); + + return allContentTypesAllowed; + } + protected _gotBlockManager() { if (!this._manager) return; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/manifests.ts index 209e3eef670e..5b760bd1909b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/manifests.ts @@ -3,8 +3,9 @@ import { manifests as componentManifests } from './components/manifests.js'; import { manifests as propertyEditorManifests } from './property-editors/manifests.js'; import { manifests as propertyValueClonerManifests } from './property-value-cloner/manifests.js'; import { manifests as workspaceManifests } from './workspace/manifests.js'; +import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry'; -export const manifests: Array = [ +export const manifests: Array = [ ...clipboardManifests, ...componentManifests, ...propertyEditorManifests, diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/manifests.ts index c6cc6a7dcdc4..c575670a4609 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/manifests.ts @@ -1,8 +1,10 @@ import { manifest as blockGridSchemaManifest } from './Umbraco.BlockGrid.js'; import { UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS, UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS } from './constants.js'; +import { manifests as propertyActionManifests } from './property-actions/manifests.js'; +import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry'; import { UmbStandardBlockValueResolver } from '@umbraco-cms/backoffice/block'; -export const manifests: Array = [ +export const manifests: Array = [ { type: 'propertyEditorUi', alias: UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS, @@ -66,7 +68,6 @@ export const manifests: Array = [ }, }, }, - blockGridSchemaManifest, { type: 'propertyValueResolver', alias: 'Umb.PropertyValueResolver.BlockGrid', @@ -76,4 +77,6 @@ export const manifests: Array = [ editorAlias: UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS, }, }, + blockGridSchemaManifest, + ...propertyActionManifests, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/property-actions/block-grid-paste-from-clipboard.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/property-actions/block-grid-paste-from-clipboard.ts new file mode 100644 index 000000000000..1480e09dcf8d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/property-actions/block-grid-paste-from-clipboard.ts @@ -0,0 +1,52 @@ +import type { UmbBlockGridValueModel } from '../../../types.js'; +import type { UmbBlockGridPropertyEditorConfig } from '../types.js'; +import { UmbPasteFromClipboardPropertyAction } from '@umbraco-cms/backoffice/clipboard'; + +/** + * The Block Grid Paste From Clipboard Property Action. + * @exports + * @class UmbBlockGridPasteFromClipboardPropertyAction + * @augments UmbPasteFromClipboardPropertyAction + */ +export class UmbBlockGridPasteFromClipboardPropertyAction extends UmbPasteFromClipboardPropertyAction { + /** + * Filters the picker based on the block grid property editor config. + * @param {UmbBlockGridValueModel} propertyValue The property editor value. + * @param {UmbBlockGridPropertyEditorConfig} config The property editor config. + * @override + * @protected + * @memberof UmbBlockGridPasteFromClipboardPropertyAction + */ + protected override async _pickerFilter( + propertyValue: UmbBlockGridValueModel, + config: UmbBlockGridPropertyEditorConfig, + ) { + // The property action always paste in the root of the grid so + // we need to check if the content types are allowed at the root + const blocksConfig = config.find((configValue) => configValue.alias === 'blocks'); + + const allowedRootContentTypeKeys = + blocksConfig?.value + .map((blockConfig) => { + if (blockConfig.allowAtRoot) { + return blockConfig.contentElementTypeKey; + } else { + return undefined; + } + }) + .filter((contentTypeKey) => contentTypeKey !== undefined) ?? []; + + const rootContentKeys = propertyValue.layout['Umbraco.BlockGrid']?.map((block) => block.contentKey) ?? []; + const rootContentTypeKeys = propertyValue.contentData + .filter((content) => rootContentKeys.includes(content.key)) + .map((content) => content.contentTypeKey); + + // ensure all content types in the paste value are allowed in the grid root + const allContentTypesAllowedAtRoot = rootContentTypeKeys.every((contentKey) => + allowedRootContentTypeKeys.includes(contentKey), + ); + + return allContentTypesAllowedAtRoot; + } +} +export { UmbBlockGridPasteFromClipboardPropertyAction as api }; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/property-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/property-actions/manifests.ts new file mode 100644 index 000000000000..8b2befb3a1be --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/property-actions/manifests.ts @@ -0,0 +1,20 @@ +import { UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS } from '../constants.js'; +import { UMB_WRITABLE_PROPERTY_CONDITION_ALIAS } from '@umbraco-cms/backoffice/property'; +import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry'; +import { UMB_PROPERTY_ACTION_PASTE_FROM_CLIPBOARD_KIND_MANIFEST } from '@umbraco-cms/backoffice/clipboard'; + +export const manifests: Array = [ + { + ...UMB_PROPERTY_ACTION_PASTE_FROM_CLIPBOARD_KIND_MANIFEST.manifest, + type: 'propertyAction', + alias: 'Umb.PropertyAction.BlockGrid.Clipboard.Paste', + name: 'Block Grid Paste From Clipboard Property Action', + api: () => import('./block-grid-paste-from-clipboard.js'), + forPropertyEditorUis: [UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS], + conditions: [ + { + alias: UMB_WRITABLE_PROPERTY_CONDITION_ALIAS, + }, + ], + }, +]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/types.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/types.ts new file mode 100644 index 000000000000..99e701404c7f --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/block-grid-editor/types.ts @@ -0,0 +1,9 @@ +// TODO: add the missing fields to the type +export type UmbBlockGridPropertyEditorConfig = Array<{ + alias: 'blocks'; + value: Array<{ + allowAtRoot: boolean; + allowInAreas: boolean; + contentElementTypeKey: string; + }>; +}>; diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/manifests.ts index 8a797e8068f9..37621422be33 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/property-editors/manifests.ts @@ -5,8 +5,9 @@ import { manifests as blockGridEditorManifests } from './block-grid-editor/manif import { manifest as blockGridGroupConfiguration } from './block-grid-group-configuration/manifests.js'; import { manifest as blockGridLayoutStylesheet } from './block-grid-layout-stylesheet/manifests.js'; import { manifest as blockGridTypeConfiguration } from './block-grid-type-configuration/manifests.js'; +import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry'; -export const manifests: Array = [ +export const manifests: Array = [ blockGridAreaTypePermission, blockGridAreasConfigEditor, blockGridColumnSpan, diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.test.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.test.ts index a54f811c9c27..56fb74df4221 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.test.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.test.ts @@ -98,12 +98,12 @@ describe('UmbBlockToBlockListClipboardPastePropertyValueTranslator', () => { describe('isCompatibleValue', () => { it('should return true if the content types are allowed', async () => { - const result = await pasteTranslator.isCompatibleValue(blockClipboardEntryValue, config); + const result = await pasteTranslator.isCompatibleValue(blockListPropertyValue, config); expect(result).to.be.true; }); it('should return false if the content types are not allowed', async () => { - const result = await pasteTranslator.isCompatibleValue(blockClipboardEntryValue, config2); + const result = await pasteTranslator.isCompatibleValue(blockListPropertyValue, config2); expect(result).to.be.false; }); }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.ts index 9493c4ef6145..32fe61adef85 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/clipboard/block/paste/block-to-block-list-paste-translator.ts @@ -35,19 +35,19 @@ export class UmbBlockToBlockListClipboardPastePropertyValueTranslator /** * Checks if the clipboard entry value is compatible with the config. - * @param {UmbBlockClipboardEntryValueModel} value - The block clipboard entry value. + * @param {UmbBlockListValueModel} propertyValue - The property value * @param {*} config - The Property Editor config. * @returns {Promise} - Whether the clipboard entry value is compatible with the config. * @memberof UmbBlockToBlockListClipboardPastePropertyValueTranslator */ async isCompatibleValue( - value: UmbBlockClipboardEntryValueModel, + propertyValue: UmbBlockListValueModel, // TODO: Replace any with the correct type. config: Array<{ alias: string; value: [{ contentElementTypeKey: string }] }>, ): Promise { const allowedBlockContentTypes = config.find((c) => c.alias === 'blocks')?.value.map((b) => b.contentElementTypeKey) ?? []; - const blockContentTypes = value.contentData.map((c) => c.contentTypeKey); + const blockContentTypes = propertyValue.contentData.map((c) => c.contentTypeKey); return blockContentTypes?.every((b) => allowedBlockContentTypes.includes(b)) ?? false; } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/constants.ts index adfc175c42de..607c1a68dab3 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/clipboard/constants.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/constants.ts @@ -1,4 +1,4 @@ export * from './clipboard-entry/constants.js'; export * from './clipboard-root/constants.js'; export * from './collection/constants.js'; -export * from './property/context/constants.js'; +export * from './property/constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/constants.ts new file mode 100644 index 000000000000..93931d504510 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/constants.ts @@ -0,0 +1 @@ +export * from './paste/constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/index.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/index.ts new file mode 100644 index 000000000000..50023908eba9 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/index.ts @@ -0,0 +1 @@ +export * from './paste/index.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/constants.ts new file mode 100644 index 000000000000..b7fe0395d405 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/constants.ts @@ -0,0 +1 @@ +export { UMB_PROPERTY_ACTION_PASTE_FROM_CLIPBOARD_KIND_MANIFEST } from './manifests.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/index.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/index.ts new file mode 100644 index 000000000000..8150ab49c49c --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/index.ts @@ -0,0 +1 @@ +export { UmbPasteFromClipboardPropertyAction } from './paste-from-clipboard.property-action.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/manifests.ts index 3c0ac1d98032..44989826c0d2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/manifests.ts @@ -1,22 +1,24 @@ import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry'; import { UMB_PROPERTY_ACTION_DEFAULT_KIND_MANIFEST } from '@umbraco-cms/backoffice/property-action'; -export const manifests: Array = [ - { - type: 'kind', - alias: 'Umb.Kind.PropertyAction.pasteFromClipboard', - matchKind: 'pasteFromClipboard', - matchType: 'propertyAction', - manifest: { - ...UMB_PROPERTY_ACTION_DEFAULT_KIND_MANIFEST.manifest, - type: 'propertyAction', - kind: 'pasteFromClipboard', - api: () => import('./paste-from-clipboard.property-action.js'), - weight: 1190, - meta: { - icon: 'icon-clipboard-paste', - label: 'Replace', - }, +export const UMB_PROPERTY_ACTION_PASTE_FROM_CLIPBOARD_KIND_MANIFEST: UmbExtensionManifestKind = { + type: 'kind', + alias: 'Umb.Kind.PropertyAction.pasteFromClipboard', + matchKind: 'pasteFromClipboard', + matchType: 'propertyAction', + manifest: { + ...UMB_PROPERTY_ACTION_DEFAULT_KIND_MANIFEST.manifest, + type: 'propertyAction', + kind: 'pasteFromClipboard', + api: () => import('./paste-from-clipboard.property-action.js'), + weight: 1190, + meta: { + icon: 'icon-clipboard-paste', + label: 'Replace', }, }, +}; + +export const manifests: Array = [ + UMB_PROPERTY_ACTION_PASTE_FROM_CLIPBOARD_KIND_MANIFEST, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/paste-from-clipboard.property-action.ts b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/paste-from-clipboard.property-action.ts index 869b3ad05b76..e4c54117e8df 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/paste-from-clipboard.property-action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/paste/paste-from-clipboard.property-action.ts @@ -25,6 +25,11 @@ export class UmbPasteFromClipboardPropertyAction extends UmbPropertyActionBase Promise} args.filter - A filter function to filter clipboard entries * @returns { Promise<{ selection: Array; propertyValues: Array }> } */ async pick(args: { multiple: boolean; propertyEditorUiAlias: string; + filter?: (value: any, config: any) => Promise; }): Promise<{ selection: Array; propertyValues: Array }> { await this.#init; @@ -149,8 +151,12 @@ export class UmbClipboardPropertyContext extends UmbContextBase extends UmbApi { - translate: (value: ClipboardEntryValueType) => Promise; - isCompatibleValue?: (value: ClipboardEntryValueType, config: ConfigType) => Promise; + translate: (clipboardEntryValue: ClipboardEntryValueType) => Promise; + isCompatibleValue?: ( + propertyValue: PropertyValueType, + config: ConfigType, + filter?: (propertyValue: PropertyValueType, config: ConfigType) => Promise, + ) => Promise; }