@fluentui-copilot/chat-input-plugins 0.0.0-nightly-20240410-0405-8d7a6b79.1
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/CHANGELOG.json +26 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE +23 -0
- package/README.md +5 -0
- package/dist/index.d.ts +141 -0
- package/lib/BasicFunctionality/BasicFunctionality.base.js +78 -0
- package/lib/BasicFunctionality/BasicFunctionality.base.js.map +1 -0
- package/lib/BasicFunctionality/index.js +2 -0
- package/lib/BasicFunctionality/index.js.map +1 -0
- package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js +122 -0
- package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -0
- package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js +2 -0
- package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js.map +1 -0
- package/lib/ChatInputEntity/index.js +3 -0
- package/lib/ChatInputEntity/index.js.map +1 -0
- package/lib/GhostText/GhostText.base.js +112 -0
- package/lib/GhostText/GhostText.base.js.map +1 -0
- package/lib/GhostText/index.js +2 -0
- package/lib/GhostText/index.js.map +1 -0
- package/lib/ImperativeControl/ImperativeControl.base.js +51 -0
- package/lib/ImperativeControl/ImperativeControl.base.js.map +1 -0
- package/lib/ImperativeControl/index.js +2 -0
- package/lib/ImperativeControl/index.js.map +1 -0
- package/lib/ManualGhostText/ManualGhostText.base.js +73 -0
- package/lib/ManualGhostText/ManualGhostText.base.js.map +1 -0
- package/lib/ManualGhostText/index.js +2 -0
- package/lib/ManualGhostText/index.js.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +88 -0
- package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +1 -0
- package/lib-commonjs/BasicFunctionality/index.js +7 -0
- package/lib-commonjs/BasicFunctionality/index.js.map +1 -0
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js +127 -0
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -0
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js +5 -0
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js.map +1 -0
- package/lib-commonjs/ChatInputEntity/index.js +8 -0
- package/lib-commonjs/ChatInputEntity/index.js.map +1 -0
- package/lib-commonjs/GhostText/GhostText.base.js +119 -0
- package/lib-commonjs/GhostText/GhostText.base.js.map +1 -0
- package/lib-commonjs/GhostText/index.js +7 -0
- package/lib-commonjs/GhostText/index.js.map +1 -0
- package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +60 -0
- package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +1 -0
- package/lib-commonjs/ImperativeControl/index.js +7 -0
- package/lib-commonjs/ImperativeControl/index.js.map +1 -0
- package/lib-commonjs/ManualGhostText/ManualGhostText.base.js +84 -0
- package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +1 -0
- package/lib-commonjs/ManualGhostText/index.js +7 -0
- package/lib-commonjs/ManualGhostText/index.js.map +1 -0
- package/lib-commonjs/index.js +33 -0
- package/lib-commonjs/index.js.map +1 -0
- package/package.json +28 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluentui-copilot/chat-input-plugins",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Wed, 10 Apr 2024 04:10:39 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-20240410-0405-8d7a6b79.1",
|
|
7
|
+
"version": "0.0.0-nightly-20240410-0405-8d7a6b79.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "fluentui-internal@service.microsoft.com",
|
|
12
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
13
|
+
"commit": "not available",
|
|
14
|
+
"comment": "Release nightly"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
19
|
+
"comment": "Bump @fluentui-copilot/text-editor to v0.0.0-nightly-20240410-0405-8d7a6b79.1",
|
|
20
|
+
"commit": "3f79f89e6290755f808ad6fbd047d049b9ada38c"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Change Log - @fluentui-copilot/chat-input-plugins
|
|
2
|
+
|
|
3
|
+
This log was last generated on Wed, 10 Apr 2024 04:10:39 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## [0.0.0-nightly-20240410-0405-8d7a6b79.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-20240410-0405-8d7a6b79.1)
|
|
8
|
+
|
|
9
|
+
Wed, 10 Apr 2024 04:10:39 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- Release nightly ([commit](https://github.com/microsoft/fluentai/commit/not available) by fluentui-internal@service.microsoft.com)
|
|
14
|
+
- Bump @fluentui-copilot/text-editor to v0.0.0-nightly-20240410-0405-8d7a6b79.1 ([commit](https://github.com/microsoft/fluentai/commit/3f79f89e6290755f808ad6fbd047d049b9ada38c) by beachball)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@fluentui-copilot/chat-input-plugins
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) Microsoft Corporation.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { EditorState } from 'lexical';
|
|
2
|
+
import { Klass } from 'lexical';
|
|
3
|
+
import { LexicalEditor } from 'lexical';
|
|
4
|
+
import { LexicalNode } from 'lexical';
|
|
5
|
+
import { NodeKey } from 'lexical';
|
|
6
|
+
|
|
7
|
+
export declare class BasicFunctionalityBase implements IBasicFunctionalityBase {
|
|
8
|
+
private __editor;
|
|
9
|
+
private __contentChangeCleanup?;
|
|
10
|
+
private __trimWhitespaceCleanup?;
|
|
11
|
+
private __enterHandlerCleanup?;
|
|
12
|
+
private __enterHandler;
|
|
13
|
+
constructor(editor: LexicalEditor);
|
|
14
|
+
insertDefaultValue(defaultValue: string): void;
|
|
15
|
+
activateContentCallbacks(onContentChange?: ((value: string) => void) | undefined, onCountChanged?: ((count: number) => void) | undefined): void;
|
|
16
|
+
deactivateContentCallbacks(): void;
|
|
17
|
+
activateTrimWhitespace(): void;
|
|
18
|
+
deactivateTrimWhitespace(): void;
|
|
19
|
+
setIsDisabled(isDisabled: boolean): void;
|
|
20
|
+
cleanup(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare type ChatInputEntityData<ExtraDataType, NodePropsType> = {
|
|
24
|
+
text: string;
|
|
25
|
+
entityProps?: NodePropsType;
|
|
26
|
+
data?: ExtraDataType;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export declare class ChatInputEntityPluginBase<ExtraDataType, NodePropsType, NodeType extends IEntityNode<ExtraDataType, NodePropsType>> implements IChatInputEntityPluginBase<ExtraDataType, NodePropsType> {
|
|
30
|
+
private __nodeClass;
|
|
31
|
+
private __editor;
|
|
32
|
+
private __id;
|
|
33
|
+
private __deleteDirection;
|
|
34
|
+
private __$createNode;
|
|
35
|
+
private _cleanup;
|
|
36
|
+
cleanup(): void;
|
|
37
|
+
constructor(editor: LexicalEditor, id: string, nodeClass: Klass<NodeType>, $createNode: (pluginId: string, text: string, data?: ExtraDataType, entityProps?: NodePropsType, key?: NodeKey) => NodeType, $isChatInputEntityNode: (node: LexicalNode | null) => node is NodeType, onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void, onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void);
|
|
38
|
+
insertChatInputEntity(props: ChatInputEntityData<ExtraDataType, NodePropsType>): string | undefined;
|
|
39
|
+
removeChatInputEntity(keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean)): void;
|
|
40
|
+
updateChatInputEntityProps(keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean), props: ChatInputEntityData<ExtraDataType, NodePropsType> | ((oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>) => ChatInputEntityData<ExtraDataType, NodePropsType>)): void;
|
|
41
|
+
getActiveEntities(): ChatInputEntityData<ExtraDataType, NodePropsType>[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare type ChatInputEntityPluginProps<ExtraDataType, NodePropsType> = {
|
|
45
|
+
id: string;
|
|
46
|
+
onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;
|
|
47
|
+
onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export declare type GetGhostTextFunction = (editor: LexicalEditor, editorState: EditorState, prevEditorState: EditorState) => Promise<string | undefined>;
|
|
51
|
+
|
|
52
|
+
export declare class GhostTextPluginBase<ComponentPropsType> {
|
|
53
|
+
private __id;
|
|
54
|
+
private __$getGhostText;
|
|
55
|
+
private __componentProps?;
|
|
56
|
+
private __exposeText?;
|
|
57
|
+
private __allowCompletion?;
|
|
58
|
+
private __cleanup?;
|
|
59
|
+
cleanup(): void;
|
|
60
|
+
constructor(editor: LexicalEditor, id: string, $getGhostText: GetGhostTextFunction, nodeClass: Klass<IGhostTextNode<ComponentPropsType>>, createNode: (id: string, content: string, exposeText?: boolean, componentProps?: ComponentPropsType) => IGhostTextNode<ComponentPropsType>, componentProps?: ComponentPropsType, exposeText?: boolean, allowCompletion?: boolean);
|
|
61
|
+
setExposeText(exposeText?: boolean): void;
|
|
62
|
+
setComponentProps(componentProps?: ComponentPropsType): void;
|
|
63
|
+
setGetGhostText($getGhostText: GetGhostTextFunction): void;
|
|
64
|
+
setAllowCompletion(allowCompletion?: boolean): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export declare interface IBasicFunctionalityBase {
|
|
68
|
+
insertDefaultValue: (defaultValue: string) => void;
|
|
69
|
+
setIsDisabled: (isDisabled: boolean) => void;
|
|
70
|
+
activateContentCallbacks(onContentChange?: (value: string) => void, onCountChanged?: (count: number) => void): void;
|
|
71
|
+
deactivateContentCallbacks(): void;
|
|
72
|
+
activateTrimWhitespace(): void;
|
|
73
|
+
deactivateTrimWhitespace(): void;
|
|
74
|
+
cleanup(): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare interface IChatInputEntityPluginBase<ExtraDataType, NodePropsType> {
|
|
78
|
+
insertChatInputEntity: (props: ChatInputEntityData<ExtraDataType, NodePropsType>) => string | undefined;
|
|
79
|
+
removeChatInputEntity: (keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean)) => void;
|
|
80
|
+
updateChatInputEntityProps: (keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean), props: ChatInputEntityData<ExtraDataType, NodePropsType> | ((oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>) => ChatInputEntityData<ExtraDataType, NodePropsType>)) => void;
|
|
81
|
+
getActiveEntities: () => ChatInputEntityData<ExtraDataType, NodePropsType>[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A lexical node representing an entity should conform to this interface
|
|
86
|
+
*/
|
|
87
|
+
export declare interface IEntityNode<ExtraDataType, NodePropsType> extends LexicalNode {
|
|
88
|
+
getEntityData: () => ChatInputEntityData<ExtraDataType, NodePropsType>;
|
|
89
|
+
updateEntityData: (data: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;
|
|
90
|
+
__pluginId: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export declare interface IGhostTextNode<ComponentPropsType> extends LexicalNode {
|
|
94
|
+
__content: string;
|
|
95
|
+
__id: string;
|
|
96
|
+
__allowCommitting?: boolean;
|
|
97
|
+
__componentProps?: ComponentPropsType;
|
|
98
|
+
__exposeText?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export declare interface IImperativeControlBase {
|
|
102
|
+
setInputText: (inputText: string) => void;
|
|
103
|
+
appendText: (text: string) => void;
|
|
104
|
+
prependText: (text: string) => void;
|
|
105
|
+
insertTextAtCursor: (text: string) => void;
|
|
106
|
+
getInputText: () => string;
|
|
107
|
+
scrollToBottom: () => void;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare interface IManualGhostTextBase<ComponentPropsType> {
|
|
111
|
+
getGhostText: () => string | undefined;
|
|
112
|
+
setGhostText: (text: string, componentProps?: ComponentPropsType) => void;
|
|
113
|
+
commitGhostText: (finalText: string) => void;
|
|
114
|
+
cancelGhostText: () => void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare class ImperativeControlBase implements IImperativeControlBase {
|
|
118
|
+
private __editor;
|
|
119
|
+
constructor(editor: LexicalEditor);
|
|
120
|
+
setInputText(inputText: string): void;
|
|
121
|
+
appendText(text: string): void;
|
|
122
|
+
prependText(text: string): void;
|
|
123
|
+
insertTextAtCursor(text: string): void;
|
|
124
|
+
getInputText(): string;
|
|
125
|
+
scrollToBottom(): void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare class ManualGhostTextBase<ComponentPropsType> {
|
|
129
|
+
private __editor;
|
|
130
|
+
private __nodeKey?;
|
|
131
|
+
private __id;
|
|
132
|
+
private __$isNodeType;
|
|
133
|
+
private __$createNode;
|
|
134
|
+
constructor(editor: LexicalEditor, id: string, $isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>, $createNode: (id: string, content: string, exposeText?: boolean, componentProps?: ComponentPropsType) => IGhostTextNode<ComponentPropsType>);
|
|
135
|
+
getGhostText(): string | undefined;
|
|
136
|
+
setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType): void;
|
|
137
|
+
commitGhostText(finalText: string): void;
|
|
138
|
+
cancelGhostText(): void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { }
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import { $createTextNode, $getRoot, $getSelection, $insertNodes, $isRangeSelection, COMMAND_PRIORITY_CRITICAL, INSERT_PARAGRAPH_COMMAND, KEY_ENTER_COMMAND } from '@fluentui-copilot/text-editor';
|
|
3
|
+
export class BasicFunctionalityBase {
|
|
4
|
+
__enterHandler(event) {
|
|
5
|
+
const selection = $getSelection();
|
|
6
|
+
if (!$isRangeSelection(selection)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (event === null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
if (event.shiftKey) {
|
|
14
|
+
return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);
|
|
15
|
+
}
|
|
16
|
+
// Mark event handled to override default behavior
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
insertDefaultValue(defaultValue) {
|
|
20
|
+
if (defaultValue) {
|
|
21
|
+
this.__editor.update(() => {
|
|
22
|
+
$insertNodes([$createTextNode(defaultValue)]);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
activateContentCallbacks(onContentChange, onCountChanged) {
|
|
27
|
+
this.deactivateContentCallbacks();
|
|
28
|
+
this.__contentChangeCleanup = this.__editor.registerTextContentListener(text => {
|
|
29
|
+
onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(text);
|
|
30
|
+
onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(text.length);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
deactivateContentCallbacks() {
|
|
34
|
+
var _this___contentChangeCleanup, _this;
|
|
35
|
+
(_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
|
|
36
|
+
this.__contentChangeCleanup = undefined;
|
|
37
|
+
}
|
|
38
|
+
activateTrimWhitespace() {
|
|
39
|
+
this.deactivateTrimWhitespace();
|
|
40
|
+
this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {
|
|
41
|
+
if (text.trim() === '') {
|
|
42
|
+
this.__editor.update(() => {
|
|
43
|
+
$getRoot().getAllTextNodes().forEach(node => {
|
|
44
|
+
node.remove();
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
// Don't allow undoing this action
|
|
48
|
+
{
|
|
49
|
+
tag: 'historic'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
deactivateTrimWhitespace() {
|
|
55
|
+
var _this___trimWhitespaceCleanup, _this;
|
|
56
|
+
(_this___trimWhitespaceCleanup = (_this = this).__trimWhitespaceCleanup) === null || _this___trimWhitespaceCleanup === void 0 ? void 0 : _this___trimWhitespaceCleanup.call(_this);
|
|
57
|
+
this.__trimWhitespaceCleanup = undefined;
|
|
58
|
+
}
|
|
59
|
+
setIsDisabled(isDisabled) {
|
|
60
|
+
this.__editor.setEditable(!isDisabled);
|
|
61
|
+
}
|
|
62
|
+
cleanup() {
|
|
63
|
+
var _this___enterHandlerCleanup, _this;
|
|
64
|
+
this.deactivateContentCallbacks();
|
|
65
|
+
this.deactivateTrimWhitespace();
|
|
66
|
+
(_this___enterHandlerCleanup = (_this = this).__enterHandlerCleanup) === null || _this___enterHandlerCleanup === void 0 ? void 0 : _this___enterHandlerCleanup.call(_this);
|
|
67
|
+
this.__enterHandlerCleanup = undefined;
|
|
68
|
+
}
|
|
69
|
+
constructor(editor) {
|
|
70
|
+
_define_property(this, "__editor", void 0);
|
|
71
|
+
_define_property(this, "__contentChangeCleanup", void 0);
|
|
72
|
+
_define_property(this, "__trimWhitespaceCleanup", void 0);
|
|
73
|
+
_define_property(this, "__enterHandlerCleanup", void 0);
|
|
74
|
+
this.__editor = editor;
|
|
75
|
+
this.__enterHandlerCleanup = this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler, COMMAND_PRIORITY_CRITICAL);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=BasicFunctionality.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["BasicFunctionality.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $insertNodes,\n $isRangeSelection,\n COMMAND_PRIORITY_CRITICAL,\n INSERT_PARAGRAPH_COMMAND,\n KEY_ENTER_COMMAND,\n} from '@fluentui-copilot/text-editor';\n\nexport interface IBasicFunctionalityBase {\n insertDefaultValue: (defaultValue: string) => void;\n setIsDisabled: (isDisabled: boolean) => void;\n activateContentCallbacks(onContentChange?: (value: string) => void, onCountChanged?: (count: number) => void): void;\n deactivateContentCallbacks(): void;\n activateTrimWhitespace(): void;\n deactivateTrimWhitespace(): void;\n cleanup(): void;\n}\n\nexport class BasicFunctionalityBase implements IBasicFunctionalityBase {\n private __editor: LexicalEditor;\n private __contentChangeCleanup?: () => void;\n private __trimWhitespaceCleanup?: () => void;\n private __enterHandlerCleanup?: () => void;\n\n private __enterHandler(event: KeyboardEvent) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection)) {\n return false;\n }\n\n if (event === null) {\n return false;\n }\n\n event.preventDefault();\n\n if (event.shiftKey) {\n return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);\n }\n\n // Mark event handled to override default behavior\n return true;\n }\n\n constructor(editor: LexicalEditor) {\n this.__editor = editor;\n\n this.__enterHandlerCleanup = this.__editor.registerCommand(\n KEY_ENTER_COMMAND,\n this.__enterHandler,\n COMMAND_PRIORITY_CRITICAL,\n );\n }\n\n insertDefaultValue(defaultValue: string) {\n if (defaultValue) {\n this.__editor.update(() => {\n $insertNodes([$createTextNode(defaultValue)]);\n });\n }\n }\n\n activateContentCallbacks(\n onContentChange?: ((value: string) => void) | undefined,\n onCountChanged?: ((count: number) => void) | undefined,\n ) {\n this.deactivateContentCallbacks();\n this.__contentChangeCleanup = this.__editor.registerTextContentListener(text => {\n onContentChange?.(text);\n onCountChanged?.(text.length);\n });\n }\n\n deactivateContentCallbacks() {\n this.__contentChangeCleanup?.();\n this.__contentChangeCleanup = undefined;\n }\n\n activateTrimWhitespace() {\n this.deactivateTrimWhitespace();\n this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {\n if (text.trim() === '') {\n this.__editor.update(\n () => {\n $getRoot()\n .getAllTextNodes()\n .forEach(node => {\n node.remove();\n });\n },\n // Don't allow undoing this action\n { tag: 'historic' },\n );\n }\n });\n }\n\n deactivateTrimWhitespace() {\n this.__trimWhitespaceCleanup?.();\n this.__trimWhitespaceCleanup = undefined;\n }\n\n setIsDisabled(isDisabled: boolean) {\n this.__editor.setEditable(!isDisabled);\n }\n\n cleanup() {\n this.deactivateContentCallbacks();\n this.deactivateTrimWhitespace();\n this.__enterHandlerCleanup?.();\n this.__enterHandlerCleanup = undefined;\n }\n}\n"],"names":["$createTextNode","$getRoot","$getSelection","$insertNodes","$isRangeSelection","COMMAND_PRIORITY_CRITICAL","INSERT_PARAGRAPH_COMMAND","KEY_ENTER_COMMAND","BasicFunctionalityBase","__enterHandler","event","selection","preventDefault","shiftKey","__editor","dispatchCommand","undefined","insertDefaultValue","defaultValue","update","activateContentCallbacks","onContentChange","onCountChanged","deactivateContentCallbacks","__contentChangeCleanup","registerTextContentListener","text","length","activateTrimWhitespace","deactivateTrimWhitespace","__trimWhitespaceCleanup","trim","getAllTextNodes","forEach","node","remove","tag","setIsDisabled","isDisabled","setEditable","cleanup","__enterHandlerCleanup","constructor","editor","registerCommand"],"mappings":";AACA,SACEA,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,yBAAyB,EACzBC,wBAAwB,EACxBC,iBAAiB,QACZ,gCAAgC;AAYvC,OAAO,MAAMC;IAMHC,eAAeC,KAAoB,EAAE;QAC3C,MAAMC,YAAYT;QAClB,IAAI,CAACE,kBAAkBO,YAAY;YACjC,OAAO;QACT;QAEA,IAAID,UAAU,MAAM;YAClB,O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,WAAW,CAAC,CAACD;IAC7B;IAEAE,UAAU;YAGR,6BAAA;QAFA,IAAI,CAACjB,0BAA0B;QAC/B,IAAI,CAACM,wBAAwB;SAC7B,8BAAA,CAAA,QAAA,IAAI,EAACY,qBAAqB,cAA1B,kDAAA,iCAAA;QACA,IAAI,CAACA,qBAAqB,GAAGzB;IAC/B;IAnEA0B,YAAYC,MAAqB,CAAE;QAzBnC,uBAAQ7B,YAAR,KAAA;QACA,uBAAQU,0BAAR,KAAA;QACA,uBAAQM,2BAAR,KAAA;QACA,uBAAQW,yBAAR,KAAA;QAuBE,IAAI,CAAC3B,QAAQ,GAAG6B;QAEhB,IAAI,CAACF,qBAAqB,GAAG,IAAI,CAAC3B,QAAQ,CAAC8B,eAAe,CACxDrC,mBACA,IAAI,CAACE,cAAc,EACnBJ;IAEJ;AA4DF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './BasicFunctionality.base';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import { $createParagraphNode, $createTextNode, $getNodeByKey, $getSelection, $insertNodes, $isDecoratorNode, $isRangeSelection, $isRootOrShadowRoot, $nodesOfType, $wrapNodeInElement, COMMAND_PRIORITY_CRITICAL, DELETE_CHARACTER_COMMAND, mergeRegister } from '@fluentui-copilot/text-editor';
|
|
3
|
+
export class ChatInputEntityPluginBase {
|
|
4
|
+
cleanup() {
|
|
5
|
+
this._cleanup();
|
|
6
|
+
}
|
|
7
|
+
insertChatInputEntity(props) {
|
|
8
|
+
let key = undefined;
|
|
9
|
+
this.__editor.update(() => {
|
|
10
|
+
const {
|
|
11
|
+
text,
|
|
12
|
+
data,
|
|
13
|
+
entityProps
|
|
14
|
+
} = props;
|
|
15
|
+
const entityNode = this.__$createNode(this.__id, text, data, entityProps);
|
|
16
|
+
$insertNodes([entityNode]);
|
|
17
|
+
entityNode.selectEnd();
|
|
18
|
+
if ($isRootOrShadowRoot(entityNode.getParentOrThrow())) {
|
|
19
|
+
$wrapNodeInElement(entityNode, $createParagraphNode).selectEnd();
|
|
20
|
+
}
|
|
21
|
+
key = entityNode.getKey();
|
|
22
|
+
});
|
|
23
|
+
return key;
|
|
24
|
+
}
|
|
25
|
+
removeChatInputEntity(keyOrPredicate) {
|
|
26
|
+
this.__editor.update(() => {
|
|
27
|
+
if (typeof keyOrPredicate === 'function') {
|
|
28
|
+
$nodesOfType(this.__nodeClass).filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i)).forEach(node => node.remove());
|
|
29
|
+
} else {
|
|
30
|
+
var _$getNodeByKey;
|
|
31
|
+
(_$getNodeByKey = $getNodeByKey(keyOrPredicate)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.remove();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
updateChatInputEntityProps(keyOrPredicate, props) {
|
|
36
|
+
const updateNode = node => {
|
|
37
|
+
const newProps = typeof props === 'function' ? props(node.getEntityData()) : props;
|
|
38
|
+
node.updateEntityData(newProps);
|
|
39
|
+
};
|
|
40
|
+
this.__editor.update(() => {
|
|
41
|
+
if (typeof keyOrPredicate === 'function') {
|
|
42
|
+
$nodesOfType(this.__nodeClass).filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i)).forEach(updateNode);
|
|
43
|
+
} else {
|
|
44
|
+
const node = $getNodeByKey(keyOrPredicate);
|
|
45
|
+
if (node) {
|
|
46
|
+
updateNode(node);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
tag: 'historic'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getActiveEntities() {
|
|
54
|
+
return this.__editor.getEditorState().read(() => $nodesOfType(this.__nodeClass).filter(node => node.__pluginId === this.__id).map(node => node.getEntityData()));
|
|
55
|
+
}
|
|
56
|
+
constructor(editor, id, nodeClass, $createNode, $isChatInputEntityNode, onChatInputEntityAdded, onChatInputEntityDeleted) {
|
|
57
|
+
_define_property(this, "__nodeClass", void 0);
|
|
58
|
+
_define_property(this, "__editor", void 0);
|
|
59
|
+
_define_property(this, "__id", void 0);
|
|
60
|
+
_define_property(this, "__deleteDirection", null);
|
|
61
|
+
_define_property(this, "__$createNode", void 0);
|
|
62
|
+
_define_property(this, "_cleanup", void 0);
|
|
63
|
+
this.__$createNode = $createNode;
|
|
64
|
+
this.__editor = editor;
|
|
65
|
+
this.__id = id;
|
|
66
|
+
this.__nodeClass = nodeClass;
|
|
67
|
+
this._cleanup = mergeRegister(
|
|
68
|
+
// Keep track of delete direction so we know where to put the selection after adding back a space
|
|
69
|
+
editor.registerCommand(DELETE_CHARACTER_COMMAND, isBackward => {
|
|
70
|
+
this.__deleteDirection = isBackward ? 'backward' : 'forward';
|
|
71
|
+
return false;
|
|
72
|
+
}, COMMAND_PRIORITY_CRITICAL),
|
|
73
|
+
// Always maintain a space before, after, and between entities in order for selection to work properly
|
|
74
|
+
editor.registerNodeTransform(this.__nodeClass, node => {
|
|
75
|
+
const nextSibling = node.getNextSibling();
|
|
76
|
+
if (!nextSibling || $isDecoratorNode(nextSibling)) {
|
|
77
|
+
const selection = $getSelection();
|
|
78
|
+
// If selection is between the two nodes, that means the user is trying to delete the space
|
|
79
|
+
// If they deleted to the left, we should move the cursor to the end of the entity
|
|
80
|
+
// If they delete to the right, we should move the cursor to the end of the newly added space
|
|
81
|
+
// This mimics changing the delete into a cursor move action
|
|
82
|
+
const shouldMoveSelection = selection && $isRangeSelection(selection) && selection.isCollapsed() && selection.anchor.offset === node.getIndexWithinParent() + 1;
|
|
83
|
+
const text = $createTextNode(' ');
|
|
84
|
+
node.insertAfter(text);
|
|
85
|
+
if (shouldMoveSelection) {
|
|
86
|
+
if (this.__deleteDirection === 'forward') {
|
|
87
|
+
text.selectEnd();
|
|
88
|
+
} else {
|
|
89
|
+
node.selectEnd();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// In the case the entity is the first node, we need a space before it.
|
|
94
|
+
if (!node.getPreviousSibling()) {
|
|
95
|
+
const text = $createTextNode(' ');
|
|
96
|
+
node.insertBefore(text);
|
|
97
|
+
}
|
|
98
|
+
}), onChatInputEntityAdded || onChatInputEntityDeleted ? editor.registerMutationListener(this.__nodeClass, (nodes, payload) => {
|
|
99
|
+
for (const [nodeKey, mutation] of nodes) {
|
|
100
|
+
if (onChatInputEntityDeleted && mutation === 'destroyed') {
|
|
101
|
+
payload.prevEditorState.read(() => {
|
|
102
|
+
const node = $getNodeByKey(nodeKey);
|
|
103
|
+
if ($isChatInputEntityNode(node) && node.__pluginId === id) {
|
|
104
|
+
onChatInputEntityDeleted(node.getEntityData());
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
} else if (onChatInputEntityAdded && mutation === 'created') {
|
|
108
|
+
editor.getEditorState().read(() => {
|
|
109
|
+
const node = $getNodeByKey(nodeKey);
|
|
110
|
+
if ($isChatInputEntityNode(node) && node.__pluginId === id) {
|
|
111
|
+
onChatInputEntityAdded(node.getEntityData());
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}) : noop);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function noop() {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=ChatInputEntityPlugin.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ChatInputEntityPlugin.base.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey, Klass } from '@fluentui-copilot/text-editor';\nimport {\n $createParagraphNode,\n $createTextNode,\n $getNodeByKey,\n $getSelection,\n $insertNodes,\n $isDecoratorNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $nodesOfType,\n $wrapNodeInElement,\n COMMAND_PRIORITY_CRITICAL,\n DELETE_CHARACTER_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData, IChatInputEntityPluginBase, IEntityNode } from './ChatInputEntityPlugin.types';\n\nexport class ChatInputEntityPluginBase<\n ExtraDataType,\n NodePropsType,\n NodeType extends IEntityNode<ExtraDataType, NodePropsType>,\n> implements IChatInputEntityPluginBase<ExtraDataType, NodePropsType>\n{\n private __nodeClass: Klass<NodeType>;\n private __editor: LexicalEditor;\n private __id: string;\n\n private __deleteDirection: 'forward' | 'backward' | null = null;\n private __$createNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => NodeType;\n\n private _cleanup: () => void;\n\n cleanup() {\n this._cleanup();\n }\n\n constructor(\n editor: LexicalEditor,\n id: string,\n nodeClass: Klass<NodeType>,\n $createNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => NodeType,\n $isChatInputEntityNode: (node: LexicalNode | null) => node is NodeType,\n onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void,\n onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void,\n ) {\n this.__$createNode = $createNode;\n this.__editor = editor;\n this.__id = id;\n this.__nodeClass = nodeClass;\n\n this._cleanup = mergeRegister(\n // Keep track of delete direction so we know where to put the selection after adding back a space\n editor.registerCommand(\n DELETE_CHARACTER_COMMAND,\n isBackward => {\n this.__deleteDirection = isBackward ? 'backward' : 'forward';\n return false;\n },\n COMMAND_PRIORITY_CRITICAL,\n ),\n // Always maintain a space before, after, and between entities in order for selection to work properly\n editor.registerNodeTransform(this.__nodeClass, node => {\n const nextSibling = node.getNextSibling();\n if (!nextSibling || $isDecoratorNode(nextSibling)) {\n const selection = $getSelection();\n\n // If selection is between the two nodes, that means the user is trying to delete the space\n // If they deleted to the left, we should move the cursor to the end of the entity\n // If they delete to the right, we should move the cursor to the end of the newly added space\n // This mimics changing the delete into a cursor move action\n const shouldMoveSelection =\n selection &&\n $isRangeSelection(selection) &&\n selection.isCollapsed() &&\n selection.anchor.offset === node.getIndexWithinParent() + 1;\n const text = $createTextNode(' ');\n node.insertAfter(text);\n if (shouldMoveSelection) {\n if (this.__deleteDirection === 'forward') {\n text.selectEnd();\n } else {\n node.selectEnd();\n }\n }\n }\n\n // In the case the entity is the first node, we need a space before it.\n if (!node.getPreviousSibling()) {\n const text = $createTextNode(' ');\n node.insertBefore(text);\n }\n }),\n onChatInputEntityAdded || onChatInputEntityDeleted\n ? editor.registerMutationListener(this.__nodeClass, (nodes, payload) => {\n for (const [nodeKey, mutation] of nodes) {\n if (onChatInputEntityDeleted && mutation === 'destroyed') {\n payload.prevEditorState.read(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isChatInputEntityNode(node) && node.__pluginId === id) {\n onChatInputEntityDeleted(node.getEntityData());\n }\n });\n } else if (onChatInputEntityAdded && mutation === 'created') {\n editor.getEditorState().read(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isChatInputEntityNode(node) && node.__pluginId === id) {\n onChatInputEntityAdded(node.getEntityData());\n }\n });\n }\n }\n })\n : noop,\n );\n }\n insertChatInputEntity(props: ChatInputEntityData<ExtraDataType, NodePropsType>): string | undefined {\n let key: string | undefined = undefined;\n this.__editor.update(() => {\n const { text, data, entityProps } = props;\n\n const entityNode = this.__$createNode(this.__id, text, data, entityProps);\n\n $insertNodes([entityNode]);\n entityNode.selectEnd();\n if ($isRootOrShadowRoot(entityNode.getParentOrThrow())) {\n $wrapNodeInElement(entityNode, $createParagraphNode).selectEnd();\n }\n\n key = entityNode.getKey();\n });\n\n return key;\n }\n removeChatInputEntity(\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n ) {\n this.__editor.update(() => {\n if (typeof keyOrPredicate === 'function') {\n $nodesOfType(this.__nodeClass)\n .filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i))\n .forEach(node => node.remove());\n } else {\n $getNodeByKey(keyOrPredicate)?.remove();\n }\n });\n }\n updateChatInputEntityProps(\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n props:\n | ChatInputEntityData<ExtraDataType, NodePropsType>\n | ((\n oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>,\n ) => ChatInputEntityData<ExtraDataType, NodePropsType>),\n ) {\n const updateNode = (node: NodeType) => {\n const newProps = typeof props === 'function' ? props(node.getEntityData()) : props;\n node.updateEntityData(newProps);\n };\n\n this.__editor.update(\n () => {\n if (typeof keyOrPredicate === 'function') {\n $nodesOfType(this.__nodeClass)\n .filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i))\n .forEach(updateNode);\n } else {\n const node = $getNodeByKey<NodeType>(keyOrPredicate);\n if (node) {\n updateNode(node);\n }\n }\n },\n { tag: 'historic' },\n );\n }\n\n getActiveEntities(): ChatInputEntityData<ExtraDataType, NodePropsType>[] {\n return this.__editor.getEditorState().read(() =>\n $nodesOfType(this.__nodeClass)\n .filter(node => node.__pluginId === this.__id)\n .map(node => node.getEntityData()),\n );\n }\n}\n\nfunction noop() {\n return;\n}\n"],"names":["$createParagraphNode","$createTextNode","$getNodeByKey","$getSelection","$insertNodes","$isDecoratorNode","$isRangeSelection","$isRootOrShadowRoot","$nodesOfType","$wrapNodeInElement","COMMAND_PRIORITY_CRITICAL","DELETE_CHARACTER_COMMAND","mergeRegister","ChatInputEntityPluginBase","cleanup","_cleanup","insertChatInputEntity","props","key","undefined","__editor","update","text","data","entityProps","entityNode","__$createNode","__id","selectEnd","getParentOrThrow","getKey","removeChatInputEntity","keyOrPredicate","__nodeClass","filter","node","i","__pluginId","getEntityData","forEach","remove","updateChatInputEntityProps","updateNode","newProps","updateEntityData","tag","getActiveEntities","getEditorState","read","map","constructor","editor","id","nodeClass","$createNode","$isChatInputEntityNode","onChatInputEntityAdded","onChatInputEntityDeleted","__deleteDirection","registerCommand","isBackward","registerNodeTransform","nextSibling","getNextSibling","selection","shouldMoveSelection","isCollapsed","anchor","offset","getIndexWithinParent","insertAfter","getPreviousSibling","insertBefore","registerMutationListener","nodes","payload","nodeKey","mutation","prevEditorState","noop"],"mappings":";AACA,SACEA,oBAAoB,EACpBC,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,wBAAwB,EACxBC,aAAa,QACR,gCAAgC;AAGvC,OAAO,MAAMC;IAqBXC,UAAU;QACR,IAAI,CAACC,QAAQ;IACf;IAuFAC,sBAAsBC,KAAwD,EAAsB;QAClG,IAAIC,MAA0BC;QAC9B,IAAI,CAACC,QAAQ,CAACC,MAAM,CAAC;YACnB,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGP;YAEpC,MAAMQ,aAAa,IAAI,CAACC,aAAa,CAAC,IAAI,CAACC,IAAI,EAAEL,MAAMC,MAAMC;YAE7DpB,aAAa;gBAACqB;aAAW;YACzBA,WAAWG,SAAS;YACpB,IAAIrB,oBAAoBkB,WAAWI,gBAAgB,KAAK;gBACtDpB,mBAAmBgB,YAAYzB,sBAAsB4B,SAAS;YAChE;YAEAV,MAAMO,WAAWK,MAAM;QACzB;QAEA,OAAOZ;IACT;IACAa,sBACEC,cAA4G,EAC5G;QACA,IAAI,CAACZ,QAAQ,CAACC,MAAM,CAAC;YACnB,IAAI,OAAOW,mBAAmB,YAAY;gBACxCxB,aAAa,IAAI,CAACyB,WAAW,EAC1BC,MAAM,CAAC,CAACC,MAAMC,IAAMD,KAAKE,UAAU,KAAK,IAAI,CAACV,IAAI,IAAIK,eAAeG,KAAKG,aAAa,IAAIF,IAC1FG,OAAO,CAACJ,CAAAA,OAAQA,KAAKK,MAAM;YAChC,OA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AAU,KAAKe,IAAI;4BAC1DK,yBAAyBtB,KAAKG,aAAa;wBAC7C;oBACF;gBACF,OAAO,IAAIkB,0BAA0BqB,aAAa,WAAW;oBAC3D1B,OAAOJ,cAAc,GAAGC,IAAI,CAAC;wBAC3B,MAAMb,OAAOjC,cAAc0E;wBAC3B,IAAIrB,uBAAuBpB,SAASA,KAAKE,UAAU,KAAKe,IAAI;4BAC1DI,uBAAuBrB,KAAKG,aAAa;wBAC3C;oBACF;gBACF;YACF;QACF,KACAyC;IAER;AAqEF;AAEA,SAASA;IACP;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ChatInputEntityPlugin.types.ts"],"sourcesContent":["import type { LexicalNode } from '@fluentui-copilot/text-editor';\n\nexport type ChatInputEntityData<ExtraDataType, NodePropsType> = {\n // Represents the string content of the entity that will returned inside the ChatInput's text content\n text: string;\n // Props to pass to the component rendered by the node\n // By default, `text` will be used as the entity's text content.\n // If entityProps contains information for rendering children, that will take priority\n entityProps?: NodePropsType;\n // Optional extra data that can be associated with the entity\n data?: ExtraDataType;\n};\n\nexport type ChatInputEntityPluginProps<ExtraDataType, NodePropsType> = {\n // An identifier for an instance of the ChatInputEntityPlugin\n // Only entities created by this instance of the plugin will be handled by it\n id: string;\n onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n};\n\n/**\n * A lexical node representing an entity should conform to this interface\n */\nexport interface IEntityNode<ExtraDataType, NodePropsType> extends LexicalNode {\n getEntityData: () => ChatInputEntityData<ExtraDataType, NodePropsType>;\n updateEntityData: (data: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n __pluginId: string;\n}\n\nexport interface IChatInputEntityPluginBase<ExtraDataType, NodePropsType> {\n // Inserts a new entity and returns its key, to be used by removeChatInputEntity or updateChatInputEntityProps\n insertChatInputEntity: (props: ChatInputEntityData<ExtraDataType, NodePropsType>) => string | undefined;\n // Removes an entity by its key, or removes all entities that match a predicate function\n removeChatInputEntity: (\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n ) => void;\n // Updates an entity by its key, or removes all entities that match a predicate function\n updateChatInputEntityProps: (\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n props:\n | ChatInputEntityData<ExtraDataType, NodePropsType>\n | ((\n oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>,\n ) => ChatInputEntityData<ExtraDataType, NodePropsType>),\n ) => void;\n getActiveEntities: () => ChatInputEntityData<ExtraDataType, NodePropsType>[];\n}\n"],"names":[],"mappings":"AAAA,WA+CC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ChatInputEntityPlugin.types';\nexport * from './ChatInputEntityPlugin.base';\n"],"names":[],"mappings":"AAAA,cAAc,gCAAgC;AAC9C,cAAc,+BAA+B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import { $createTextNode, $getNodeByKey, $getSelection, $setSelection, COMMAND_PRIORITY_LOW, KEY_TAB_COMMAND, mergeRegister } from '@fluentui-copilot/text-editor';
|
|
3
|
+
export class GhostTextPluginBase {
|
|
4
|
+
cleanup() {
|
|
5
|
+
var _this___cleanup, _this;
|
|
6
|
+
(_this___cleanup = (_this = this).__cleanup) === null || _this___cleanup === void 0 ? void 0 : _this___cleanup.call(_this);
|
|
7
|
+
}
|
|
8
|
+
setExposeText(exposeText) {
|
|
9
|
+
this.__exposeText = exposeText;
|
|
10
|
+
}
|
|
11
|
+
setComponentProps(componentProps) {
|
|
12
|
+
this.__componentProps = componentProps;
|
|
13
|
+
}
|
|
14
|
+
setGetGhostText($getGhostText) {
|
|
15
|
+
this.__$getGhostText = $getGhostText;
|
|
16
|
+
}
|
|
17
|
+
setAllowCompletion(allowCompletion) {
|
|
18
|
+
this.__allowCompletion = allowCompletion;
|
|
19
|
+
}
|
|
20
|
+
constructor(editor, id, $getGhostText, nodeClass, createNode, componentProps,
|
|
21
|
+
// Whether or not the ghost text should count as text inside the input for submitting and character count
|
|
22
|
+
exposeText, allowCompletion) {
|
|
23
|
+
_define_property(this, "__id", void 0);
|
|
24
|
+
_define_property(this, "__$getGhostText", void 0);
|
|
25
|
+
_define_property(this, "__componentProps", void 0);
|
|
26
|
+
_define_property(this, "__exposeText", void 0);
|
|
27
|
+
_define_property(this, "__allowCompletion", void 0);
|
|
28
|
+
_define_property(this, "__cleanup", void 0);
|
|
29
|
+
this.__id = id;
|
|
30
|
+
this.__$getGhostText = $getGhostText;
|
|
31
|
+
this.__componentProps = componentProps;
|
|
32
|
+
this.__exposeText = exposeText;
|
|
33
|
+
this.__allowCompletion = allowCompletion;
|
|
34
|
+
let ghostTextNodeKey = null;
|
|
35
|
+
let lastText = undefined;
|
|
36
|
+
function $clearGhostText() {
|
|
37
|
+
const ghostTextNode = ghostTextNodeKey !== null ? $getNodeByKey(ghostTextNodeKey) : null;
|
|
38
|
+
ghostTextNodeKey = null;
|
|
39
|
+
lastText = undefined;
|
|
40
|
+
if (ghostTextNode && ghostTextNode.isAttached()) {
|
|
41
|
+
ghostTextNode.remove();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function handleGhostTextNodeTransform(node) {
|
|
45
|
+
const key = node.getKey();
|
|
46
|
+
if (node.__id === id && key !== ghostTextNodeKey) {
|
|
47
|
+
// Only one ghost text
|
|
48
|
+
node.remove();
|
|
49
|
+
$clearGhostText();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const handleGhostTextResponse = text => {
|
|
53
|
+
if (text === lastText) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
editor.update(() => {
|
|
57
|
+
$clearGhostText();
|
|
58
|
+
const selection = $getSelection();
|
|
59
|
+
if (!text || !selection) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const selectionCopy = selection.clone();
|
|
63
|
+
const node = createNode(this.__id, text, this.__exposeText, this.__componentProps);
|
|
64
|
+
ghostTextNodeKey = node.getKey();
|
|
65
|
+
lastText = text;
|
|
66
|
+
selection.insertNodes([node]);
|
|
67
|
+
$setSelection(selectionCopy);
|
|
68
|
+
}, {
|
|
69
|
+
tag: 'historic'
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const handleUpdate = props => {
|
|
73
|
+
const {
|
|
74
|
+
editorState,
|
|
75
|
+
prevEditorState
|
|
76
|
+
} = props;
|
|
77
|
+
editorState.read(() => {
|
|
78
|
+
const promise = this.__$getGhostText(editor, editorState, prevEditorState);
|
|
79
|
+
promise.then(handleGhostTextResponse).catch(e => console.error(e));
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
function unmountGhostText() {
|
|
83
|
+
if (ghostTextNodeKey) {
|
|
84
|
+
editor.update(() => {
|
|
85
|
+
$clearGhostText();
|
|
86
|
+
}, {
|
|
87
|
+
tag: 'historic'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function $handleTabCommand(e) {
|
|
92
|
+
if (ghostTextNodeKey === null || lastText === null) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const ghostTextNode = $getNodeByKey(ghostTextNodeKey);
|
|
96
|
+
if (!ghostTextNode) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
const textNode = $createTextNode(lastText);
|
|
101
|
+
ghostTextNode.replace(textNode);
|
|
102
|
+
textNode.selectEnd();
|
|
103
|
+
$clearGhostText();
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
this.__cleanup = mergeRegister(editor.registerNodeTransform(nodeClass, handleGhostTextNodeTransform), editor.registerUpdateListener(handleUpdate), this.__allowCompletion ? editor.registerCommand(KEY_TAB_COMMAND, $handleTabCommand, COMMAND_PRIORITY_LOW) : noop, unmountGhostText);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function noop() {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=GhostText.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["GhostText.base.ts"],"sourcesContent":["import type { EditorState, Klass, LexicalEditor, LexicalNode, UpdateListener } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getNodeByKey,\n $getSelection,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n KEY_TAB_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\n\nexport type GetGhostTextFunction = (\n editor: LexicalEditor,\n editorState: EditorState,\n prevEditorState: EditorState,\n) => Promise<string | undefined>;\n\nexport interface IGhostTextNode<ComponentPropsType> extends LexicalNode {\n __content: string;\n __id: string;\n __allowCommitting?: boolean;\n __componentProps?: ComponentPropsType;\n __exposeText?: boolean;\n}\n\nexport class GhostTextPluginBase<ComponentPropsType> {\n private __id: string;\n private __$getGhostText: GetGhostTextFunction;\n private __componentProps?: ComponentPropsType;\n private __exposeText?: boolean;\n private __allowCompletion?: boolean;\n\n private __cleanup?: () => void;\n\n cleanup() {\n this.__cleanup?.();\n }\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $getGhostText: GetGhostTextFunction,\n nodeClass: Klass<IGhostTextNode<ComponentPropsType>>,\n createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n componentProps?: ComponentPropsType,\n // Whether or not the ghost text should count as text inside the input for submitting and character count\n exposeText?: boolean,\n allowCompletion?: boolean,\n ) {\n this.__id = id;\n this.__$getGhostText = $getGhostText;\n this.__componentProps = componentProps;\n this.__exposeText = exposeText;\n this.__allowCompletion = allowCompletion;\n\n let ghostTextNodeKey: string | null = null;\n let lastText: string | undefined = undefined;\n\n function $clearGhostText() {\n const ghostTextNode = ghostTextNodeKey !== null ? $getNodeByKey(ghostTextNodeKey) : null;\n ghostTextNodeKey = null;\n lastText = undefined;\n if (ghostTextNode && ghostTextNode.isAttached()) {\n ghostTextNode.remove();\n }\n }\n function handleGhostTextNodeTransform(node: IGhostTextNode<ComponentPropsType>) {\n const key = node.getKey();\n\n if (node.__id === id && key !== ghostTextNodeKey) {\n // Only one ghost text\n node.remove();\n $clearGhostText();\n }\n }\n\n const handleGhostTextResponse = (text?: string) => {\n if (text === lastText) {\n return;\n }\n\n editor.update(\n () => {\n $clearGhostText();\n\n const selection = $getSelection();\n if (!text || !selection) {\n return;\n }\n\n const selectionCopy = selection.clone();\n\n const node = createNode(this.__id, text, this.__exposeText, this.__componentProps);\n ghostTextNodeKey = node.getKey();\n lastText = text;\n\n selection.insertNodes([node]);\n $setSelection(selectionCopy);\n },\n { tag: 'historic' },\n );\n };\n\n const handleUpdate: UpdateListener = props => {\n const { editorState, prevEditorState } = props;\n editorState.read(() => {\n const promise = this.__$getGhostText(editor, editorState, prevEditorState);\n promise.then(handleGhostTextResponse).catch(e => console.error(e));\n });\n };\n\n function unmountGhostText() {\n if (ghostTextNodeKey) {\n editor.update(\n () => {\n $clearGhostText();\n },\n { tag: 'historic' },\n );\n }\n }\n\n function $handleTabCommand(e: KeyboardEvent) {\n if (ghostTextNodeKey === null || lastText === null) {\n return false;\n }\n\n const ghostTextNode = $getNodeByKey(ghostTextNodeKey);\n if (!ghostTextNode) {\n return false;\n }\n\n e.preventDefault();\n\n const textNode = $createTextNode(lastText);\n ghostTextNode.replace(textNode);\n textNode.selectEnd();\n $clearGhostText();\n return true;\n }\n\n this.__cleanup = mergeRegister(\n editor.registerNodeTransform(nodeClass, handleGhostTextNodeTransform),\n editor.registerUpdateListener(handleUpdate),\n this.__allowCompletion ? editor.registerCommand(KEY_TAB_COMMAND, $handleTabCommand, COMMAND_PRIORITY_LOW) : noop,\n unmountGhostText,\n );\n }\n\n setExposeText(exposeText?: boolean) {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType) {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction) {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean) {\n this.__allowCompletion = allowCompletion;\n }\n}\nfunction noop(): void {\n return;\n}\n"],"names":["$createTextNode","$getNodeByKey","$getSelection","$setSelection","COMMAND_PRIORITY_LOW","KEY_TAB_COMMAND","mergeRegister","GhostTextPluginBase","cleanup","__cleanup","setExposeText","exposeText","__exposeText","setComponentProps","componentProps","__componentProps","setGetGhostText","$getGhostText","__$getGhostText","setAllowCompletion","allowCompletion","__allowCompletion","constructor","editor","id","nodeClass","createNode","__id","ghostTextNodeKey","lastText","undefined","$clearGhostText","ghostTextNode","isAttached","remove","handleGhostTextNodeTransform","node","key","getKey","handleGhostTextResponse","text","update","selection","selectionCopy","clone","insertNodes","tag","handleUpdate","props","editorState","prevEditorState","read","promise","then","catch","e","console","error","unmountGhostText","$handleTabCommand","preventDefault","textNode","replace","selectEnd","registerNodeTransform","registerUpdateListener","registerCommand","noop"],"mappings":";AACA,SACEA,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,eAAe,EACfC,aAAa,QACR,gCAAgC;AAgBvC,OAAO,MAAMC;IASXC,UAAU;YACR,iBAAA;SAAA,kBAAA,CAAA,QAAA,IAAI,EAACC,SAAS,cAAd,sCAAA,qBAAA;IACF;IAsHAC,cAAcC,UAAoB,EAAE;QAClC,IAAI,CAACC,YAAY,GAAGD;IACtB;IAEAE,kBAAkBC,cAAmC,EAAE;QACrD,IAAI,CAACC,gBAAgB,GAAGD;IAC1B;IAEAE,gBAAgBC,aAAmC,EAAE;QACnD,IAAI,CAACC,eAAe,GAAGD;IACzB;IAEAE,mBAAmBC,eAAyB,EAAE;QAC5C,IAAI,CAACC,iBAAiB,GAAGD;IAC3B;IAlIAE,YACEC,MAAqB,EACr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AC;oBAACT;iBAAK;gBAC5BjC,cAAcwC;YAChB,GACA;gBAAEG,KAAK;YAAW;QAEtB;QAEA,MAAMC,eAA+BC,CAAAA;YACnC,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGF;YACzCC,YAAYE,IAAI,CAAC;gBACf,MAAMC,UAAU,IAAI,CAAClC,eAAe,CAACK,QAAQ0B,aAAaC;gBAC1DE,QAAQC,IAAI,CAACd,yBAAyBe,KAAK,CAACC,CAAAA,IAAKC,QAAQC,KAAK,CAACF;YACjE;QACF;QAEA,SAASG;YACP,IAAI9B,kBAAkB;gBACpBL,OAAOkB,MAAM,CACX;oBACEV;gBACF,GACA;oBAAEe,KAAK;gBAAW;YAEtB;QACF;QAEA,SAASa,kBAAkBJ,CAAgB;YACzC,IAAI3B,qBAAqB,QAAQC,aAAa,MAAM;gBAClD,OAAO;YACT;YAEA,MAAMG,gBAAgB/B,cAAc2B;YACpC,IAAI,CAACI,eAAe;gBAClB,OAAO;YACT;YAEAuB,EAAEK,cAAc;YAEhB,MAAMC,WAAW7D,gBAAgB6B;YACjCG,cAAc8B,OAAO,CAACD;YACtBA,SAASE,SAAS;YAClBhC;YACA,OAAO;QACT;QAEA,IAAI,CAACtB,SAAS,GAAGH,cACfiB,OAAOyC,qBAAqB,CAACvC,WAAWU,+BACxCZ,OAAO0C,sBAAsB,CAAClB,eAC9B,IAAI,CAAC1B,iBAAiB,GAAGE,OAAO2C,eAAe,CAAC7D,iBAAiBsD,mBAAmBvD,wBAAwB+D,MAC5GT;IAEJ;AAiBF;AACA,SAASS;IACP;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './GhostText.base';\n"],"names":[],"mappings":"AAAA,cAAc,mBAAmB"}
|