@umbraco-cms/backoffice 15.3.0 → 15.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,8 +84,7 @@ export class UmbContextProvider {
84
84
  // Note we are not removing the event listener in the hostDisconnected, therefor we do it here [NL].
85
85
  this.#eventTarget?.removeEventListener(UMB_CONTEXT_REQUEST_EVENT_TYPE, this.#handleContextRequest);
86
86
  this.#eventTarget?.removeEventListener(UMB_DEBUG_CONTEXT_EVENT_TYPE, this.#handleDebugContextRequest);
87
- // We want to call a destroy method on the instance, if it has one.
88
- this.#instance?.destroy?.();
87
+ // We do not want to call a destroy method on the instance, because maybe it should be re-provided later on. [NL]
89
88
  this.#instance = undefined;
90
89
  this.#eventTarget = undefined;
91
90
  }
@@ -69,7 +69,7 @@ export class UmbLocalizationRegistry {
69
69
  if (!translations.length)
70
70
  return;
71
71
  if (diff.length) {
72
- const filteredTranslations = translations.filter((t) => diff.some((ext) => ext.meta.culture === t.$code));
72
+ const filteredTranslations = translations.filter((t) => diff.some((ext) => ext.meta.culture.toLowerCase() === t.$code));
73
73
  umbLocalizationManager.registerManyLocalizations(filteredTranslations);
74
74
  }
75
75
  // Set the document language
@@ -44,10 +44,8 @@ let UmbInputTinyMceElement = class UmbInputTinyMceElement extends UUIFormControl
44
44
  return this._editorElement?.querySelector('iframe') ?? undefined;
45
45
  }
46
46
  set value(newValue) {
47
- if (newValue === this.value)
48
- return;
49
- super.value = newValue;
50
47
  const newContent = typeof newValue === 'string' ? newValue : '';
48
+ super.value = newContent;
51
49
  if (this.#editorRef && this.#editorRef.getContent() != newContent) {
52
50
  this.#editorRef.setContent(newContent);
53
51
  }
@@ -5,36 +5,33 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { customElement, html } from '../../../../external/lit/index.js';
8
- import { UmbPropertyEditorUiRteElementBase, UMB_BLOCK_RTE_DATA_CONTENT_KEY } from '../../../rte/index.js';
8
+ import { UmbPropertyEditorUiRteElementBase } from '../../../rte/index.js';
9
9
  import '../../components/input-tiny-mce/input-tiny-mce.element.js';
10
10
  /**
11
11
  * @element umb-property-editor-ui-tiny-mce
12
12
  */
13
13
  let UmbPropertyEditorUITinyMceElement = class UmbPropertyEditorUITinyMceElement extends UmbPropertyEditorUiRteElementBase {
14
14
  #onChange(event) {
15
- const value = typeof event.target.value === 'string' ? event.target.value : '';
15
+ const markup = typeof event.target.value === 'string' ? event.target.value : '';
16
16
  // If we don't get any markup clear the property editor value.
17
- if (value === '') {
17
+ if (markup === '') {
18
18
  this.value = undefined;
19
19
  this._fireChangeEvent();
20
20
  return;
21
21
  }
22
- // Clone the DOM, to remove the classes and attributes on the original:
23
- const div = document.createElement('div');
24
- div.innerHTML = value;
25
- // Loop through used, to remove the classes on these.
26
- const blockEls = div.querySelectorAll(`umb-rte-block, umb-rte-block-inline`);
27
- blockEls.forEach((blockEl) => {
28
- blockEl.removeAttribute('contenteditable');
29
- blockEl.removeAttribute('class');
30
- });
31
- const markup = div.innerHTML;
32
22
  // Remove unused Blocks of Blocks Layout. Leaving only the Blocks that are present in Markup.
33
- //const blockElements = editor.dom.select(`umb-rte-block, umb-rte-block-inline`);
34
- const usedContentKeys = Array.from(blockEls).map((blockElement) => blockElement.getAttribute(UMB_BLOCK_RTE_DATA_CONTENT_KEY));
35
- if (super.value) {
36
- super.value = {
37
- ...super.value,
23
+ const usedContentKeys = [];
24
+ // Regex matching all block elements in the markup, and extracting the content key. It's the same as the one used on the backend.
25
+ const regex = new RegExp(/<umb-rte-block(?:-inline)?(?: class="(?:.[^"]*)")? data-content-key="(?<key>.[^"]*)">(?:<!--Umbraco-Block-->)?<\/umb-rte-block(?:-inline)?>/gi);
26
+ let blockElement;
27
+ while ((blockElement = regex.exec(markup)) !== null) {
28
+ if (blockElement.groups?.key) {
29
+ usedContentKeys.push(blockElement.groups.key);
30
+ }
31
+ }
32
+ if (this.value) {
33
+ this.value = {
34
+ ...this.value,
38
35
  markup: markup,
39
36
  };
40
37
  }