@rufous/ui 0.1.92 → 0.1.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.cjs +34 -10
- package/dist/main.js +35 -11
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -49678,6 +49678,12 @@ function createSpellCheckPlugin() {
|
|
|
49678
49678
|
let viewRef = null;
|
|
49679
49679
|
const runCheck = (view) => {
|
|
49680
49680
|
if (!typo || !view.dom?.isConnected) return;
|
|
49681
|
+
if (view.state.doc.content.size <= 2) {
|
|
49682
|
+
const tr2 = view.state.tr.setMeta(spellCheckPluginKey, { decorations: DecorationSet.empty });
|
|
49683
|
+
tr2.setMeta("addToHistory", false);
|
|
49684
|
+
view.dispatch(tr2);
|
|
49685
|
+
return;
|
|
49686
|
+
}
|
|
49681
49687
|
const { doc: doc3 } = view.state;
|
|
49682
49688
|
const misspelled = findMisspelled(doc3);
|
|
49683
49689
|
const decos = misspelled.map(
|
|
@@ -49702,10 +49708,17 @@ function createSpellCheckPlugin() {
|
|
|
49702
49708
|
init() {
|
|
49703
49709
|
return DecorationSet.empty;
|
|
49704
49710
|
},
|
|
49705
|
-
apply(tr, oldDecos) {
|
|
49711
|
+
apply(tr, oldDecos, _oldState, newState) {
|
|
49706
49712
|
const meta = tr.getMeta(spellCheckPluginKey);
|
|
49707
49713
|
if (meta?.decorations) return meta.decorations;
|
|
49708
|
-
if (tr.docChanged)
|
|
49714
|
+
if (tr.docChanged) {
|
|
49715
|
+
if (newState.doc.content.size <= 2) return DecorationSet.empty;
|
|
49716
|
+
try {
|
|
49717
|
+
return oldDecos.map(tr.mapping, tr.doc);
|
|
49718
|
+
} catch {
|
|
49719
|
+
return DecorationSet.empty;
|
|
49720
|
+
}
|
|
49721
|
+
}
|
|
49709
49722
|
return oldDecos;
|
|
49710
49723
|
}
|
|
49711
49724
|
},
|
|
@@ -49855,6 +49868,14 @@ var RufousTextEditor = ({
|
|
|
49855
49868
|
style
|
|
49856
49869
|
}) => {
|
|
49857
49870
|
const mentionSuggestion = (0, import_react60.useMemo)(() => createMentionSuggestion(mentions), [mentions]);
|
|
49871
|
+
const onChangeRef = (0, import_react60.useRef)(onChange);
|
|
49872
|
+
const onBlurRef = (0, import_react60.useRef)(onBlur);
|
|
49873
|
+
(0, import_react60.useEffect)(() => {
|
|
49874
|
+
onChangeRef.current = onChange;
|
|
49875
|
+
}, [onChange]);
|
|
49876
|
+
(0, import_react60.useEffect)(() => {
|
|
49877
|
+
onBlurRef.current = onBlur;
|
|
49878
|
+
}, [onBlur]);
|
|
49858
49879
|
const editor = (0, import_react61.useEditor)({
|
|
49859
49880
|
editable,
|
|
49860
49881
|
extensions: [
|
|
@@ -49944,16 +49965,19 @@ var RufousTextEditor = ({
|
|
|
49944
49965
|
},
|
|
49945
49966
|
content: initialContent || "",
|
|
49946
49967
|
onUpdate: ({ editor: e }) => {
|
|
49947
|
-
|
|
49948
|
-
onChange(e.getHTML(), e.getJSON());
|
|
49949
|
-
}
|
|
49950
|
-
},
|
|
49951
|
-
onBlur: ({ editor: e }) => {
|
|
49952
|
-
if (onBlur) {
|
|
49953
|
-
onBlur(e.getHTML(), e.getJSON());
|
|
49954
|
-
}
|
|
49968
|
+
onChangeRef.current?.(e.getHTML(), e.getJSON());
|
|
49955
49969
|
}
|
|
49956
49970
|
});
|
|
49971
|
+
(0, import_react60.useEffect)(() => {
|
|
49972
|
+
if (!editor) return;
|
|
49973
|
+
const handler = () => {
|
|
49974
|
+
onBlurRef.current?.(editor.getHTML(), editor.getJSON());
|
|
49975
|
+
};
|
|
49976
|
+
editor.on("blur", handler);
|
|
49977
|
+
return () => {
|
|
49978
|
+
editor.off("blur", handler);
|
|
49979
|
+
};
|
|
49980
|
+
}, [editor]);
|
|
49957
49981
|
const [linkModalOpen, setLinkModalOpen] = (0, import_react60.useState)(false);
|
|
49958
49982
|
const [linkUrl, setLinkUrl] = (0, import_react60.useState)("");
|
|
49959
49983
|
const [linkText, setLinkText] = (0, import_react60.useState)("");
|
package/dist/main.js
CHANGED
|
@@ -8721,7 +8721,7 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8721
8721
|
PhoneField.displayName = "PhoneField";
|
|
8722
8722
|
|
|
8723
8723
|
// lib/RufousTextEditor/RufousTextEditor.tsx
|
|
8724
|
-
import React117, { useMemo as useMemo4, useCallback as useCallback14, useState as useState35 } from "react";
|
|
8724
|
+
import React117, { useMemo as useMemo4, useCallback as useCallback14, useState as useState35, useRef as useRef31, useEffect as useEffect28 } from "react";
|
|
8725
8725
|
import { useEditor, EditorContent, EditorContext, FloatingMenu, BubbleMenu } from "@tiptap/react";
|
|
8726
8726
|
import StarterKit from "@tiptap/starter-kit";
|
|
8727
8727
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
@@ -21009,6 +21009,12 @@ function createSpellCheckPlugin() {
|
|
|
21009
21009
|
let viewRef = null;
|
|
21010
21010
|
const runCheck = (view) => {
|
|
21011
21011
|
if (!typo || !view.dom?.isConnected) return;
|
|
21012
|
+
if (view.state.doc.content.size <= 2) {
|
|
21013
|
+
const tr2 = view.state.tr.setMeta(spellCheckPluginKey, { decorations: DecorationSet.empty });
|
|
21014
|
+
tr2.setMeta("addToHistory", false);
|
|
21015
|
+
view.dispatch(tr2);
|
|
21016
|
+
return;
|
|
21017
|
+
}
|
|
21012
21018
|
const { doc: doc3 } = view.state;
|
|
21013
21019
|
const misspelled = findMisspelled(doc3);
|
|
21014
21020
|
const decos = misspelled.map(
|
|
@@ -21033,10 +21039,17 @@ function createSpellCheckPlugin() {
|
|
|
21033
21039
|
init() {
|
|
21034
21040
|
return DecorationSet.empty;
|
|
21035
21041
|
},
|
|
21036
|
-
apply(tr, oldDecos) {
|
|
21042
|
+
apply(tr, oldDecos, _oldState, newState) {
|
|
21037
21043
|
const meta = tr.getMeta(spellCheckPluginKey);
|
|
21038
21044
|
if (meta?.decorations) return meta.decorations;
|
|
21039
|
-
if (tr.docChanged)
|
|
21045
|
+
if (tr.docChanged) {
|
|
21046
|
+
if (newState.doc.content.size <= 2) return DecorationSet.empty;
|
|
21047
|
+
try {
|
|
21048
|
+
return oldDecos.map(tr.mapping, tr.doc);
|
|
21049
|
+
} catch {
|
|
21050
|
+
return DecorationSet.empty;
|
|
21051
|
+
}
|
|
21052
|
+
}
|
|
21040
21053
|
return oldDecos;
|
|
21041
21054
|
}
|
|
21042
21055
|
},
|
|
@@ -21186,6 +21199,14 @@ var RufousTextEditor = ({
|
|
|
21186
21199
|
style
|
|
21187
21200
|
}) => {
|
|
21188
21201
|
const mentionSuggestion = useMemo4(() => createMentionSuggestion(mentions), [mentions]);
|
|
21202
|
+
const onChangeRef = useRef31(onChange);
|
|
21203
|
+
const onBlurRef = useRef31(onBlur);
|
|
21204
|
+
useEffect28(() => {
|
|
21205
|
+
onChangeRef.current = onChange;
|
|
21206
|
+
}, [onChange]);
|
|
21207
|
+
useEffect28(() => {
|
|
21208
|
+
onBlurRef.current = onBlur;
|
|
21209
|
+
}, [onBlur]);
|
|
21189
21210
|
const editor = useEditor({
|
|
21190
21211
|
editable,
|
|
21191
21212
|
extensions: [
|
|
@@ -21275,16 +21296,19 @@ var RufousTextEditor = ({
|
|
|
21275
21296
|
},
|
|
21276
21297
|
content: initialContent || "",
|
|
21277
21298
|
onUpdate: ({ editor: e }) => {
|
|
21278
|
-
|
|
21279
|
-
onChange(e.getHTML(), e.getJSON());
|
|
21280
|
-
}
|
|
21281
|
-
},
|
|
21282
|
-
onBlur: ({ editor: e }) => {
|
|
21283
|
-
if (onBlur) {
|
|
21284
|
-
onBlur(e.getHTML(), e.getJSON());
|
|
21285
|
-
}
|
|
21299
|
+
onChangeRef.current?.(e.getHTML(), e.getJSON());
|
|
21286
21300
|
}
|
|
21287
21301
|
});
|
|
21302
|
+
useEffect28(() => {
|
|
21303
|
+
if (!editor) return;
|
|
21304
|
+
const handler = () => {
|
|
21305
|
+
onBlurRef.current?.(editor.getHTML(), editor.getJSON());
|
|
21306
|
+
};
|
|
21307
|
+
editor.on("blur", handler);
|
|
21308
|
+
return () => {
|
|
21309
|
+
editor.off("blur", handler);
|
|
21310
|
+
};
|
|
21311
|
+
}, [editor]);
|
|
21288
21312
|
const [linkModalOpen, setLinkModalOpen] = useState35(false);
|
|
21289
21313
|
const [linkUrl, setLinkUrl] = useState35("");
|
|
21290
21314
|
const [linkText, setLinkText] = useState35("");
|