Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] paste markdown content and then edit clears content #380

Open
1 task done
snewcomer opened this issue Nov 4, 2024 · 4 comments
Open
1 task done

[BUG] paste markdown content and then edit clears content #380

snewcomer opened this issue Nov 4, 2024 · 4 comments

Comments

@snewcomer
Copy link

snewcomer commented Nov 4, 2024

Has this bug been raised before?

  • I have checked "open" AND "closed" issues and this is not a duplicate

Description

After pasting md content into yoopta editor

# Meeting

Date: [YYYY-MM-DD]
Chair: [Name]

## Executive Summary

And then typing to set Meeting as h1, it clears content.

Seen on version 4.8.4 and above.

Screenshots

yoopta.mov

Do you want to work on this issue?

Yes

@Darginec05
Copy link
Collaborator

copy/pasting issue 🧐
I think we should add more validation for slate in each plugin using extensions API

@snewcomer
Copy link
Author

Is it setting the value appropriately on paste? Or dropping content bc of validation “on set”?

@Darginec05
Copy link
Collaborator

So, problem in the next:

Block Paragraph contains only one element paragraph. Here is valid example:

 - block
    - element
      - text  

But by pasting this content from your example it creates four elements per Paragraph block.
Here is invalid example

 - block
    - element
      - text 
    - element
      - text  
    - element
      - text  
    - element
      - text  

So, If you will check value of pasted block. It will be:

// current not valid value after pasting
const ParagraphBlockData = {
  id: 'eacacf8a-3421-46ee-b1b9-f024359f92d4',
  type: 'Paragraph',
  value: [
    // element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: '# Meeting',
        },
      ],
    },
    // element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: '',
        },
      ],
    },
    // element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: 'Date: [YYYY-MM-DD]',
        },
      ],
    },
    // element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: 'Chair: [Name]',
        },
      ],
    },
    // element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: '',
        },
      ],
    },
    // element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: '## Executive Summary',
        },
      ],
    },
  ],
  meta: {
    align: 'left',
    depth: 0,
    order: 0,
  },
};

instead of this valid:

const ParagraphBlockData = {
  id: 'eacacf8a-3421-46ee-b1b9-f024359f92d4',
  type: 'Paragraph',
  value: [
    // only one element
    {
      id: 'f2f77e36-f40d-4c69-951d-ba47fe9ed468',
      type: 'paragraph',
      children: [
        {
          text: '# Meeting \n Date: [YYYY-MM-DD] \n Chair: [Name] \n ## Executive Summary',
        },
      ],
    },
  ],
  meta: {
    align: 'left',
    depth: 0,
    order: 0,
  },
};

@Darginec05
Copy link
Collaborator

The pasting of content is handled <SlateEditorComponent />, but I suggest to make validation on slate side.
Let me know if I have explained the problem and the solution to you in an accessible way :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants