Skip to content

How withdraw plain text from editor? #1209

Answered by sn4f
sn4f asked this question in Q&A
Discussion options

You must be logged in to vote

We can close this discussion.

Done with:

serializer.ts

import { Node } from 'slate';

export const serialize = (nodes: Node[]) => {
  return nodes.map((n) => Node.string(n)).join('\n');
};

deserializer.ts

export const deserialize = (string: string) => {
  return string.split('\n').map((line) => {
    return {
      children: [{ text: line }],
    };
  });
};

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sn4f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant