Merge branch 'v15/dev' into contrib

This commit is contained in:
Sebastiaan Janssen
2025-04-01 12:27:28 +02:00
3 changed files with 22 additions and 26 deletions

View File

@@ -67,7 +67,9 @@ export class UmbLocalizationRegistry {
if (!translations.length) return;
if (diff.length) {
const filteredTranslations = translations.filter((t) => diff.some((ext) => ext.meta.culture === t.$code));
const filteredTranslations = translations.filter((t) =>
diff.some((ext) => ext.meta.culture.toLowerCase() === t.$code),
);
umbLocalizationManager.registerManyLocalizations(filteredTranslations);
}

View File

@@ -61,9 +61,8 @@ export class UmbInputTinyMceElement extends UUIFormControlMixin(UmbLitElement, '
}
override set value(newValue: FormDataEntryValue | FormData) {
if (newValue === this.value) return;
super.value = newValue;
const newContent = typeof newValue === 'string' ? newValue : '';
super.value = newContent;
if (this.#editorRef && this.#editorRef.getContent() != newContent) {
this.#editorRef.setContent(newContent);

View File

@@ -1,6 +1,6 @@
import type { UmbInputTinyMceElement } from '../../components/input-tiny-mce/input-tiny-mce.element.js';
import { customElement, html } from '@umbraco-cms/backoffice/external/lit';
import { UmbPropertyEditorUiRteElementBase, UMB_BLOCK_RTE_DATA_CONTENT_KEY } from '@umbraco-cms/backoffice/rte';
import { UmbPropertyEditorUiRteElementBase } from '@umbraco-cms/backoffice/rte';
import '../../components/input-tiny-mce/input-tiny-mce.element.js';
@@ -10,37 +10,32 @@ import '../../components/input-tiny-mce/input-tiny-mce.element.js';
@customElement('umb-property-editor-ui-tiny-mce')
export class UmbPropertyEditorUITinyMceElement extends UmbPropertyEditorUiRteElementBase {
#onChange(event: CustomEvent & { target: UmbInputTinyMceElement }) {
const value = typeof event.target.value === 'string' ? event.target.value : '';
const markup = typeof event.target.value === 'string' ? event.target.value : '';
// If we don't get any markup clear the property editor value.
if (value === '') {
if (markup === '') {
this.value = undefined;
this._fireChangeEvent();
return;
}
// Clone the DOM, to remove the classes and attributes on the original:
const div = document.createElement('div');
div.innerHTML = value;
// Loop through used, to remove the classes on these.
const blockEls = div.querySelectorAll(`umb-rte-block, umb-rte-block-inline`);
blockEls.forEach((blockEl) => {
blockEl.removeAttribute('contenteditable');
blockEl.removeAttribute('class');
});
const markup = div.innerHTML;
// Remove unused Blocks of Blocks Layout. Leaving only the Blocks that are present in Markup.
//const blockElements = editor.dom.select(`umb-rte-block, umb-rte-block-inline`);
const usedContentKeys = Array.from(blockEls).map((blockElement) =>
blockElement.getAttribute(UMB_BLOCK_RTE_DATA_CONTENT_KEY),
);
const usedContentKeys: string[] = [];
if (super.value) {
super.value = {
...super.value,
// Regex matching all block elements in the markup, and extracting the content key. It's the same as the one used on the backend.
const regex = new RegExp(
/<umb-rte-block(?:-inline)?(?: class="(?:.[^"]*)")? data-content-key="(?<key>.[^"]*)">(?:<!--Umbraco-Block-->)?<\/umb-rte-block(?:-inline)?>/gi,
);
let blockElement: RegExpExecArray | null;
while ((blockElement = regex.exec(markup)) !== null) {
if (blockElement.groups?.key) {
usedContentKeys.push(blockElement.groups.key);
}
}
if (this.value) {
this.value = {
...this.value,
markup: markup,
};
} else {