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 13 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: ceea5f1

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 ceea5f1
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/67812dedcdb1dc000830a732
😎 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)

@nperez0111 nperez0111 marked this pull request as draft December 31, 2024 15:42
Copy link

pkg-pr-new bot commented Jan 10, 2025

Open in Stackblitz

@tiptap/core

npm i https://pkg.pr.new/@tiptap/core@5558

@tiptap/extension-blockquote

npm i https://pkg.pr.new/@tiptap/extension-blockquote@5558

@tiptap/extension-bubble-menu

npm i https://pkg.pr.new/@tiptap/extension-bubble-menu@5558

@tiptap/extension-bullet-list

npm i https://pkg.pr.new/@tiptap/extension-bullet-list@5558

@tiptap/extension-character-count

npm i https://pkg.pr.new/@tiptap/extension-character-count@5558

@tiptap/extension-bold

npm i https://pkg.pr.new/@tiptap/extension-bold@5558

@tiptap/extension-code

npm i https://pkg.pr.new/@tiptap/extension-code@5558

@tiptap/extension-code-block

npm i https://pkg.pr.new/@tiptap/extension-code-block@5558

@tiptap/extension-code-block-lowlight

npm i https://pkg.pr.new/@tiptap/extension-code-block-lowlight@5558

@tiptap/extension-collaboration

npm i https://pkg.pr.new/@tiptap/extension-collaboration@5558

@tiptap/extension-collaboration-cursor

npm i https://pkg.pr.new/@tiptap/extension-collaboration-cursor@5558

@tiptap/extension-color

npm i https://pkg.pr.new/@tiptap/extension-color@5558

@tiptap/extension-document

npm i https://pkg.pr.new/@tiptap/extension-document@5558

@tiptap/extension-dropcursor

npm i https://pkg.pr.new/@tiptap/extension-dropcursor@5558

@tiptap/extension-floating-menu

npm i https://pkg.pr.new/@tiptap/extension-floating-menu@5558

@tiptap/extension-focus

npm i https://pkg.pr.new/@tiptap/extension-focus@5558

@tiptap/extension-font-family

npm i https://pkg.pr.new/@tiptap/extension-font-family@5558

@tiptap/extension-gapcursor

npm i https://pkg.pr.new/@tiptap/extension-gapcursor@5558

@tiptap/extension-hard-break

npm i https://pkg.pr.new/@tiptap/extension-hard-break@5558

@tiptap/extension-heading

npm i https://pkg.pr.new/@tiptap/extension-heading@5558

@tiptap/extension-highlight

npm i https://pkg.pr.new/@tiptap/extension-highlight@5558

@tiptap/extension-history

npm i https://pkg.pr.new/@tiptap/extension-history@5558

@tiptap/extension-horizontal-rule

npm i https://pkg.pr.new/@tiptap/extension-horizontal-rule@5558

@tiptap/extension-image

npm i https://pkg.pr.new/@tiptap/extension-image@5558

@tiptap/extension-italic

npm i https://pkg.pr.new/@tiptap/extension-italic@5558

@tiptap/extension-link

npm i https://pkg.pr.new/@tiptap/extension-link@5558

@tiptap/extension-list-item

npm i https://pkg.pr.new/@tiptap/extension-list-item@5558

@tiptap/extension-list-keymap

npm i https://pkg.pr.new/@tiptap/extension-list-keymap@5558

@tiptap/extension-mention

npm i https://pkg.pr.new/@tiptap/extension-mention@5558

@tiptap/extension-ordered-list

npm i https://pkg.pr.new/@tiptap/extension-ordered-list@5558

@tiptap/extension-paragraph

npm i https://pkg.pr.new/@tiptap/extension-paragraph@5558

@tiptap/extension-placeholder

npm i https://pkg.pr.new/@tiptap/extension-placeholder@5558

@tiptap/extension-strike

npm i https://pkg.pr.new/@tiptap/extension-strike@5558

@tiptap/extension-subscript

npm i https://pkg.pr.new/@tiptap/extension-subscript@5558

@tiptap/extension-superscript

npm i https://pkg.pr.new/@tiptap/extension-superscript@5558

@tiptap/extension-table

npm i https://pkg.pr.new/@tiptap/extension-table@5558

@tiptap/extension-table-cell

npm i https://pkg.pr.new/@tiptap/extension-table-cell@5558

@tiptap/extension-table-header

npm i https://pkg.pr.new/@tiptap/extension-table-header@5558

@tiptap/extension-table-row

npm i https://pkg.pr.new/@tiptap/extension-table-row@5558

@tiptap/extension-task-item

npm i https://pkg.pr.new/@tiptap/extension-task-item@5558

@tiptap/extension-task-list

npm i https://pkg.pr.new/@tiptap/extension-task-list@5558

@tiptap/extension-text

npm i https://pkg.pr.new/@tiptap/extension-text@5558

@tiptap/extension-text-align

npm i https://pkg.pr.new/@tiptap/extension-text-align@5558

@tiptap/extension-text-style

npm i https://pkg.pr.new/@tiptap/extension-text-style@5558

@tiptap/extension-typography

npm i https://pkg.pr.new/@tiptap/extension-typography@5558

@tiptap/extension-underline

npm i https://pkg.pr.new/@tiptap/extension-underline@5558

@tiptap/extension-youtube

npm i https://pkg.pr.new/@tiptap/extension-youtube@5558

@tiptap/extensions

npm i https://pkg.pr.new/@tiptap/extensions@5558

@tiptap/html

npm i https://pkg.pr.new/@tiptap/html@5558

@tiptap/pm

npm i https://pkg.pr.new/@tiptap/pm@5558

@tiptap/react

npm i https://pkg.pr.new/@tiptap/react@5558

@tiptap/starter-kit

npm i https://pkg.pr.new/@tiptap/starter-kit@5558

@tiptap/static-renderer

npm i https://pkg.pr.new/@tiptap/static-renderer@5558

@tiptap/suggestion

npm i https://pkg.pr.new/@tiptap/suggestion@5558

@tiptap/vue-2

npm i https://pkg.pr.new/@tiptap/vue-2@5558

@tiptap/vue-3

npm i https://pkg.pr.new/@tiptap/vue-3@5558

commit: ceea5f1

@nperez0111 nperez0111 marked this pull request as ready for review January 10, 2025 14:12
@nperez0111
Copy link
Contributor Author

This is ready now @bdbch

I'm unsure that it really is worth it for us to use the JSX transforms internally (although I did convert bold and blockquote as a proof of concept). But, it is a really nice API for consumers

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