From f998551b3c1e5d9285856dfdfc54a5d068f29419 Mon Sep 17 00:00:00 2001 From: Ivaylo Pavlov Date: Sun, 16 Feb 2025 19:54:47 +0000 Subject: [PATCH 1/2] Replace substr with substring --- packages/lexical-playground/src/commenting/index.ts | 2 +- packages/lexical-playground/src/nodes/PollNode.tsx | 2 +- .../lexical-playground/src/plugins/AutocompletePlugin/index.tsx | 2 +- packages/lexical-react/src/shared/LexicalMenu.ts | 2 +- packages/lexical/src/LexicalUtils.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/lexical-playground/src/commenting/index.ts b/packages/lexical-playground/src/commenting/index.ts index 59aa95baec0..c37469ba5e8 100644 --- a/packages/lexical-playground/src/commenting/index.ts +++ b/packages/lexical-playground/src/commenting/index.ts @@ -41,7 +41,7 @@ function createUID(): string { return Math.random() .toString(36) .replace(/[^a-z]+/g, '') - .substr(0, 5); + .substring(0, 5); } export function createComment( diff --git a/packages/lexical-playground/src/nodes/PollNode.tsx b/packages/lexical-playground/src/nodes/PollNode.tsx index f4f57f47cda..e6d25ce268d 100644 --- a/packages/lexical-playground/src/nodes/PollNode.tsx +++ b/packages/lexical-playground/src/nodes/PollNode.tsx @@ -35,7 +35,7 @@ function createUID(): string { return Math.random() .toString(36) .replace(/[^a-z]+/g, '') - .substr(0, 5); + .substring(0, 5); } export function createPollOption(text = ''): Option { diff --git a/packages/lexical-playground/src/plugins/AutocompletePlugin/index.tsx b/packages/lexical-playground/src/plugins/AutocompletePlugin/index.tsx index 6a3da055337..c2f94339fbb 100644 --- a/packages/lexical-playground/src/plugins/AutocompletePlugin/index.tsx +++ b/packages/lexical-playground/src/plugins/AutocompletePlugin/index.tsx @@ -51,7 +51,7 @@ type SearchPromise = { export const uuid = Math.random() .toString(36) .replace(/[^a-z]+/g, '') - .substr(0, 5); + .substring(0, 5); // TODO lookup should be custom function $search(selection: null | BaseSelection): [boolean, string] { diff --git a/packages/lexical-react/src/shared/LexicalMenu.ts b/packages/lexical-react/src/shared/LexicalMenu.ts index 3e0d5217241..2104ea63c48 100644 --- a/packages/lexical-react/src/shared/LexicalMenu.ts +++ b/packages/lexical-react/src/shared/LexicalMenu.ts @@ -111,7 +111,7 @@ function getFullMatchOffset( ): number { let triggerOffset = offset; for (let i = triggerOffset; i <= entryText.length; i++) { - if (documentText.substr(-i) === entryText.substr(0, i)) { + if (documentText.substring(-i) === entryText.substring(0, i)) { triggerOffset = i; } } diff --git a/packages/lexical/src/LexicalUtils.ts b/packages/lexical/src/LexicalUtils.ts index 695d45d05c2..d61cb0587e7 100644 --- a/packages/lexical/src/LexicalUtils.ts +++ b/packages/lexical/src/LexicalUtils.ts @@ -649,7 +649,7 @@ export function createUID(): string { return Math.random() .toString(36) .replace(/[^a-z]+/g, '') - .substr(0, 5); + .substring(0, 5); } export function getAnchorTextFromDOM(anchorNode: Node): null | string { From 35c2a15892a2bb879c682f243429dd3ec5e5dd5a Mon Sep 17 00:00:00 2001 From: Ivaylo Pavlov Date: Mon, 17 Feb 2025 23:32:25 +0000 Subject: [PATCH 2/2] Update LexicalMenu.ts --- packages/lexical-react/src/shared/LexicalMenu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexical-react/src/shared/LexicalMenu.ts b/packages/lexical-react/src/shared/LexicalMenu.ts index 2104ea63c48..7c97a5ad6f9 100644 --- a/packages/lexical-react/src/shared/LexicalMenu.ts +++ b/packages/lexical-react/src/shared/LexicalMenu.ts @@ -111,7 +111,7 @@ function getFullMatchOffset( ): number { let triggerOffset = offset; for (let i = triggerOffset; i <= entryText.length; i++) { - if (documentText.substring(-i) === entryText.substring(0, i)) { + if (documentText.slice(-i) === entryText.substring(0, i)) { triggerOffset = i; } }