-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Text area using variables #8034
Conversation
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.
LGTM
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.
Great work!! I left a few questions to better understand the challenges you faced! Thank you.
editorProps: { | ||
handleKeyDown: (view, event) => { | ||
if (event.key === 'Enter' && !event.shiftKey) { | ||
event.preventDefault(); | ||
|
||
const { state } = view; | ||
const { tr } = state; | ||
|
||
// Insert hard break using the view's state and dispatch | ||
const transaction = tr.replaceSelectionWith( | ||
state.schema.nodes.hardBreak.create(), | ||
); | ||
|
||
view.dispatch(transaction); | ||
|
||
return true; | ||
} | ||
return false; | ||
}, | ||
}, |
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.
Why do we implement that logic? It seems that Tiptap should handle it, shouldn't it?
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.
Tip tap does not perform hardbreak on Enter
. The behavior is not great by default
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.
Thanks for the info!
}, | ||
}, | ||
enableInputRules: false, | ||
enablePasteRules: false, |
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 it have something to do with the fact that we can't copy and paste from other <VariableTagInput />
components and get the variables correctly wired? I'm not saying that we absolutely want that behavior, I'm just wondering what problem you solved by disabling enabledPasteRules
.
CleanShot.2024-10-25.at.11.02.14.mp4
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 am not sure. Tiptap by default enable a lot of features that we do not need. Following the doc, their recommendation is for exemple to use a StarterKit
for several extensions. And enabling input and paste rules that I did not fully understand https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules. By default I prefer removing these and put back only the ones I need later.
But to answer your video, no, the behavior si the same with or without those paste rules
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.
Okay! Great! I agree with you 💯
43283fa
to
4e80dab
Compare
4e80dab
to
1e252f4
Compare
1e252f4
to
db4b0df
Compare
Enregistrement.de.l.ecran.2024-10-24.a.17.07.14.mov