simplifying the use of props (#18430)
This commit is contained in:
@@ -34,7 +34,7 @@ export abstract class UmbPropertyEditorUiRteElementBase extends UmbLitElement im
|
||||
public set value(value: UmbPropertyEditorUiValueType | undefined) {
|
||||
if (!value) {
|
||||
this._value = undefined;
|
||||
this._markup = this._latestMarkup = '';
|
||||
this._markup = '';
|
||||
this.#managerContext.setLayouts([]);
|
||||
this.#managerContext.setContents([]);
|
||||
this.#managerContext.setSettings([]);
|
||||
@@ -52,7 +52,7 @@ export abstract class UmbPropertyEditorUiRteElementBase extends UmbLitElement im
|
||||
this._value = buildUpValue as UmbPropertyEditorUiValueType;
|
||||
|
||||
// Only update the actual editor markup if it is not the same as the value.
|
||||
if (this._latestMarkup !== this._value.markup) {
|
||||
if (this._markup !== this._value.markup) {
|
||||
this._markup = this._value.markup;
|
||||
}
|
||||
|
||||
@@ -84,11 +84,6 @@ export abstract class UmbPropertyEditorUiRteElementBase extends UmbLitElement im
|
||||
@state()
|
||||
protected _markup = '';
|
||||
|
||||
/**
|
||||
* The latest value gotten from the RTE editor.
|
||||
*/
|
||||
protected _latestMarkup = '';
|
||||
|
||||
readonly #managerContext = new UmbBlockRteManagerContext(this);
|
||||
readonly #entriesContext = new UmbBlockRteEntriesContext(this);
|
||||
|
||||
@@ -141,7 +136,7 @@ export abstract class UmbPropertyEditorUiRteElementBase extends UmbLitElement im
|
||||
this._value = undefined;
|
||||
} else {
|
||||
this._value = {
|
||||
markup: this._latestMarkup,
|
||||
markup: this._markup,
|
||||
blocks: {
|
||||
layout: { [UMB_BLOCK_RTE_PROPERTY_EDITOR_SCHEMA_ALIAS]: layouts },
|
||||
contentData: contents,
|
||||
|
||||
@@ -61,6 +61,7 @@ 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 : '';
|
||||
|
||||
|
||||
@@ -43,16 +43,16 @@ export class UmbPropertyEditorUITinyMceElement extends UmbPropertyEditorUiRteEle
|
||||
// Then get the content of the editor and update the value.
|
||||
// maybe in this way doc.body.innerHTML;
|
||||
|
||||
this._latestMarkup = markup;
|
||||
this._markup = markup;
|
||||
|
||||
if (this.value) {
|
||||
this.value = {
|
||||
...this.value,
|
||||
markup: this._latestMarkup,
|
||||
markup: this._markup,
|
||||
};
|
||||
} else {
|
||||
this.value = {
|
||||
markup: this._latestMarkup,
|
||||
markup: this._markup,
|
||||
blocks: {
|
||||
layout: {},
|
||||
contentData: [],
|
||||
|
||||
@@ -19,6 +19,7 @@ const TIPTAP_CORE_EXTENSION_ALIAS = 'Umb.Tiptap.RichTextEssentials';
|
||||
export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof UmbLitElement, string>(UmbLitElement) {
|
||||
@property({ type: String })
|
||||
override set value(value: string) {
|
||||
if (value === this.#value) return;
|
||||
this.#value = value;
|
||||
|
||||
// Try to set the value to the editor if it is ready.
|
||||
|
||||
@@ -36,16 +36,16 @@ export class UmbPropertyEditorUiTiptapElement extends UmbPropertyEditorUiRteElem
|
||||
|
||||
this._filterUnusedBlocks(usedContentKeys);
|
||||
|
||||
this._latestMarkup = value;
|
||||
this._markup = value;
|
||||
|
||||
if (this.value) {
|
||||
this.value = {
|
||||
...this.value,
|
||||
markup: this._latestMarkup,
|
||||
markup: this._markup,
|
||||
};
|
||||
} else {
|
||||
this.value = {
|
||||
markup: this._latestMarkup,
|
||||
markup: this._markup,
|
||||
blocks: {
|
||||
layout: {},
|
||||
contentData: [],
|
||||
|
||||
Reference in New Issue
Block a user