CharacterCounter: Fix Bug
This commit is contained in:
parent
760dce8c9c
commit
563688e2b1
1 changed files with 1 additions and 3 deletions
|
|
@ -11,11 +11,9 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import { classNameFactory } from "@utils/css";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { useEffect, UserStore, useState } from "@webpack/common";
|
||||
|
||||
const cl = classNameFactory("vc-charCounter-");
|
||||
const SlateUtils = findByPropsLazy("getSelectedText");
|
||||
|
||||
const settings = definePluginSettings({
|
||||
colorEffects: {
|
||||
|
|
@ -66,7 +64,7 @@ export default definePlugin({
|
|||
const listener = () => {
|
||||
if (!editorRef?.current) return setSelectedCount(0);
|
||||
|
||||
setTimeout(() => setSelectedCount(SlateUtils.getSelectedText(editorRef.current?.getSlateEditor())?.length ?? 0), 50);
|
||||
setSelectedCount(document.getSelection()?.toString()?.length ?? 0);
|
||||
};
|
||||
|
||||
document.addEventListener("selectionchange", listener);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue