Skip to content

Commit

Permalink
fixup! ♻️(frontend) fix AI requests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoLC committed Dec 6, 2024
1 parent f45e724 commit 85626c6
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block as CoreBlock } from '@blocknote/core';

type Block = Omit<CoreBlock, 'type'> & {
tid?: string;
type: string;
type?: string;
text?: string;
content: Block[] | Block;
children?: Block[] | Block;
Expand All @@ -21,7 +21,7 @@ export function addIdToTextNodes(node: Node) {
if (Array.isArray(node)) {
node.forEach((child) => addIdToTextNodes(child));
} else if (typeof node === 'object' && node !== null) {
if (node.type === 'text') {
if (node?.type === 'text') {
node.tid = generateId();
}

Expand All @@ -37,7 +37,7 @@ export function addIdToTextNodes(node: Node) {
// Handle table content
if (
!Array.isArray(node.content) &&
node.type === 'table' &&
node?.type === 'table' &&
node.content &&
node.content.type === 'tableContent'
) {
Expand All @@ -63,7 +63,7 @@ export function extractTextWithId(
if (Array.isArray(node)) {
node.forEach((child) => extractTextWithId(child, texts));
} else if (typeof node === 'object' && node !== null) {
if (node.type === 'text' && node.tid) {
if (node?.type === 'text' && node.tid) {
texts[node.tid] = node.text || '';
}

Expand All @@ -79,7 +79,7 @@ export function extractTextWithId(
// Handle table content
if (
!Array.isArray(node.content) &&
node.type === 'table' &&
node?.type === 'table' &&
node.content &&
node.content.type === 'tableContent'
) {
Expand Down Expand Up @@ -107,7 +107,7 @@ export function updateTextsWithId(
node.forEach((child) => updateTextsWithId(child, updatedTexts));
} else if (typeof node === 'object' && node !== null) {
if (
node.type === 'text' &&
node?.type === 'text' &&
node.tid &&
updatedTexts[node.tid] !== undefined
) {
Expand All @@ -126,7 +126,7 @@ export function updateTextsWithId(
// Handle table content
if (
!Array.isArray(node.content) &&
node.type === 'table' &&
node?.type === 'table' &&
node.content &&
node.content.type === 'tableContent'
) {
Expand Down

0 comments on commit 85626c6

Please sign in to comment.