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(core): add support for markviews #5759

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

feat(core): add support for markviews #5759

wants to merge 7 commits into from

Conversation

nperez0111
Copy link
Contributor

@nperez0111 nperez0111 commented Oct 23, 2024

Changes Overview

This adds support for Prosemirror markviews to Marks.

For this to actually become supported we will need to:

  • Have a MarkView class that can manage the markview element instead of having to create your own elements
  • Have a way to render React / Vue components like node views does

From there, we'd pretty much just support them!

Here is what the API looks like right now, but we will probably add a class to make these elements for you:

  addMarkView() {
    return ({ mark, HTMLAttributes }) => {
      const dom = document.createElement('b')
      const contentDOM = document.createElement('span')

      dom.appendChild(contentDOM)

      return {
        dom,
        contentDOM,
      }
    }
  },

I've implemented both React rendering for mark views and Vue 3 rendering (I couldn't be bothered to do vue-2, we should probably deprecate that package).

Implementation Approach

Pretty much following the same sort of implementation as node views, I was able to add support for markviews.

Testing Done

Verification Steps

I added a temporary markview to a mark and it worked just fine

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 Oct 23, 2024

⚠️ No Changeset found

Latest commit: f7c2a98

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 Oct 23, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit f7c2a98
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/6780f29467ebb200083ce42e
😎 Deploy Preview https://deploy-preview-5759--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.

Awesome idea, LGTM!

@bdbch
Copy link
Member

bdbch commented Nov 30, 2024

Tests failed and we'd need to merge with develop again as we got a few merge conflicts.

Looking forward to get this merged.

@nperez0111
Copy link
Contributor Author

I want to do this for v3, & I need to make a react markview impl

Types have also changed in prosemirror view since

@bdbch
Copy link
Member

bdbch commented Dec 2, 2024

Should we change the target branch to next then?

@nperez0111 nperez0111 changed the base branch from develop to next December 2, 2024 12:52
@nperez0111 nperez0111 force-pushed the markviews branch 2 times, most recently from af7c46f to f910b40 Compare December 30, 2024 16:22
@bdbch
Copy link
Member

bdbch commented Jan 8, 2025

@nperez0111 let me know when you need another code review on this one.

Copy link

pkg-pr-new bot commented Jan 9, 2025

Open in Stackblitz

@tiptap/core

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

@tiptap/extension-bubble-menu

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

@tiptap/extension-bold

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

@tiptap/extension-bullet-list

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

@tiptap/extension-blockquote

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

@tiptap/extension-character-count

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

@tiptap/extension-code

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

@tiptap/extension-code-block

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

@tiptap/extension-code-block-lowlight

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

@tiptap/extension-collaboration

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

@tiptap/extension-collaboration-cursor

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

@tiptap/extension-color

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

@tiptap/extension-document

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

@tiptap/extension-dropcursor

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

@tiptap/extension-floating-menu

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

@tiptap/extension-focus

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

@tiptap/extension-font-family

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

@tiptap/extension-gapcursor

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

@tiptap/extension-hard-break

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

@tiptap/extension-heading

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

@tiptap/extension-highlight

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

@tiptap/extension-history

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

@tiptap/extension-horizontal-rule

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

@tiptap/extension-image

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

@tiptap/extension-italic

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

@tiptap/extension-link

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

@tiptap/extension-list-item

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

@tiptap/extension-list-keymap

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

@tiptap/extension-mention

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

@tiptap/extension-ordered-list

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

@tiptap/extension-paragraph

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

@tiptap/extension-placeholder

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

@tiptap/extension-strike

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

@tiptap/extension-subscript

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

@tiptap/extension-superscript

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

@tiptap/extension-table

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

@tiptap/extension-table-cell

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

@tiptap/extension-table-header

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

@tiptap/extension-table-row

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

@tiptap/extension-task-item

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

@tiptap/extension-task-list

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

@tiptap/extension-text

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

@tiptap/extension-text-align

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

@tiptap/extension-text-style

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

@tiptap/extension-typography

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

@tiptap/extension-underline

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

@tiptap/extension-youtube

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

@tiptap/extensions

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

@tiptap/html

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

@tiptap/pm

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

@tiptap/react

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

@tiptap/starter-kit

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

@tiptap/static-renderer

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

@tiptap/suggestion

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

@tiptap/vue-2

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

@tiptap/vue-3

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

commit: f7c2a98

@nperez0111
Copy link
Contributor Author

@bdbch close to a review here, would probably want to add some tests that it works properly. I also found out that prosemirror-dev-tools extension does not have support for markviews yet and causes it to render incorrectly, so disable the extension to get it to run properly. I made an issue so that they know to fix it: TeemuKoivisto/prosemirror-dev-toolkit#84

@nperez0111
Copy link
Contributor Author

Alright, all done here @bdbch

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

Successfully merging this pull request may close these issues.

3 participants