diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/rte-embed.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/rte-embed.handlers.ts index 592d1c6435..671bb2af10 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/rte-embed.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/rte-embed.handlers.ts @@ -3,11 +3,11 @@ import type { OEmbedResponseModel } from '@umbraco-cms/backoffice/external/backe import { umbracoPath } from '@umbraco-cms/backoffice/utils'; export const handlers = [ - rest.get(umbracoPath('/rteembed'), (req, res, ctx) => { - const widthParam = req.url.searchParams.get('width'); + rest.get(umbracoPath('/oembed/query'), (req, res, ctx) => { + const widthParam = req.url.searchParams.get('maxWidth'); const width = widthParam ? parseInt(widthParam) : 360; - const heightParam = req.url.searchParams.get('height'); + const heightParam = req.url.searchParams.get('maxHeight'); const height = heightParam ? parseInt(heightParam) : 240; const response: OEmbedResponseModel = { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/modal/common/embedded-media/embedded-media-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/modal/common/embedded-media/embedded-media-modal.element.ts index 7011b6044d..f5f4251c4a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/modal/common/embedded-media/embedded-media-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/modal/common/embedded-media/embedded-media-modal.element.ts @@ -11,6 +11,7 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< UmbEmbeddedMediaModalValue > { #oEmbedRepository = new UmbOEmbedRepository(this); + #validUrl?: string; @state() private _loading?: UUIButtonState; @@ -48,13 +49,14 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< maxHeight: this._height, }); - if (!data) { + if (data) { + this.#validUrl = this._url; + this.value = { ...this.value, markup: data.markup, url: this.#validUrl }; + this._loading = 'success'; + } else { + this.#validUrl = undefined; this._loading = 'failed'; - return; } - - this.value = { ...this.value, markup: data.markup, url: this._url }; - this._loading = 'success'; } #onUrlChange(e: UUIInputEvent) { @@ -63,14 +65,12 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< #onWidthChange(e: UUIInputEvent) { this._width = parseInt(e.target.value as string, 10); - //this.#getPreview(); - //this.#changeSize('width'); + this.#getPreview(); } #onHeightChange(e: UUIInputEvent) { this._height = parseInt(e.target.value as string, 10); - //this.#getPreview(); - //this.#changeSize('height'); + this.#getPreview(); } #onConstrainChange() { @@ -78,39 +78,13 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< this.value = { ...this.value, constrain: this._constrain }; } - /** - * Calculates the width or height axis dimension when the other is changed. - * If constrain is false, axis change independently - * @param axis {string} - */ - /* - #changeSize(axis: 'width' | 'height') { - const resize = this._model.originalWidth !== this._model.width || this._model.originalHeight !== this._model.height; - - if (this._model.constrain) { - if (axis === 'width') { - this._model.height = Math.round((this._model.width / this._model.originalWidth) * this._model.height); - } else { - this._model.width = Math.round((this._model.height / this._model.originalHeight) * this._model.width); - } - } - - this._model.originalWidth = this._model.width; - this._model.originalHeight = this._model.height; - - if (this._model.url !== '' && resize) { - this.#getPreview(); - } - } - */ - render() { return html`
- + ${when( - this._loading !== undefined, + this.#validUrl !== undefined, () => html`
@@ -133,11 +107,21 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< )} - + - + @@ -164,27 +148,11 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< static styles = [ UmbTextStyles, css` - h3 { - margin-left: var(--uui-size-space-5); - margin-right: var(--uui-size-space-5); - } - uui-input { width: 100%; --uui-button-border-radius: 0; } - .sr-only { - clip: rect(0, 0, 0, 0); - border: 0; - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; - } - umb-property-layout:first-child { padding-top: 0; } @@ -192,10 +160,6 @@ export class UmbEmbeddedMediaModalElement extends UmbModalBaseElement< umb-property-layout:last-child { padding-bottom: 0; } - - p { - margin-bottom: 0; - } `, ]; }