-
Notifications
You must be signed in to change notification settings - Fork 312
feat: Added KaTeX icon/button to chat toolbar for documentation access #986
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
Open
KrishnaShuk
wants to merge
1
commit into
RocketChat:develop
Choose a base branch
from
KrishnaShuk:feature/katex-toolbar-button
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+62
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,9 @@ const ChatInputFormattingToolbar = ({ | |
inputRef, | ||
triggerButton, | ||
optionConfig = { | ||
surfaceItems: ['emoji', 'formatter', 'link', 'audio', 'video', 'file'], | ||
surfaceItems: ['emoji', 'formatter', 'link', 'katex', 'audio', 'video', 'file'], | ||
formatters: ['bold', 'italic', 'strike', 'code', 'multiline'], | ||
smallScreenSurfaceItems: ['emoji', 'video', 'audio', 'file'], | ||
smallScreenSurfaceItems: ['emoji', 'video', 'audio', 'file', 'katex'], | ||
popOverItems: ['formatter', 'link'], | ||
}, | ||
}) => { | ||
|
@@ -56,6 +56,9 @@ const ChatInputFormattingToolbar = ({ | |
}; | ||
const handleFormatterClick = (item) => { | ||
formatSelection(messageRef, item.pattern); | ||
if (item.onClick) { | ||
item.onClick(); | ||
} | ||
setPopoverOpen(false); | ||
}; | ||
const handleEmojiClick = (emojiEvent) => { | ||
|
@@ -190,6 +193,33 @@ const ChatInputFormattingToolbar = ({ | |
</ActionButton> | ||
</Tooltip> | ||
), | ||
katex: ( | ||
<Tooltip text="KaTeX" position="top" key="katex"> | ||
<ActionButton | ||
ghost | ||
style={{ | ||
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 we not pass these many styles directly, instead utilise css jsx files for that |
||
padding: '0 8px', | ||
minWidth: 'auto', | ||
fontSize: '17px', | ||
fontFamily: 'KaTeX_Math-Italic, Times New Roman', | ||
color: theme.palette?.mode === 'dark' ? '#fff' : '#2f343d', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
transform: 'scaleX(0.9) rotate(-2deg)', | ||
position: 'relative', | ||
top: '-1px' | ||
}} | ||
disabled={isRecordingMessage} | ||
onClick={() => { | ||
if (isRecordingMessage) return; | ||
window.open('https://katex.org/docs/supported.html', '_blank'); | ||
}} | ||
> | ||
𝒇 | ||
</ActionButton> | ||
</Tooltip> | ||
), | ||
formatter: formatters | ||
.map((name) => formatter.find((item) => item.name === name)) | ||
.map((item) => | ||
|
@@ -214,7 +244,7 @@ const ChatInputFormattingToolbar = ({ | |
</> | ||
) : ( | ||
<Tooltip | ||
text={item.name} | ||
text={item.tooltip} | ||
position="top" | ||
key={`formatter-${item.name}`} | ||
> | ||
|
@@ -225,6 +255,9 @@ const ChatInputFormattingToolbar = ({ | |
onClick={() => { | ||
if (isRecordingMessage) return; | ||
formatSelection(messageRef, item.pattern); | ||
if (item.onClick) { | ||
item.onClick(); | ||
} | ||
}} | ||
> | ||
<Icon | ||
|
@@ -294,7 +327,7 @@ const ChatInputFormattingToolbar = ({ | |
if (itemInFormatter) { | ||
return ( | ||
<Tooltip | ||
text={itemInFormatter.name} | ||
text={itemInFormatter.tooltip} | ||
position="top" | ||
key={`formatter-${itemInFormatter.name}`} | ||
> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
const KaTeX = (props) => ( | ||
<svg | ||
width="21" | ||
height="21" | ||
viewBox="0 0 21 21" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
> | ||
<path | ||
d="M4 4L8 10.5L4 17H6L9.25 11.5L6 6H4Z" | ||
fill="currentColor" | ||
/> | ||
<path | ||
d="M17 4H10V6H12.5V15H10V17H17V15H14.5V6H17V4Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default KaTeX; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's this ?