Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Dec 13, 2024
1 parent 2c20b99 commit 64aadf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/core/src/lib/utils/pluginInjectNodeProps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { findNode } from '@udecode/slate';
import { isDefined } from '@udecode/utils';
import { findNodePath } from '@udecode/slate-react';
import { IS_SERVER, isDefined } from '@udecode/utils';

import type { SlateEditor } from '../../lib/editor';
import type {
Expand Down Expand Up @@ -55,9 +56,11 @@ export const pluginInjectNodeProps = (

const elementPath = findNode(editor, { match: (n) => n === node })?.[1];

// Need REVIEW
// Before is using findNodePath import from 'slate-react'
if (!elementPath || !injectMatch(node, elementPath)) return;
if (IS_SERVER) {
if (!elementPath || !injectMatch(node, elementPath)) return;
} else {
if (!injectMatch(node, findNodePath(editor, node)!)) return;
}

const queryResult = query?.({
...injectNodeProps,
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const IS_APPLE =
typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac OS X');

export const IS_SERVER = typeof window === 'undefined';

0 comments on commit 64aadf6

Please sign in to comment.