@blocknote/xl-ai 0.42.3 → 0.43.0
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/blocknote-xl-ai.cjs +34 -5
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +25678 -1443
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -6
- package/src/AIExtension.ts +366 -409
- package/src/api/formats/json/tools/jsontools.test.ts +2 -2
- package/src/api/formats/tests/sharedTestCases.ts +2 -2
- package/src/components/AIMenu/AIMenu.tsx +17 -8
- package/src/components/AIMenu/AIMenuController.tsx +83 -29
- package/src/components/AIMenu/PromptSuggestionMenu.tsx +4 -2
- package/src/components/AIMenu/getDefaultAIMenuItems.tsx +17 -5
- package/src/components/FormattingToolbar/AIToolbarButton.tsx +8 -4
- package/src/components/SuggestionMenu/getAISlashMenuItems.tsx +5 -2
- package/src/index.ts +0 -1
- package/src/prosemirror/agent.test.ts +2 -2
- package/src/testUtil/cases/editors/blockFormatting.ts +2 -2
- package/src/testUtil/cases/editors/emptyEditor.ts +2 -2
- package/src/testUtil/cases/editors/formattingAndMentions.ts +2 -2
- package/src/testUtil/cases/editors/simpleEditor.ts +3 -3
- package/src/testUtil/cases/editors/tables.ts +2 -2
- package/src/testUtil/cases/updateOperationTestCases.ts +4 -4
- package/types/src/AIExtension.d.ts +34 -49
- package/types/src/components/AIMenu/AIMenuController.d.ts +2 -0
- package/types/src/index.d.ts +0 -1
- package/src/components/AIMenu/BlockPositioner.tsx +0 -86
- package/types/src/components/AIMenu/BlockPositioner.d.ts +0 -10
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { useUIElementPositioning } from "@blocknote/react";
|
|
2
|
-
import {
|
|
3
|
-
OpenChangeReason,
|
|
4
|
-
UseDismissProps,
|
|
5
|
-
UseFloatingOptions,
|
|
6
|
-
autoUpdate,
|
|
7
|
-
offset,
|
|
8
|
-
size,
|
|
9
|
-
} from "@floating-ui/react";
|
|
10
|
-
import { useMemo } from "react";
|
|
11
|
-
// The block positioner automattically positions it's children below the block with `blockID`
|
|
12
|
-
export const BlockPositioner = (props: {
|
|
13
|
-
blockID?: string;
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
onOpenChange?: (
|
|
16
|
-
open: boolean,
|
|
17
|
-
event: Event,
|
|
18
|
-
reason: OpenChangeReason,
|
|
19
|
-
) => void;
|
|
20
|
-
canDismissViaOutsidePress?: boolean;
|
|
21
|
-
floatingOptions?: Partial<
|
|
22
|
-
UseFloatingOptions & { canDismiss: boolean | UseDismissProps }
|
|
23
|
-
>;
|
|
24
|
-
}) => {
|
|
25
|
-
const element = props.blockID
|
|
26
|
-
? document.querySelector(`[data-id="${props.blockID}"]`)
|
|
27
|
-
: undefined;
|
|
28
|
-
|
|
29
|
-
// Note that we can't pass element directly, because the useDismiss then doesn't work when clicking on the element
|
|
30
|
-
// (for that to work, we'd need to implement getReferenceProps(), but it's probably unsafe to attach those listeners to a prosemirror managed element)
|
|
31
|
-
const reference = useMemo(() => {
|
|
32
|
-
return element
|
|
33
|
-
? {
|
|
34
|
-
getBoundingClientRect: () => {
|
|
35
|
-
return element.getBoundingClientRect();
|
|
36
|
-
},
|
|
37
|
-
contextElement: element,
|
|
38
|
-
}
|
|
39
|
-
: null;
|
|
40
|
-
}, [element]);
|
|
41
|
-
|
|
42
|
-
const { isMounted, ref, style, getFloatingProps, isPositioned } =
|
|
43
|
-
useUIElementPositioning(element ? true : false, reference, 3000, {
|
|
44
|
-
canDismiss: {
|
|
45
|
-
enabled: true,
|
|
46
|
-
escapeKey: true,
|
|
47
|
-
outsidePress: props.canDismissViaOutsidePress,
|
|
48
|
-
},
|
|
49
|
-
placement: "bottom",
|
|
50
|
-
middleware: [
|
|
51
|
-
offset(10),
|
|
52
|
-
// flip(),
|
|
53
|
-
size({
|
|
54
|
-
apply({ rects, elements }) {
|
|
55
|
-
Object.assign(elements.floating.style, {
|
|
56
|
-
width: `${rects.reference.width}px`,
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
],
|
|
61
|
-
onOpenChange: props.onOpenChange,
|
|
62
|
-
whileElementsMounted: (referenceEl, floatingEl, update) => {
|
|
63
|
-
const cleanup = autoUpdate(referenceEl, floatingEl, update, {
|
|
64
|
-
animationFrame: true,
|
|
65
|
-
});
|
|
66
|
-
return cleanup;
|
|
67
|
-
},
|
|
68
|
-
...props.floatingOptions,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (!isMounted) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<div
|
|
77
|
-
ref={ref}
|
|
78
|
-
style={{
|
|
79
|
-
...style,
|
|
80
|
-
}}
|
|
81
|
-
{...getFloatingProps()}
|
|
82
|
-
>
|
|
83
|
-
{isPositioned && props.children}
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
86
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { OpenChangeReason, UseDismissProps, UseFloatingOptions } from "@floating-ui/react";
|
|
2
|
-
export declare const BlockPositioner: (props: {
|
|
3
|
-
blockID?: string;
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
onOpenChange?: (open: boolean, event: Event, reason: OpenChangeReason) => void;
|
|
6
|
-
canDismissViaOutsidePress?: boolean;
|
|
7
|
-
floatingOptions?: Partial<UseFloatingOptions & {
|
|
8
|
-
canDismiss: boolean | UseDismissProps;
|
|
9
|
-
}>;
|
|
10
|
-
}) => import("react/jsx-runtime").JSX.Element | null;
|