@fluentui-copilot/chat-input-plugins 0.0.0-nightly-20251006-0406-b5da4f6a.1 → 0.0.0-nightly-20251010-0406-7df7c6d1.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 +3 -3
- package/CHANGELOG.md +4 -4
- package/package.json +2 -2
- package/dist/index.d.ts +0 -192
- package/lib/BasicFunctionality/BasicFunctionality.base.js +0 -107
- package/lib/BasicFunctionality/BasicFunctionality.base.js.map +0 -1
- package/lib/BasicFunctionality/SentinelNode.js +0 -41
- package/lib/BasicFunctionality/SentinelNode.js.map +0 -1
- package/lib/BasicFunctionality/SentinelNodeHandlers.js +0 -79
- package/lib/BasicFunctionality/SentinelNodeHandlers.js.map +0 -1
- package/lib/BasicFunctionality/index.js +0 -2
- package/lib/BasicFunctionality/index.js.map +0 -1
- package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js +0 -117
- package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js.map +0 -1
- package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js +0 -1
- package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js.map +0 -1
- package/lib/ChatInputEntity/index.js +0 -1
- package/lib/ChatInputEntity/index.js.map +0 -1
- package/lib/GhostText/GhostText.base.js +0 -158
- package/lib/GhostText/GhostText.base.js.map +0 -1
- package/lib/GhostText/index.js +0 -1
- package/lib/GhostText/index.js.map +0 -1
- package/lib/ImperativeControl/ImperativeControl.base.js +0 -87
- package/lib/ImperativeControl/ImperativeControl.base.js.map +0 -1
- package/lib/ImperativeControl/index.js +0 -1
- package/lib/ImperativeControl/index.js.map +0 -1
- package/lib/ManualGhostText/ManualGhostText.base.js +0 -78
- package/lib/ManualGhostText/ManualGhostText.base.js.map +0 -1
- package/lib/ManualGhostText/index.js +0 -1
- package/lib/ManualGhostText/index.js.map +0 -1
- package/lib/PasteUnfurling/PasteUnfurling.base.js +0 -60
- package/lib/PasteUnfurling/PasteUnfurling.base.js.map +0 -1
- package/lib/PasteUnfurling/PasteUnfurling.types.js +0 -1
- package/lib/PasteUnfurling/PasteUnfurling.types.js.map +0 -1
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +0 -162
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js.map +0 -1
- package/lib/PasteUnfurling/index.js +0 -1
- package/lib/PasteUnfurling/index.js.map +0 -1
- package/lib/index.js +0 -6
- package/lib/index.js.map +0 -1
- package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +0 -115
- package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +0 -1
- package/lib-commonjs/BasicFunctionality/SentinelNode.js +0 -61
- package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +0 -1
- package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js +0 -87
- package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js.map +0 -1
- package/lib-commonjs/BasicFunctionality/index.js +0 -29
- package/lib-commonjs/BasicFunctionality/index.js.map +0 -1
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js +0 -125
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +0 -1
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js +0 -4
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js.map +0 -1
- package/lib-commonjs/ChatInputEntity/index.js +0 -11
- package/lib-commonjs/ChatInputEntity/index.js.map +0 -1
- package/lib-commonjs/GhostText/GhostText.base.js +0 -167
- package/lib-commonjs/GhostText/GhostText.base.js.map +0 -1
- package/lib-commonjs/GhostText/index.js +0 -11
- package/lib-commonjs/GhostText/index.js.map +0 -1
- package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +0 -97
- package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +0 -1
- package/lib-commonjs/ImperativeControl/index.js +0 -11
- package/lib-commonjs/ImperativeControl/index.js.map +0 -1
- package/lib-commonjs/ManualGhostText/ManualGhostText.base.js +0 -88
- package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +0 -1
- package/lib-commonjs/ManualGhostText/index.js +0 -11
- package/lib-commonjs/ManualGhostText/index.js.map +0 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js +0 -70
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js.map +0 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js +0 -4
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js.map +0 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +0 -197
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +0 -1
- package/lib-commonjs/PasteUnfurling/index.js +0 -11
- package/lib-commonjs/PasteUnfurling/index.js.map +0 -1
- package/lib-commonjs/index.js +0 -48
- package/lib-commonjs/index.js.map +0 -1
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import { TextNode } from '@fluentui-copilot/text-editor';
|
|
3
|
-
export class MockClipboardEvent extends Event {
|
|
4
|
-
constructor(...args){
|
|
5
|
-
super(...args);
|
|
6
|
-
_define_property(this, "clipboardData", null);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export function createPasteEvent(data) {
|
|
10
|
-
const event = new MockClipboardEvent('paste');
|
|
11
|
-
event.clipboardData = {
|
|
12
|
-
types: [
|
|
13
|
-
data.map(({ mimeType })=>mimeType)
|
|
14
|
-
],
|
|
15
|
-
getData: (format)=>{
|
|
16
|
-
const item = data.find(({ mimeType })=>mimeType === format);
|
|
17
|
-
if (item) {
|
|
18
|
-
return item.value;
|
|
19
|
-
}
|
|
20
|
-
return '';
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
return event;
|
|
24
|
-
}
|
|
25
|
-
export class MockEntityNode extends TextNode {
|
|
26
|
-
static getType() {
|
|
27
|
-
return 'mockEntity';
|
|
28
|
-
}
|
|
29
|
-
constructor(text, url){
|
|
30
|
-
super(text);
|
|
31
|
-
_define_property(this, "url", void 0);
|
|
32
|
-
this.url = url;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export function $createMockEntityNode(text, url) {
|
|
36
|
-
return new MockEntityNode(text, url);
|
|
37
|
-
}
|
|
38
|
-
export function $isMockEntityNode(node) {
|
|
39
|
-
return node instanceof MockEntityNode;
|
|
40
|
-
}
|
|
41
|
-
export const parseLinkPreview = (event)=>{
|
|
42
|
-
let previewData;
|
|
43
|
-
try {
|
|
44
|
-
var _event_clipboardData;
|
|
45
|
-
const previewDataString = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/link-preview');
|
|
46
|
-
if (previewDataString === undefined || previewDataString === '') {
|
|
47
|
-
return {
|
|
48
|
-
handled: false
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
previewData = JSON.parse(previewDataString);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
return {
|
|
54
|
-
handled: false
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const title = previewData.title;
|
|
58
|
-
const url = previewData.url;
|
|
59
|
-
if (!title || !url) {
|
|
60
|
-
return {
|
|
61
|
-
handled: false
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
handled: true,
|
|
66
|
-
transformedParts: [
|
|
67
|
-
{
|
|
68
|
-
type: 'entity',
|
|
69
|
-
value: {
|
|
70
|
-
text: title,
|
|
71
|
-
data: {
|
|
72
|
-
url
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
const urlRegex = /(\b(?:https?):\/\/[^\s]+)/gi;
|
|
80
|
-
export const parseLink = (event)=>{
|
|
81
|
-
var _event_clipboardData;
|
|
82
|
-
const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
|
|
83
|
-
if (!text) {
|
|
84
|
-
return {
|
|
85
|
-
handled: false
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
const parts = text.split(urlRegex);
|
|
89
|
-
// If an entity was found, parts will be at least 3 elements long
|
|
90
|
-
if (parts.length < 3) {
|
|
91
|
-
return {
|
|
92
|
-
handled: false
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
const transformedParts = parts.map((str, i)=>{
|
|
96
|
-
if (i % 2 === 0) {
|
|
97
|
-
return {
|
|
98
|
-
type: 'text',
|
|
99
|
-
value: str
|
|
100
|
-
};
|
|
101
|
-
} else {
|
|
102
|
-
return {
|
|
103
|
-
type: 'entity',
|
|
104
|
-
value: {
|
|
105
|
-
text: str,
|
|
106
|
-
data: {
|
|
107
|
-
url: str
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
})// Filter out all the nulls for empty strings
|
|
113
|
-
.filter((node)=>node !== null);
|
|
114
|
-
return {
|
|
115
|
-
handled: true,
|
|
116
|
-
transformedParts
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
// A transform can be async in case it needs to fetch data from a server.
|
|
120
|
-
export const parseEntity = async (event)=>{
|
|
121
|
-
var _event_clipboardData;
|
|
122
|
-
const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
|
|
123
|
-
if (!text) {
|
|
124
|
-
return {
|
|
125
|
-
handled: false
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// Assume entities come in the syntax <entity>title</entity>
|
|
129
|
-
const re = /<entity[^>]*>([^<]*)<\/entity>/g;
|
|
130
|
-
const parts = text.split(re);
|
|
131
|
-
// If an entity was found, parts will be at least 3 elements long
|
|
132
|
-
if (parts.length < 3) {
|
|
133
|
-
return {
|
|
134
|
-
handled: false
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
// Even elements are text, odd elements are entities
|
|
138
|
-
// ["", entity, "", entity, "", ...]
|
|
139
|
-
const transformedParts = parts.map((str, i)=>{
|
|
140
|
-
if (i % 2 === 0) {
|
|
141
|
-
return {
|
|
142
|
-
type: 'text',
|
|
143
|
-
value: str
|
|
144
|
-
};
|
|
145
|
-
} else {
|
|
146
|
-
return {
|
|
147
|
-
type: 'entity',
|
|
148
|
-
value: {
|
|
149
|
-
text: str,
|
|
150
|
-
data: {
|
|
151
|
-
url: str
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
})// Filter out all the nulls for empty strings
|
|
157
|
-
.filter((node)=>node !== null);
|
|
158
|
-
return {
|
|
159
|
-
handled: true,
|
|
160
|
-
transformedParts
|
|
161
|
-
};
|
|
162
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["PasteUnfurlingTestUtils.ts"],"sourcesContent":["import type { LexicalNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingTransformedPart, PasteUnfurlingTransformResult } from '..';\n\nexport class MockClipboardEvent extends Event implements ClipboardEvent {\n clipboardData: DataTransfer | null = null;\n}\n\nexport function createPasteEvent(data: { mimeType: string; value: string }[]) {\n const event = new MockClipboardEvent('paste');\n\n event.clipboardData = {\n types: [data.map(({ mimeType }) => mimeType)],\n getData: (format: string) => {\n const item = data.find(({ mimeType }) => mimeType === format);\n if (item) {\n return item.value;\n }\n return '';\n },\n } as unknown as DataTransfer;\n\n return event;\n}\n\nexport class MockEntityNode extends TextNode {\n url: string;\n\n constructor(text: string, url: string) {\n super(text);\n this.url = url;\n }\n\n static getType(): string {\n return 'mockEntity';\n }\n}\n\nexport type ExtraDataType = { url: string };\n\nexport function $createMockEntityNode(text: string, url: string): MockEntityNode {\n return new MockEntityNode(text, url);\n}\n\nexport function $isMockEntityNode(node: LexicalNode | null | undefined): node is MockEntityNode {\n return node instanceof MockEntityNode;\n}\n\nexport const parseLinkPreview = (event: ClipboardEvent): PasteUnfurlingTransformResult<ExtraDataType, {}> => {\n let previewData;\n try {\n const previewDataString = event.clipboardData?.getData('text/link-preview');\n if (previewDataString === undefined || previewDataString === '') {\n return { handled: false };\n }\n\n previewData = JSON.parse(previewDataString);\n } catch (e) {\n return { handled: false };\n }\n\n const title: string | undefined = previewData.title;\n const url: string | undefined = previewData.url;\n if (!title || !url) {\n return { handled: false };\n }\n\n return {\n handled: true,\n transformedParts: [{ type: 'entity', value: { text: title, data: { url } } }],\n };\n};\nconst urlRegex = /(\\b(?:https?):\\/\\/[^\\s]+)/gi;\n\nexport const parseLink = (event: ClipboardEvent): PasteUnfurlingTransformResult<ExtraDataType, {}> => {\n const text = event.clipboardData?.getData('text/plain');\n if (!text) {\n return {\n handled: false,\n };\n }\n\n const parts = text.split(urlRegex);\n // If an entity was found, parts will be at least 3 elements long\n if (parts.length < 3) {\n return { handled: false };\n }\n const transformedParts = parts\n .map((str, i) => {\n if (i % 2 === 0) {\n return { type: 'text', value: str };\n } else {\n return {\n type: 'entity',\n value: { text: str, data: { url: str } },\n };\n }\n })\n // Filter out all the nulls for empty strings\n .filter(node => node !== null) as PasteUnfurlingTransformedPart<ExtraDataType, {}>[];\n\n return { handled: true, transformedParts };\n};\n\n// A transform can be async in case it needs to fetch data from a server.\nexport const parseEntity = async (event: ClipboardEvent): Promise<PasteUnfurlingTransformResult<ExtraDataType, {}>> => {\n const text = event.clipboardData?.getData('text/plain');\n if (!text) {\n return {\n handled: false,\n };\n }\n\n // Assume entities come in the syntax <entity>title</entity>\n const re = /<entity[^>]*>([^<]*)<\\/entity>/g;\n const parts = text.split(re);\n // If an entity was found, parts will be at least 3 elements long\n if (parts.length < 3) {\n return { handled: false };\n }\n\n // Even elements are text, odd elements are entities\n // [\"\", entity, \"\", entity, \"\", ...]\n const transformedParts = parts\n .map((str, i) => {\n if (i % 2 === 0) {\n return { type: 'text', value: str };\n } else {\n return {\n type: 'entity',\n value: { text: str, data: { url: str } },\n };\n }\n })\n // Filter out all the nulls for empty strings\n .filter(node => node !== null) as PasteUnfurlingTransformedPart<ExtraDataType, {}>[];\n\n return { handled: true, transformedParts };\n};\n"],"names":["TextNode","MockClipboardEvent","Event","clipboardData","createPasteEvent","data","event","types","map","mimeType","getData","format","item","find","value","MockEntityNode","getType","constructor","text","url","$createMockEntityNode","$isMockEntityNode","node","parseLinkPreview","previewData","previewDataString","undefined","handled","JSON","parse","e","title","transformedParts","type","urlRegex","parseLink","parts","split","length","str","i","filter","parseEntity","re"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SAASA,QAAQ,QAAQ,gCAAgC;AAGzD,OAAO,MAAMC,2BAA2BC;;;QACtCC,uBAAAA,iBAAqC;;AACvC;AAEA,OAAO,SAASC,iBAAiBC,IAA2C;IAC1E,MAAMC,QAAQ,IAAIL,mBAAmB;IAErCK,MAAMH,aAAa,GAAG;QACpBI,OAAO;YAACF,KAAKG,GAAG,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKA;SAAU;QAC7CC,SAAS,CAACC;YACR,MAAMC,OAAOP,KAAKQ,IAAI,CAAC,CAAC,EAAEJ,QAAQ,EAAE,GAAKA,aAAaE;YACtD,IAAIC,MAAM;gBACR,OAAOA,KAAKE,KAAK;YACnB;YACA,OAAO;QACT;IACF;IAEA,OAAOR;AACT;AAEA,OAAO,MAAMS,uBAAuBf;IAQlC,OAAOgB,UAAkB;QACvB,OAAO;IACT;IAPAC,YAAYC,IAAY,EAAEC,GAAW,CAAE;QACrC,KAAK,CAACD;QAHRC,uBAAAA,OAAAA,KAAAA;QAIE,IAAI,CAACA,GAAG,GAAGA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AG;YACf,OAAO;gBAAEP,MAAM;gBAAQnB,OAAOyB;YAAI;QACpC,OAAO;YACL,OAAO;gBACLN,MAAM;gBACNnB,OAAO;oBAAEI,MAAMqB;oBAAKlC,MAAM;wBAAEc,KAAKoB;oBAAI;gBAAE;YACzC;QACF;IACF,EACA,6CAA6C;KAC5CE,MAAM,CAACnB,CAAAA,OAAQA,SAAS;IAE3B,OAAO;QAAEK,SAAS;QAAMK;IAAiB;AAC3C,EAAE;AAEF,yEAAyE;AACzE,OAAO,MAAMU,cAAc,OAAOpC;QACnBA;IAAb,MAAMY,QAAOZ,uBAAAA,MAAMH,aAAa,cAAnBG,2CAAAA,qBAAqBI,OAAO,CAAC;IAC1C,IAAI,CAACQ,MAAM;QACT,OAAO;YACLS,SAAS;QACX;IACF;IAEA,4DAA4D;IAC5D,MAAMgB,KAAK;IACX,MAAMP,QAAQlB,KAAKmB,KAAK,CAACM;IACzB,iEAAiE;IACjE,IAAIP,MAAME,MAAM,GAAG,GAAG;QACpB,OAAO;YAAEX,SAAS;QAAM;IAC1B;IAEA,oDAAoD;IACpD,oCAAoC;IACpC,MAAMK,mBAAmBI,MACtB5B,GAAG,CAAC,CAAC+B,KAAKC;QACT,IAAIA,IAAI,MAAM,GAAG;YACf,OAAO;gBAAEP,MAAM;gBAAQnB,OAAOyB;YAAI;QACpC,OAAO;YACL,OAAO;gBACLN,MAAM;gBACNnB,OAAO;oBAAEI,MAAMqB;oBAAKlC,MAAM;wBAAEc,KAAKoB;oBAAI;gBAAE;YACzC;QACF;IACF,EACA,6CAA6C;KAC5CE,MAAM,CAACnB,CAAAA,OAAQA,SAAS;IAE3B,OAAO;QAAEK,SAAS;QAAMK;IAAiB;AAC3C,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { registerPasteUnfurlingPlugin } from './PasteUnfurling.base';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export { registerPasteUnfurlingPlugin } from './PasteUnfurling.base';\nexport type { PasteUnfurlingPluginBaseProps, PasteUnfurlingTransformFunction, PasteUnfurlingTransformResult, PasteUnfurlingTransformedPart } from './PasteUnfurling.types';\n"],"names":["registerPasteUnfurlingPlugin"],"rangeMappings":"","mappings":"AAAA,SAASA,4BAA4B,QAAQ,wBAAwB"}
|
package/lib/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { BasicFunctionalityBase, SentinelNode, $createSentinelNode, $isSentinelNode, SENTINEL_VALUE } from './BasicFunctionality';
|
|
2
|
-
export { ChatInputEntityPluginBase } from './ChatInputEntity';
|
|
3
|
-
export { GhostTextPluginBase } from './GhostText';
|
|
4
|
-
export { ImperativeControlBase } from './ImperativeControl';
|
|
5
|
-
export { ManualGhostTextBase } from './ManualGhostText';
|
|
6
|
-
export { registerPasteUnfurlingPlugin } from './PasteUnfurling';
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n BasicFunctionalityBase,\n SentinelNode,\n $createSentinelNode,\n $isSentinelNode,\n SENTINEL_VALUE,\n} from './BasicFunctionality';\nexport type { IBasicFunctionalityBase } from './BasicFunctionality';\n\nexport { ChatInputEntityPluginBase } from './ChatInputEntity';\nexport type {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} from './ChatInputEntity';\n\nexport { GhostTextPluginBase } from './GhostText';\nexport type { GetGhostTextFunction, IGhostTextNode } from './GhostText';\n\nexport { ImperativeControlBase } from './ImperativeControl';\nexport type { IImperativeControlBase } from './ImperativeControl';\n\nexport { ManualGhostTextBase } from './ManualGhostText';\nexport type { IManualGhostTextBase } from './ManualGhostText';\n\nexport { registerPasteUnfurlingPlugin } from './PasteUnfurling';\nexport type {\n PasteUnfurlingPluginBaseProps,\n PasteUnfurlingTransformFunction,\n PasteUnfurlingTransformedPart,\n PasteUnfurlingTransformResult,\n} from './PasteUnfurling';\n"],"names":["BasicFunctionalityBase","SentinelNode","$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase","registerPasteUnfurlingPlugin"],"rangeMappings":";;;;;","mappings":"AAAA,SACEA,sBAAsB,EACtBC,YAAY,EACZC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,QACT,uBAAuB;AAG9B,SAASC,yBAAyB,QAAQ,oBAAoB;AAQ9D,SAASC,mBAAmB,QAAQ,cAAc;AAGlD,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,mBAAmB,QAAQ,oBAAoB;AAGxD,SAASC,4BAA4B,QAAQ,mBAAmB"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "BasicFunctionalityBase", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return BasicFunctionalityBase;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _define_property = require("@swc/helpers/_/_define_property");
|
|
12
|
-
const _texteditor = require("@fluentui-copilot/text-editor");
|
|
13
|
-
const _SentinelNode = require("./SentinelNode");
|
|
14
|
-
const _SentinelNodeHandlers = require("./SentinelNodeHandlers");
|
|
15
|
-
function isClipboardEvent(event) {
|
|
16
|
-
return event.type === 'paste';
|
|
17
|
-
}
|
|
18
|
-
function getTextFromEditorState(state) {
|
|
19
|
-
// Remove the sentinel node whenever getting the text
|
|
20
|
-
return state.read(()=>(0, _texteditor.$getRoot)().getTextContent()).replace(_SentinelNode.SENTINEL_VALUE, '');
|
|
21
|
-
}
|
|
22
|
-
class BasicFunctionalityBase {
|
|
23
|
-
__enterHandler(event) {
|
|
24
|
-
const selection = (0, _texteditor.$getSelection)();
|
|
25
|
-
if (!(0, _texteditor.$isRangeSelection)(selection)) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if (event === null) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
event.preventDefault();
|
|
32
|
-
if (event.shiftKey) {
|
|
33
|
-
return this.__editor.dispatchCommand(_texteditor.INSERT_PARAGRAPH_COMMAND, undefined);
|
|
34
|
-
}
|
|
35
|
-
// Mark event handled to override default behavior
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
activateContentCallbacks(onContentChange, onCountChanged) {
|
|
39
|
-
this.deactivateContentCallbacks();
|
|
40
|
-
this.__contentChangeCleanup = this.__editor.registerUpdateListener(({ editorState, prevEditorState, tags })=>{
|
|
41
|
-
const prevText = getTextFromEditorState(prevEditorState);
|
|
42
|
-
const newText = getTextFromEditorState(editorState);
|
|
43
|
-
// If the text has not changed, don't trigger callbacks
|
|
44
|
-
if (prevText === newText) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(newText);
|
|
48
|
-
onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(newText.length);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
deactivateContentCallbacks() {
|
|
52
|
-
var _this___contentChangeCleanup, _this;
|
|
53
|
-
(_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
|
|
54
|
-
this.__contentChangeCleanup = undefined;
|
|
55
|
-
}
|
|
56
|
-
activatePasteCallback(onPaste) {
|
|
57
|
-
this.__pasteHandlerCleanup = this.__editor.registerCommand(_texteditor.PASTE_COMMAND, (event)=>{
|
|
58
|
-
if (!isClipboardEvent(event)) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
onPaste(event);
|
|
62
|
-
if (event.defaultPrevented) {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}, _texteditor.COMMAND_PRIORITY_HIGH);
|
|
67
|
-
}
|
|
68
|
-
deactivatePasteCallback() {
|
|
69
|
-
var _this___pasteHandlerCleanup, _this;
|
|
70
|
-
(_this___pasteHandlerCleanup = (_this = this).__pasteHandlerCleanup) === null || _this___pasteHandlerCleanup === void 0 ? void 0 : _this___pasteHandlerCleanup.call(_this);
|
|
71
|
-
this.__pasteHandlerCleanup = undefined;
|
|
72
|
-
}
|
|
73
|
-
activateTrimWhitespace() {
|
|
74
|
-
this.deactivateTrimWhitespace();
|
|
75
|
-
this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener((text)=>{
|
|
76
|
-
if (text.trim() === '') {
|
|
77
|
-
this.__editor.update(()=>{
|
|
78
|
-
(0, _texteditor.$getRoot)().getAllTextNodes().forEach((node)=>{
|
|
79
|
-
node.remove();
|
|
80
|
-
});
|
|
81
|
-
}, {
|
|
82
|
-
tag: 'historic'
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
deactivateTrimWhitespace() {
|
|
88
|
-
var _this___trimWhitespaceCleanup, _this;
|
|
89
|
-
(_this___trimWhitespaceCleanup = (_this = this).__trimWhitespaceCleanup) === null || _this___trimWhitespaceCleanup === void 0 ? void 0 : _this___trimWhitespaceCleanup.call(_this);
|
|
90
|
-
this.__trimWhitespaceCleanup = undefined;
|
|
91
|
-
}
|
|
92
|
-
setIsDisabled(isDisabled) {
|
|
93
|
-
this.__editor.setEditable(!isDisabled);
|
|
94
|
-
}
|
|
95
|
-
cleanup() {
|
|
96
|
-
var _this___baseHandlersCleanup, _this;
|
|
97
|
-
this.deactivateContentCallbacks();
|
|
98
|
-
this.deactivateTrimWhitespace();
|
|
99
|
-
this.deactivatePasteCallback();
|
|
100
|
-
(_this___baseHandlersCleanup = (_this = this).__baseHandlersCleanup) === null || _this___baseHandlersCleanup === void 0 ? void 0 : _this___baseHandlersCleanup.call(_this);
|
|
101
|
-
this.__baseHandlersCleanup = undefined;
|
|
102
|
-
}
|
|
103
|
-
constructor(editor, isSentinelNodeEnabled = true){
|
|
104
|
-
(0, _define_property._)(this, "__editor", void 0);
|
|
105
|
-
(0, _define_property._)(this, "__contentChangeCleanup", void 0);
|
|
106
|
-
(0, _define_property._)(this, "__trimWhitespaceCleanup", void 0);
|
|
107
|
-
(0, _define_property._)(this, "__baseHandlersCleanup", void 0);
|
|
108
|
-
(0, _define_property._)(this, "__pasteHandlerCleanup", void 0);
|
|
109
|
-
this.__editor = editor;
|
|
110
|
-
this.__baseHandlersCleanup = (0, _texteditor.mergeRegister)(this.__editor.registerCommand(_texteditor.KEY_ENTER_COMMAND, this.__enterHandler.bind(this), _texteditor.COMMAND_PRIORITY_HIGH), isSentinelNodeEnabled ? (0, _SentinelNodeHandlers.registerSentinelNodeHandlers)(editor) : noop);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function noop() {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["BasicFunctionality.base.ts"],"sourcesContent":["import type { EditorState, LexicalEditor } from '@fluentui-copilot/text-editor';\nimport { COMMAND_PRIORITY_HIGH } from '@fluentui-copilot/text-editor';\nimport {\n $getRoot,\n $getSelection,\n $isRangeSelection,\n INSERT_PARAGRAPH_COMMAND,\n KEY_ENTER_COMMAND,\n PASTE_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport { SENTINEL_VALUE } from './SentinelNode';\nimport { registerSentinelNodeHandlers } from './SentinelNodeHandlers';\n\nfunction isClipboardEvent(event: ClipboardEvent | KeyboardEvent | InputEvent): event is ClipboardEvent {\n return event.type === 'paste';\n}\n\nexport interface IBasicFunctionalityBase {\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 activatePasteCallback(onPaste: (event: ClipboardEvent) => void): void;\n deactivatePasteCallback(): void;\n cleanup(): void;\n}\n\nfunction getTextFromEditorState(state: EditorState): string {\n // Remove the sentinel node whenever getting the text\n return state.read(() => $getRoot().getTextContent()).replace(SENTINEL_VALUE, '');\n}\n\nexport class BasicFunctionalityBase implements IBasicFunctionalityBase {\n private __editor: LexicalEditor;\n private __contentChangeCleanup?: () => void;\n private __trimWhitespaceCleanup?: () => void;\n private __baseHandlersCleanup?: () => void;\n private __pasteHandlerCleanup?: () => 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, isSentinelNodeEnabled = true) {\n this.__editor = editor;\n\n this.__baseHandlersCleanup = mergeRegister(\n this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_HIGH),\n isSentinelNodeEnabled ? registerSentinelNodeHandlers(editor) : noop,\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.registerUpdateListener(({ editorState, prevEditorState, tags }) => {\n const prevText = getTextFromEditorState(prevEditorState);\n const newText = getTextFromEditorState(editorState);\n\n // If the text has not changed, don't trigger callbacks\n if (prevText === newText) {\n return;\n }\n\n onContentChange?.(newText);\n onCountChanged?.(newText.length);\n });\n }\n\n deactivateContentCallbacks() {\n this.__contentChangeCleanup?.();\n this.__contentChangeCleanup = undefined;\n }\n\n activatePasteCallback(onPaste: (event: ClipboardEvent) => void) {\n this.__pasteHandlerCleanup = this.__editor.registerCommand(\n PASTE_COMMAND,\n (event: ClipboardEvent | KeyboardEvent | InputEvent) => {\n if (!isClipboardEvent(event)) {\n return false;\n }\n\n onPaste(event);\n\n if (event.defaultPrevented) {\n return true;\n }\n\n return false;\n },\n COMMAND_PRIORITY_HIGH,\n );\n }\n\n deactivatePasteCallback() {\n this.__pasteHandlerCleanup?.();\n this.__pasteHandlerCleanup = 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.deactivatePasteCallback();\n this.__baseHandlersCleanup?.();\n this.__baseHandlersCleanup = undefined;\n }\n}\n\nfunction noop() {\n return;\n}\n"],"names":["BasicFunctionalityBase","isClipboardEvent","event","type","getTextFromEditorState","state","read","$getRoot","getTextContent","replace","SENTINEL_VALUE","__enterHandler","selection","$getSelection","$isRangeSelection","preventDefault","shiftKey","__editor","dispatchCommand","INSERT_PARAGRAPH_COMMAND","undefined","activateContentCallbacks","onContentChange","onCountChanged","deactivateContentCallbacks","__contentChangeCleanup","registerUpdateListener","editorState","prevEditorState","tags","prevText","newText","length","_this___contentChangeCleanup","_this","call","activatePasteCallback","onPaste","__pasteHandlerCleanup","registerCommand","PASTE_COMMAND","defaultPrevented","COMMAND_PRIORITY_HIGH","deactivatePasteCallback","_this___pasteHandlerCleanup","activateTrimWhitespace","deactivateTrimWhitespace","__trimWhitespaceCleanup","registerTextContentListener","text","trim","update","getAllTextNodes","forEach","node","remove","tag","_this___trimWhitespaceCleanup","setIsDisabled","isDisabled","setEditable","cleanup","_this___baseHandlersCleanup","__baseHandlersCleanup","constructor","editor","isSentinelNodeEnabled","_define_property","mergeRegister","KEY_ENTER_COMMAND","bind","registerSentinelNodeHandlers","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkCaA;;;eAAAA;;;;4BAjCyB;8BAUP;sCACc;AAE7C,SAASC,iBAAiBC,KAAkD;IAC1E,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAaA,SAASC,uBAAuBC,KAAkB;IAChD,qDAAqD;IACrD,OAAOA,MAAMC,IAAI,CAAC,IAAMC,IAAAA,oBAAAA,IAAWC,cAAc,IAAIC,OAAO,CAACC,4BAAAA,EAAgB;AAC/E;AAEO,MAAMV;IAOHW,eAAeT,KAAoB,EAAE;QAC3C,MAAMU,YAAYC,IAAAA,yBAAAA;QAClB,IAAI,CAACC,IAAAA,6BAAAA,EAAkBF,YAAY;YACjC,OAAO;QACT;QAEA,IAAIV,UAAU,MAAM;YAClB,OAAO;QACT;QAEAA,MAAMa,cAAc;QAEpB,IAAIb,MAAMc,QAAQ,EAAE;YAClB,OAAO,IAAI,CAACC,QAAQ,CAACC,eAAe,CAACC,oCAAAA,EAA0BC;QACjE;QAEA,kDAAkD;QAClD,OAAO;IACT;IAWAC,yBACEC,eAAuD,EACvDC,cAAsD,EACtD;QACA,IAAI,CAACC,0BAA0B;QAC/B,IAAI,CAACC,sBAAsB,GAAG,IAAI,CAACR,QAAQ,CAACS,sBAAsB,CAAC,CAAC,EAAEC,WAAW,EAAEC,eAAe,EAAEC,IAAI,EAAE;YACxG,MAAMC,WAAW1B,uBAAuBwB;YACxC,MAAMG,UAAU3B,uBAAuBuB;YAEvC,uDAAuD;YACvD,IAAIG,aAAaC,SAAS;gBACxB;YACF;YAEAT,oBAAAA,QAAAA,oBAAAA,KAAAA,I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F"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
$createSentinelNode: function() {
|
|
13
|
-
return $createSentinelNode;
|
|
14
|
-
},
|
|
15
|
-
$isSentinelNode: function() {
|
|
16
|
-
return $isSentinelNode;
|
|
17
|
-
},
|
|
18
|
-
SENTINEL_VALUE: function() {
|
|
19
|
-
return SENTINEL_VALUE;
|
|
20
|
-
},
|
|
21
|
-
SentinelNode: function() {
|
|
22
|
-
return SentinelNode;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _texteditor = require("@fluentui-copilot/text-editor");
|
|
26
|
-
const SENTINEL_VALUE = '\u200b\u200c';
|
|
27
|
-
class SentinelNode extends _texteditor.TextNode {
|
|
28
|
-
static getType() {
|
|
29
|
-
return 'sentinel';
|
|
30
|
-
}
|
|
31
|
-
static clone(node) {
|
|
32
|
-
return new SentinelNode(node.__key);
|
|
33
|
-
}
|
|
34
|
-
createDOM(config) {
|
|
35
|
-
const element = super.createDOM(config);
|
|
36
|
-
element.ariaHidden = 'true';
|
|
37
|
-
return element;
|
|
38
|
-
}
|
|
39
|
-
isToken() {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
exportJSON() {
|
|
43
|
-
return {
|
|
44
|
-
...super.exportJSON(),
|
|
45
|
-
type: 'sentinel',
|
|
46
|
-
version: 1
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
static importJSON(serializedNode) {
|
|
50
|
-
return $createSentinelNode();
|
|
51
|
-
}
|
|
52
|
-
constructor(key){
|
|
53
|
-
super(SENTINEL_VALUE, key);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function $createSentinelNode(key) {
|
|
57
|
-
return new SentinelNode(key);
|
|
58
|
-
}
|
|
59
|
-
function $isSentinelNode(node) {
|
|
60
|
-
return node instanceof SentinelNode;
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedTextNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\n// 2 zero width characters will not be visible in the editor.\n// \\u200b is the zero width space character which can allow line wrapping in a word\n// \\u200c is the zero width non-joiner character which prevents ligatures from connecting the two surrounding characters\n// These two characters together are a no-op and should not be present together in any legitimate user input.\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\n super(SENTINEL_VALUE, key);\n }\n\n static getType() {\n return 'sentinel';\n }\n static clone(node: SentinelNode) {\n return new SentinelNode(node.__key);\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n element.ariaHidden = 'true';\n return element;\n }\n\n isToken() {\n return true;\n }\n\n exportJSON(): SerializedTextNode {\n return {\n ...super.exportJSON(),\n type: 'sentinel',\n version: 1,\n };\n }\n\n static importJSON(serializedNode: SerializedTextNode): SentinelNode {\n return $createSentinelNode();\n }\n}\n\nexport function $createSentinelNode(key?: NodeKey) {\n return new SentinelNode(key);\n}\n\nexport function $isSentinelNode(node: LexicalNode | null): node is SentinelNode {\n return node instanceof SentinelNode;\n}\n"],"names":["$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","SentinelNode","TextNode","getType","clone","node","__key","createDOM","config","element","ariaHidden","isToken","exportJSON","type","version","importJSON","serializedNode","constructor","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA4CgBA,mBAAAA;eAAAA;;IAIAC,eAAAA;eAAAA;;IAzCHC,cAAAA;eAAAA;;IAEAC,YAAAA;eAAAA;;;4BARY;AAMlB,MAAMD,iBAAiB;AAEvB,MAAMC,qBAAqBC,oBAAAA;IAKhC,OAAOC,UAAU;QACf,OAAO;IACT;IACA,OAAOC,MAAMC,IAAkB,EAAE;QAC/B,OAAO,IAAIJ,aAAaI,KAAKC,KAAK;IACpC;IAEAC,UAAUC,MAAoB,EAAe;QAC3C,MAAMC,UAAU,KAAK,CAACF,UAAUC;QAChCC,QAAQC,UAAU,GAAG;QACrB,OAAOD;IACT;IAEAE,UAAU;QACR,OAAO;IACT;IAEAC,aAAiC;QAC/B,OAAO;YACL,GAAG,KAAK,CAACA,YAAY;YACrBC,MAAM;YACNC,SAAS;QACX;IACF;IAEA,OAAOC,WAAWC,cAAkC,EAAgB;QAClE,OAAOlB;IACT;IA/BAmB,YAAYC,GAAa,CAAE;QACzB,KAAK,CAAClB,gBAAgBkB;IACxB;AA8BF;AAEO,SAASpB,oBAAoBoB,GAAa;IAC/C,OAAO,IAAIjB,aAAaiB;AAC1B;AAEO,SAASnB,gBAAgBM,IAAwB;IACtD,OAAOA,gBAAgBJ;AACzB"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "registerSentinelNodeHandlers", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return registerSentinelNodeHandlers;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _texteditor = require("@fluentui-copilot/text-editor");
|
|
12
|
-
const _SentinelNode = require("./SentinelNode");
|
|
13
|
-
function registerSentinelNodeHandlers(editor) {
|
|
14
|
-
// Add a sentinel node at the end of the input when there is content.
|
|
15
|
-
// This sentinel node fixes a number of issues.
|
|
16
|
-
// In Safari, Lexical's behaviour of adding <br /> tags to the end of the input when it ends
|
|
17
|
-
// in a decorator node causes cursor location issues: https://github.com/facebook/lexical/issues/4487
|
|
18
|
-
// Otherwise, when a decorator node is the last node in the input, the cursor can't move past it.
|
|
19
|
-
// Adding an invisible text node that doesn't contribute to the content and can't be selected to the end of the input
|
|
20
|
-
// mitigates these issues.
|
|
21
|
-
const sentinelNodeUpdateHandler = ({ editorState })=>{
|
|
22
|
-
editorState.read(()=>{
|
|
23
|
-
const leaves = (0, _texteditor.$getLeafNodes)((0, _texteditor.$getRoot)());
|
|
24
|
-
if (leaves.length === 0) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const lastNode = leaves[leaves.length - 1];
|
|
28
|
-
const lastNodeKey = lastNode.getKey();
|
|
29
|
-
// If the last node isn't a sentinel, add one
|
|
30
|
-
if (!(0, _SentinelNode.$isSentinelNode)(lastNode)) {
|
|
31
|
-
editor.update(()=>{
|
|
32
|
-
var _$getNodeByKey;
|
|
33
|
-
(_$getNodeByKey = (0, _texteditor.$getNodeByKey)(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.insertAfter((0, _SentinelNode.$createSentinelNode)());
|
|
34
|
-
}, {
|
|
35
|
-
discrete: true,
|
|
36
|
-
tag: 'historic'
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
// If the sentinel node is not selected, we're done
|
|
41
|
-
const previous = lastNode.getPreviousSibling();
|
|
42
|
-
if (!previous || !lastNode.isSelected()) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const selection = (0, _texteditor.$getSelection)();
|
|
46
|
-
if (!(0, _texteditor.$isRangeSelection)(selection)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
// If the cursor is inside the sentinel node, move it out (next to the beginning)
|
|
50
|
-
// We allow selection on the boundary of the sentinel in case the adjacent node is a decorator node
|
|
51
|
-
// where selection is ill-defined.
|
|
52
|
-
if (selection.isCollapsed() && selection.anchor.offset > 0) {
|
|
53
|
-
editor.update(()=>{
|
|
54
|
-
var _$getNodeByKey;
|
|
55
|
-
(_$getNodeByKey = (0, _texteditor.$getNodeByKey)(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.selectStart();
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// If the selection is a range which includes the sentinel, modify the range to exclude it
|
|
60
|
-
if (!selection.isCollapsed()) {
|
|
61
|
-
let selectionChanged = false;
|
|
62
|
-
const newSelection = selection.clone();
|
|
63
|
-
if (newSelection.anchor.getNode() === lastNode && newSelection.anchor.offset > 0) {
|
|
64
|
-
newSelection.anchor.set(lastNodeKey, 0, 'text');
|
|
65
|
-
selectionChanged = true;
|
|
66
|
-
}
|
|
67
|
-
if (newSelection.focus.getNode() === lastNode && newSelection.focus.offset > 0) {
|
|
68
|
-
newSelection.focus.set(lastNodeKey, 0, 'text');
|
|
69
|
-
selectionChanged = true;
|
|
70
|
-
}
|
|
71
|
-
if (selectionChanged) {
|
|
72
|
-
editor.update(()=>{
|
|
73
|
-
if ((0, _texteditor.$getNodeByKey)(lastNodeKey) !== null) {
|
|
74
|
-
(0, _texteditor.$setSelection)((0, _texteditor.$normalizeSelection__EXPERIMENTAL)(newSelection));
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
return (0, _texteditor.mergeRegister)(editor.registerUpdateListener(sentinelNodeUpdateHandler), editor.registerNodeTransform(_SentinelNode.SentinelNode, (node)=>{
|
|
82
|
-
if (!node.getPreviousSibling() || node.getNextSibling()) {
|
|
83
|
-
node.remove();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["SentinelNodeHandlers.ts"],"sourcesContent":["import type {\n LexicalEditor,\n UpdateListener} from '@fluentui-copilot/text-editor';\nimport {\n $getLeafNodes,\n $getNodeByKey,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n mergeRegister\n} from '@fluentui-copilot/text-editor';\nimport { $isSentinelNode, $createSentinelNode, SentinelNode } from './SentinelNode';\n\nexport function registerSentinelNodeHandlers(editor: LexicalEditor) {\n // Add a sentinel node at the end of the input when there is content.\n // This sentinel node fixes a number of issues.\n // In Safari, Lexical's behaviour of adding <br /> tags to the end of the input when it ends\n // in a decorator node causes cursor location issues: https://github.com/facebook/lexical/issues/4487\n // Otherwise, when a decorator node is the last node in the input, the cursor can't move past it.\n // Adding an invisible text node that doesn't contribute to the content and can't be selected to the end of the input\n // mitigates these issues.\n const sentinelNodeUpdateHandler: UpdateListener = ({ editorState }) => {\n editorState.read(() => {\n const leaves = $getLeafNodes($getRoot());\n if (leaves.length === 0) {\n return;\n }\n\n const lastNode = leaves[leaves.length - 1];\n const lastNodeKey = lastNode.getKey();\n\n // If the last node isn't a sentinel, add one\n if (!$isSentinelNode(lastNode)) {\n editor.update(\n () => {\n // We find the node by its key again in case the node was removed before this update runs\n $getNodeByKey(lastNodeKey)?.insertAfter($createSentinelNode());\n },\n // historic tag prevents every sentinel node addition from being added to LexicalHistoryPlugin undo stack\n { discrete: true, tag: 'historic' },\n );\n return;\n }\n\n // If the sentinel node is not selected, we're done\n const previous = lastNode.getPreviousSibling();\n if (!previous || !lastNode.isSelected()) {\n return;\n }\n\n const selection = $getSelection();\n if (!$isRangeSelection(selection)) {\n return;\n }\n\n // If the cursor is inside the sentinel node, move it out (next to the beginning)\n // We allow selection on the boundary of the sentinel in case the adjacent node is a decorator node\n // where selection is ill-defined.\n if (selection.isCollapsed() && selection.anchor.offset > 0) {\n editor.update(() => {\n $getNodeByKey(lastNodeKey)?.selectStart();\n });\n return;\n }\n\n // If the selection is a range which includes the sentinel, modify the range to exclude it\n if (!selection.isCollapsed()) {\n let selectionChanged = false;\n const newSelection = selection.clone();\n\n if (newSelection.anchor.getNode() === lastNode && newSelection.anchor.offset > 0) {\n newSelection.anchor.set(lastNodeKey, 0, 'text');\n selectionChanged = true;\n }\n if (newSelection.focus.getNode() === lastNode && newSelection.focus.offset > 0) {\n newSelection.focus.set(lastNodeKey, 0, 'text');\n selectionChanged = true;\n }\n\n if (selectionChanged) {\n editor.update(() => {\n if ($getNodeByKey(lastNodeKey) !== null) {\n $setSelection($normalizeSelection__EXPERIMENTAL(newSelection));\n }\n });\n }\n }\n });\n };\n\n return mergeRegister(\n editor.registerUpdateListener(sentinelNodeUpdateHandler),\n editor.registerNodeTransform(SentinelNode, node => {\n if (!node.getPreviousSibling() || node.getNextSibling()) {\n node.remove();\n return;\n }\n }),\n );\n}\n"],"names":["registerSentinelNodeHandlers","editor","sentinelNodeUpdateHandler","editorState","read","leaves","$getLeafNodes","$getRoot","length","lastNode","lastNodeKey","getKey","$isSentinelNode","update","$getNodeByKey","insertAfter","$createSentinelNode","discrete","tag","previous","getPreviousSibling","isSelected","selection","$getSelection","$isRangeSelection","isCollapsed","anchor","offset","selectStart","selectionChanged","newSelection","clone","getNode","set","focus","$setSelection","$normalizeSelection__EXPERIMENTAL","mergeRegister","registerUpdateListener","registerNodeTransform","SentinelNode","node","getNextSibling","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAegBA;;;eAAAA;;;4BAHT;8BAC4D;AAE5D,SAASA,6BAA6BC,MAAqB;IAChE,qEAAqE;IACrE,+CAA+C;IAC/C,4FAA4F;IAC5F,qGAAqG;IACrG,iGAAiG;IACjG,qHAAqH;IACrH,0BAA0B;IAC1B,MAAMC,4BAA4C,CAAC,EAAEC,WAAW,EAAE;QAChEA,YAAYC,IAAI,CAAC;YACf,MAAMC,SAASC,IAAAA,yBAAAA,EAAcC,IAAAA,oBAAAA;YAC7B,IAAIF,OAAOG,M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I,KAAK,CAACF,OAAO,OAAOvB,YAAYqB,aAAaI,KAAK,CAACP,MAAM,GAAG,GAAG;oBAC9EG,aAAaI,KAAK,CAACD,GAAG,CAACvB,aAAa,GAAG;oBACvCmB,mBAAmB;gBACrB;gBAEA,IAAIA,kBAAkB;oBACpB5B,OAAOY,MAAM,CAAC;wBACZ,IAAIC,IAAAA,yBAAAA,EAAcJ,iBAAiB,MAAM;4BACvCyB,IAAAA,yBAAAA,EAAcC,IAAAA,6CAAAA,EAAkCN;wBAClD;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOO,IAAAA,yBAAAA,EACLpC,OAAOqC,sBAAsB,CAACpC,4BAC9BD,OAAOsC,qBAAqB,CAACC,0BAAAA,EAAcC,CAAAA;QACzC,IAAI,CAACA,KAAKrB,kBAAkB,MAAMqB,KAAKC,cAAc,IAAI;YACvDD,KAAKE,MAAM;YACX;QACF;IACF;AAEJ"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
$createSentinelNode: function() {
|
|
13
|
-
return _SentinelNode.$createSentinelNode;
|
|
14
|
-
},
|
|
15
|
-
$isSentinelNode: function() {
|
|
16
|
-
return _SentinelNode.$isSentinelNode;
|
|
17
|
-
},
|
|
18
|
-
BasicFunctionalityBase: function() {
|
|
19
|
-
return _BasicFunctionalitybase.BasicFunctionalityBase;
|
|
20
|
-
},
|
|
21
|
-
SENTINEL_VALUE: function() {
|
|
22
|
-
return _SentinelNode.SENTINEL_VALUE;
|
|
23
|
-
},
|
|
24
|
-
SentinelNode: function() {
|
|
25
|
-
return _SentinelNode.SentinelNode;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const _BasicFunctionalitybase = require("./BasicFunctionality.base");
|
|
29
|
-
const _SentinelNode = require("./SentinelNode");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IBasicFunctionalityBase } from './BasicFunctionality.base';\nexport { BasicFunctionalityBase } from './BasicFunctionality.base';\nexport { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';\n"],"names":["$createSentinelNode","$isSentinelNode","BasicFunctionalityBase","SENTINEL_VALUE","SentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAESA,mBAAmB;eAAnBA,iCAAmB;;IAAEC,eAAe;eAAfA,6BAAe;;IADpCC,sBAAsB;eAAtBA,8CAAsB;;IACgBC,cAAc;eAAdA,4BAAc;;IAAEC,YAAY;eAAZA,0BAAY;;;wCADpC;8BAC4C"}
|