-
Notifications
You must be signed in to change notification settings - Fork 292
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
feat: Migrate input bar to Lexical #15507
Conversation
* refactor: move send button out of lexical input * remove unused prop * restore old component html structure --------- Co-authored-by: Przemyslaw Jozwik <[email protected]>
Codecov Report
@@ Coverage Diff @@
## dev #15507 +/- ##
==========================================
- Coverage 44.67% 44.28% -0.39%
==========================================
Files 668 683 +15
Lines 22671 22920 +249
Branches 5169 5214 +45
==========================================
+ Hits 10128 10150 +22
- Misses 11245 11469 +224
- Partials 1298 1301 +3 |
src/script/components/LexicalInput/components/Mention/Mention.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/components/Mention/Mention.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/components/Mention/Mention.tsx
Outdated
Show resolved
Hide resolved
let handled = false; | ||
const nodeToSelect = getPreviousSibling(node); | ||
if ($isElementNode(nodeToSelect)) { | ||
nodeToSelect.selectEnd(); |
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 are you using only if blocks? using else if will make it more readable. Alternatively you can use separate helper functions for each type of node selection to make the code more self-explanatory.
const selectEnd = ($isElementNode(node: Node)): void => {
node.selectEnd();
handled = true;
};
const selectText = ($isTextNode(node: Node)): void => {
node.select();
handled = true;
};
if ($isElementNode(nodeToSelect)) {
selectEnd(nodeToSelect);
} else if ($isTextNode(nodeToSelect)) {
selectText(nodeToSelect);
}
// rest of the code
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.
It comes from Mention plugin from Lexical, and this if's is more readable ;)
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 don't think so, it was a large block of if's without any description. its definitely not more readable.
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.
It's change to one function named onArrowPress. So now we can reuse it for keys: ArrowLeft and ArrowRight and other keys if we want. So I'll add for You comment for what element we handling.
const nodeToSelect = getNextSibling(node); | ||
if ($isElementNode(nodeToSelect)) { | ||
nodeToSelect.selectStart(); | ||
handled = 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.
same feedback goes here too
src/script/components/LexicalInput/components/SendMessageButton/SendMessageButton.tsx
Outdated
Show resolved
Hide resolved
@@ -1,6 +1,6 @@ | |||
/* | |||
* Wire | |||
* Copyright (C) 2022 Wire Swiss GmbH | |||
* Copyright (C) 2023 Wire Swiss GmbH |
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.
if this is an existing file then copyright should't change
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.
It's not used, I remove hook.
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.
this is an existing file, for existing file we shouldn't change the copyright year.
src/script/components/LexicalInput/components/Mention/Mention.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/components/Mention/Mention.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/BeautifulMentionsPlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/BeautifulMentionsPlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/BeautifulMentionsPlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/DraftStatePlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/BeautifulMentionsPlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/GlobalEventsPlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/plugins/GlobalEventsPlugin.tsx
Outdated
Show resolved
Hide resolved
src/script/components/LexicalInput/components/Mention/Mention.tsx
Outdated
Show resolved
Hide resolved
7d67402
to
beaf068
Compare
src/script/components/RichTextEditor/plugins/EmojiPickerPlugin/EmojiPickerPlugin.tsx
Show resolved
Hide resolved
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.
Reviewers: please bear in mind that this plugin was copy/pasted from the lexical repo (and modified to work in reverse order)
8ca864f
to
7a4d20e
Compare
}; | ||
}, [updateTheme]); | ||
setTheme(getTheme()); | ||
useUserPropertyChange(getTheme, WebAppEvents.PROPERTIES.UPDATE.INTERFACE.THEME, setTheme); |
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.
Since I needed the same logic for the "replaceEmoji" user preference, I extracted that logic to a more generic hook
export function HistoryPlugin(): null { | ||
const [editor] = useLexicalComposerContext(); | ||
|
||
useEffect(() => registerHistory(editor, createEmptyHistoryState(), 300), [editor]); |
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.
Please move 300 to const, now we don't know what it mean :(
package.json
Outdated
"@lexical/history": "^0.11.3", | ||
"@lexical/react": "^0.11.1", |
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.
Don't we want to use exact versions here as well?
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.
good call 👌
Description
This is a major refactor of the InputBar to now use https://lexical.dev/
This will fix issues like dealing with international keyboard better and also improve the overall architecture of the input bar
Note for the reviewers
This is a huge PR, no doubt about this. Note that:
RichTextEditor
folder, there lives the core of the input bar logic.E2E test to run:
:
symbol;)
should be converted to 😉 )To Fix: