Skip to content

Commit

Permalink
fix: link dialog regression
Browse files Browse the repository at this point in the history
Fixes #681
  • Loading branch information
petyosi committed Jan 28, 2025
1 parent 9c8c331 commit 3a2687d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 25 deletions.
28 changes: 27 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 29 additions & 24 deletions src/plugins/link-dialog/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { $createLinkNode, $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link'
import {
$addUpdateTag,

Check warning on line 3 in src/plugins/link-dialog/index.ts

View workflow job for this annotation

GitHub Actions / Release

'$addUpdateTag' is defined but never used. Allowed unused vars must match /^_/u
$createTextNode,
$getSelection,
$insertNodes,
Expand Down Expand Up @@ -234,6 +235,7 @@ export const linkDialogState$ = Cell<InactiveLinkDialog | PreviewLinkDialog | Ed
rectangle: getSelectionRectangle(activeEditor)
} as PreviewLinkDialog
} else {
console.log('setting to inactive')

Check warning on line 238 in src/plugins/link-dialog/index.ts

View workflow job for this annotation

GitHub Actions / Release

Unexpected console statement
return { type: 'inactive' } as InactiveLinkDialog
}
} else {
Expand Down Expand Up @@ -290,30 +292,33 @@ export const openLinkEditDialog$ = Action((r) => {
),
([, selection, editor]) => {
editor?.focus(() => {
editor.getEditorState().read(() => {
const node = getLinkNodeInSelection(selection)
const rectangle = getSelectionRectangle(editor)!
if (node) {
r.pub(linkDialogState$, {
type: 'edit',
initialUrl: node.getURL(),
initialTitle: node.getTitle() ?? '',
url: node.getURL(),
title: node.getTitle() ?? '',
linkNodeKey: node.getKey(),
rectangle
})
} else {
r.pub(linkDialogState$, {
type: 'edit',
initialUrl: '',
initialTitle: '',
title: '',
url: '',
linkNodeKey: '',
rectangle
})
}
// needs to be done due to a change in v0.22
setTimeout(() => {
editor.getEditorState().read(() => {
const node = getLinkNodeInSelection(selection)
const rectangle = getSelectionRectangle(editor)!
if (node) {
r.pub(linkDialogState$, {
type: 'edit',
initialUrl: node.getURL(),
initialTitle: node.getTitle() ?? '',
url: node.getURL(),
title: node.getTitle() ?? '',
linkNodeKey: node.getKey(),
rectangle
})
} else {
r.pub(linkDialogState$, {
type: 'edit',
initialUrl: '',
initialTitle: '',
title: '',
url: '',
linkNodeKey: '',
rectangle
})
}
})
})
})
}
Expand Down

0 comments on commit 3a2687d

Please sign in to comment.