File size: 423 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { Editor } from 'slate';

const getCurrentData = (editor: Editor): Record<string, unknown> => {
  const [existingNodeWithData] = Editor.nodes(editor, {
    mode: 'all',
    match: (node) => {
      return Boolean(node.data);
    },
  });
  const existingData = existingNodeWithData
    ? (existingNodeWithData[0]?.data as Record<string, unknown>)
    : {};

  return existingData;
};

export default getCurrentData;