Skip to content

Commit

Permalink
refactor(PastePlugin): update selection type to RangeSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
olafsulich committed Jan 15, 2025
1 parent 1811850 commit c7fcbf6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
COMMAND_PRIORITY_LOW,
$isRangeSelection,
$isTextNode,
BaseSelection,
} from 'lexical';

import {User} from 'src/script/entity/User';
Expand All @@ -39,6 +40,8 @@ interface PastePluginProps {
getMentionCandidates: () => User[];
}

type RangeSelection = BaseSelection | null;

/**
* PastePlugin handles pasting content into the editor while preserving formatting and special nodes.
* It specifically handles:
Expand Down Expand Up @@ -87,7 +90,7 @@ export const PastePlugin = ({getMentionCandidates}: PastePluginProps): JSX.Eleme
* @returns boolean - True if mentions were handled successfully
*/
const handleLexicalMentions = useCallback(
(doc: Document, selection: ReturnType<typeof $getSelection> | null, availableUsers: User[]): boolean => {
(doc: Document, selection: RangeSelection | null, availableUsers: User[]): boolean => {
if (!selection) {
return false;
}
Expand Down Expand Up @@ -133,7 +136,7 @@ export const PastePlugin = ({getMentionCandidates}: PastePluginProps): JSX.Eleme
* @returns boolean - True if formatted content was handled successfully
*/
const handleFormattedContent = useCallback(
(doc: Document, selection: ReturnType<typeof $getSelection> | null): boolean => {
(doc: Document, selection: RangeSelection | null): boolean => {
if (!selection) {
return false;
}
Expand Down Expand Up @@ -178,7 +181,7 @@ export const PastePlugin = ({getMentionCandidates}: PastePluginProps): JSX.Eleme
* @param availableUsers - List of users that can be mentioned in current context
*/
const processMentions = useCallback(
(selection: ReturnType<typeof $getSelection> | null, mentions: NodeListOf<Element>, availableUsers: User[]) => {
(selection: RangeSelection | null, mentions: NodeListOf<Element>, availableUsers: User[]) => {
if (!selection) {
return;
}
Expand Down

0 comments on commit c7fcbf6

Please sign in to comment.