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 1 commit into
base: develop
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: a6adab0

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 failed. Why did it fail? →

Name Link
🔨 Latest commit a6adab0
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/66cdc55e29b3b1000838067e

Copy link
Contributor

@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

@@ -0,0 +1,18 @@
# @tiptap/static-renderer
Copy link
Contributor

Choose a reason for hiding this comment

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

fix here


declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
Copy link
Contributor

Choose a reason for hiding this comment

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

could this cause issues globally with the normal react typings (for example I get typescript issues while using normal React JSX?)

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

Successfully merging this pull request may close these issues.

2 participants