-
Notifications
You must be signed in to change notification settings - Fork 9
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
Rich text comments #108
base: main
Are you sure you want to change the base?
Rich text comments #108
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
packages/frontpage/next.config.mjs
Outdated
// FIXME: Remove this when we're closer to production | ||
typescript: { | ||
ignoreBuildErrors: true, | ||
}, | ||
eslint: { | ||
ignoreDuringBuilds: 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.
I must remember to remove this later...
aa4aa26
to
f91d6b4
Compare
|
||
type CommentContent = string | { content: string; facets: CommentFacet[] }; | ||
|
||
function $nodeToCommentContent(node: LexicalNode): CommentContent[] { |
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.
Some notes on the ComentContent[]
type for later as this will be included in our lexicon:
There are two representations for some text without any facets:
"foo"
{content: "foo", facets: []}
I'm not sure there are good ways around this without making the type much harder to encode and decode.
We force an array type even though CommentContent | CommentContent[]
would be equally valid and not much more difficult to implement. This is to make it easier to decode later.
This reduces the amount of possible empty value representations by one, but there are still a few. These are all equivalent and mean "empty value"
- empty array:
[]
- empty array with string:
[""]
- empty array with obj:
[{content: "", facets: []}]
- empty array with many strings/objs:
["", {content: "", facets: []}]
This actually leads to there being an infinite amount of possible empty values... This is really not ideal because it can't easily be caught by putting char length constraints on the text, as no matter how many nodes you have the length of the concatenated string will always be 0. I think this needs to be fixed somehow.
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.
Having multiple ways of doing something in the data model is bad because in general the more ways there are to do something, the more complex it is to enforce constraints, which leads to a higher likelihood of a loophole being possible.
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.
Worth noting that we're kind of constrained by the atproto lexicon spec here, some solutions (such as non-empty types) are not possible right now.
We can abandon this tho, and consider rich-text fields as unknown
in the lexicon for now while we wait for a proper richtext
type to be added to the spec I suppose.
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 originally thought that a flat array would suitable here, but actually nested nodes need to be supported.
Consider a link that has some characters bolded, but not all. In markdown:
[some **link**](example.com)
We don't want to represent this as a flat array because the best we can do with that is:
[some ](example.com)[**link**](example.com)
This is not what the author intended. Adding heuristics to merge sibling links is not possible either because it should be valid to have two links that are the same next to eachother in the text.
The question now becomes: should rich text nodes be able to be nested arbitrarily or are there some rules we should put in place here to prevent arbitrary recursion depths?
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.
The nested structure also introduces another way to represent empty text:
[
{
content: [
{
content: [...],
facets: []
}
],
facets: []
}
]
8349597
to
bdd9843
Compare
bdd9843
to
584b767
Compare
584b767
to
90159c0
Compare
90159c0
to
d2f6b1b
Compare
d2f6b1b
to
ebd257f
Compare
No description provided.