-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[lexical-playground] Fix bug: Insert an image inside another image's caption (#6109) #6230
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
cbd6a7f
to
1266e34
Compare
1266e34
to
97e772b
Compare
97e772b
to
49b4c27
Compare
update: the image caption nested editor uses PlainTextPlugin so it can paste the content as plain text - similar behavior as for a Sticky Note node. Fixed the issue so that an image/GIF/table etc. can be pasted to an image caption. |
49b4c27
to
9ae0fd2
Compare
update: resolved an issue with non-functional text formatting and alignment in the image caption nested editor. image_caption_formatting_fix.mov |
setActiveEditor(newEditor); | ||
$updateToolbar(newEditor); |
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 think you don't need to pass newEditor
to $updateToolbar()
as you can grab it from activeEditor
var from the component scope
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.
not sure why but the function has a stale activeEditor
value sometimes, so passing as an argument
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 think you don't need to pass
newEditor
to$updateToolbar()
as you can grab it fromactiveEditor
var from the component scope
thanks, updated that
(newEditor: LexicalEditor) => { | ||
const selection = $getSelection(); | ||
if ($isRangeSelection(selection)) { | ||
if (newEditor !== editor && $isEditorIsNestedEditor(newEditor)) { |
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 (newEditor !== editor && $isEditorIsNestedEditor(newEditor)) { | |
if (activeEditor !== editor && $isEditorIsNestedEditor(activeEditor)) { |
packages/lexical/src/LexicalUtils.ts
Outdated
/** | ||
* Checks if the editor is a nested editor created by LexicalNestedComposer | ||
*/ | ||
export function $isEditorIsNestedEditor(editor: LexicalEditor): boolean { |
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.
Instead of having this function you can simply check if editor._parentEditor
is non null
:)
Although maybe we still can have helper...
@@ -74,6 +74,7 @@ import {Dispatch, useCallback, useEffect, useState} from 'react'; | |||
import * as React from 'react'; | |||
import {IS_APPLE} from 'shared/environment'; | |||
|
|||
import {$isEditorIsNestedEditor} from '../../../../lexical/src/LexicalUtils'; |
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.
You can't really import non-exported file from lexical
package here
But you can move it to @lexical/utils
9ae0fd2
to
776831e
Compare
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.
Excellent!
Context:
Now users are able to insert an image/GIF/table etc, into another image's caption.
Solution:
This PR limits what the users can insert into the image caption and its nested editor. Excluding some controls from the toolbar if the selection is inside the nested editor that belongs to the image caption.
Closes #6109
Test plan
Before
before-image-caption.mov
After
image-caption.mov