Skip to content

Commit

Permalink
Chore: Fix deprecated usage of toggleLink with $toggleLink (follow up…
Browse files Browse the repository at this point in the history
… to #5979)
  • Loading branch information
etrepum committed May 10, 2024
1 parent 40f6699 commit d719289
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import {
$createLinkNode,
$isLinkNode,
$toggleLink,
LinkNode,
SerializedLinkNode,
toggleLink,
} from '@lexical/link';
import {
$getRoot,
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('LexicalLinkNode tests', () => {
});
});

test('toggleLink applies the title attribute when creating', async () => {
test('$toggleLink applies the title attribute when creating', async () => {
const {editor} = testEnv;
await editor.update(() => {
const p = new ParagraphNode();
Expand All @@ -401,7 +401,7 @@ describe('LexicalLinkNode tests', () => {

await editor.update(() => {
$selectAll();
toggleLink('https://lexical.dev/', {title: 'Lexical Website'});
$toggleLink('https://lexical.dev/', {title: 'Lexical Website'});
});

const paragraph = editor!.getEditorState().toJSON().root
Expand Down
8 changes: 4 additions & 4 deletions packages/lexical-react/src/LexicalLinkPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import {LinkNode, TOGGLE_LINK_COMMAND, toggleLink} from '@lexical/link';
import {$toggleLink, LinkNode, TOGGLE_LINK_COMMAND} from '@lexical/link';
import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
import {mergeRegister, objectKlassEquals} from '@lexical/utils';
import {
Expand Down Expand Up @@ -34,17 +34,17 @@ export function LinkPlugin({validateUrl}: Props): null {
TOGGLE_LINK_COMMAND,
(payload) => {
if (payload === null) {
toggleLink(payload);
$toggleLink(payload);
return true;
} else if (typeof payload === 'string') {
if (validateUrl === undefined || validateUrl(payload)) {
toggleLink(payload);
$toggleLink(payload);
return true;
}
return false;
} else {
const {url, target, rel, title} = payload;
toggleLink(url, {rel, target, title});
$toggleLink(url, {rel, target, title});
return true;
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-website/docs/react/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ React wrapper for `@lexical/history` that adds support for history stack managem

### `LexicalLinkPlugin`

React wrapper for `@lexical/link` that adds support for links, including `toggleLink` command support that toggles link for selected text
React wrapper for `@lexical/link` that adds support for links, including `$toggleLink` command support that toggles link for selected text

```jsx
<LinkPlugin />
Expand Down

0 comments on commit d719289

Please sign in to comment.