Skip to content

Commit 4e681cb

Browse files
committed
feat: insert rte blocks
1 parent 38caff3 commit 4e681cb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/packages/rte/components/rte-base.element.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export abstract class UmbRteBaseElement extends UmbLitElement implements UmbProp
127127
this.#managerContext.exposes,
128128
]).pipe(debounceTime(20)),
129129
([layouts, contents, settings, exposes]) => {
130-
console.log('new blocks', layouts, contents, exposes);
131130
this._value = {
132131
...this._value,
133132
blocks: {
@@ -137,7 +136,7 @@ export abstract class UmbRteBaseElement extends UmbLitElement implements UmbProp
137136
expose: exposes,
138137
},
139138
};
140-
//context.setValue(this._value);
139+
141140
this._fireChangeEvent();
142141
},
143142
'motherObserver',

src/packages/rte/tiptap/property-editors/tiptap/property-editor-ui-tiptap.element.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ const elementName = 'umb-property-editor-ui-tiptap';
1313
export class UmbPropertyEditorUiTiptapElement extends UmbRteBaseElement {
1414
#onChange(event: CustomEvent & { target: UmbInputTiptapElement }) {
1515
const value = event.target.value;
16-
this._latestMarkup = value;
17-
18-
this._value = {
19-
...this._value,
20-
markup: this._latestMarkup,
21-
};
2216

2317
// Remove unused Blocks of Blocks Layout. Leaving only the Blocks that are present in Markup.
2418
const usedContentKeys: string[] = [];
@@ -28,14 +22,21 @@ export class UmbPropertyEditorUiTiptapElement extends UmbRteBaseElement {
2822
/<umb-rte-block(?:-inline)?(?: class="(?:.[^"]*)")? data-content-key="(?<key>.[^"]*)">(?:<!--Umbraco-Block-->)?<\/umb-rte-block(?:-inline)?>/gi,
2923
);
3024
let blockElement: RegExpExecArray | null;
31-
while ((blockElement = regex.exec(this._latestMarkup)) !== null) {
25+
while ((blockElement = regex.exec(value)) !== null) {
3226
if (blockElement.groups?.key) {
3327
usedContentKeys.push(blockElement.groups.key);
3428
}
3529
}
3630

3731
this._filterUnusedBlocks(usedContentKeys);
3832

33+
this._latestMarkup = value;
34+
35+
this._value = {
36+
...this._value,
37+
markup: this._latestMarkup,
38+
};
39+
3940
this._fireChangeEvent();
4041
}
4142

0 commit comments

Comments
 (0)