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

Text area using variables #8034

Merged
merged 4 commits into from
Oct 25, 2024
Merged

Text area using variables #8034

merged 4 commits into from
Oct 25, 2024

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Oct 24, 2024

  • Adding multiline props to component
  • Update design and logic accordingly
  • Fix hotkey scope for right drawer
Enregistrement.de.l.ecran.2024-10-24.a.17.07.14.mov

Copy link
Contributor

@martmull martmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Devessier Devessier left a 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.

Comment on lines +171 to +190
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;
},
},
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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,
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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 💯

@thomtrp thomtrp enabled auto-merge (squash) October 25, 2024 12:49
@thomtrp thomtrp merged commit 2e73d02 into main Oct 25, 2024
18 checks passed
@thomtrp thomtrp deleted the tt-text-area-tag-variables branch October 25, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants