@fluentui-copilot/react-editor-input 0.2.2 → 0.3.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 (44) hide show
  1. package/CHANGELOG.json +15 -0
  2. package/CHANGELOG.md +10 -1
  3. package/dist/index.d.ts +3 -10
  4. package/lib/components/EditorInput/EditorInput.js +2 -3
  5. package/lib/components/EditorInput/EditorInput.js.map +1 -1
  6. package/lib/components/EditorInput/EditorInput.types.js +3 -1
  7. package/lib/components/EditorInput/EditorInput.types.js.map +1 -1
  8. package/lib/components/EditorInput/index.js +0 -1
  9. package/lib/components/EditorInput/index.js.map +1 -1
  10. package/lib/components/EditorInput/renderEditorInput.js +12 -10
  11. package/lib/components/EditorInput/renderEditorInput.js.map +1 -1
  12. package/lib/components/EditorInput/useEditorInput.js +58 -18
  13. package/lib/components/EditorInput/useEditorInput.js.map +1 -1
  14. package/lib/components/EditorInput/useEditorInputStyles.styles.js +7 -0
  15. package/lib/components/EditorInput/useEditorInputStyles.styles.js.map +1 -1
  16. package/lib/index.js +1 -1
  17. package/lib/index.js.map +1 -1
  18. package/lib-commonjs/components/EditorInput/EditorInput.js +1 -3
  19. package/lib-commonjs/components/EditorInput/EditorInput.js.map +1 -1
  20. package/lib-commonjs/components/EditorInput/EditorInput.types.js +3 -1
  21. package/lib-commonjs/components/EditorInput/EditorInput.types.js.map +1 -1
  22. package/lib-commonjs/components/EditorInput/index.js +0 -1
  23. package/lib-commonjs/components/EditorInput/index.js.map +1 -1
  24. package/lib-commonjs/components/EditorInput/renderEditorInput.js +11 -10
  25. package/lib-commonjs/components/EditorInput/renderEditorInput.js.map +1 -1
  26. package/lib-commonjs/components/EditorInput/useEditorInput.js +72 -10
  27. package/lib-commonjs/components/EditorInput/useEditorInput.js.map +1 -1
  28. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.js +7 -0
  29. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.js.map +1 -1
  30. package/lib-commonjs/index.js +0 -3
  31. package/lib-commonjs/index.js.map +1 -1
  32. package/package.json +4 -4
  33. package/lib/components/EditorInput/useEditorInputContextValues.js +0 -16
  34. package/lib/components/EditorInput/useEditorInputContextValues.js.map +0 -1
  35. package/lib/utilities/useLexicalContentEditable.js +0 -68
  36. package/lib/utilities/useLexicalContentEditable.js.map +0 -1
  37. package/lib/utilities/useLexicalEditor.js +0 -75
  38. package/lib/utilities/useLexicalEditor.js.map +0 -1
  39. package/lib-commonjs/components/EditorInput/useEditorInputContextValues.js +0 -27
  40. package/lib-commonjs/components/EditorInput/useEditorInputContextValues.js.map +0 -1
  41. package/lib-commonjs/utilities/useLexicalContentEditable.js +0 -87
  42. package/lib-commonjs/utilities/useLexicalContentEditable.js.map +0 -1
  43. package/lib-commonjs/utilities/useLexicalEditor.js +0 -74
  44. package/lib-commonjs/utilities/useLexicalEditor.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/react-editor-input",
3
3
  "entries": [
4
+ {
5
+ "date": "Wed, 25 Sep 2024 19:49:21 GMT",
6
+ "tag": "@fluentui-copilot/react-editor-input_v0.3.0",
7
+ "version": "0.3.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "estebanmu@microsoft.com",
12
+ "package": "@fluentui-copilot/react-editor-input",
13
+ "commit": "cf2200a2e3e936a797f057fd58ef492f97c07a8e",
14
+ "comment": "Revert \"feat(react-editor-input): Update Lexical versions and refactor Lexical initialization (#2052)\""
15
+ }
16
+ ]
17
+ }
18
+ },
4
19
  {
5
20
  "date": "Wed, 04 Sep 2024 18:11:50 GMT",
6
21
  "tag": "@fluentui-copilot/react-editor-input_v0.2.0",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Change Log - @fluentui-copilot/react-editor-input
2
2
 
3
- This log was last generated on Wed, 04 Sep 2024 18:11:50 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 25 Sep 2024 19:49:21 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.3.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.3.0)
8
+
9
+ Wed, 25 Sep 2024 19:49:21 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-editor-input_v0.2.0..@fluentui-copilot/react-editor-input_v0.3.0)
11
+
12
+ ### Minor changes
13
+
14
+ - Revert "feat(react-editor-input): Update Lexical versions and refactor Lexical initialization (#2052)" ([PR #2202](https://github.com/microsoft/fluentai/pull/2202) by estebanmu@microsoft.com)
15
+
7
16
  ## [0.2.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.2.0)
8
17
 
9
18
  Wed, 04 Sep 2024 18:11:50 GMT
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ 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 { LexicalComposerContextWithEditor } from '@fluentui-copilot/react-text-editor';
8
7
  import type { LexicalEditor } from '@fluentui-copilot/react-text-editor';
9
8
  import type { LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';
10
9
  import * as React_2 from 'react';
@@ -15,10 +14,6 @@ export declare const EditorInput: ForwardRefComponent<EditorInputProps>;
15
14
 
16
15
  export declare const editorInputClassNames: SlotClassNames<EditorInputSlots>;
17
16
 
18
- export declare type EditorInputContextValues = {
19
- lexicalComposer: LexicalComposerContextWithEditor;
20
- };
21
-
22
17
  /**
23
18
  * EditorInput Props
24
19
  */
@@ -69,10 +64,10 @@ export declare type EditorInputSlots = {
69
64
  /**
70
65
  * State used in rendering EditorInput
71
66
  */
72
- export declare type EditorInputState = ComponentState<EditorInputSlots> & Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace'>> & Partial<Pick<EditorInputProps, 'onPaste' | 'editorRef'>> & {
67
+ export declare type EditorInputState = ComponentState<EditorInputSlots> & Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'editorRef'>> & Partial<Pick<EditorInputProps, 'onPaste'>> & {
73
68
  lexicalInitialConfig: InitialConfigType;
69
+ defaultValue?: string;
74
70
  handleOnChange: (value: string) => void;
75
- lexicalEditor: LexicalEditor;
76
71
  };
77
72
 
78
73
  /**
@@ -85,7 +80,7 @@ export declare type EditorInputValueData = {
85
80
  /**
86
81
  * Render the final JSX of EditorInput
87
82
  */
88
- export declare const renderEditorInput_unstable: (state: EditorInputState, contextValues: EditorInputContextValues) => JSX.Element;
83
+ export declare const renderEditorInput_unstable: (state: EditorInputState) => JSX.Element;
89
84
 
90
85
  /**
91
86
  * Create the state required to render EditorInput.
@@ -98,8 +93,6 @@ export declare const renderEditorInput_unstable: (state: EditorInputState, conte
98
93
  */
99
94
  export declare const useEditorInput_unstable: (props: EditorInputProps, ref: React_2.Ref<HTMLSpanElement>) => EditorInputState;
100
95
 
101
- export declare function useEditorInputContextValues(state: EditorInputState): EditorInputContextValues;
102
-
103
96
  /**
104
97
  * Apply styling to the EditorInput slots based on the state
105
98
  */
@@ -2,12 +2,11 @@ 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
+ // EditorInput component - TODO: add more docs
6
6
  export const EditorInput = /*#__PURE__*/React.forwardRef((props, ref) => {
7
7
  const state = useEditorInput_unstable(props, ref);
8
- const contextValues = useEditorInputContextValues(state);
9
8
  useEditorInputStyles_unstable(state);
10
- return renderEditorInput_unstable(state, contextValues);
9
+ return renderEditorInput_unstable(state);
11
10
  });
12
11
  EditorInput.displayName = 'EditorInput';
13
12
  //# sourceMappingURL=EditorInput.js.map
@@ -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';\nimport { useEditorInputContextValues } from './useEditorInputContextValues';\n\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\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,OAAO,MAAMC,4BAAqDL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQR,wBAAwBM,OAAOC;IAC7C,MAAME,gBAAgBN,4BAA4BK;IAElDN,8BAA8BM;IAE9B,OAAOP,2BAA2BO,OAAOC;AAC3C,GAAG;AAEHL,YAAYM,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';\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,2 +1,4 @@
1
- export {};
1
+ /**
2
+ * Data passed to the `onChange` callback when the chat input's value changes.
3
+ */export {};
2
4
  //# sourceMappingURL=EditorInput.types.js.map
@@ -1 +1 @@
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 * 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/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace'>> &\n Partial<Pick<EditorInputProps, 'onPaste' | 'editorRef'>> & {\n lexicalInitialConfig: InitialConfigType;\n handleOnChange: (value: string) => void;\n lexicalEditor: LexicalEditor;\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":"AA8EA,WAEE"}
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 * 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/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'editorRef'>> &\n Partial<Pick<EditorInputProps, 'onPaste'>> & {\n lexicalInitialConfig: InitialConfigType;\n defaultValue?: string;\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":"AAkEA;;CAEC,GACD,WAEE"}
@@ -3,5 +3,4 @@ export * from './EditorInput.types';
3
3
  export * from './renderEditorInput';
4
4
  export * from './useEditorInput';
5
5
  export * from './useEditorInputStyles.styles';
6
- export * from './useEditorInputContextValues';
7
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EditorInput';\nexport * from './EditorInput.types';\nexport * from './renderEditorInput';\nexport * from './useEditorInput';\nexport * from './useEditorInputStyles.styles';\nexport * from './useEditorInputContextValues';\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,gCAAgC;AAC9C,cAAc,gCAAgC"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EditorInput';\nexport * from './EditorInput.types';\nexport * from './renderEditorInput';\nexport * from './useEditorInput';\nexport * from './useEditorInputStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,gCAAgC"}
@@ -1,26 +1,28 @@
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 { LexicalErrorBoundary, LexicalEditorRefPlugin, LexicalHistoryPlugin, LexicalComposerContext } from '@fluentui-copilot/react-text-editor';
3
+ import { LexicalComposer, LexicalErrorBoundary, LexicalEditorRefPlugin, LexicalHistoryPlugin } 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
7
  */
8
- export const renderEditorInput_unstable = (state, contextValues) => {
8
+ export const renderEditorInput_unstable = state => {
9
9
  assertSlots(state);
10
10
  return /*#__PURE__*/_jsx(state.root, {
11
- children: /*#__PURE__*/_jsxs(LexicalComposerContext.Provider, {
12
- value: contextValues.lexicalComposer,
11
+ children: /*#__PURE__*/_jsxs(LexicalComposer, {
12
+ initialConfig: state.lexicalInitialConfig,
13
13
  children: [/*#__PURE__*/_jsx(state.textPlugin, {
14
14
  contentEditable: /*#__PURE__*/_jsx(state.input, {}),
15
- ErrorBoundary: LexicalErrorBoundary
15
+ ErrorBoundary: LexicalErrorBoundary,
16
+ placeholder: state.placeholderValue ? /*#__PURE__*/_jsx(state.placeholderValue, {}) : null
16
17
  }), /*#__PURE__*/_jsxs(_Fragment, {
17
- children: [state.placeholderValue ? /*#__PURE__*/_jsx(state.placeholderValue, {}) : null, /*#__PURE__*/_jsx(BasicFunctionalityPlugin, {
18
+ children: [/*#__PURE__*/_jsx(BasicFunctionalityPlugin, {
18
19
  onContentChange: state.handleOnChange,
19
20
  onPaste: state.onPaste,
20
- trimWhitespace: state.trimWhiteSpace
21
- }), state.history && /*#__PURE__*/_jsx(LexicalHistoryPlugin, {}), state.editorRef && /*#__PURE__*/_jsx(LexicalEditorRefPlugin, {
22
- editorRef: state.editorRef
23
- })]
21
+ trimWhitespace: state.trimWhiteSpace,
22
+ defaultValue: state.defaultValue
23
+ }), state.history && /*#__PURE__*/_jsx(LexicalHistoryPlugin, {})]
24
+ }), /*#__PURE__*/_jsx(LexicalEditorRefPlugin, {
25
+ editorRef: state.editorRef
24
26
  })]
25
27
  })
26
28
  });
@@ -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, EditorInputContextValues } from './EditorInput.types';\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';\n\n/**\n * Render the final JSX of EditorInput\n */\nexport const renderEditorInput_unstable = (state: EditorInputState, contextValues: EditorInputContextValues) => {\n assertSlots<EditorInputSlots>(state);\n\n return (\n <state.root>\n <LexicalComposerContext.Provider value={contextValues.lexicalComposer}>\n <state.textPlugin contentEditable={<state.input />} ErrorBoundary={LexicalErrorBoundary} />\n <>\n {state.placeholderValue ? <state.placeholderValue /> : null}\n <BasicFunctionalityPlugin\n onContentChange={state.handleOnChange}\n onPaste={state.onPaste}\n trimWhitespace={state.trimWhiteSpace}\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","placeholderValue","onContentChange","handleOnChange","onPaste","trimWhitespace","trimWhiteSpace","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;AAEtF;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CAACC,OAAyBC;IAClER,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;;8BACnE;;wBACGM,MAAMU,gBAAgB,iBAAG,KAACV,MAAMU,gBAAgB,QAAM;sCACvD,KAACZ;4BACCa,iBAAiBX,MAAMY,cAAc;4BACrCC,SAASb,MAAMa,OAAO;4BACtBC,gBAAgBd,MAAMe,cAAc;;wBAErCf,MAAMgB,OAAO,kBAAI,KAACpB;wBAClBI,MAAMiB,SAAS,kBAAI,KAACtB;4BAAuBsB,WAAWjB,MAAMiB,SAAS;;;;;;;AAKhF,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 { 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 defaultValue={state.defaultValue}\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","defaultValue","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,cAAcf,MAAMe,YAAY;;wBAEjCf,MAAMgB,OAAO,kBAAI,KAACnB;;;8BAErB,KAACD;oBAAuBqB,WAAWjB,MAAMiB,SAAS;;;;;AAI1D,EAAE"}
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
- import { getPartitionedNativeProps, slot, useId, useMergedRefs } from '@fluentui/react-components';
3
- import { LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';
4
- import { useLexicalContentEditable } from '../../utilities/useLexicalContentEditable';
2
+ import { getPartitionedNativeProps, slot, useId, useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-components';
3
+ import { SentinelNode } from '@fluentui-copilot/chat-input-plugins';
4
+ import { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';
5
+ import { useControllableState } from '@fluentui/react-utilities';
5
6
  /**
6
7
  * Create the state required to render EditorInput.
7
8
  *
@@ -18,7 +19,7 @@ export const useEditorInput_unstable = (props, ref) => {
18
19
  trimWhiteSpace = false,
19
20
  textPlugin = LexicalPlainTextPlugin,
20
21
  history = true,
21
- editorRef
22
+ editorRef: userEditorRef
22
23
  } = props;
23
24
  const {
24
25
  root,
@@ -28,26 +29,60 @@ export const useEditorInput_unstable = (props, ref) => {
28
29
  props,
29
30
  excludedPropNames: ['onChange', 'onPaste', 'defaultValue']
30
31
  });
31
- const {
32
- canShowPlaceholder,
33
- spanRef,
34
- disabled,
35
- lexicalEditor,
36
- lexicalInitialConfig
37
- } = useLexicalContentEditable(props);
32
+ const editorRef = useMergedRefs(React.useRef(null), userEditorRef);
33
+ // The disabled state can also be changed by lexical (e.g. by a custom plugin) so
34
+ // we use `useControllableState` to coordinate
35
+ const [disabled, setDisabled] = useControllableState({
36
+ state: props.disabled,
37
+ initialState: false
38
+ });
39
+ const customNodes = props.customNodes ? [...props.customNodes, SentinelNode] : [SentinelNode];
40
+ const spanRef = React.useCallback(span => {
41
+ var
42
+ // Register the `input` span with lexical
43
+ _editorRef_current;
44
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setRootElement(span);
45
+ }, [editorRef]);
46
+ // Update lexical when disabled changes
47
+ useIsomorphicLayoutEffect(() => {
48
+ if (editorRef.current) {
49
+ var _editorRef_current;
50
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setEditable(!disabled);
51
+ }
52
+ }, [disabled]);
53
+ useIsomorphicLayoutEffect(() => {
54
+ if (editorRef.current) {
55
+ var _editorRef_current;
56
+ return mergeRegister(editorRef.current.registerEditableListener(isEditable => {
57
+ setDisabled(!isEditable);
58
+ }), (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.registerRootListener(root => {
59
+ if (!root) {
60
+ return;
61
+ }
62
+ // Remove lexical's inline style so we can apply our own
63
+ // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly
64
+ root.style.whiteSpace = '';
65
+ }));
66
+ }
67
+ }, [editorRef]);
38
68
  const handleOnChange = React.useCallback(newValue => {
39
69
  onChange === null || onChange === void 0 ? void 0 : onChange({}, {
40
70
  value: newValue
41
71
  });
42
72
  }, [onChange]);
43
- const placeholderValue = canShowPlaceholder ? slot.optional(props.placeholderValue, {
73
+ const [defaultString, defaultValueFunction] = (() => {
74
+ if (typeof props.defaultValue === 'function') {
75
+ return [undefined, props.defaultValue];
76
+ }
77
+ return [props.defaultValue, undefined];
78
+ })();
79
+ const placeholderValue = slot.optional(props.placeholderValue, {
44
80
  elementType: 'span'
45
- }) : undefined;
81
+ });
46
82
  const placeholderId = useId('chat-input-placeholder', placeholderValue === null || placeholderValue === void 0 ? void 0 : placeholderValue.id);
47
83
  if (placeholderValue) {
48
84
  placeholderValue.id = placeholderId;
49
85
  }
50
- const describedBy = primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId;
51
86
  return {
52
87
  components: {
53
88
  root: 'span',
@@ -70,20 +105,25 @@ export const useEditorInput_unstable = (props, ref) => {
70
105
  disabled,
71
106
  suppressContentEditableWarning: true,
72
107
  ...primary,
73
- 'aria-describedby': canShowPlaceholder ? describedBy : undefined
108
+ 'aria-describedby': primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId
74
109
  },
75
110
  elementType: 'span'
76
111
  }),
77
112
  placeholderValue,
78
- lexicalInitialConfig,
113
+ lexicalInitialConfig: {
114
+ namespace: 'fai-EditorInput',
115
+ onError: console.error,
116
+ nodes: customNodes,
117
+ editorState: defaultValueFunction
118
+ },
79
119
  editorRef,
80
120
  disabled,
81
121
  textPlugin,
82
122
  onPaste,
83
123
  handleOnChange,
124
+ defaultValue: defaultString,
84
125
  trimWhiteSpace,
85
- history,
86
- lexicalEditor
126
+ history
87
127
  };
88
128
  };
89
129
  //# sourceMappingURL=useEditorInput.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getPartitionedNativeProps, slot, useId, useMergedRefs } from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';\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 } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const { canShowPlaceholder, spanRef, disabled, lexicalEditor, lexicalInitialConfig } =\n useLexicalContentEditable(props);\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange?.({}, { value: newValue });\n },\n [onChange],\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\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 tabIndex: disabled ? -1 : 0,\n disabled,\n suppressContentEditableWarning: true,\n ...primary,\n 'aria-describedby': canShowPlaceholder ? describedBy : undefined,\n },\n elementType: 'span',\n }),\n placeholderValue,\n lexicalInitialConfig,\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n trimWhiteSpace,\n history,\n lexicalEditor,\n };\n};\n"],"names":["React","getPartitionedNativeProps","slot","useId","useMergedRefs","LexicalPlainTextPlugin","useLexicalContentEditable","useEditorInput_unstable","props","ref","onChange","onPaste","trimWhiteSpace","textPlugin","history","editorRef","root","primary","primarySlotTagName","excludedPropNames","canShowPlaceholder","spanRef","disabled","lexicalEditor","lexicalInitialConfig","handleOnChange","useCallback","newValue","value","placeholderValue","optional","elementType","undefined","placeholderId","id","describedBy","components","input","always","defaultProps","role","contentEditable","tabIndex","suppressContentEditableWarning"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,aAAa,QAAQ,6BAA6B;AAEnG,SAASC,sBAAsB,QAAQ,sCAAsC;AAC7E,SAASC,yBAAyB,QAAQ,4CAA4C;AAEtF;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,aAAaR,sBAAsB,EACnCS,UAAU,IAAI,EACdC,SAAS,EACV,GAAGP;IACJ,MAAM,EAAEQ,IAAI,EAAEC,OAAO,EAAE,GAAGhB,0BAA0B;QAClDiB,oBAAoB;QACpBV;QACAW,mBAAmB;YAAC;YAAY;YAAW;SAAe;IAC5D;IAEA,MAAM,EAAEC,kBAAkB,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,oBAAoB,EAAE,GAClFlB,0BAA0BE;IAC5B,MAAMiB,iBAAiBzB,MAAM0B,WAAW,CACtC,CAACC;QACCjB,qBAAAA,+BAAAA,SAAW,CAAC,GAAG;YAAEkB,OAAOD;QAAS;IACnC,GACA;QAACjB;KAAS;IAGZ,MAAMmB,mBAAmBT,qBACrBlB,KAAK4B,QAAQ,CAACtB,MAAMqB,gBAAgB,EAAE;QAAEE,aAAa;IAAO,KAC5DC;IACJ,MAAMC,gBAAgB9B,MAAM,0BAA0B0B,6BAAAA,uCAAAA,iBAAkBK,EAAE;IAC1E,IAAIL,kBAAkB;QACpBA,iBAAiBK,EAAE,GAAGD;IACxB;IAEA,MAAME,cAAclB,OAAO,CAAC,mBAAmB,GAAG,CAAC,EAAEA,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAAEgB,cAAc,CAAC,GAAGA;IAEtG,OAAO;QACLG,YAAY;YACVpB,MAAM;YACNqB,OAAO;YACPR,kBAAkB;QACpB;QACAb,MAAMd,KAAKoC,MAAM,CAAC9B,MAAMQ,IAAI,EAAE;YAAEuB,cAAc;gBAAE,GAAGvB,IAAI;YAAC;YAAGe,aAAa;QAAO;QAC/EM,OAAOnC,KAAKoC,MAAM,CAAC9B,MAAM6B,KAAK,EAAE;YAC9BE,cAAc;gBACZ9B,KAAKL,cAAcK,KAAKY;gBACxBmB,MAAM;gBACNC,iBAAiB,CAACnB;gBAClB,iBAAiBA,WAAW,OAAOU;gBACnCU,UAAUpB,WAAW,CAAC,IAAI;gBAC1BA;gBACAqB,gCAAgC;gBAChC,GAAG1B,OAAO;gBACV,oBAAoBG,qBAAqBe,cAAcH;YACzD;YACAD,aAAa;QACf;QACAF;QACAL;QACAT;QACAO;QACAT;QACAF;QACAc;QACAb;QACAE;QACAS;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n slot,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SentinelNode } from '@fluentui-copilot/chat-input-plugins';\nimport type { LexicalEditor } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';\nimport { 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 } = 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 => {\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 [defaultString, defaultValueFunction] = (() => {\n if (typeof props.defaultValue === 'function') {\n return [undefined, props.defaultValue];\n }\n return [props.defaultValue, undefined];\n })();\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 tabIndex: disabled ? -1 : 0,\n disabled,\n suppressContentEditableWarning: true,\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 },\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n defaultValue: defaultString,\n trimWhiteSpace,\n history,\n };\n};\n"],"names":["React","getPartitionedNativeProps","slot","useId","useIsomorphicLayoutEffect","useMergedRefs","SentinelNode","LexicalPlainTextPlugin","mergeRegister","useControllableState","useEditorInput_unstable","props","ref","onChange","onPaste","trimWhiteSpace","textPlugin","history","editorRef","userEditorRef","root","primary","primarySlotTagName","excludedPropNames","useRef","disabled","setDisabled","state","initialState","customNodes","spanRef","useCallback","span","current","setRootElement","setEditable","registerEditableListener","isEditable","registerRootListener","style","whiteSpace","handleOnChange","newValue","value","defaultString","defaultValueFunction","defaultValue","undefined","placeholderValue","optional","elementType","placeholderId","id","components","input","always","defaultProps","role","contentEditable","tabIndex","suppressContentEditableWarning","lexicalInitialConfig","namespace","onError","console","error","nodes","editorState"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,yBAAyB,EACzBC,IAAI,EACJC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,QACR,6BAA6B;AAEpC,SAASC,YAAY,QAAQ,uCAAuC;AAEpE,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,sCAAsC;AAC5F,SAASC,oBAAoB,QAAQ,4BAA4B;AAEjE;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,aAAaT,sBAAsB,EACnCU,UAAU,IAAI,EACdC,WAAWC,aAAa,EACzB,GAAGR;IACJ,MAAM,EAAES,IAAI,EAAEC,OAAO,EAAE,GAAGpB,0BAA0B;QAClDqB,oBAAoB;QACpBX;QACAY,mBAAmB;YAAC;YAAY;YAAW;SAAe;IAC5D;IAEA,MAAML,YAAYb,cAAcL,MAAMwB,MAAM,CAAgB,OAAOL;IACnE,iFAAiF;IACjF,8CAA8C;IAC9C,MAAM,CAACM,UAAUC,YAAY,GAAGjB,qBAAqB;QACnDkB,OAAOhB,MAAMc,QAAQ;QACrBG,cAAc;IAChB;IAEA,MAAMC,cAAclB,MAAMkB,WAAW,GAAG;WAAIlB,MAAMkB,WAAW;QAAEvB;KAAa,GAAG;QAACA;KAAa;IAE7F,MAAMwB,UAAU9B,MAAM+B,WAAW,CAC/BC,CAAAA;YACE,yCAAyC;QACzCd;SAAAA,qBAAAA,UAAUe,OAAO,cAAjBf,yCAAAA,mBAAmBgB,cAAc,CAACF;IACpC,GACA;QAACd;KAAU;IAGb,uCAAuC;IACvCd,0BAA0B;QACxB,IAAIc,UAAUe,OAAO,EAAE;gBACrBf;aAAAA,qBAAAA,UAAUe,OAAO,cAAjBf,yCAAAA,mBAAmBiB,WAAW,CAAC,CAACV;QAClC;IACF,GAAG;QAACA;KAAS;IAEbrB,0BAA0B;QACxB,IAAIc,UAAUe,OAAO,EAAE;gBAKnBf;YAJF,OAAOV,cACLU,UAAUe,OAAO,CAACG,wBAAwB,CAACC,CAAAA;gBACzCX,YAAY,CAACW;YACf,KACAnB,qBAAAA,UAAUe,OAAO,cAAjBf,yCAAAA,mBAAmBoB,oBAAoB,CAAClB,CAAAA;gBACtC,IAAI,CAACA,MAAM;oBACT;gBACF;gBAEA,wDAAwD;gBACxD,wFAAwF;gBACxFA,KAAKmB,KAAK,CAACC,UAAU,GAAG;YAC1B;QAEJ;IACF,GAAG;QAACtB;KAAU;IAEd,MAAMuB,iBAAiBzC,MAAM+B,WAAW,CACtC,CAACW;QACC7B,qBAAAA,+BAAAA,SAAW,CAAC,GAAG;YAAE8B,OAAOD;QAAS;IACnC,GACA;QAAC7B;KAAS;IAGZ,MAAM,CAAC+B,eAAeC,qBAAqB,GAAG,AAAC,CAAA;QAC7C,IAAI,OAAOlC,MAAMmC,YAAY,KAAK,YAAY;YAC5C,OAAO;gBAACC;gBAAWpC,MAAMmC,YAAY;aAAC;QACxC;QACA,OAAO;YAACnC,MAAMmC,YAAY;YAAEC;SAAU;IACxC,CAAA;IAEA,MAAMC,mBAAmB9C,KAAK+C,QAAQ,CAACtC,MAAMqC,gBAAgB,EAAE;QAAEE,aAAa;IAAO;IACrF,MAAMC,gBAAgBhD,MAAM,0BAA0B6C,6BAAAA,uCAAAA,iBAAkBI,EAAE;IAC1E,IAAIJ,kBAAkB;QACpBA,iBAAiBI,EAAE,GAAGD;IACxB;IAEA,OAAO;QACLE,YAAY;YACVjC,MAAM;YACNkC,OAAO;YACPN,kBAAkB;QACpB;QACA5B,MAAMlB,KAAKqD,MAAM,CAAC5C,MAAMS,IAAI,EAAE;YAAEoC,cAAc;gBAAE,GAAGpC,IAAI;YAAC;YAAG8B,aAAa;QAAO;QAC/EI,OAAOpD,KAAKqD,MAAM,CAAC5C,MAAM2C,KAAK,EAAE;YAC9BE,cAAc;gBACZ5C,KAAKP,cAAcO,KAAKkB;gBACxB2B,MAAM;gBACNC,iBAAiB,CAACjC;gBAClB,iBAAiBA,WAAW,OAAOsB;gBACnCY,UAAUlC,WAAW,CAAC,IAAI;gBAC1BA;gBACAmC,gCAAgC;gBAChC,GAAGvC,OAAO;gBACV,oBAAoBA,OAAO,CAAC,mBAAmB,GAC3C,CAAC,EAAEA,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAAE8B,cAAc,CAAC,GACjDA;YACN;YACAD,aAAa;QACf;QACAF;QACAa,sBAAsB;YACpBC,WAAW;YACXC,SAASC,QAAQC,KAAK;YACtBC,OAAOrC;YACPsC,aAAatB;QACf;QACA3B;QACAO;QACAT;QACAF;QACA2B;QACAK,cAAcF;QACd7B;QACAE;IACF;AACF,EAAE"}
@@ -48,6 +48,13 @@ export const useEditorInputStyles_unstable = state => {
48
48
  const styles = useStyles();
49
49
  state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);
50
50
  state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);
51
+ state.lexicalInitialConfig = {
52
+ ...state.lexicalInitialConfig,
53
+ theme: {
54
+ ...useLexicalStyles(),
55
+ ...state.lexicalInitialConfig.theme
56
+ }
57
+ };
51
58
  if (state.placeholderValue) {
52
59
  state.placeholderValue.className = mergeClasses(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
53
60
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\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 },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground3,\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","usePlaceholderClassName","zIndex","gridArea","color","colorNeutralForeground3","body1","useInputClassName","width","useStyles","placeholderDisabled","colorNeutralForegroundDisabled","useEditorInputStyles_unstable","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,EAAEC,MAAM,EAAEC,gBAAgB,QAAQ,6BAA6B;AAIjH,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;IACV;AACF,GAAG;AAEH,OAAO,MAAMC,0BAA0Bf,gBAAgB;IACrDgB,QAAQ;IACRC,UAAU;IAEVC,OAAOf,OAAOgB,uBAAuB;IACrC,GAAGf,iBAAiBgB,KAAK;IAEzB,kCAAkC;QAChCF,OAAO;IACT;AACF,GAAG;AAEH,OAAO,MAAMG,oBAAoBrB,gBAAgB;IAC/CiB,UAAU;IACVD,QAAQ;IACRM,OAAO;AACT,GAAG;AAEH,MAAMC,YAAYtB,WAAW;IAC3BuB,qBAAqB;QACnBN,OAAOf,OAAOsB,8BAA8B;IAC9C;AACF;AACA;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C;IAEA,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IACrB,MAAME,uBAAuBd;IAC7B,MAAMe,gBAAgBrB;IACtB,MAAMsB,iBAAiBV;IACvB,MAAMW,SAAST;IAEfI,MAAMrB,IAAI,CAAC2B,SAAS,GAAG/B,aAAaG,sBAAsBC,IAAI,EAAEwB,eAAeH,MAAMrB,IAAI,CAAC2B,SAAS;IAEnGN,MAAMpB,KAAK,CAAC0B,SAAS,GAAG/B,aAAaG,sBAAsBE,KAAK,EAAEwB,gBAAgBJ,MAAMpB,KAAK,CAAC0B,SAAS;IAEvG,IAAIN,MAAMnB,gBAAgB,EAAE;QAC1BmB,MAAMnB,gBAAgB,CAACyB,SAAS,GAAG/B,aACjCG,sBAAsBG,gBAAgB,EACtCqB,sBACAD,YAAYI,OAAOR,mBAAmB,EACtCG,MAAMnB,gBAAgB,CAACyB,SAAS;IAEpC;IAEA,OAAON;AACT,EAAE"}
1
+ {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\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 },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground3,\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","usePlaceholderClassName","zIndex","gridArea","color","colorNeutralForeground3","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,EAAEC,MAAM,EAAEC,gBAAgB,QAAQ,6BAA6B;AAIjH,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;IACV;AACF,GAAG;AAEH,OAAO,MAAMC,0BAA0Bf,gBAAgB;IACrDgB,QAAQ;IACRC,UAAU;IAEVC,OAAOf,OAAOgB,uBAAuB;IACrC,GAAGf,iBAAiBgB,KAAK;IAEzB,kCAAkC;QAChCF,OAAO;IACT;AACF,GAAG;AAEH,OAAO,MAAMG,oBAAoBrB,gBAAgB;IAC/CiB,UAAU;IACVD,QAAQ;IACRM,OAAO;AACT,GAAG;AAEH,MAAMC,YAAYtB,WAAW;IAC3BuB,qBAAqB;QACnBN,OAAOf,OAAOsB,8BAA8B;IAC9C;AACF;AACA;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C;IAEA,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IACrB,MAAME,uBAAuBd;IAC7B,MAAMe,gBAAgBrB;IACtB,MAAMsB,iBAAiBV;IACvB,MAAMW,SAAST;IAEfI,MAAMrB,IAAI,CAAC2B,SAAS,GAAG/B,aAAaG,sBAAsBC,IAAI,EAAEwB,eAAeH,MAAMrB,IAAI,CAAC2B,SAAS;IAEnGN,MAAMpB,KAAK,CAAC0B,SAAS,GAAG/B,aAAaG,sBAAsBE,KAAK,EAAEwB,gBAAgBJ,MAAMpB,KAAK,CAAC0B,SAAS;IAEvGN,MAAMO,oBAAoB,GAAG;QAC3B,GAAGP,MAAMO,oBAAoB;QAC7BC,OAAO;YAAE,GAAGvB,kBAAkB;YAAE,GAAGe,MAAMO,oBAAoB,CAACC,KAAK;QAAC;IACtE;IAEA,IAAIR,MAAMnB,gBAAgB,EAAE;QAC1BmB,MAAMnB,gBAAgB,CAACyB,SAAS,GAAG/B,aACjCG,sBAAsBG,gBAAgB,EACtCqB,sBACAD,YAAYI,OAAOR,mBAAmB,EACtCG,MAAMnB,gBAAgB,CAACyB,SAAS;IAEpC;IAEA,OAAON;AACT,EAAE"}
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable, useEditorInputContextValues } from './EditorInput';
1
+ export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable } from './EditorInput';
2
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export type {\n EditorInputProps,\n EditorInputSlots,\n EditorInputState,\n EditorInputValueData,\n EditorInputContextValues,\n} from './EditorInput';\nexport {\n EditorInput,\n editorInputClassNames,\n renderEditorInput_unstable,\n useEditorInputStyles_unstable,\n useEditorInput_unstable,\n useEditorInputContextValues,\n} from './EditorInput';\n"],"names":["EditorInput","editorInputClassNames","renderEditorInput_unstable","useEditorInputStyles_unstable","useEditorInput_unstable","useEditorInputContextValues"],"rangeMappings":"","mappings":"AAOA,SACEA,WAAW,EACXC,qBAAqB,EACrBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,uBAAuB,EACvBC,2BAA2B,QACtB,gBAAgB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export type { EditorInputProps, EditorInputSlots, EditorInputState, EditorInputValueData } from './EditorInput';\nexport {\n EditorInput,\n editorInputClassNames,\n renderEditorInput_unstable,\n useEditorInputStyles_unstable,\n useEditorInput_unstable,\n} from './EditorInput';\n"],"names":["EditorInput","editorInputClassNames","renderEditorInput_unstable","useEditorInputStyles_unstable","useEditorInput_unstable"],"rangeMappings":"","mappings":"AACA,SACEA,WAAW,EACXC,qBAAqB,EACrBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,uBAAuB,QAClB,gBAAgB"}
@@ -13,11 +13,9 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
13
  const _useEditorInput = require("./useEditorInput");
14
14
  const _renderEditorInput = require("./renderEditorInput");
15
15
  const _useEditorInputStylesstyles = require("./useEditorInputStyles.styles");
16
- const _useEditorInputContextValues = require("./useEditorInputContextValues");
17
16
  const EditorInput = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
18
17
  const state = (0, _useEditorInput.useEditorInput_unstable)(props, ref);
19
- const contextValues = (0, _useEditorInputContextValues.useEditorInputContextValues)(state);
20
18
  (0, _useEditorInputStylesstyles.useEditorInputStyles_unstable)(state);
21
- return (0, _renderEditorInput.renderEditorInput_unstable)(state, contextValues);
19
+ return (0, _renderEditorInput.renderEditorInput_unstable)(state);
22
20
  });
23
21
  EditorInput.displayName = 'EditorInput'; //# sourceMappingURL=EditorInput.js.map
@@ -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';\nimport { useEditorInputContextValues } from './useEditorInputContextValues';\n\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\n return renderEditorInput_unstable(state, contextValues);\n});\n\nEditorInput.displayName = 'EditorInput';\n"],"names":["EditorInput","React","forwardRef","props","state","useEditorInput_unstable","contextValues","useEditorInputContextValues","useEditorInputStyles_unstable","renderEditorInput_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;gCACiB;mCACG;4CACG;6CAGF;AAErC,MAAMA,cAAAA,WAAAA,GAAAA,OAAqDC,UAAMC,CAAU,CAACC,OAACA;UAClFC,QAAMA,IAAAA,uCAAQC,EAAAA,OAAwBF;UACtCG,gBAAMA,IAAAA,wDAAgBC,EAAAA;iEAEtBC,EAAAA;WAEAC,IAAAA,6CAAOA,EAAAA,OAA2BL;AACpC;AAEAJ,YAAYU,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';\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":["EditorInput","React","forwardRef","props","state","useEditorInput_unstable","useEditorInputStyles_unstable","renderEditorInput_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;gCACiB;mCACG;4CACG;AAKvC,MAAMA,cAAAA,WAAAA,GAAAA,OAAqDC,UAAMC,CAAU,CAACC,OAACA;UAClFC,QAAMA,IAAAA,uCAAQC,EAAAA,OAAwBF;iEAEtCG,EAAAA;WACAC,IAAAA,6CAAOA,EAAAA;AACT;AAEAP,YAAYQ,WAAW,GAAG"}
@@ -1,4 +1,6 @@
1
- "use strict";
1
+ /**
2
+ * Data passed to the `onChange` callback when the chat input's value changes.
3
+ */ "use strict";
2
4
  Object.defineProperty(exports, "__esModule", {
3
5
  value: true
4
6
  });
@@ -1 +1 @@
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 * 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/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace'>> &\n Partial<Pick<EditorInputProps, 'onPaste' | 'editorRef'>> & {\n lexicalInitialConfig: InitialConfigType;\n handleOnChange: (value: string) => void;\n lexicalEditor: LexicalEditor;\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":""}
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 * 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/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace' | 'editorRef'>> &\n Partial<Pick<EditorInputProps, 'onPaste'>> & {\n lexicalInitialConfig: InitialConfigType;\n defaultValue?: string;\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":"AAkEA;;CAEC"}
@@ -8,5 +8,4 @@ _export_star._(require("./EditorInput.types"), exports);
8
8
  _export_star._(require("./renderEditorInput"), exports);
9
9
  _export_star._(require("./useEditorInput"), exports);
10
10
  _export_star._(require("./useEditorInputStyles.styles"), exports);
11
- _export_star._(require("./useEditorInputContextValues"), exports);
12
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EditorInput';\nexport * from './EditorInput.types';\nexport * from './renderEditorInput';\nexport * from './useEditorInput';\nexport * from './useEditorInputStyles.styles';\nexport * from './useEditorInputContextValues';\n"],"names":[],"rangeMappings":";;;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA;uBACA"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EditorInput';\nexport * from './EditorInput.types';\nexport * from './renderEditorInput';\nexport * from './useEditorInput';\nexport * from './useEditorInputStyles.styles';\n"],"names":[],"rangeMappings":";;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
@@ -12,29 +12,30 @@ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
12
  const _reactcomponents = require("@fluentui/react-components");
13
13
  const _reacttexteditor = require("@fluentui-copilot/react-text-editor");
14
14
  const _reactchatinputplugins = require("@fluentui-copilot/react-chat-input-plugins");
15
- const renderEditorInput_unstable = (state, contextValues)=>{
15
+ const renderEditorInput_unstable = (state)=>{
16
16
  (0, _reactcomponents.assertSlots)(state);
17
17
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {
18
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reacttexteditor.LexicalComposerContext.Provider, {
19
- value: contextValues.lexicalComposer,
18
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reacttexteditor.LexicalComposer, {
19
+ initialConfig: state.lexicalInitialConfig,
20
20
  children: [
21
21
  /*#__PURE__*/ (0, _jsxruntime.jsx)(state.textPlugin, {
22
22
  contentEditable: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.input, {}),
23
- ErrorBoundary: _reacttexteditor.LexicalErrorBoundary
23
+ ErrorBoundary: _reacttexteditor.LexicalErrorBoundary,
24
+ placeholder: state.placeholderValue ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.placeholderValue, {}) : null
24
25
  }),
25
26
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
26
27
  children: [
27
- state.placeholderValue ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.placeholderValue, {}) : null,
28
28
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactchatinputplugins.BasicFunctionalityPlugin, {
29
29
  onContentChange: state.handleOnChange,
30
30
  onPaste: state.onPaste,
31
- trimWhitespace: state.trimWhiteSpace
31
+ trimWhitespace: state.trimWhiteSpace,
32
+ defaultValue: state.defaultValue
32
33
  }),
33
- state.history && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacttexteditor.LexicalHistoryPlugin, {}),
34
- state.editorRef && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacttexteditor.LexicalEditorRefPlugin, {
35
- editorRef: state.editorRef
36
- })
34
+ state.history && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacttexteditor.LexicalHistoryPlugin, {})
37
35
  ]
36
+ }),
37
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacttexteditor.LexicalEditorRefPlugin, {
38
+ editorRef: state.editorRef
38
39
  })
39
40
  ]
40
41
  })
@@ -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, EditorInputContextValues } from './EditorInput.types';\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';\n\n/**\n * Render the final JSX of EditorInput\n */\nexport const renderEditorInput_unstable = (state: EditorInputState, contextValues: EditorInputContextValues) => {\n assertSlots<EditorInputSlots>(state);\n\n return (\n <state.root>\n <LexicalComposerContext.Provider value={contextValues.lexicalComposer}>\n <state.textPlugin contentEditable={<state.input />} ErrorBoundary={LexicalErrorBoundary} />\n <>\n {state.placeholderValue ? <state.placeholderValue /> : null}\n <BasicFunctionalityPlugin\n onContentChange={state.handleOnChange}\n onPaste={state.onPaste}\n trimWhitespace={state.trimWhiteSpace}\n />\n {state.history && <LexicalHistoryPlugin />}\n {state.editorRef && <LexicalEditorRefPlugin editorRef={state.editorRef} />}\n </>\n </LexicalComposerContext.Provider>\n </state.root>\n );\n};\n"],"names":["assertSlots","state","_jsx","root","LexicalComposerContext","value","contextValues","lexicalComposer","Provider","textPlugin","contentEditable","ErrorBoundary","LexicalErrorBoundary","placeholderValue","BasicFunctionalityPlugin","onContentChange","editorRef","LexicalEditorRefPlugin","onPaste"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAiBEA;;;eAAAA;;;4BAhBF;iCAE4B;iCAOrB;uCACkC;AAMvCA,MAAAA,6BAA8BC,CAAAA,OAAAA;oCAE9B,EAAAA;sBAEI,GAAAC,IAAAA,eAAA,EAAAD,MAAAE,IAAA,EAACC;kBAAgCC,WAAOC,GAAAA,IAAAA,gBAAAA,EAAcC,uCAAe,CAAAC,QAAA,EAAA;;;8BACnEN,IAAAA,eAAA,EAACD,MAAMQ,UAAU,EAAA;qCAACC,WAAAA,GAAAA,IAAAA,eAAAA,EAAAA,MAAAA,KAAiB,EAACT,CAAAA;mCAAgBU,qCAAeC;;;;8CACnE,GAAA,WAAA,GAAAV,IAAAA,eAAA,EAAAD,MAAAY,gBAAA,EAAA,CAAA,KAAA;wBAAA,WAAA,GAAAX,IAAAA,eAAA,EAAAY,+CAAA,EAAA;;2CACGb,OAAMY;gEACNC;;yCACCC,WAAAA,GAAAA,IAAAA,eAAiBd,EAAAA,qCAAoB,EAAA,CAAA;wBAAAA,MAAAe,SAAA,IAAA,WAAA,GAAAd,IAAAA,eAAA,EAAAe,uCAAA,EAAA;sDACrCC"}
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 defaultValue={state.defaultValue}\n />\n {state.history && <LexicalHistoryPlugin />}\n </>\n <LexicalEditorRefPlugin editorRef={state.editorRef} />\n </LexicalComposer>\n </state.root>\n );\n};\n"],"names":["assertSlots","state","_jsx","root","LexicalComposer","initialConfig","lexicalInitialConfig","textPlugin","contentEditable","ErrorBoundary","LexicalErrorBoundary","placeholder","placeholderValue","BasicFunctionalityPlugin","onContentChange","onPaste","trimWhitespace","defaultValue","editorRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAiBEA;;;eAAAA;;;4BAhBF;iCAE4B;iCAOrB;uCACkC;AAMvCA,MAAAA,6BAA8BC,CAAAA;oCAE9B,EAAAA;sBAEI,GAAAC,IAAAA,eAAA,EAAAD,MAAAE,IAAA,EAACC;kBAAgBC,WAAAA,GAAeJ,IAAAA,gBAAAA,EAAMK,gCAAAA,EAAAA;;;8BACpCJ,IAAAA,eAAA,EAACD,MAAMM,UAAU,EAAA;qCACfC,WAAAA,GAAAA,IAAAA,eAAAA,EAAAA,MAAAA,KAAiB,EAACP,CAAAA;mCAClBQ,qCAAeC;iCACfC,MAAAA,gBAAmBC,GAAAA,WAAgB,GAAAV,IAAAA,eAAA,EAAAD,MAAAW,gBAAUA,EAAAA,CAAAA,KAAAA;;;;mCAE/C,GAAAV,IAAAA,eAAA,EAAAW,+CAAA,EAAA;;;kDAEIC,cAAiBb;gDACjBc,YAASd;;yCACTe,WAAAA,GAAAA,IAAAA,eAAgBf,EAAAA,qCAAoB,EAAA,CAAA;qBAAA;;mDACpCgB,uCAAoBA,EAAAA;;;;;;gDAIiBC"}