Skip to content

Commit 3c95bfe

Browse files
committed
Merge remote-tracking branch 'origin/release/14.1'
2 parents 1bf0a73 + 3d25294 commit 3c95bfe

File tree

2 files changed

+65
-50
lines changed

2 files changed

+65
-50
lines changed

src/packages/block/block/workspace/block-workspace.context.ts

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,70 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
141141
'observeLayoutInitially',
142142
);
143143

144+
this.#observeBlockData(unique);
145+
146+
if (this.#liveEditingMode) {
147+
this.#establishLiveSync();
148+
}
149+
}
150+
151+
async create(contentElementTypeId: string) {
152+
await this.#retrieveBlockEntries;
153+
await this.#retrieveModalContext;
154+
if (!this.#blockEntries) {
155+
throw new Error('Block Entries not found');
156+
return;
157+
}
158+
if (!this.#modalContext) {
159+
throw new Error('Modal Context not found');
160+
return;
161+
}
162+
163+
// TODO: Missing some way to append more layout data... this could be part of modal data, (or context api?)
164+
165+
this.setIsNew(true);
166+
167+
const blockCreated = await this.#blockEntries.create(
168+
contentElementTypeId,
169+
{},
170+
this.#modalContext.data as UmbBlockWorkspaceData,
171+
);
172+
if (!blockCreated) {
173+
throw new Error('Block Entries could not create block');
174+
}
175+
176+
// TODO: We should investigate if it makes sense to gather
177+
178+
if (!this.#liveEditingMode) {
179+
this.#layout.setValue(blockCreated.layout as LayoutDataType);
180+
this.content.setData(blockCreated.content);
181+
if (blockCreated.settings) {
182+
this.settings.setData(blockCreated.settings);
183+
}
184+
} else {
185+
// Insert already, cause we are in live editing mode:
186+
const blockInserted = await this.#blockEntries.insert(
187+
blockCreated.layout,
188+
blockCreated.content,
189+
blockCreated.settings,
190+
this.#modalContext.data as UmbBlockWorkspaceData,
191+
);
192+
if (!blockInserted) {
193+
throw new Error('Block Entries could not insert block');
194+
}
195+
196+
const unique = blockCreated.layout.contentUdi;
197+
198+
this.#observeBlockData(unique);
199+
this.#establishLiveSync();
200+
}
201+
}
202+
203+
#observeBlockData(unique: string) {
204+
if (!this.#blockEntries) {
205+
throw new Error('Block Entries not found');
206+
return;
207+
}
144208
this.observe(
145209
this.#blockEntries.layoutOf(unique),
146210
(layoutData) => {
@@ -194,56 +258,6 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
194258
},
195259
'observeLayout',
196260
);
197-
198-
if (this.#liveEditingMode) {
199-
this.#establishLiveSync();
200-
}
201-
}
202-
203-
async create(contentElementTypeId: string) {
204-
await this.#retrieveBlockEntries;
205-
await this.#retrieveModalContext;
206-
if (!this.#blockEntries) {
207-
throw new Error('Block Entries not found');
208-
return;
209-
}
210-
if (!this.#modalContext) {
211-
throw new Error('Modal Context not found');
212-
return;
213-
}
214-
215-
// TODO: Missing some way to append more layout data... this could be part of modal data, (or context api?)
216-
217-
this.setIsNew(true);
218-
219-
const blockCreated = await this.#blockEntries.create(
220-
contentElementTypeId,
221-
{},
222-
this.#modalContext.data as UmbBlockWorkspaceData,
223-
);
224-
if (!blockCreated) {
225-
throw new Error('Block Entries could not create block');
226-
}
227-
228-
this.#layout.setValue(blockCreated.layout as LayoutDataType);
229-
this.content.setData(blockCreated.content);
230-
if (blockCreated.settings) {
231-
this.settings.setData(blockCreated.settings);
232-
}
233-
234-
if (this.#liveEditingMode) {
235-
// Insert already, cause we are in live editing mode:
236-
const blockInserted = await this.#blockEntries.insert(
237-
blockCreated.layout,
238-
blockCreated.content,
239-
blockCreated.settings,
240-
this.#modalContext.data as UmbBlockWorkspaceData,
241-
);
242-
if (!blockInserted) {
243-
throw new Error('Block Entries could not insert block');
244-
}
245-
this.#establishLiveSync();
246-
}
247261
}
248262

249263
#establishLiveSync() {

src/packages/ufm/components/ufm-render/ufm-render.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export class UmbUfmRenderElement extends UmbLitElement {
9797
css`
9898
* {
9999
max-width: 100%;
100+
word-wrap: break-word;
100101
}
101102
102103
pre {

0 commit comments

Comments
 (0)