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

parsing issue #15

Open
Kavehrafie opened this issue May 2, 2023 · 5 comments
Open

parsing issue #15

Kavehrafie opened this issue May 2, 2023 · 5 comments

Comments

@Kavehrafie
Copy link

Thanks for the package. It works fine but when I save the layout and retrieve the content the parent div gets lost for some reason and the layout disappear.

@tranquocviet226
Copy link

The same

@handwithfivefingers
Copy link

  const editor = useEditor({
    extensions: extensions,
    content: value ? JSON.parse(value) : "",
    onUpdate(ctx) {
      const json = ctx.editor.getJSON();
      onChange({
        target: { name, value: JSON.stringify(json) },
      });
    },
  });

Save as json can work

@aptjoshua
Copy link

aptjoshua commented Dec 12, 2024

I struggled with this issue for quite some time and hope the work around I've found helps others.

I discovered that <div was being replaced by <p. After digging in a little deeper it seems that extending the Paragraph extension to render a div instead of p will partially fix the issue. There are still some formatting issues but it is somewhat functional with this change.

import { mergeAttributes } from '@tiptap/core';

Paragraph.extend({parseHTML() {return [{ tag: 'div' }]}, renderHTML({ HTMLAttributes }) {return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]},})

@cguerrero1205
Copy link

cguerrero1205 commented Jan 18, 2025

I struggled with this issue for quite some time and hope the work around I've found helps others.

I discovered that <div was being replaced by <p. After digging in a little deeper it seems that extending the Paragraph extension to render a div instead of p will partially fix the issue. There are still some formatting issues but it is somewhat functional with this change.

import { mergeAttributes } from '@tiptap/core';

Paragraph.extend({parseHTML() {return [{ tag: 'div' }]}, renderHTML({ HTMLAttributes }) {return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]},})

Hello, I think I have the same problem as you.

Image

In the text editor, the columns are displayed fine; likewise it works when I do .editor?.getHTML(); but in RichTextReadOnly it is not displayed with the <div class=“column-block”>... but it converts each column into paragraphs, as you can see in the image.

Could you please indicate in which file you make the change you indicate in your comment? to test if this solves my problem.

Thank you.

@aptjoshua
Copy link

This change is made in the file where your Paragraph extension is imported.

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

5 participants