@fluentui-copilot/react-editor-input 0.5.6 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.json +57 -1
  2. package/CHANGELOG.md +23 -2
  3. package/dist/index.d.ts +20 -5
  4. package/lib/EditorInput.js +1 -1
  5. package/lib/EditorInput.js.map +1 -1
  6. package/lib/components/AnimatedPlaceholder/renderAnimatedPlaceholder.js.map +1 -1
  7. package/lib/components/EditorInput/EditorInput.js +3 -1
  8. package/lib/components/EditorInput/EditorInput.js.map +1 -1
  9. package/lib/components/EditorInput/EditorInput.types.js +1 -3
  10. package/lib/components/EditorInput/EditorInput.types.js.map +1 -1
  11. package/lib/components/EditorInput/index.js +1 -0
  12. package/lib/components/EditorInput/index.js.map +1 -1
  13. package/lib/components/EditorInput/renderEditorInput.js +10 -9
  14. package/lib/components/EditorInput/renderEditorInput.js.map +1 -1
  15. package/lib/components/EditorInput/useEditorInput.js +18 -63
  16. package/lib/components/EditorInput/useEditorInput.js.map +1 -1
  17. package/lib/components/EditorInput/useEditorInputContextValues.js +16 -0
  18. package/lib/components/EditorInput/useEditorInputContextValues.js.map +1 -0
  19. package/lib/components/EditorInput/useEditorInputStyles.styles.js +0 -7
  20. package/lib/components/EditorInput/useEditorInputStyles.styles.js.map +1 -1
  21. package/lib/components/EditorInput/useEditorInputStyles.styles.raw.js +0 -7
  22. package/lib/components/EditorInput/useEditorInputStyles.styles.raw.js.map +1 -1
  23. package/lib/index.js +1 -1
  24. package/lib/index.js.map +1 -1
  25. package/lib/utilities/useCanShowPlaceholder.js +18 -0
  26. package/lib/utilities/useCanShowPlaceholder.js.map +1 -0
  27. package/lib/utilities/useLexicalContentEditable.js +69 -0
  28. package/lib/utilities/useLexicalContentEditable.js.map +1 -0
  29. package/lib/utilities/useLexicalEditor.js +63 -0
  30. package/lib/utilities/useLexicalEditor.js.map +1 -0
  31. package/lib-commonjs/EditorInput.js +3 -0
  32. package/lib-commonjs/EditorInput.js.map +1 -1
  33. package/lib-commonjs/components/AnimatedPlaceholder/renderAnimatedPlaceholder.js.map +1 -1
  34. package/lib-commonjs/components/EditorInput/EditorInput.js +3 -1
  35. package/lib-commonjs/components/EditorInput/EditorInput.js.map +1 -1
  36. package/lib-commonjs/components/EditorInput/EditorInput.types.js +1 -3
  37. package/lib-commonjs/components/EditorInput/EditorInput.types.js.map +1 -1
  38. package/lib-commonjs/components/EditorInput/index.js +4 -0
  39. package/lib-commonjs/components/EditorInput/index.js.map +1 -1
  40. package/lib-commonjs/components/EditorInput/renderEditorInput.js +9 -8
  41. package/lib-commonjs/components/EditorInput/renderEditorInput.js.map +1 -1
  42. package/lib-commonjs/components/EditorInput/useEditorInput.js +14 -58
  43. package/lib-commonjs/components/EditorInput/useEditorInput.js.map +1 -1
  44. package/lib-commonjs/components/EditorInput/useEditorInputContextValues.js +27 -0
  45. package/lib-commonjs/components/EditorInput/useEditorInputContextValues.js.map +1 -0
  46. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.js +0 -7
  47. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.js.map +1 -1
  48. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.raw.js +0 -7
  49. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.raw.js.map +1 -1
  50. package/lib-commonjs/index.js +12 -0
  51. package/lib-commonjs/index.js.map +1 -1
  52. package/lib-commonjs/utilities/useCanShowPlaceholder.js +29 -0
  53. package/lib-commonjs/utilities/useCanShowPlaceholder.js.map +1 -0
  54. package/lib-commonjs/utilities/useLexicalContentEditable.js +80 -0
  55. package/lib-commonjs/utilities/useLexicalContentEditable.js.map +1 -0
  56. package/lib-commonjs/utilities/useLexicalEditor.js +72 -0
  57. package/lib-commonjs/utilities/useLexicalEditor.js.map +1 -0
  58. package/package.json +13 -13
package/CHANGELOG.json CHANGED
@@ -2,7 +2,63 @@
2
2
  "name": "@fluentui-copilot/react-editor-input",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 29 Sep 2025 20:25:10 GMT",
5
+ "date": "Wed, 22 Oct 2025 17:50:54 GMT",
6
+ "tag": "@fluentui-copilot/react-editor-input_v0.6.0",
7
+ "version": "0.6.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "owcampbe@microsoft.com",
12
+ "package": "@fluentui-copilot/react-editor-input",
13
+ "commit": "299198d77b3c35a345d0eec00495557dddd45d00",
14
+ "comment": "feat: Initialize lexical and render placeholder internally."
15
+ }
16
+ ],
17
+ "none": [
18
+ {
19
+ "author": "hochelmartin@gmail.com",
20
+ "package": "@fluentui-copilot/react-editor-input",
21
+ "commit": "85efb411485b778327290c03aacb479fc9779dab",
22
+ "comment": "chore: migrate to dts generation against public api instead of internal path aliases tsc resolution"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "date": "Tue, 14 Oct 2025 00:04:49 GMT",
29
+ "tag": "@fluentui-copilot/react-editor-input_v0.5.7",
30
+ "version": "0.5.7",
31
+ "comments": {
32
+ "patch": [
33
+ {
34
+ "author": "tristan.watanabe@gmail.com",
35
+ "package": "@fluentui-copilot/react-editor-input",
36
+ "commit": "ced6fa3a284cc90eae5ca16357e15b349f720ca0",
37
+ "comment": "fix: migrate to React 19 compatible JSX and Ref types."
38
+ },
39
+ {
40
+ "author": "tristan.watanabe@gmail.com",
41
+ "package": "@fluentui-copilot/react-editor-input",
42
+ "commit": "74cfcbd7c8afdc8fe3f4b512a9a421613fa32841",
43
+ "comment": "chore: update react peer deps to support React 19."
44
+ },
45
+ {
46
+ "author": "tristan.watanabe@gmail.com",
47
+ "package": "@fluentui-copilot/react-editor-input",
48
+ "commit": "9a3bf49a3c6302529b2c9b6bc3fc63f549aaf88f",
49
+ "comment": "chore: enforce explicit return types."
50
+ },
51
+ {
52
+ "author": "twatanabe@microsoft.com",
53
+ "package": "@fluentui-copilot/react-editor-input",
54
+ "commit": "068a3c71be5da80beeab05640fe768ef631b0c00",
55
+ "comment": "chore: bump @fluentui/react-components peer dep minbar to ^9.70.0."
56
+ }
57
+ ]
58
+ }
59
+ },
60
+ {
61
+ "date": "Mon, 29 Sep 2025 20:26:50 GMT",
6
62
  "tag": "@fluentui-copilot/react-editor-input_v0.5.6",
7
63
  "version": "0.5.6",
8
64
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,33 @@
1
1
  # Change Log - @fluentui-copilot/react-editor-input
2
2
 
3
- This log was last generated on Mon, 29 Sep 2025 20:25:10 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 22 Oct 2025 17:50:54 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.6.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.6.0)
8
+
9
+ Wed, 22 Oct 2025 17:50:54 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-editor-input_v0.5.7..@fluentui-copilot/react-editor-input_v0.6.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: Initialize lexical and render placeholder internally. ([PR #3085](https://github.com/microsoft/fluentai/pull/3085) by owcampbe@microsoft.com)
15
+
16
+ ## [0.5.7](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.5.7)
17
+
18
+ Tue, 14 Oct 2025 00:04:49 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-editor-input_v0.5.6..@fluentui-copilot/react-editor-input_v0.5.7)
20
+
21
+ ### Patches
22
+
23
+ - fix: migrate to React 19 compatible JSX and Ref types. ([PR #3355](https://github.com/microsoft/fluentai/pull/3355) by tristan.watanabe@gmail.com)
24
+ - chore: update react peer deps to support React 19. ([PR #3361](https://github.com/microsoft/fluentai/pull/3361) by tristan.watanabe@gmail.com)
25
+ - chore: enforce explicit return types. ([PR #3360](https://github.com/microsoft/fluentai/pull/3360) by tristan.watanabe@gmail.com)
26
+ - chore: bump @fluentui/react-components peer dep minbar to ^9.70.0. ([PR #3344](https://github.com/microsoft/fluentai/pull/3344) by twatanabe@microsoft.com)
27
+
7
28
  ## [0.5.6](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.5.6)
8
29
 
9
- Mon, 29 Sep 2025 20:25:10 GMT
30
+ Mon, 29 Sep 2025 20:26:50 GMT
10
31
  [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-editor-input_v0.5.5..@fluentui-copilot/react-editor-input_v0.5.6)
11
32
 
12
33
  ### Patches
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ import type { ComponentProps } from '@fluentui/react-components';
4
4
  import type { ComponentState } from '@fluentui/react-components';
5
5
  import type { ForwardRefComponent } from '@fluentui/react-components';
6
6
  import type { InitialConfigType } from '@fluentui-copilot/react-text-editor';
7
+ import type { JSXElement } from '@fluentui/react-components';
8
+ import type { LexicalComposerContextWithEditor } from '@fluentui-copilot/react-text-editor';
7
9
  import type { LexicalEditor } from '@fluentui-copilot/react-text-editor';
8
10
  import type { LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';
9
11
  import type { PresenceMotionSlotProps } from '@fluentui/react-motion';
@@ -40,6 +42,10 @@ export declare const EditorInput: ForwardRefComponent<EditorInputProps>;
40
42
 
41
43
  export declare const editorInputClassNames: SlotClassNames<EditorInputSlots>;
42
44
 
45
+ export declare type EditorInputContextValues = {
46
+ lexicalComposer: LexicalComposerContextWithEditor;
47
+ };
48
+
43
49
  /**
44
50
  * EditorInput Props
45
51
  */
@@ -85,7 +91,7 @@ export declare type EditorInputProps = Omit<ComponentProps<Partial<EditorInputSl
85
91
  * @default true
86
92
  */
87
93
  history?: boolean;
88
- editorRef?: React.RefObject<LexicalEditor>;
94
+ editorRef?: React.RefObject<LexicalEditor | null>;
89
95
  /**
90
96
  * Customize the default styles of elements inserted by Lexical in the editor.
91
97
  */
@@ -107,9 +113,10 @@ export declare type EditorInputSlots = {
107
113
  /**
108
114
  * State used in rendering EditorInput
109
115
  */
110
- export declare type EditorInputState = ComponentState<EditorInputSlots> & Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'editorRef' | 'isSentinelNodeEnabled'>> & Partial<Pick<EditorInputProps, 'onPaste'>> & {
111
- lexicalInitialConfig: InitialConfigType;
116
+ export declare type EditorInputState = ComponentState<EditorInputSlots> & Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'isSentinelNodeEnabled'>> & Partial<Pick<EditorInputProps, 'editorRef' | 'onPaste'>> & {
112
117
  handleOnChange: (value: string) => void;
118
+ lexicalEditor: LexicalEditor;
119
+ lexicalInitialConfig: InitialConfigType;
113
120
  };
114
121
 
115
122
  /**
@@ -122,12 +129,12 @@ export declare type EditorInputValueData = {
122
129
  /**
123
130
  * Render the final JSX of AnimatedPlaceholder
124
131
  */
125
- export declare const renderAnimatedPlaceholder_unstable: (state: AnimatedPlaceholderState) => JSX.Element;
132
+ export declare const renderAnimatedPlaceholder_unstable: (state: AnimatedPlaceholderState) => JSXElement;
126
133
 
127
134
  /**
128
135
  * Render the final JSX of EditorInput
129
136
  */
130
- export declare const renderEditorInput_unstable: (state: EditorInputState) => JSX.Element;
137
+ export declare const renderEditorInput_unstable: (state: EditorInputState, contextValues: EditorInputContextValues) => JSXElement;
131
138
 
132
139
  /**
133
140
  * Create the state required to render AnimatedPlaceholder.
@@ -156,9 +163,17 @@ export declare const useAnimatedPlaceholderStyles_unstable: (state: AnimatedPlac
156
163
  */
157
164
  export declare const useEditorInput_unstable: (props: EditorInputProps, ref: React_2.Ref<HTMLSpanElement>) => EditorInputState;
158
165
 
166
+ export declare function useEditorInputContextValues(state: EditorInputState): EditorInputContextValues;
167
+
159
168
  /**
160
169
  * Apply styling to the EditorInput slots based on the state
161
170
  */
162
171
  export declare const useEditorInputStyles_unstable: (state: EditorInputState) => EditorInputState;
163
172
 
173
+ export declare const useInputClassName: () => string;
174
+
175
+ export declare const useLexicalStyles: () => Record<"paragraph", string>;
176
+
177
+ export declare const usePlaceholderClassName: () => string;
178
+
164
179
  export { }
@@ -1 +1 @@
1
- export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './components/EditorInput/index';
1
+ export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputContextValues, useEditorInputStyles_unstable, useEditorInput_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './components/EditorInput/index';
@@ -1 +1 @@
1
- {"version":3,"sources":["EditorInput.ts"],"sourcesContent":["export type { EditorInputProps, EditorInputSlots, EditorInputState, EditorInputValueData } from './components/EditorInput/index';\nexport { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './components/EditorInput/index';\n"],"names":["EditorInput","editorInputClassNames","renderEditorInput_unstable","useEditorInputStyles_unstable","useEditorInput_unstable","useInputClassName","useLexicalStyles","usePlaceholderClassName"],"rangeMappings":"","mappings":"AACA,SAASA,WAAW,EAAEC,qBAAqB,EAAEC,0BAA0B,EAAEC,6BAA6B,EAAEC,uBAAuB,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,uBAAuB,QAAQ,iCAAiC"}
1
+ {"version":3,"sources":["EditorInput.ts"],"sourcesContent":["export {\n EditorInput,\n editorInputClassNames,\n renderEditorInput_unstable,\n useEditorInputContextValues,\n useEditorInputStyles_unstable,\n useEditorInput_unstable,\n useInputClassName,\n useLexicalStyles,\n usePlaceholderClassName,\n} from './components/EditorInput/index';\nexport type {\n EditorInputContextValues,\n EditorInputProps,\n EditorInputSlots,\n EditorInputState,\n EditorInputValueData,\n} from './components/EditorInput/index';\n"],"names":["EditorInput","editorInputClassNames","renderEditorInput_unstable","useEditorInputContextValues","useEditorInputStyles_unstable","useEditorInput_unstable","useInputClassName","useLexicalStyles","usePlaceholderClassName"],"rangeMappings":"","mappings":"AAAA,SACEA,WAAW,EACXC,qBAAqB,EACrBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,uBAAuB,EACvBC,iBAAiB,EACjBC,gBAAgB,EAChBC,uBAAuB,QAClB,iCAAiC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["renderAnimatedPlaceholder.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { AnimatedPlaceholderState, AnimatedPlaceholderSlots } from './AnimatedPlaceholder.types';\n\n/**\n * Render the final JSX of AnimatedPlaceholder\n */\nexport const renderAnimatedPlaceholder_unstable = (state: AnimatedPlaceholderState) => {\n assertSlots<AnimatedPlaceholderSlots>(state);\n\n return (\n <state.root>\n <state.motion>\n <state.placeholder />\n </state.motion>\n </state.root>\n );\n};\n"],"names":["assertSlots","renderAnimatedPlaceholder_unstable","state","root","motion","placeholder"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAGzD;;CAEC,GACD,OAAO,MAAMC,qCAAqC,CAACC;IACjDF,YAAsCE;IAEtC,qBACE,KAACA,MAAMC,IAAI;kBACT,cAAA,KAACD,MAAME,MAAM;sBACX,cAAA,KAACF,MAAMG,WAAW;;;AAI1B,EAAE"}
1
+ {"version":3,"sources":["renderAnimatedPlaceholder.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { JSXElement } from '@fluentui/react-components';\nimport type { AnimatedPlaceholderState, AnimatedPlaceholderSlots } from './AnimatedPlaceholder.types';\n\n/**\n * Render the final JSX of AnimatedPlaceholder\n */\nexport const renderAnimatedPlaceholder_unstable = (state: AnimatedPlaceholderState): JSXElement => {\n assertSlots<AnimatedPlaceholderSlots>(state);\n\n return (\n <state.root>\n <state.motion>\n <state.placeholder />\n </state.motion>\n </state.root>\n );\n};\n"],"names":["assertSlots","renderAnimatedPlaceholder_unstable","state","root","motion","placeholder"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAIzD;;CAEC,GACD,OAAO,MAAMC,qCAAqC,CAACC;IACjDF,YAAsCE;IAEtC,qBACE,KAACA,MAAMC,IAAI;kBACT,cAAA,KAACD,MAAME,MAAM;sBACX,cAAA,KAACF,MAAMG,WAAW;;;AAI1B,EAAE"}
@@ -2,10 +2,12 @@ import * as React from 'react';
2
2
  import { useEditorInput_unstable } from './useEditorInput';
3
3
  import { renderEditorInput_unstable } from './renderEditorInput';
4
4
  import { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';
5
+ import { useEditorInputContextValues } from './useEditorInputContextValues';
5
6
  // EditorInput component - TODO: add more docs
6
7
  export const EditorInput = /*#__PURE__*/ React.forwardRef((props, ref)=>{
7
8
  const state = useEditorInput_unstable(props, ref);
9
+ const contextValues = useEditorInputContextValues(state);
8
10
  useEditorInputStyles_unstable(state);
9
- return renderEditorInput_unstable(state);
11
+ return renderEditorInput_unstable(state, contextValues);
10
12
  });
11
13
  EditorInput.displayName = 'EditorInput';
@@ -1 +1 @@
1
- {"version":3,"sources":["EditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useEditorInput_unstable } from './useEditorInput';\nimport { renderEditorInput_unstable } from './renderEditorInput';\nimport { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';\nimport type { EditorInputProps } from './EditorInput.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n// EditorInput component - TODO: add more docs\nexport const EditorInput: ForwardRefComponent<EditorInputProps> = React.forwardRef((props, ref) => {\n const state = useEditorInput_unstable(props, ref);\n\n useEditorInputStyles_unstable(state);\n return renderEditorInput_unstable(state);\n});\n\nEditorInput.displayName = 'EditorInput';\n"],"names":["React","useEditorInput_unstable","renderEditorInput_unstable","useEditorInputStyles_unstable","EditorInput","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,gCAAgC;AAI9E,8CAA8C;AAC9C,OAAO,MAAMC,4BAAqDJ,MAAMK,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQP,wBAAwBK,OAAOC;IAE7CJ,8BAA8BK;IAC9B,OAAON,2BAA2BM;AACpC,GAAG;AAEHJ,YAAYK,WAAW,GAAG"}
1
+ {"version":3,"sources":["EditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useEditorInput_unstable } from './useEditorInput';\nimport { renderEditorInput_unstable } from './renderEditorInput';\nimport { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';\nimport type { EditorInputProps } from './EditorInput.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\nimport { useEditorInputContextValues } from './useEditorInputContextValues';\n\n// EditorInput component - TODO: add more docs\nexport const EditorInput: ForwardRefComponent<EditorInputProps> = React.forwardRef((props, ref) => {\n const state = useEditorInput_unstable(props, ref);\n const contextValues = useEditorInputContextValues(state);\n\n useEditorInputStyles_unstable(state);\n return renderEditorInput_unstable(state, contextValues);\n});\n\nEditorInput.displayName = 'EditorInput';\n"],"names":["React","useEditorInput_unstable","renderEditorInput_unstable","useEditorInputStyles_unstable","useEditorInputContextValues","EditorInput","forwardRef","props","ref","state","contextValues","displayName"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,gCAAgC;AAG9E,SAASC,2BAA2B,QAAQ,gCAAgC;AAE5E,8CAA8C;AAC9C,OAAO,MAAMC,4BAAqDL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQR,wBAAwBM,OAAOC;IAC7C,MAAME,gBAAgBN,4BAA4BK;IAElDN,8BAA8BM;IAC9B,OAAOP,2BAA2BO,OAAOC;AAC3C,GAAG;AAEHL,YAAYM,WAAW,GAAG"}
@@ -1,3 +1 @@
1
- /**
2
- * Data passed to the `onChange` callback when the chat input's value changes.
3
- */ export { };
1
+ export { };
@@ -1 +1 @@
1
- {"version":3,"sources":["EditorInput.types.ts"],"sourcesContent":["import type { InitialConfigType, LexicalEditor, LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type EditorInputSlots = {\n root: NonNullable<Slot<'span'>>;\n input: NonNullable<Slot<'span'>>;\n placeholderValue?: Slot<'span'>;\n};\n\n/**\n * EditorInput Props\n */\nexport type EditorInputProps = Omit<\n ComponentProps<Partial<EditorInputSlots>, 'input'>,\n 'onChange' | 'onPaste' | 'defaultValue' | 'onSubmit'\n> & {\n disabled?: boolean;\n /**\n * If defaultValue is a string, it will be added to the input on first render.\n * If defaultValue is a function, it can call lexical $ functions to imperatively set the initial content with more complex nodes.\n */\n defaultValue?: string | (() => void);\n /**\n * Called when the default value is given to the editor.\n * If `defaultValue` was a function, this will be called with the state of the editor after\n * calling that function.\n * If `defaultValue` was a string, this will be called with the same string.\n */\n onDefaultValueSet?: (defaultValue: string) => void;\n /**\n * Callback for when the user changes the value.\n * TODO: Add proper event type for callback\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange?: (ev: any, data: EditorInputValueData) => void;\n /**\n * Callback for when content is pasted into the Editor.\n */\n onPaste?: (ev: ClipboardEvent) => void;\n /**\n * When true, the input will be cleared when only whitespace is remaining.\n * @default false\n */\n trimWhiteSpace?: boolean;\n /**\n * Used to register any custom nodes used by plugins added. Can also be used to override the default nodes.\n */\n customNodes?: InitialConfigType['nodes'];\n /**\n * The plugin which is in charge of initializing Lexical and is given the `input` and `placeholder` slots\n * @default LexicalPlainTextPlugin\n */\n textPlugin?: typeof LexicalPlainTextPlugin;\n /**\n * Controls whether history is tracked to provide undo and redo functionality\n * @default true\n */\n history?: boolean;\n\n editorRef?: React.RefObject<LexicalEditor>;\n\n /**\n * Customize the default styles of elements inserted by Lexical in the editor.\n */\n customTheme?: InitialConfigType['theme'];\n\n /**\n * Whether or not to enable the sentinel node. The sentinel node is a node that is inserted at the end of the editor\n * The SentinelNode fixes a Safari bug in lexical versions below 0.20.1\n * @default true\n */\n isSentinelNodeEnabled?: boolean;\n};\n\n/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<\n Pick<\n EditorInputProps,\n 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'editorRef' | 'isSentinelNodeEnabled'\n >\n > &\n Partial<Pick<EditorInputProps, 'onPaste'>> & {\n lexicalInitialConfig: InitialConfigType;\n handleOnChange: (value: string) => void;\n };\n\n/**\n * Data passed to the `onChange` callback when the chat input's value changes.\n */\nexport type EditorInputValueData = {\n value: string;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAyFA;;CAEC,GACD,WAEE"}
1
+ {"version":3,"sources":["EditorInput.types.ts"],"sourcesContent":["import type {\n InitialConfigType,\n LexicalComposerContextWithEditor,\n LexicalEditor,\n LexicalPlainTextPlugin,\n} from '@fluentui-copilot/react-text-editor';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type EditorInputSlots = {\n root: NonNullable<Slot<'span'>>;\n input: NonNullable<Slot<'span'>>;\n placeholderValue?: Slot<'span'>;\n};\n\n/**\n * EditorInput Props\n */\nexport type EditorInputProps = Omit<\n ComponentProps<Partial<EditorInputSlots>, 'input'>,\n 'onChange' | 'onPaste' | 'defaultValue' | 'onSubmit'\n> & {\n disabled?: boolean;\n /**\n * If defaultValue is a string, it will be added to the input on first render.\n * If defaultValue is a function, it can call lexical $ functions to imperatively set the initial content with more complex nodes.\n */\n defaultValue?: string | (() => void);\n /**\n * Called when the default value is given to the editor.\n * If `defaultValue` was a function, this will be called with the state of the editor after\n * calling that function.\n * If `defaultValue` was a string, this will be called with the same string.\n */\n onDefaultValueSet?: (defaultValue: string) => void;\n /**\n * Callback for when the user changes the value.\n * TODO: Add proper event type for callback\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange?: (ev: any, data: EditorInputValueData) => void;\n /**\n * Callback for when content is pasted into the Editor.\n */\n onPaste?: (ev: ClipboardEvent) => void;\n /**\n * When true, the input will be cleared when only whitespace is remaining.\n * @default false\n */\n trimWhiteSpace?: boolean;\n /**\n * Used to register any custom nodes used by plugins added. Can also be used to override the default nodes.\n */\n customNodes?: InitialConfigType['nodes'];\n /**\n * The plugin which is in charge of initializing Lexical and is given the `input` and `placeholder` slots\n * @default LexicalPlainTextPlugin\n */\n textPlugin?: typeof LexicalPlainTextPlugin;\n /**\n * Controls whether history is tracked to provide undo and redo functionality\n * @default true\n */\n history?: boolean;\n\n editorRef?: React.RefObject<LexicalEditor | null>;\n\n /**\n * Customize the default styles of elements inserted by Lexical in the editor.\n */\n customTheme?: InitialConfigType['theme'];\n\n /**\n * Whether or not to enable the sentinel node. The sentinel node is a node that is inserted at the end of the editor\n * The SentinelNode fixes a Safari bug in lexical versions below 0.20.1\n * @default true\n */\n isSentinelNodeEnabled?: boolean;\n};\n\n/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'isSentinelNodeEnabled'>> &\n Partial<Pick<EditorInputProps, 'editorRef' | 'onPaste'>> & {\n handleOnChange: (value: string) => void;\n lexicalEditor: LexicalEditor;\n lexicalInitialConfig: InitialConfigType;\n };\n\n/**\n * Data passed to the `onChange` callback when the chat input's value changes.\n */\nexport type EditorInputValueData = {\n value: string;\n};\n\nexport type EditorInputContextValues = {\n lexicalComposer: LexicalComposerContextWithEditor;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAiGA,WAEE"}
@@ -2,3 +2,4 @@ export { EditorInput } from './EditorInput';
2
2
  export { renderEditorInput_unstable } from './renderEditorInput';
3
3
  export { useEditorInput_unstable } from './useEditorInput';
4
4
  export { editorInputClassNames, useEditorInputStyles_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './useEditorInputStyles.styles';
5
+ export { useEditorInputContextValues } from './useEditorInputContextValues';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export { EditorInput } from './EditorInput';\nexport type { EditorInputProps, EditorInputSlots, EditorInputState, EditorInputValueData } from './EditorInput.types';\nexport { renderEditorInput_unstable } from './renderEditorInput';\nexport { useEditorInput_unstable } from './useEditorInput';\nexport { editorInputClassNames, useEditorInputStyles_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './useEditorInputStyles.styles';\n"],"names":["EditorInput","renderEditorInput_unstable","useEditorInput_unstable","editorInputClassNames","useEditorInputStyles_unstable","useInputClassName","useLexicalStyles","usePlaceholderClassName"],"rangeMappings":";;;","mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAE5C,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,qBAAqB,EAAEC,6BAA6B,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,uBAAuB,QAAQ,gCAAgC"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { EditorInput } from './EditorInput';\nexport type {\n EditorInputProps,\n EditorInputSlots,\n EditorInputState,\n EditorInputValueData,\n EditorInputContextValues,\n} from './EditorInput.types';\nexport { renderEditorInput_unstable } from './renderEditorInput';\nexport { useEditorInput_unstable } from './useEditorInput';\nexport {\n editorInputClassNames,\n useEditorInputStyles_unstable,\n useInputClassName,\n useLexicalStyles,\n usePlaceholderClassName,\n} from './useEditorInputStyles.styles';\nexport { useEditorInputContextValues } from './useEditorInputContextValues';\n"],"names":["EditorInput","renderEditorInput_unstable","useEditorInput_unstable","editorInputClassNames","useEditorInputStyles_unstable","useInputClassName","useLexicalStyles","usePlaceholderClassName","useEditorInputContextValues"],"rangeMappings":";;;;","mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAQ5C,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SACEC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iBAAiB,EACjBC,gBAAgB,EAChBC,uBAAuB,QAClB,gCAAgC;AACvC,SAASC,2BAA2B,QAAQ,gCAAgC"}
@@ -1,33 +1,34 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
2
  import { assertSlots } from '@fluentui/react-components';
3
- import { LexicalComposer, LexicalErrorBoundary, LexicalEditorRefPlugin, LexicalHistoryPlugin } from '@fluentui-copilot/react-text-editor';
3
+ import { LexicalErrorBoundary, LexicalEditorRefPlugin, LexicalHistoryPlugin, LexicalComposerContext } from '@fluentui-copilot/react-text-editor';
4
4
  import { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';
5
5
  /**
6
6
  * Render the final JSX of EditorInput
7
- */ export const renderEditorInput_unstable = (state)=>{
7
+ */ export const renderEditorInput_unstable = (state, contextValues)=>{
8
8
  assertSlots(state);
9
9
  return /*#__PURE__*/ _jsx(state.root, {
10
- children: /*#__PURE__*/ _jsxs(LexicalComposer, {
11
- initialConfig: state.lexicalInitialConfig,
10
+ children: /*#__PURE__*/ _jsxs(LexicalComposerContext.Provider, {
11
+ value: contextValues.lexicalComposer,
12
12
  children: [
13
13
  /*#__PURE__*/ _jsx(state.textPlugin, {
14
14
  contentEditable: /*#__PURE__*/ _jsx(state.input, {}),
15
15
  ErrorBoundary: LexicalErrorBoundary,
16
- placeholder: state.placeholderValue ? /*#__PURE__*/ _jsx(state.placeholderValue, {}) : null
16
+ placeholder: null
17
17
  }),
18
18
  /*#__PURE__*/ _jsxs(_Fragment, {
19
19
  children: [
20
+ state.placeholderValue ? /*#__PURE__*/ _jsx(state.placeholderValue, {}) : null,
20
21
  /*#__PURE__*/ _jsx(BasicFunctionalityPlugin, {
21
22
  onContentChange: state.handleOnChange,
22
23
  onPaste: state.onPaste,
23
24
  trimWhitespace: state.trimWhiteSpace,
24
25
  isSentinelNodeEnabled: state.isSentinelNodeEnabled
25
26
  }),
26
- state.history && /*#__PURE__*/ _jsx(LexicalHistoryPlugin, {})
27
+ state.history && /*#__PURE__*/ _jsx(LexicalHistoryPlugin, {}),
28
+ state.editorRef && /*#__PURE__*/ _jsx(LexicalEditorRefPlugin, {
29
+ editorRef: state.editorRef
30
+ })
27
31
  ]
28
- }),
29
- /*#__PURE__*/ _jsx(LexicalEditorRefPlugin, {
30
- editorRef: state.editorRef
31
32
  })
32
33
  ]
33
34
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["renderEditorInput.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { EditorInputState, EditorInputSlots } from './EditorInput.types';\nimport {\n LexicalComposer,\n LexicalErrorBoundary,\n LexicalEditorRefPlugin,\n LexicalHistoryPlugin,\n} from '@fluentui-copilot/react-text-editor';\nimport { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';\n\n/**\n * Render the final JSX of EditorInput\n */\nexport const renderEditorInput_unstable = (state: EditorInputState) => {\n assertSlots<EditorInputSlots>(state);\n\n return (\n <state.root>\n <LexicalComposer initialConfig={state.lexicalInitialConfig}>\n <state.textPlugin\n contentEditable={<state.input />}\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={state.placeholderValue ? <state.placeholderValue /> : null}\n />\n <>\n <BasicFunctionalityPlugin\n onContentChange={state.handleOnChange}\n onPaste={state.onPaste}\n trimWhitespace={state.trimWhiteSpace}\n isSentinelNodeEnabled={state.isSentinelNodeEnabled}\n />\n {state.history && <LexicalHistoryPlugin />}\n </>\n <LexicalEditorRefPlugin editorRef={state.editorRef} />\n </LexicalComposer>\n </state.root>\n );\n};\n"],"names":["assertSlots","LexicalComposer","LexicalErrorBoundary","LexicalEditorRefPlugin","LexicalHistoryPlugin","BasicFunctionalityPlugin","renderEditorInput_unstable","state","root","initialConfig","lexicalInitialConfig","textPlugin","contentEditable","input","ErrorBoundary","placeholder","placeholderValue","onContentChange","handleOnChange","onPaste","trimWhitespace","trimWhiteSpace","isSentinelNodeEnabled","history","editorRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAEzD,SACEC,eAAe,EACfC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,QACf,sCAAsC;AAC7C,SAASC,wBAAwB,QAAQ,6CAA6C;AAEtF;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CAACC;IACzCP,YAA8BO;IAE9B,qBACE,KAACA,MAAMC,IAAI;kBACT,cAAA,MAACP;YAAgBQ,eAAeF,MAAMG,oBAAoB;;8BACxD,KAACH,MAAMI,UAAU;oBACfC,+BAAiB,KAACL,MAAMM,KAAK;oBAC7BC,eAAeZ;oBACfa,aAAaR,MAAMS,gBAAgB,iBAAG,KAACT,MAAMS,gBAAgB,QAAM;;8BAErE;;sCACE,KAACX;4BACCY,iBAAiBV,MAAMW,cAAc;4BACrCC,SAASZ,MAAMY,OAAO;4BACtBC,gBAAgBb,MAAMc,cAAc;4BACpCC,uBAAuBf,MAAMe,qBAAqB;;wBAEnDf,MAAMgB,OAAO,kBAAI,KAACnB;;;8BAErB,KAACD;oBAAuBqB,WAAWjB,MAAMiB,SAAS;;;;;AAI1D,EAAE"}
1
+ {"version":3,"sources":["renderEditorInput.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { JSXElement } from '@fluentui/react-components';\nimport {\n LexicalErrorBoundary,\n LexicalEditorRefPlugin,\n LexicalHistoryPlugin,\n LexicalComposerContext,\n} from '@fluentui-copilot/react-text-editor';\nimport { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';\nimport type { EditorInputState, EditorInputContextValues, EditorInputSlots } from './EditorInput.types';\n\n/**\n * Render the final JSX of EditorInput\n */\nexport const renderEditorInput_unstable = (\n state: EditorInputState,\n contextValues: EditorInputContextValues,\n): JSXElement => {\n assertSlots<EditorInputSlots>(state);\n\n return (\n <state.root>\n <LexicalComposerContext.Provider value={contextValues.lexicalComposer}>\n <state.textPlugin contentEditable={<state.input />} ErrorBoundary={LexicalErrorBoundary} placeholder={null} />\n <>\n {state.placeholderValue ? <state.placeholderValue /> : null}\n <BasicFunctionalityPlugin\n onContentChange={state.handleOnChange}\n onPaste={state.onPaste}\n trimWhitespace={state.trimWhiteSpace}\n isSentinelNodeEnabled={state.isSentinelNodeEnabled}\n />\n {state.history && <LexicalHistoryPlugin />}\n {state.editorRef && <LexicalEditorRefPlugin editorRef={state.editorRef} />}\n </>\n </LexicalComposerContext.Provider>\n </state.root>\n );\n};\n"],"names":["assertSlots","LexicalErrorBoundary","LexicalEditorRefPlugin","LexicalHistoryPlugin","LexicalComposerContext","BasicFunctionalityPlugin","renderEditorInput_unstable","state","contextValues","root","Provider","value","lexicalComposer","textPlugin","contentEditable","input","ErrorBoundary","placeholder","placeholderValue","onContentChange","handleOnChange","onPaste","trimWhitespace","trimWhiteSpace","isSentinelNodeEnabled","history","editorRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAEzD,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,EACpBC,sBAAsB,QACjB,sCAAsC;AAC7C,SAASC,wBAAwB,QAAQ,6CAA6C;AAGtF;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEAR,YAA8BO;IAE9B,qBACE,KAACA,MAAME,IAAI;kBACT,cAAA,MAACL,uBAAuBM,QAAQ;YAACC,OAAOH,cAAcI,eAAe;;8BACnE,KAACL,MAAMM,UAAU;oBAACC,+BAAiB,KAACP,MAAMQ,KAAK;oBAAKC,eAAef;oBAAsBgB,aAAa;;8BACtG;;wBACGV,MAAMW,gBAAgB,iBAAG,KAACX,MAAMW,gBAAgB,QAAM;sCACvD,KAACb;4BACCc,iBAAiBZ,MAAMa,cAAc;4BACrCC,SAASd,MAAMc,OAAO;4BACtBC,gBAAgBf,MAAMgB,cAAc;4BACpCC,uBAAuBjB,MAAMiB,qBAAqB;;wBAEnDjB,MAAMkB,OAAO,kBAAI,KAACtB;wBAClBI,MAAMmB,SAAS,kBAAI,KAACxB;4BAAuBwB,WAAWnB,MAAMmB,SAAS;;;;;;;AAKhF,EAAE"}
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
- import { getPartitionedNativeProps, slot, useFluent, useId, useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-components';
3
- import { SentinelNode, SENTINEL_VALUE } from '@fluentui-copilot/chat-input-plugins';
2
+ import { getPartitionedNativeProps, slot, useFluent, useId, useMergedRefs } from '@fluentui/react-components';
3
+ import { SENTINEL_VALUE } from '@fluentui-copilot/chat-input-plugins';
4
4
  import { $createTextNode, $insertNodes } from '@fluentui-copilot/react-text-editor';
5
5
  import { $getRoot } from '@fluentui-copilot/react-text-editor';
6
- import { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';
7
- import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities';
6
+ import { LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';
7
+ import { mergeCallbacks } from '@fluentui/react-utilities';
8
+ import { useLexicalContentEditable } from '../../utilities/useLexicalContentEditable';
8
9
  /**
9
10
  * Create the state required to render EditorInput.
10
11
  *
@@ -14,7 +15,7 @@ import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities'
14
15
  * @param props - props from this instance of EditorInput
15
16
  * @param ref - reference to root HTMLElement of EditorInput
16
17
  */ export const useEditorInput_unstable = (props, ref)=>{
17
- const { onChange, onPaste, trimWhiteSpace = false, textPlugin = LexicalPlainTextPlugin, history = true, editorRef: userEditorRef, customTheme, isSentinelNodeEnabled = true } = props;
18
+ const { onChange, onPaste, trimWhiteSpace = false, textPlugin = LexicalPlainTextPlugin, history = true, editorRef, isSentinelNodeEnabled = true } = props;
18
19
  const { root, primary } = getPartitionedNativeProps({
19
20
  primarySlotTagName: 'span',
20
21
  props,
@@ -24,52 +25,6 @@ import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities'
24
25
  'defaultValue'
25
26
  ]
26
27
  });
27
- const editorRef = useMergedRefs(React.useRef(null), userEditorRef);
28
- // The disabled state can also be changed by lexical (e.g. by a custom plugin) so
29
- // we use `useControllableState` to coordinate
30
- const [disabled, setDisabled] = useControllableState({
31
- state: props.disabled,
32
- initialState: false
33
- });
34
- const customNodes = props.customNodes ? [
35
- ...props.customNodes,
36
- SentinelNode
37
- ] : [
38
- SentinelNode
39
- ];
40
- const spanRef = React.useCallback((span)=>{
41
- var // Register the `input` span with lexical
42
- _editorRef_current;
43
- (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setRootElement(span);
44
- }, [
45
- editorRef
46
- ]);
47
- // Update lexical when disabled changes
48
- useIsomorphicLayoutEffect(()=>{
49
- if (editorRef.current) {
50
- var _editorRef_current;
51
- (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setEditable(!disabled);
52
- }
53
- }, [
54
- disabled
55
- ]);
56
- useIsomorphicLayoutEffect(()=>{
57
- if (editorRef.current) {
58
- var _editorRef_current;
59
- return mergeRegister(editorRef.current.registerEditableListener((isEditable)=>{
60
- setDisabled(!isEditable);
61
- }), (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.registerRootListener((root)=>{
62
- if (!root) {
63
- return;
64
- }
65
- // Remove lexical's inline style so we can apply our own
66
- // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly
67
- root.style.whiteSpace = '';
68
- }));
69
- }
70
- }, [
71
- editorRef
72
- ]);
73
28
  const handleOnChange = React.useCallback((newValue)=>{
74
29
  onChange === null || onChange === void 0 ? void 0 : onChange({}, {
75
30
  value: newValue
@@ -77,14 +32,19 @@ import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities'
77
32
  }, [
78
33
  onChange
79
34
  ]);
80
- const defaultValueFunction = useDefaultValueFunction(props);
81
- const placeholderValue = slot.optional(props.placeholderValue, {
82
- elementType: 'span'
35
+ const { canShowPlaceholder, spanRef, disabled, lexicalEditor, lexicalInitialConfig } = useLexicalContentEditable({
36
+ customNodes: props.customNodes,
37
+ defaultValue: useDefaultValueFunction(props),
38
+ disabled: props.disabled
83
39
  });
40
+ const placeholderValue = canShowPlaceholder ? slot.optional(props.placeholderValue, {
41
+ elementType: 'span'
42
+ }) : undefined;
84
43
  const placeholderId = useId('chat-input-placeholder', placeholderValue === null || placeholderValue === void 0 ? void 0 : placeholderValue.id);
85
44
  if (placeholderValue) {
86
45
  placeholderValue.id = placeholderId;
87
46
  }
47
+ const describedBy = primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId;
88
48
  return {
89
49
  components: {
90
50
  root: 'span',
@@ -107,18 +67,12 @@ import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities'
107
67
  suppressContentEditableWarning: true,
108
68
  tabIndex: disabled ? undefined : 0,
109
69
  ...primary,
110
- 'aria-describedby': primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId
70
+ 'aria-describedby': describedBy
111
71
  },
112
72
  elementType: 'span'
113
73
  }),
114
74
  placeholderValue,
115
- lexicalInitialConfig: {
116
- namespace: 'fai-EditorInput',
117
- onError: console.error,
118
- nodes: customNodes,
119
- editorState: defaultValueFunction,
120
- theme: customTheme
121
- },
75
+ lexicalInitialConfig,
122
76
  editorRef,
123
77
  disabled,
124
78
  textPlugin,
@@ -126,7 +80,8 @@ import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities'
126
80
  handleOnChange,
127
81
  trimWhiteSpace,
128
82
  history,
129
- isSentinelNodeEnabled
83
+ isSentinelNodeEnabled,
84
+ lexicalEditor
130
85
  };
131
86
  };
132
87
  function useDefaultValueFunction(props) {
@@ -1 +1 @@
1
- {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n slot,\n useFluent,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SentinelNode, SENTINEL_VALUE } from '@fluentui-copilot/chat-input-plugins';\nimport type { LexicalEditor } from '@fluentui-copilot/react-text-editor';\nimport { $createTextNode, $insertNodes } from '@fluentui-copilot/react-text-editor';\nimport { $getRoot } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';\nimport { mergeCallbacks, useControllableState } from '@fluentui/react-utilities';\n\n/**\n * Create the state required to render EditorInput.\n *\n * The returned state can be modified with hooks such as useEditorInputStyles_unstable,\n * before being passed to renderEditorInput_unstable.\n *\n * @param props - props from this instance of EditorInput\n * @param ref - reference to root HTMLElement of EditorInput\n */\nexport const useEditorInput_unstable = (props: EditorInputProps, ref: React.Ref<HTMLSpanElement>): EditorInputState => {\n const {\n onChange,\n onPaste,\n trimWhiteSpace = false,\n textPlugin = LexicalPlainTextPlugin,\n history = true,\n editorRef: userEditorRef,\n customTheme,\n isSentinelNodeEnabled = true,\n } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const editorRef = useMergedRefs(React.useRef<LexicalEditor>(null), userEditorRef);\n // The disabled state can also be changed by lexical (e.g. by a custom plugin) so\n // we use `useControllableState` to coordinate\n const [disabled, setDisabled] = useControllableState({\n state: props.disabled,\n initialState: false,\n });\n\n const customNodes = props.customNodes ? [...props.customNodes, SentinelNode] : [SentinelNode];\n\n const spanRef = React.useCallback(\n (span: HTMLSpanElement | null) => {\n // Register the `input` span with lexical\n editorRef.current?.setRootElement(span);\n },\n [editorRef],\n );\n\n // Update lexical when disabled changes\n useIsomorphicLayoutEffect(() => {\n if (editorRef.current) {\n editorRef.current?.setEditable(!disabled);\n }\n }, [disabled]);\n\n useIsomorphicLayoutEffect(() => {\n if (editorRef.current) {\n return mergeRegister(\n editorRef.current.registerEditableListener(isEditable => {\n setDisabled(!isEditable);\n }),\n editorRef.current?.registerRootListener(root => {\n if (!root) {\n return;\n }\n\n // Remove lexical's inline style so we can apply our own\n // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly\n root.style.whiteSpace = '';\n }),\n );\n }\n }, [editorRef]);\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange?.({}, { value: newValue });\n },\n [onChange],\n );\n\n const defaultValueFunction = useDefaultValueFunction(props);\n\n const placeholderValue = slot.optional(props.placeholderValue, { elementType: 'span' });\n const placeholderId = useId('chat-input-placeholder', placeholderValue?.id);\n if (placeholderValue) {\n placeholderValue.id = placeholderId;\n }\n\n return {\n components: {\n root: 'span',\n input: 'span',\n placeholderValue: 'span',\n },\n root: slot.always(props.root, { defaultProps: { ...root }, elementType: 'span' }),\n input: slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs(ref, spanRef),\n role: 'textbox',\n contentEditable: !disabled,\n 'aria-readonly': disabled ? true : undefined,\n disabled,\n suppressContentEditableWarning: true,\n tabIndex: disabled ? undefined : 0,\n ...primary,\n 'aria-describedby': primary['aria-describedby']\n ? `${primary['aria-describedby']} ${placeholderId}`\n : placeholderId,\n },\n elementType: 'span',\n }),\n placeholderValue,\n lexicalInitialConfig: {\n namespace: 'fai-EditorInput',\n onError: console.error,\n nodes: customNodes,\n editorState: defaultValueFunction,\n theme: customTheme,\n },\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n trimWhiteSpace,\n history,\n isSentinelNodeEnabled,\n };\n};\n\nfunction useDefaultValueFunction(props: EditorInputProps) {\n const { targetDocument } = useFluent();\n const requestAnimationFrame = targetDocument?.defaultView?.requestAnimationFrame;\n\n const [defaultValueFunction] = React.useState(() => {\n const { defaultValue, onDefaultValueSet } = props;\n if (defaultValue === undefined) {\n return undefined;\n }\n\n const insertDefaultValueFunction =\n typeof defaultValue === 'function'\n ? defaultValue\n : () => {\n $insertNodes([$createTextNode(defaultValue)]);\n };\n\n // After the defaultValue function has run, read back the result and give\n // it to the onDefaultValueSet callback.\n const readDefaultValueFunction = onDefaultValueSet\n ? () => {\n const text = $getRoot().getTextContent().replace(SENTINEL_VALUE, '');\n\n // This runs while rendering `LexicalComposer` so delay calling back into the parent\n // until after finished rendering `LexicalComposer`\n requestAnimationFrame?.(() => {\n onDefaultValueSet?.(text);\n });\n }\n : undefined;\n\n return mergeCallbacks(insertDefaultValueFunction, readDefaultValueFunction);\n });\n\n return defaultValueFunction;\n}\n"],"names":["React","getPartitionedNativeProps","slot","useFluent","useId","useIsomorphicLayoutEffect","useMergedRefs","SentinelNode","SENTINEL_VALUE","$createTextNode","$insertNodes","$getRoot","LexicalPlainTextPlugin","mergeRegister","mergeCallbacks","useControllableState","useEditorInput_unstable","props","ref","onChange","onPaste","trimWhiteSpace","textPlugin","history","editorRef","userEditorRef","customTheme","isSentinelNodeEnabled","root","primary","primarySlotTagName","excludedPropNames","useRef","disabled","setDisabled","state","initialState","customNodes","spanRef","useCallback","span","current","setRootElement","setEditable","registerEditableListener","isEditable","registerRootListener","style","whiteSpace","handleOnChange","newValue","value","defaultValueFunction","useDefaultValueFunction","placeholderValue","optional","elementType","placeholderId","id","components","input","always","defaultProps","role","contentEditable","undefined","suppressContentEditableWarning","tabIndex","lexicalInitialConfig","namespace","onError","console","error","nodes","editorState","theme","targetDocument","requestAnimationFrame","defaultView","useState","defaultValue","onDefaultValueSet","insertDefaultValueFunction","readDefaultValueFunction","text","getTextContent","replace"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,yBAAyB,EACzBC,IAAI,EACJC,SAAS,EACTC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,QACR,6BAA6B;AAEpC,SAASC,YAAY,EAAEC,cAAc,QAAQ,uCAAuC;AAEpF,SAASC,eAAe,EAAEC,YAAY,QAAQ,sCAAsC;AACpF,SAASC,QAAQ,QAAQ,sCAAsC;AAC/D,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,sCAAsC;AAC5F,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,4BAA4B;AAEjF;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,aAAaV,sBAAsB,EACnCW,UAAU,IAAI,EACdC,WAAWC,aAAa,EACxBC,WAAW,EACXC,wBAAwB,IAAI,EAC7B,GAAGV;IACJ,MAAM,EAAEW,IAAI,EAAEC,OAAO,EAAE,GAAG5B,0BAA0B;QAClD6B,oBAAoB;QACpBb;QACAc,mBAAmB;YAAC;YAAY;YAAW;SAAe;IAC5D;IAEA,MAAMP,YAAYlB,cAAcN,MAAMgC,MAAM,CAAgB,OAAOP;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AEA,MAAMiB,6BACJ,OAAOF,iBAAiB,aACpBA,eACA;YACEtE,aAAa;gBAACD,gBAAgBuE;aAAc;QAC9C;QAEN,yEAAyE;QACzE,wCAAwC;QACxC,MAAMG,2BAA2BF,oBAC7B;YACE,MAAMG,OAAOzE,WAAW0E,cAAc,GAAGC,OAAO,CAAC9E,gBAAgB;YAEjE,oFAAoF;YACpF,mDAAmD;YACnDqE,kCAAAA,4CAAAA,sBAAwB;gBACtBI,8BAAAA,wCAAAA,kBAAoBG;YACtB;QACF,IACAnB;QAEJ,OAAOnD,eAAeoE,4BAA4BC;IACpD;IAEA,OAAO/B;AACT"}
1
+ {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getPartitionedNativeProps, slot, useFluent, useId, useMergedRefs } from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SENTINEL_VALUE } from '@fluentui-copilot/chat-input-plugins';\nimport { $createTextNode, $insertNodes } from '@fluentui-copilot/react-text-editor';\nimport { $getRoot } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';\nimport { mergeCallbacks } from '@fluentui/react-utilities';\nimport { useLexicalContentEditable } from '../../utilities/useLexicalContentEditable';\n\n/**\n * Create the state required to render EditorInput.\n *\n * The returned state can be modified with hooks such as useEditorInputStyles_unstable,\n * before being passed to renderEditorInput_unstable.\n *\n * @param props - props from this instance of EditorInput\n * @param ref - reference to root HTMLElement of EditorInput\n */\nexport const useEditorInput_unstable = (props: EditorInputProps, ref: React.Ref<HTMLSpanElement>): EditorInputState => {\n const {\n onChange,\n onPaste,\n trimWhiteSpace = false,\n textPlugin = LexicalPlainTextPlugin,\n history = true,\n editorRef,\n isSentinelNodeEnabled = true,\n } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange?.({}, { value: newValue });\n },\n [onChange],\n );\n\n const { canShowPlaceholder, spanRef, disabled, lexicalEditor, lexicalInitialConfig } = useLexicalContentEditable({\n customNodes: props.customNodes,\n defaultValue: useDefaultValueFunction(props),\n disabled: props.disabled,\n });\n\n const placeholderValue = canShowPlaceholder\n ? slot.optional(props.placeholderValue, { elementType: 'span' })\n : undefined;\n const placeholderId = useId('chat-input-placeholder', placeholderValue?.id);\n if (placeholderValue) {\n placeholderValue.id = placeholderId;\n }\n const describedBy = primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId;\n\n return {\n components: {\n root: 'span',\n input: 'span',\n placeholderValue: 'span',\n },\n root: slot.always(props.root, { defaultProps: { ...root }, elementType: 'span' }),\n input: slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs(ref, spanRef),\n role: 'textbox',\n contentEditable: !disabled,\n 'aria-readonly': disabled ? true : undefined,\n disabled,\n suppressContentEditableWarning: true,\n tabIndex: disabled ? undefined : 0,\n ...primary,\n 'aria-describedby': describedBy,\n },\n elementType: 'span',\n }),\n placeholderValue,\n lexicalInitialConfig,\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n trimWhiteSpace,\n history,\n isSentinelNodeEnabled,\n lexicalEditor,\n };\n};\n\nfunction useDefaultValueFunction(props: EditorInputProps) {\n const { targetDocument } = useFluent();\n const requestAnimationFrame = targetDocument?.defaultView?.requestAnimationFrame;\n\n const [defaultValueFunction] = React.useState(() => {\n const { defaultValue, onDefaultValueSet } = props;\n if (defaultValue === undefined) {\n return undefined;\n }\n\n const insertDefaultValueFunction =\n typeof defaultValue === 'function'\n ? defaultValue\n : () => {\n $insertNodes([$createTextNode(defaultValue)]);\n };\n\n // After the defaultValue function has run, read back the result and give\n // it to the onDefaultValueSet callback.\n const readDefaultValueFunction = onDefaultValueSet\n ? () => {\n const text = $getRoot().getTextContent().replace(SENTINEL_VALUE, '');\n\n // This runs while rendering `LexicalComposer` so delay calling back into the parent\n // until after finished rendering `LexicalComposer`\n requestAnimationFrame?.(() => {\n onDefaultValueSet?.(text);\n });\n }\n : undefined;\n\n return mergeCallbacks(insertDefaultValueFunction, readDefaultValueFunction);\n });\n\n return defaultValueFunction;\n}\n"],"names":["React","getPartitionedNativeProps","slot","useFluent","useId","useMergedRefs","SENTINEL_VALUE","$createTextNode","$insertNodes","$getRoot","LexicalPlainTextPlugin","mergeCallbacks","useLexicalContentEditable","useEditorInput_unstable","props","ref","onChange","onPaste","trimWhiteSpace","textPlugin","history","editorRef","isSentinelNodeEnabled","root","primary","primarySlotTagName","excludedPropNames","handleOnChange","useCallback","newValue","value","canShowPlaceholder","spanRef","disabled","lexicalEditor","lexicalInitialConfig","customNodes","defaultValue","useDefaultValueFunction","placeholderValue","optional","elementType","undefined","placeholderId","id","describedBy","components","input","always","defaultProps","role","contentEditable","suppressContentEditableWarning","tabIndex","targetDocument","requestAnimationFrame","defaultView","defaultValueFunction","useState","onDefaultValueSet","insertDefaultValueFunction","readDefaultValueFunction","text","getTextContent","replace"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,EAAEC,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAEC,aAAa,QAAQ,6BAA6B;AAE9G,SAASC,cAAc,QAAQ,uCAAuC;AACtE,SAASC,eAAe,EAAEC,YAAY,QAAQ,sCAAsC;AACpF,SAASC,QAAQ,QAAQ,sCAAsC;AAC/D,SAASC,sBAAsB,QAAQ,sCAAsC;AAC7E,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,yBAAyB,QAAQ,4CAA4C;AAEtF;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,E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lC,KAAKV,cAAcU,KAAKiB;gBACxBkB,MAAM;gBACNC,iBAAiB,CAAClB;gBAClB,iBAAiBA,WAAW,OAAOS;gBACnCT;gBACAmB,gCAAgC;gBAChCC,UAAUpB,WAAWS,YAAY;gBACjC,GAAGlB,OAAO;gBACV,oBAAoBqB;YACtB;YACAJ,aAAa;QACf;QACAF;QACAJ;QACAd;QACAY;QACAd;QACAF;QACAU;QACAT;QACAE;QACAE;QACAY;IACF;AACF,EAAE;AAEF,SAASI,wBAAwBxB,KAAuB;QAExBwC;IAD9B,MAAM,EAAEA,cAAc,EAAE,GAAGnD;IAC3B,MAAMoD,wBAAwBD,2BAAAA,sCAAAA,8BAAAA,eAAgBE,WAAW,cAA3BF,kDAAAA,4BAA6BC,qBAAqB;IAEhF,MAAM,CAACE,qBAAqB,GAAGzD,MAAM0D,QAAQ,CAAC;QAC5C,MAAM,EAAErB,YAAY,EAAEsB,iBAAiB,EAAE,GAAG7C;QAC5C,IAAIuB,iBAAiBK,WAAW;YAC9B,OAAOA;QACT;QAEA,MAAMkB,6BACJ,OAAOvB,iBAAiB,aACpBA,eACA;YACE7B,aAAa;gBAACD,gBAAgB8B;aAAc;QAC9C;QAEN,yEAAyE;QACzE,wCAAwC;QACxC,MAAMwB,2BAA2BF,oBAC7B;YACE,MAAMG,OAAOrD,WAAWsD,cAAc,GAAGC,OAAO,CAAC1D,gBAAgB;YAEjE,oFAAoF;YACpF,mDAAmD;YACnDiD,kCAAAA,4CAAAA,sBAAwB;gBACtBI,8BAAAA,wCAAAA,kBAAoBG;YACtB;QACF,IACApB;QAEJ,OAAO/B,eAAeiD,4BAA4BC;IACpD;IAEA,OAAOJ;AACT"}
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { createLexicalComposerContext } from '@fluentui-copilot/react-text-editor';
3
+ export function useEditorInputContextValues(state) {
4
+ const { lexicalInitialConfig, lexicalEditor } = state;
5
+ const { theme } = lexicalInitialConfig;
6
+ const context = React.useMemo(()=>[
7
+ lexicalEditor,
8
+ createLexicalComposerContext(null, theme)
9
+ ], [
10
+ lexicalEditor,
11
+ theme
12
+ ]);
13
+ return {
14
+ lexicalComposer: context
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInputContextValues.ts"],"sourcesContent":["import * as React from 'react';\nimport type { LexicalComposerContextWithEditor } from '@fluentui-copilot/react-text-editor';\nimport { createLexicalComposerContext } from '@fluentui-copilot/react-text-editor';\nimport type { EditorInputContextValues, EditorInputState } from './EditorInput.types';\n\nexport function useEditorInputContextValues(state: EditorInputState): EditorInputContextValues {\n const { lexicalInitialConfig, lexicalEditor } = state;\n const { theme } = lexicalInitialConfig;\n\n const context: LexicalComposerContextWithEditor = React.useMemo(\n () => [lexicalEditor, createLexicalComposerContext(null, theme)],\n [lexicalEditor, theme],\n );\n\n return { lexicalComposer: context };\n}\n"],"names":["React","createLexicalComposerContext","useEditorInputContextValues","state","lexicalInitialConfig","lexicalEditor","theme","context","useMemo","lexicalComposer"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,4BAA4B,QAAQ,sCAAsC;AAGnF,OAAO,SAASC,4BAA4BC,KAAuB;IACjE,MAAM,EAAEC,oBAAoB,EAAEC,aAAa,EAAE,GAAGF;IAChD,MAAM,EAAEG,KAAK,EAAE,GAAGF;IAElB,MAAMG,UAA4CP,MAAMQ,OAAO,CAC7D,IAAM;YAACH;YAAeJ,6BAA6B,MAAMK;SAAO,EAChE;QAACD;QAAeC;KAAM;IAGxB,OAAO;QAAEG,iBAAiBF;IAAQ;AACpC"}
@@ -50,13 +50,6 @@ export const useEditorInputStyles_unstable = state => {
50
50
  const styles = useStyles();
51
51
  state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);
52
52
  state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);
53
- state.lexicalInitialConfig = {
54
- ...state.lexicalInitialConfig,
55
- theme: {
56
- ...useLexicalStyles(),
57
- ...state.lexicalInitialConfig.theme
58
- }
59
- };
60
53
  if (state.placeholderValue) {
61
54
  state.placeholderValue.className = mergeClasses(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
62
55
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens, typographyStyles } from '@fluentui-copilot/tokens';\nimport type { SlotClassNames } from '@fluentui/react-components';\nimport type { EditorInputSlots, EditorInputState } from './EditorInput.types';\n\nexport const editorInputClassNames: SlotClassNames<EditorInputSlots> = {\n root: 'fai-EditorInput',\n input: 'fai-EditorInput__input',\n placeholderValue: 'fai-EditorInput__placeholderValue',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootClassName = makeResetStyles({\n display: 'inline-grid',\n whiteSpace: 'pre-wrap',\n});\n\nexport const useLexicalStyles = makeStyles({\n paragraph: {\n margin: 0,\n textAlign: 'start',\n },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground4,\n ...typographyStyles.body1,\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n});\n\nexport const useInputClassName = makeResetStyles({\n gridArea: '1 / 1 / 1 / 1',\n zIndex: 1,\n width: '100%',\n});\n\nconst useStyles = makeStyles({\n placeholderDisabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n/**\n * Apply styling to the EditorInput slots based on the state\n */\nexport const useEditorInputStyles_unstable = (state: EditorInputState): EditorInputState => {\n 'use no memo';\n\n const { disabled } = state;\n const placeholderClassName = usePlaceholderClassName();\n const rootClassName = useRootClassName();\n const inputClassName = useInputClassName();\n const styles = useStyles();\n\n state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);\n\n state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);\n\n state.lexicalInitialConfig = {\n ...state.lexicalInitialConfig,\n theme: { ...useLexicalStyles(), ...state.lexicalInitialConfig.theme },\n };\n\n if (state.placeholderValue) {\n state.placeholderValue.className = mergeClasses(\n editorInputClassNames.placeholderValue,\n placeholderClassName,\n disabled && styles.placeholderDisabled,\n state.placeholderValue.className,\n );\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","editorInputClassNames","root","input","placeholderValue","useRootClassName","display","whiteSpace","useLexicalStyles","paragraph","margin","textAlign","usePlaceholderClassName","zIndex","gridArea","color","colorNeutralForeground4","body1","useInputClassName","width","useStyles","placeholderDisabled","colorNeutralForegroundDisabled","useEditorInputStyles_unstable","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className","lexicalInitialConfig","theme"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,6BAA6B;AACvF,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,2BAA2B;AAIpE,OAAO,MAAMC,wBAA0D;IACrEC,MAAM;IACNC,OAAO;IACPC,kBAAkB;AACpB,EAAE;AAEF;;CAEC,GACD,MAAMC,mBAAmBT,gBAAgB;IACvCU,SAAS;IACTC,YAAY;AACd;AAEA,OAAO,MAAMC,mBAAmBX,WAAW;IACzCY,WAAW;QACTC,QAAQ;QACRC,WAAW;IACb;AACF,GAAG;AAEH,OAAO,MAAMC,0BAA0BhB,gBAAgB;IACrDiB,QAAQ;IACRC,UAAU;IAEVC,OAAOhB,OAAOiB,uBAAuB;IACrC,GAAGhB,iBAAiBiB,KAAK;IAEzB,kCAAkC;QAChCF,OAAO;IACT;AACF,GAAG;AAEH,OAAO,MAAMG,oBAAoBtB,gBAAgB;IAC/CkB,UAAU;IACVD,QAAQ;IACRM,OAAO;AACT,GAAG;AAEH,MAAMC,YAAYvB,WAAW;IAC3BwB,qBAAqB;QACnBN,OAAOhB,OAAOuB,8BAA8B;IAC9C;AACF;AACA;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C;IAEA,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IACrB,MAAME,uBAAuBd;IAC7B,MAAMe,gBAAgBtB;IACtB,MAAMuB,iBAAiBV;IACvB,MAAMW,SAAST;IAEfI,MAAMtB,IAAI,CAAC4B,SAAS,GAAGhC,aAAaG,sBAAsBC,IAAI,EAAEyB,eAAeH,MAAMtB,IAAI,CAAC4B,SAAS;IAEnGN,MAAMrB,KAAK,CAAC2B,SAAS,GAAGhC,aAAaG,sBAAsBE,KAAK,EAAEyB,gBAAgBJ,MAAMrB,KAAK,CAAC2B,SAAS;IAEvGN,MAAMO,oBAAoB,GAAG;QAC3B,GAAGP,MAAMO,oBAAoB;QAC7BC,OAAO;YAAE,GAAGxB,kBAAkB;YAAE,GAAGgB,MAAMO,oBAAoB,CAACC,KAAK;QAAC;IACtE;IAEA,IAAIR,MAAMpB,gBAAgB,EAAE;QAC1BoB,MAAMpB,gBAAgB,CAAC0B,SAAS,GAAGhC,aACjCG,sBAAsBG,gBAAgB,EACtCsB,sBACAD,YAAYI,OAAOR,mBAAmB,EACtCG,MAAMpB,gBAAgB,CAAC0B,SAAS;IAEpC;IAEA,OAAON;AACT,EAAE"}
1
+ {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens, typographyStyles } from '@fluentui-copilot/tokens';\nimport type { SlotClassNames } from '@fluentui/react-components';\nimport type { EditorInputSlots, EditorInputState } from './EditorInput.types';\n\nexport const editorInputClassNames: SlotClassNames<EditorInputSlots> = {\n root: 'fai-EditorInput',\n input: 'fai-EditorInput__input',\n placeholderValue: 'fai-EditorInput__placeholderValue',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootClassName = makeResetStyles({\n display: 'inline-grid',\n whiteSpace: 'pre-wrap',\n});\n\nexport const useLexicalStyles = makeStyles({\n paragraph: {\n margin: 0,\n textAlign: 'start',\n },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground4,\n ...typographyStyles.body1,\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n});\n\nexport const useInputClassName = makeResetStyles({\n gridArea: '1 / 1 / 1 / 1',\n zIndex: 1,\n width: '100%',\n});\n\nconst useStyles = makeStyles({\n placeholderDisabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n/**\n * Apply styling to the EditorInput slots based on the state\n */\nexport const useEditorInputStyles_unstable = (state: EditorInputState): EditorInputState => {\n 'use no memo';\n\n const { disabled } = state;\n const placeholderClassName = usePlaceholderClassName();\n const rootClassName = useRootClassName();\n const inputClassName = useInputClassName();\n const styles = useStyles();\n\n state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);\n\n state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);\n\n if (state.placeholderValue) {\n state.placeholderValue.className = mergeClasses(\n editorInputClassNames.placeholderValue,\n placeholderClassName,\n disabled && styles.placeholderDisabled,\n state.placeholderValue.className,\n );\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","editorInputClassNames","root","input","placeholderValue","useRootClassName","display","whiteSpace","useLexicalStyles","paragraph","margin","textAlign","usePlaceholderClassName","zIndex","gridArea","color","colorNeutralForeground4","body1","useInputClassName","width","useStyles","placeholderDisabled","colorNeutralForegroundDisabled","useEditorInputStyles_unstable","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,6BAA6B;AACvF,SAASC,MAAM,EAAEC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EA,OAAON;AACT,EAAE"}
@@ -47,13 +47,6 @@ const useStyles = makeStyles({
47
47
  const styles = useStyles();
48
48
  state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);
49
49
  state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);
50
- state.lexicalInitialConfig = {
51
- ...state.lexicalInitialConfig,
52
- theme: {
53
- ...useLexicalStyles(),
54
- ...state.lexicalInitialConfig.theme
55
- }
56
- };
57
50
  if (state.placeholderValue) {
58
51
  state.placeholderValue.className = mergeClasses(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
59
52
  }