-
-
Notifications
You must be signed in to change notification settings - Fork 543
feat: Better parsing of external HTML attributes & inline styles #1605
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
8cad7bd
1b23c70
13acc7e
c8bc46f
8af8476
86214e5
b47de6a
a6389c7
0ced7f2
ced52b4
2bbdd6c
1b999ca
ab09848
0f029ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import { Mark } from "@tiptap/core"; | ||
import { getTextColorAttribute } from "../../blocks/defaultProps.js"; | ||
import { createStyleSpecFromTipTapMark } from "../../schema/index.js"; | ||
|
||
const TextColorMark = Mark.create({ | ||
name: "textColor", | ||
priority: 1000, | ||
|
||
addAttributes() { | ||
return { | ||
stringValue: { | ||
default: undefined, | ||
parseHTML: (element) => element.getAttribute("data-text-color"), | ||
renderHTML: (attributes) => ({ | ||
"data-text-color": attributes.stringValue, | ||
}), | ||
}, | ||
stringValue: getTextColorAttribute("stringValue"), | ||
}; | ||
}, | ||
|
||
|
@@ -25,8 +21,8 @@ const TextColorMark = Mark.create({ | |
return false; | ||
} | ||
|
||
if (element.hasAttribute("data-text-color")) { | ||
return { stringValue: element.getAttribute("data-text-color") }; | ||
if (element.hasAttribute("data-text-color") || element.style.color) { | ||
return {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return {}? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we don't need to parse the color because it's already handled in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't we omit line 25 / 26 then entirely? it's still a bit confusing right? (maybe tiptap issue) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because This is a kind of weird TipTap thing especially with We could choose to parse the actual value of |
||
} | ||
|
||
return false; | ||
|
Uh oh!
There was an error while loading. Please reload this page.