@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.
Files changed (76) hide show
  1. package/CHANGELOG.json +3 -3
  2. package/CHANGELOG.md +4 -4
  3. package/package.json +2 -2
  4. package/dist/index.d.ts +0 -192
  5. package/lib/BasicFunctionality/BasicFunctionality.base.js +0 -107
  6. package/lib/BasicFunctionality/BasicFunctionality.base.js.map +0 -1
  7. package/lib/BasicFunctionality/SentinelNode.js +0 -41
  8. package/lib/BasicFunctionality/SentinelNode.js.map +0 -1
  9. package/lib/BasicFunctionality/SentinelNodeHandlers.js +0 -79
  10. package/lib/BasicFunctionality/SentinelNodeHandlers.js.map +0 -1
  11. package/lib/BasicFunctionality/index.js +0 -2
  12. package/lib/BasicFunctionality/index.js.map +0 -1
  13. package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js +0 -117
  14. package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js.map +0 -1
  15. package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js +0 -1
  16. package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js.map +0 -1
  17. package/lib/ChatInputEntity/index.js +0 -1
  18. package/lib/ChatInputEntity/index.js.map +0 -1
  19. package/lib/GhostText/GhostText.base.js +0 -158
  20. package/lib/GhostText/GhostText.base.js.map +0 -1
  21. package/lib/GhostText/index.js +0 -1
  22. package/lib/GhostText/index.js.map +0 -1
  23. package/lib/ImperativeControl/ImperativeControl.base.js +0 -87
  24. package/lib/ImperativeControl/ImperativeControl.base.js.map +0 -1
  25. package/lib/ImperativeControl/index.js +0 -1
  26. package/lib/ImperativeControl/index.js.map +0 -1
  27. package/lib/ManualGhostText/ManualGhostText.base.js +0 -78
  28. package/lib/ManualGhostText/ManualGhostText.base.js.map +0 -1
  29. package/lib/ManualGhostText/index.js +0 -1
  30. package/lib/ManualGhostText/index.js.map +0 -1
  31. package/lib/PasteUnfurling/PasteUnfurling.base.js +0 -60
  32. package/lib/PasteUnfurling/PasteUnfurling.base.js.map +0 -1
  33. package/lib/PasteUnfurling/PasteUnfurling.types.js +0 -1
  34. package/lib/PasteUnfurling/PasteUnfurling.types.js.map +0 -1
  35. package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +0 -162
  36. package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js.map +0 -1
  37. package/lib/PasteUnfurling/index.js +0 -1
  38. package/lib/PasteUnfurling/index.js.map +0 -1
  39. package/lib/index.js +0 -6
  40. package/lib/index.js.map +0 -1
  41. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +0 -115
  42. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +0 -1
  43. package/lib-commonjs/BasicFunctionality/SentinelNode.js +0 -61
  44. package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +0 -1
  45. package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js +0 -87
  46. package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js.map +0 -1
  47. package/lib-commonjs/BasicFunctionality/index.js +0 -29
  48. package/lib-commonjs/BasicFunctionality/index.js.map +0 -1
  49. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js +0 -125
  50. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +0 -1
  51. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js +0 -4
  52. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js.map +0 -1
  53. package/lib-commonjs/ChatInputEntity/index.js +0 -11
  54. package/lib-commonjs/ChatInputEntity/index.js.map +0 -1
  55. package/lib-commonjs/GhostText/GhostText.base.js +0 -167
  56. package/lib-commonjs/GhostText/GhostText.base.js.map +0 -1
  57. package/lib-commonjs/GhostText/index.js +0 -11
  58. package/lib-commonjs/GhostText/index.js.map +0 -1
  59. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +0 -97
  60. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +0 -1
  61. package/lib-commonjs/ImperativeControl/index.js +0 -11
  62. package/lib-commonjs/ImperativeControl/index.js.map +0 -1
  63. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js +0 -88
  64. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +0 -1
  65. package/lib-commonjs/ManualGhostText/index.js +0 -11
  66. package/lib-commonjs/ManualGhostText/index.js.map +0 -1
  67. package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js +0 -70
  68. package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js.map +0 -1
  69. package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js +0 -4
  70. package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js.map +0 -1
  71. package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +0 -197
  72. package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +0 -1
  73. package/lib-commonjs/PasteUnfurling/index.js +0 -11
  74. package/lib-commonjs/PasteUnfurling/index.js.map +0 -1
  75. package/lib-commonjs/index.js +0 -48
  76. package/lib-commonjs/index.js.map +0 -1
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ManualGhostTextBase", {
6
- enumerable: true,
7
- get: function() {
8
- return _ManualGhostTextbase.ManualGhostTextBase;
9
- }
10
- });
11
- const _ManualGhostTextbase = require("./ManualGhostText.base");
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export type { IManualGhostTextBase } from './ManualGhostText.base';\nexport { ManualGhostTextBase } from './ManualGhostText.base';\n"],"names":["ManualGhostTextBase"],"rangeMappings":";;;;;;;;;;","mappings":";;;;+BACSA;;;eAAAA,wCAAmB;;;qCAAQ"}
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "registerPasteUnfurlingPlugin", {
6
- enumerable: true,
7
- get: function() {
8
- return registerPasteUnfurlingPlugin;
9
- }
10
- });
11
- const _texteditor = require("@fluentui-copilot/text-editor");
12
- function unhandledPart(part) {
13
- throw new Error(`Unhandled part: ${part}`);
14
- }
15
- function registerPasteUnfurlingPlugin(editor, props) {
16
- const { entityPluginId, transforms, $createEntityNode } = props;
17
- function insertParts(parts) {
18
- editor.update(()=>{
19
- const nodes = parts.map((part)=>{
20
- switch(part.type){
21
- case 'entity':
22
- return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);
23
- case 'text':
24
- return (0, _texteditor.$createTextNode)(part.value);
25
- }
26
- return unhandledPart(part);
27
- });
28
- (0, _texteditor.$insertNodes)(nodes);
29
- });
30
- }
31
- function handlePaste(event) {
32
- const transformPromises = [];
33
- for (const transform of transforms){
34
- transformPromises.push(Promise.resolve(transform(event, editor)));
35
- }
36
- Promise.allSettled(transformPromises).then((results)=>{
37
- let handledPaste = false;
38
- for (const result of results){
39
- if (result.status === 'fulfilled') {
40
- const transformResult = result.value;
41
- if (transformResult.transformedParts) {
42
- insertParts(transformResult.transformedParts);
43
- }
44
- if (transformResult.handled) {
45
- handledPaste = true;
46
- break;
47
- }
48
- }
49
- }
50
- if (!handledPaste) {
51
- var _commandsMap_get;
52
- const commandsMap = editor._commands;
53
- const defaultEditorListeners = (_commandsMap_get = commandsMap.get(_texteditor.PASTE_COMMAND)) === null || _commandsMap_get === void 0 ? void 0 : _commandsMap_get[_texteditor.COMMAND_PRIORITY_EDITOR];
54
- if (defaultEditorListeners) {
55
- // After the promises have resolved, we're not guaranteed to be in the same update state as the original command
56
- editor.update(()=>{
57
- for (const listener of defaultEditorListeners){
58
- const defaultHandled = listener(event, editor);
59
- if (defaultHandled) {
60
- break;
61
- }
62
- }
63
- });
64
- }
65
- }
66
- });
67
- return true;
68
- }
69
- return editor.registerCommand(_texteditor.PASTE_COMMAND, handlePaste, _texteditor.COMMAND_PRIORITY_LOW);
70
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["PasteUnfurling.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n PASTE_COMMAND,\n $insertNodes,\n $createTextNode,\n} from '@fluentui-copilot/text-editor';\nimport type {\n PasteUnfurlingPluginBaseProps,\n PasteUnfurlingTransformedPart,\n PasteUnfurlingTransformResult,\n} from './PasteUnfurling.types';\n\nfunction unhandledPart(part: never): never {\n throw new Error(`Unhandled part: ${part}`);\n}\n\nexport function registerPasteUnfurlingPlugin<ExtraDataType, NodePropsType>(\n editor: LexicalEditor,\n props: PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[]) {\n editor.update(() => {\n const nodes = parts.map(part => {\n switch (part.type) {\n case 'entity':\n return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);\n case 'text':\n return $createTextNode(part.value);\n }\n return unhandledPart(part);\n });\n $insertNodes(nodes);\n });\n }\n\n function handlePaste(event: ClipboardEvent): boolean {\n const transformPromises: Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>[] = [];\n\n for (const transform of transforms) {\n transformPromises.push(Promise.resolve(transform(event, editor)));\n }\n\n Promise.allSettled(transformPromises).then(results => {\n let handledPaste = false;\n\n for (const result of results) {\n if (result.status === 'fulfilled') {\n const transformResult = result.value;\n if (transformResult.transformedParts) {\n insertParts(transformResult.transformedParts);\n }\n\n if (transformResult.handled) {\n handledPaste = true;\n break;\n }\n }\n }\n\n if (!handledPaste) {\n const commandsMap = editor._commands;\n const defaultEditorListeners = commandsMap.get(PASTE_COMMAND)?.[COMMAND_PRIORITY_EDITOR];\n if (defaultEditorListeners) {\n // After the promises have resolved, we're not guaranteed to be in the same update state as the original command\n editor.update(() => {\n for (const listener of defaultEditorListeners) {\n const defaultHandled = listener(event, editor);\n if (defaultHandled) {\n break;\n }\n }\n });\n }\n }\n });\n\n return true;\n }\n\n return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_LOW);\n}\n"],"names":["registerPasteUnfurlingPlugin","unhandledPart","part","Error","editor","props","entityPluginId","transforms","$createEntityNode","insertParts","parts","update","nodes","map","type","value","text","data","entityProps","$createTextNode","$insertNodes","handlePaste","event","transformPromises","transform","push","Promise","resolve","allSettled","then","results","handledPaste","result","status","transformResult","transformedParts","handled","commandsMap","_commands","defaultEditorListeners","get","PASTE_COMMAND","COMMAND_PRIORITY_EDITOR","listener","defaultHandled","registerCommand","COMMAND_PRIORITY_LOW"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkBgBA;;;eAAAA;;;4BAXT;AAOP,SAASC,cAAcC,IAAW;IAChC,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAED,KAAK,CAAC;AAC3C;AAEO,SAASF,6BACdI,MAAqB,EACrBC,KAAkE;IAElE,MAAM,EAAEC,cAAc,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GAAGH;IAE1D,SAASI,YAAYC,KAAoE;QACvFN,OAAOO,MAAM,CAAC;YACZ,MAAMC,QAAQF,MAAMG,GAAG,CAACX,CAAAA;gBACtB,OAAQA,KAAKY,IAAI;oBACf,KAAK;wBACH,OAAON,kBAAkBF,gBAAgBJ,KAAKa,KAAK,CAACC,IAAI,EAAEd,KAAKa,KAAK,CAACE,IAAI,EAAEf,KAAKa,KAAK,CAACG,WAAW;oBACnG,KAAK;wBACH,OAAOC,IAAAA,2BAAAA,EAAgBjB,KAAKa,KAAK;gBACrC;gBACA,OAAOd,cAAcC;YACvB;YACAkB,IAAAA,wBAAAA,EAAaR;QACf;IACF;IAEA,SAASS,YAAYC,KAAqB;QACxC,MAAMC,oBAA4F,EAAE;QAEpG,KAAK,MAAMC,aAAajB,WAAY;YAClCgB,kBAAkBE,IAAI,CAACC,QAAQC,OAAO,CAACH,UAAUF,OAAOlB;QAC1D;QAEAsB,QAAQE,UAAU,CAACL,mBAAmBM,IAAI,CAACC,CAAAA;YACzC,IAAIC,eAAe;YAEnB,KAAK,MAAMC,UAAUF,QAAS;gBAC5B,IAAIE,OAAOC,MAAM,KAAK,aAAa;oBACjC,MAAMC,kBAAkBF,OAAOjB,KAAK;oBACpC,IAAImB,gBAAgBC,gBAAgB,EAAE;wBACpC1B,YAAYyB,gBAAgBC,gBAAgB;oBAC9C;oBAEA,IAAID,gBAAgBE,OAAO,EAAE;wBAC3BL,eAAe;wBACf;oBACF;gBACF;YACF;YAEA,IAAI,CAACA,cAAc;oBAEcM;gBAD/B,MAAMA,cAAcjC,OAAOkC,SAAS;gBACpC,MAAMC,yBAAAA,AAAyBF,CAAAA,mBAAAA,YAAYG,GAAG,CAACC,yBAAAA,CAAAA,MAAAA,QAAhBJ,qBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,gBAAgC,CAACK,mCAAAA,CAAwB;gBACxF,IAAIH,wBAAwB;oBAC1B,gHAAgH;oBAChHnC,OAAOO,MAAM,CAAC;wBACZ,KAAK,MAAMgC,YAAYJ,uBAAwB;4BAC7C,MAAMK,iBAAiBD,SAASrB,OAAOlB;4BACvC,IAAIwC,gBAAgB;gCAClB;4BACF;wBACF;oBACF;gBACF;YACF;QACF;QAEA,OAAO;IACT;IAEA,OAAOxC,OAAOyC,eAAe,CAACJ,yBAAAA,EAAepB,aAAayB,gCAAAA;AAC5D"}
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
@@ -1 +0,0 @@
1
- {"version":3,"sources":["PasteUnfurling.types.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData } from '../ChatInputEntity';\n\nexport type PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) =>\n | PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>\n | Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>;\n\nexport type PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType>[];\n $createEntityNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => LexicalNode;\n};\n"],"names":[],"rangeMappings":"","mappings":""}
@@ -1,197 +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
- $createMockEntityNode: function() {
13
- return $createMockEntityNode;
14
- },
15
- $isMockEntityNode: function() {
16
- return $isMockEntityNode;
17
- },
18
- MockClipboardEvent: function() {
19
- return MockClipboardEvent;
20
- },
21
- MockEntityNode: function() {
22
- return MockEntityNode;
23
- },
24
- createPasteEvent: function() {
25
- return createPasteEvent;
26
- },
27
- parseEntity: function() {
28
- return parseEntity;
29
- },
30
- parseLink: function() {
31
- return parseLink;
32
- },
33
- parseLinkPreview: function() {
34
- return parseLinkPreview;
35
- }
36
- });
37
- const _define_property = require("@swc/helpers/_/_define_property");
38
- const _texteditor = require("@fluentui-copilot/text-editor");
39
- class MockClipboardEvent extends Event {
40
- constructor(...args){
41
- super(...args);
42
- (0, _define_property._)(this, "clipboardData", null);
43
- }
44
- }
45
- function createPasteEvent(data) {
46
- const event = new MockClipboardEvent('paste');
47
- event.clipboardData = {
48
- types: [
49
- data.map(({ mimeType })=>mimeType)
50
- ],
51
- getData: (format)=>{
52
- const item = data.find(({ mimeType })=>mimeType === format);
53
- if (item) {
54
- return item.value;
55
- }
56
- return '';
57
- }
58
- };
59
- return event;
60
- }
61
- class MockEntityNode extends _texteditor.TextNode {
62
- static getType() {
63
- return 'mockEntity';
64
- }
65
- constructor(text, url){
66
- super(text);
67
- (0, _define_property._)(this, "url", void 0);
68
- this.url = url;
69
- }
70
- }
71
- function $createMockEntityNode(text, url) {
72
- return new MockEntityNode(text, url);
73
- }
74
- function $isMockEntityNode(node) {
75
- return node instanceof MockEntityNode;
76
- }
77
- const parseLinkPreview = (event)=>{
78
- let previewData;
79
- try {
80
- var _event_clipboardData;
81
- const previewDataString = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/link-preview');
82
- if (previewDataString === undefined || previewDataString === '') {
83
- return {
84
- handled: false
85
- };
86
- }
87
- previewData = JSON.parse(previewDataString);
88
- } catch (e) {
89
- return {
90
- handled: false
91
- };
92
- }
93
- const title = previewData.title;
94
- const url = previewData.url;
95
- if (!title || !url) {
96
- return {
97
- handled: false
98
- };
99
- }
100
- return {
101
- handled: true,
102
- transformedParts: [
103
- {
104
- type: 'entity',
105
- value: {
106
- text: title,
107
- data: {
108
- url
109
- }
110
- }
111
- }
112
- ]
113
- };
114
- };
115
- const urlRegex = /(\b(?:https?):\/\/[^\s]+)/gi;
116
- const parseLink = (event)=>{
117
- var _event_clipboardData;
118
- const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
119
- if (!text) {
120
- return {
121
- handled: false
122
- };
123
- }
124
- const parts = text.split(urlRegex);
125
- // If an entity was found, parts will be at least 3 elements long
126
- if (parts.length < 3) {
127
- return {
128
- handled: false
129
- };
130
- }
131
- const transformedParts = parts.map((str, i)=>{
132
- if (i % 2 === 0) {
133
- return {
134
- type: 'text',
135
- value: str
136
- };
137
- } else {
138
- return {
139
- type: 'entity',
140
- value: {
141
- text: str,
142
- data: {
143
- url: str
144
- }
145
- }
146
- };
147
- }
148
- }) // Filter out all the nulls for empty strings
149
- .filter((node)=>node !== null);
150
- return {
151
- handled: true,
152
- transformedParts
153
- };
154
- };
155
- const parseEntity = async (event)=>{
156
- var _event_clipboardData;
157
- const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
158
- if (!text) {
159
- return {
160
- handled: false
161
- };
162
- }
163
- // Assume entities come in the syntax <entity>title</entity>
164
- const re = /<entity[^>]*>([^<]*)<\/entity>/g;
165
- const parts = text.split(re);
166
- // If an entity was found, parts will be at least 3 elements long
167
- if (parts.length < 3) {
168
- return {
169
- handled: false
170
- };
171
- }
172
- // Even elements are text, odd elements are entities
173
- // ["", entity, "", entity, "", ...]
174
- const transformedParts = parts.map((str, i)=>{
175
- if (i % 2 === 0) {
176
- return {
177
- type: 'text',
178
- value: str
179
- };
180
- } else {
181
- return {
182
- type: 'entity',
183
- value: {
184
- text: str,
185
- data: {
186
- url: str
187
- }
188
- }
189
- };
190
- }
191
- }) // Filter out all the nulls for empty strings
192
- .filter((node)=>node !== null);
193
- return {
194
- handled: true,
195
- transformedParts
196
- };
197
- };
@@ -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":["$createMockEntityNode","$isMockEntityNode","MockClipboardEvent","MockEntityNode","createPasteEvent","parseEntity","parseLink","parseLinkPreview","Event","clipboardData","data","event","types","map","mimeType","getData","format","item","find","value","TextNode","getType","constructor","text","url","node","previewData","previewDataString","undefined","handled","JSON","parse","e","title","transformedParts","type","urlRegex","parts","split","length","str","i","filter","re"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAwCgBA,qBAAAA;eAAAA;;IAIAC,iBAAAA;eAAAA;;IAxCHC,kBAAAA;eAAAA;;IAqBAC,cAAAA;eAAAA;;IAjBGC,gBAAAA;eAAAA;;IAiGHC,WAAAA;eAAAA;;IA/BAC,SAAAA;eAAAA;;IA1BAC,g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AC1C,IAAI,CAACQ,MAAM;QACT,OAAO;YACLM,SAAS;QACX;IACF;IAEA,4DAA4D;IAC5D,MAAMc,KAAK;IACX,MAAMN,QAAQd,KAAKe,KAAK,CAACK;IACzB,iEAAiE;IACjE,IAAIN,MAAME,MAAM,GAAG,GAAG;QACpB,OAAO;YAAEV,SAAS;QAAM;IAC1B;IAEA,oDAAoD;IACpD,oCAAoC;IACpC,MAAMK,mBAAmBG,MACtBxB,GAAG,CAAC,CAAC2B,KAAKC;QACT,IAAIA,IAAI,MAAM,GAAG;YACf,OAAO;gBAAEN,MAAM;gBAAQhB,OAAOqB;YAAI;QACpC,OAAO;YACL,OAAO;gBACLL,MAAM;gBACNhB,OAAO;oBAAEI,MAAMiB;oBAAK9B,MAAM;wBAAEc,KAAKgB;oBAAI;gBAAE;YACzC;QACF;IACF,GACA,6CAA6C;KAC5CE,MAAM,CAACjB,CAAAA,OAAQA,SAAS;IAE3B,OAAO;QAAEI,SAAS;QAAMK;IAAiB;AAC3C"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "registerPasteUnfurlingPlugin", {
6
- enumerable: true,
7
- get: function() {
8
- return _PasteUnfurlingbase.registerPasteUnfurlingPlugin;
9
- }
10
- });
11
- const _PasteUnfurlingbase = require("./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":";;;;+BAASA;;;eAAAA,gDAA4B;;;oCAAQ"}
@@ -1,48 +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 _BasicFunctionality.$createSentinelNode;
14
- },
15
- $isSentinelNode: function() {
16
- return _BasicFunctionality.$isSentinelNode;
17
- },
18
- BasicFunctionalityBase: function() {
19
- return _BasicFunctionality.BasicFunctionalityBase;
20
- },
21
- ChatInputEntityPluginBase: function() {
22
- return _ChatInputEntity.ChatInputEntityPluginBase;
23
- },
24
- GhostTextPluginBase: function() {
25
- return _GhostText.GhostTextPluginBase;
26
- },
27
- ImperativeControlBase: function() {
28
- return _ImperativeControl.ImperativeControlBase;
29
- },
30
- ManualGhostTextBase: function() {
31
- return _ManualGhostText.ManualGhostTextBase;
32
- },
33
- SENTINEL_VALUE: function() {
34
- return _BasicFunctionality.SENTINEL_VALUE;
35
- },
36
- SentinelNode: function() {
37
- return _BasicFunctionality.SentinelNode;
38
- },
39
- registerPasteUnfurlingPlugin: function() {
40
- return _PasteUnfurling.registerPasteUnfurlingPlugin;
41
- }
42
- });
43
- const _BasicFunctionality = require("./BasicFunctionality");
44
- const _ChatInputEntity = require("./ChatInputEntity");
45
- const _GhostText = require("./GhostText");
46
- const _ImperativeControl = require("./ImperativeControl");
47
- const _ManualGhostText = require("./ManualGhostText");
48
- const _PasteUnfurling = require("./PasteUnfurling");
@@ -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":["$createSentinelNode","$isSentinelNode","BasicFunctionalityBase","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase","SENTINEL_VALUE","SentinelNode","registerPasteUnfurlingPlugin"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAGEA,mBAAmB;eAAnBA,uCAAmB;;IACnBC,eAAe;eAAfA,mCAAe;;IAHfC,sBAAsB;eAAtBA,0CAAsB;;IAQfC,yBAAyB;eAAzBA,0CAAyB;;IAQzBC,mBAAmB;eAAnBA,8BAAmB;;IAGnBC,qBAAqB;eAArBA,wCAAqB;;IAGrBC,mBAAmB;eAAnBA,oCAAmB;;IAlB1BC,cAAc;eAAdA,kCAAc;;IAHdC,YAAY;eAAZA,gCAAY;;IAwBLC,4BAA4B;eAA5BA,4CAA4B;;;oCApB9B;iCAGmC;2BAQN;mCAGE;iCAGF;gCAGS"}