CharacterCounter: Fix Bug

This commit is contained in:
thororen1234 2026-06-18 15:10:21 -04:00
parent 760dce8c9c
commit 563688e2b1
No known key found for this signature in database

View file

@ -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);