ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
27.55k stars 2.29k forks source link

[Bug]: Text content gets removed when a new extension is created for it when the extension tag has textcontent and node element data together with it #5795

Open GSKarthik369 opened 2 weeks ago

GSKarthik369 commented 2 weeks ago

Affected Packages

table

Version(s)

2.0.0.beta

Bug Description

Text content gets removed when an extension a new extension is created for it when the extension tag has textcontent and node element data together with it

My extension

export const Tbcaption = Node.create({
  name: "tbcaption",

  addOptions() {
    return {
      HTMLAttributes: {},
    };
  },

  group: "block",

  content: "inline*",
  addAttributes() {
    return {
      class: {
         default: "tb-caption",
      },
      id: {
        default: null,
      },
    };
  },
  parseHTML() {
    return [{ tag: "caption" }];
  },
  renderHTML({ HTMLAttributes }) {
    return ["caption", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
  },
});

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

This is the given node to this extension

<p class="Captiontitle" data-id="caption"><strong>Table&nbsp;1.
    Simulation Results: Number of Clusters </strong>
    <inline-formula>
        <tex-math>
            $\mathbf{\mathit{ρ}}_{2}=0.05$
        </tex-math>
    </inline-formula>
    <strong>
        and
    </strong>
    <inline-formula>
        <tex-math>
            $\mathbf{\mathit{ρ}}_{3}=0.003$
        </tex-math>
    </inline-formula>
</p>

But after getting processed by the extension we are getting this as the renderHTML for caption

<caption class="Captiontitle" data-id="caption">
    <inline-formula>
        <tex-math>
            $\mathbf{\mathit{ρ}}_{2}=0.05$
        </tex-math>
    </inline-formula>
    <strong>
        and
    </strong>
    <inline-formula>
        <tex-math>
            $\mathbf{\mathit{ρ}}_{3}=0.003$
        </tex-math>
    </inline-formula>
</caption>

Below data in the given paragraph is getting removed

<strong>
  Table&nbsp;1. Simulation Results: Number of Clusters
</strong>

Additional Context (Optional)

Have tried most of all the content methods mentioned in the documentaion

content: inline*

content: (inline|text)+

content: (inline|paragraph)+

content: paragraph*

content: paragraph+

and so on

Dependency Updates