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

feat(jsx): add @tiptap/jsx for more convenient rendering of Tiptap content #5558

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

nperez0111
Copy link
Contributor

Changes Overview

This implements @tiptap/jsx which is a package that can render JSX in a node's renderHTML method to the format that Tiptap expects.
This makes for a more modern experience of describing the content of a Node as you might do in modern frameworks like React/Vue.

Implementation Approach

Here is an example of what this allows for:

/* @jsx jsxTiptap */
import { jsxTiptap, children } from "@tiptap/jsx";
import { Node } from "@tiptap/core";

const Nested = () => (
  <span>
    <span>{children}</span>
    <br />
    nested
  </span>
);

const Demo = Node.create({
  name: "demo",
  group: "block",
  content: "block*",
  draggable: true,
  addAttributes() {
    return {
      id: {
        default: null,
      },
    };
  },
  renderHTML({ HTMLAttributes }) {
    return <div {...HTMLAttributes}><Nested /></div>;
  },
  parseHTML() {
    console.log("parseHTML");
    return [
      {
        tag: "div",
      },
    ];
  },
});

export default Demo;

Testing Done

Need to add some tests for ensuring that the arrays are all generated correctly. More of a POC than anything.

Verification Steps

Additional Notes

Checklist

  • I have created a changeset for this PR if necessary.
  • My changes do not break the library.
  • I have added tests where applicable.
  • I have followed the project guidelines.
  • I have fixed any lint issues.

Related Issues

Copy link

changeset-bot bot commented Aug 27, 2024

⚠️ No Changeset found

Latest commit: d8ca76e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Aug 27, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit d8ca76e
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/67197c56fd6f510008a46903
😎 Deploy Preview https://deploy-preview-5558--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@bdbch bdbch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just a quick comment regarding naming and namespaces

packages/jsx/README.md Outdated Show resolved Hide resolved
packages/jsx/src/jsx.tsx Outdated Show resolved Hide resolved
@bdbch
Copy link
Member

bdbch commented Nov 30, 2024

What's the status of this one. Going through our approved PRs to see where we can move forward.

@nperez0111
Copy link
Contributor Author

I want to do this for v3, not relative to develop so I haven't worked on it in a minute

@bdbch bdbch changed the base branch from develop to next December 2, 2024 09:53
@bdbch
Copy link
Member

bdbch commented Dec 2, 2024

Moved the target branch to next (we'll probably need to sync next with develop soon too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Ready to Merge
Development

Successfully merging this pull request may close these issues.

2 participants