diff --git a/lab/html-based-buildify/client/prosemirror-editor.ts b/lab/html-based-buildify/client/prosemirror-editor.ts index fd94392d8fe0bc8f2bb4969afe48c74aad442588..4b40f7f32c283d6b086ca4d33deb17b288adb4b1 100644 --- a/lab/html-based-buildify/client/prosemirror-editor.ts +++ b/lab/html-based-buildify/client/prosemirror-editor.ts @@ -161,7 +161,7 @@ export class ProsemirrorEditor extends FormField<string> { super.update(changedProperties); if (changedProperties.has('value') && this._editor) { - const html = this.value.value || `<x-text style="text-align: left"><span>hallo welt</span></x-text>`; + const html = this.value.value || ''; const node = document.createElement('div'); node.innerHTML = html; @@ -188,7 +188,7 @@ export class ProsemirrorEditor extends FormField<string> { const editorElement = this.renderRoot.querySelector(`#${EDITOR_ID}`); if (!editorElement) throw new Error('editor or content not found'); - const html = this.value.value || `<x-text style="text-align: left"><span>hallo welt</span></x-text>`; + const html = this.value.value || ''; const node = document.createElement('div'); node.innerHTML = html; diff --git a/lab/wiki/client/action-picker-provider.ts b/lab/wiki/client/action-picker-provider.ts index be0708996c4c8890817e2a82985a72ff2bdd6f29..7dc7b97835b62d2fd66694b73ed67d7185b1e7f5 100644 --- a/lab/wiki/client/action-picker-provider.ts +++ b/lab/wiki/client/action-picker-provider.ts @@ -32,7 +32,9 @@ export const createWikiActionPickerProvider = (onNavigate: (id: string, jumpTo?: name: r.text ?? 'No text', description: Object.keys(r.metaObject()) .map(k => { - return `${k}: ${r.metaObject()[k]}`; + const v = r.metaObject()[k]; + if (v.trim().length === 0) return k.trim(); + return `${k.trim()}: ${v.trim()}`; }) .join(' • '), action: () => { diff --git a/lab/wiki/client/x-wiki-editor.ts b/lab/wiki/client/x-wiki-editor.ts index edded8adc50e02d9597f3f257e332dae4c53aee4..7f9158cc969f3a497f01e60cb68589cbcb81ab48 100644 --- a/lab/wiki/client/x-wiki-editor.ts +++ b/lab/wiki/client/x-wiki-editor.ts @@ -271,6 +271,11 @@ export class XWikiEditor extends ChemistryLitElement { <x-button ${css({ minWidth: 'initial' })} @click=${async () => { + if (this._entry.value?.title?.trim().length === 0) { + XSnackbar.show(this.t.translate('wiki', 'actions', 'titleRequired')); + return; + } + this._loading.next(true); if (this._entry.value?._id) { await this._entry.value.save(); diff --git a/lab/wiki/html-text-splitter.ts b/lab/wiki/html-text-splitter.ts index 726c59a48438c1a4156b3c4a3dcb48c66b72c2e6..125afb921d19df2d6ec6cb2e761da2e03f985182 100644 --- a/lab/wiki/html-text-splitter.ts +++ b/lab/wiki/html-text-splitter.ts @@ -199,7 +199,7 @@ async function chunkSpanBased( newChunk.meta[`Heading ${header.level}`] = header.text; }); span.meta.accordions.forEach(accordion => { - newChunk.meta[`Accordion ${accordion.level}: ${accordion.title}`] = accordion.title; + newChunk.meta[`Accordion ${accordion.level}: ${accordion.title}`] = ''; }); } } diff --git a/lab/wiki/server/redis.ts b/lab/wiki/server/redis.ts index 7ef9ffc95457b905662e4ef5cd345906801a6981..66078bf5237d9d255934279c8073afddad4f75ca 100644 --- a/lab/wiki/server/redis.ts +++ b/lab/wiki/server/redis.ts @@ -228,9 +228,13 @@ async function processBatch(chunks: any[], prefix: string, entry: EntityData<Wik await Promise.all( chunks.map((chunk, index) => { + if (embeddings[index]?.status === 'rejected') { + return Promise.resolve(); + } + const chunkID = A.getGloballyUniqueID(); return client.json.set(`${prefix}-${chunkID}`, '$', { - embedding: embeddings[index], + embedding: embeddings[index]?.value, meta: chunk.meta, text: chunk.text, } as any); @@ -247,7 +251,7 @@ export async function ensureWikiEntries(ids?: string[] | string) { const client = REDIS_CLIENT.getClient(); const idsArray = ids ? (Array.isArray(ids) ? ids : [ids]) : []; - logger.debug( + logger.info( { ids, }, @@ -256,7 +260,7 @@ export async function ensureWikiEntries(ids?: string[] | string) { const rawWikiCollection = await getRawCollection<EntityData<WikiEntry>>(WikiEntry._collectionName); const wikiEntries = await rawWikiCollection - .find({ /*published: true,*/ needEmbeddingSync: true, ...(idsArray.length ? { _id: { $in: idsArray } } : {}) }) + .find({ needEmbeddingSync: true, ...(idsArray.length ? { _id: { $in: idsArray } } : {}) }) .toArray(); for (const entry of wikiEntries) { @@ -275,7 +279,7 @@ export async function ensureWikiEntries(ids?: string[] | string) { } const chunks = await splitHtml(entry.content); - logger.debug( + logger.info( { chunkCount: chunks.length, }, @@ -296,7 +300,7 @@ export async function ensureWikiEntries(ids?: string[] | string) { } } - logger.debug('done with processing wiki entries'); + logger.info('done with processing wiki entries'); // * set needEmbeddingSync as done await rawWikiCollection.updateMany( @@ -347,6 +351,7 @@ export async function search(search: string, limit: number = 5) { }, DIALECT: 2, }); + console.log(results.documents); return results.documents; } diff --git a/lab/wiki/translation.ts b/lab/wiki/translation.ts index ccd2fdd1fe61021697ddc668b04d04f1afa27d3a..4ae12cf9ef01228d6cf6fe2310e442149f49c417 100644 --- a/lab/wiki/translation.ts +++ b/lab/wiki/translation.ts @@ -38,6 +38,7 @@ export type WikiTranslationDict = { delete: string[]; confirmDelete: string[]; confirmDraftDelete: string[]; + titleRequired: string[]; }; }; field: { @@ -101,6 +102,7 @@ export const defaultWikiTranslation: WikiTranslationDict = { delete: ['Löschen', 'Delete'], confirmDelete: ['Soll die Seite wirklich gelöscht werden?', 'Delete page?'], confirmDraftDelete: ['Soll der Entwurf wirklich gelöscht werden?', 'Delete draft?'], + titleRequired: ['Bitte geben Sie einen Titel ein', 'Please enter a title'], }, }, field: {