-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feature: add global node type name attributes to editor DOM #5786
base: develop
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 3fa56e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 54 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…nto global-nodename-attribute
export const Typenames = Extension.create({ | ||
name: 'typenames', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typenames?
Maybe namedAttributes
? Or labeledAttributes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this adds the nodetype names of nodes and marks? Wouldn't typenames make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typename just is super generic.
It should be clear that this is applying to the HTMLAttributes of nodes & marks, unsure of a good name for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typenameAttributes
?
'data-tiptap': { | ||
default: extension.name, | ||
rendered: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this get stored to the Tiptap JSON? Kind of redundant if it does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think those are added to the Tiptap JSON.
@@ -0,0 +1,19 @@ | |||
import { Extension } from '../Extension.js' | |||
|
|||
export const Typenames = Extension.create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better TypeNames
?
Just figured - the |
…a initialization logic
@@ -10,6 +10,8 @@ import React from 'react' | |||
const MenuBar = () => { | |||
const { editor } = useCurrentEditor() | |||
|
|||
window.editor = editor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you accidentally left this in?
Changes Overview
This pull request introduces a new feature to add type attributes to nodes and marks in the editor for better identification, which can be useful for testing and styling purposes. The changes span across multiple files to implement and support this feature.
This makes it easier to style specific HTML elements of the editor while not overwriting any styles for node view related elements or other decorations that may unwillingly be styled.
If enabled, a node could be rendered like this in HTML:
Implementation Approach
I added a new option called
addTypeAttributes
to the editor which is global and enabled by default. ThisaddTypeAttributes
option enables aTypenames
extension that will dynamically add those type names to the editor DOM.Those attributes are currently stripped from the editors output.
Testing Done
I tested this all locally on any test of our demos pages.
Verification Steps
Clone and check the branch for your self or check the deployed netlify page.
Additional Notes
I don't think this is a breaking change as it's not really changing the general behavior of the editor and the
data-node-type
attribute is vague enough to not be used by the general user base.Checklist