SynthesisContainer
The SynthesisContainer
class is responsible for managing the insertion of text into the editor
at a specified location and for handling the scrolling of the editor to ensure that the inserted
text is visible to the user. It also provides functionality to display a placeholder in the editor
and to remove it later.
Methods
addConfirmButton()
Adds a confirm button to the editor. This function generates a unique ID for the button, appends the button to the editor content, and attaches an event listener to the button. When the button is clicked, it prevents the default form submission behavior and executes the provided callback function.
Parameters
Parameter | Type | Description |
---|---|---|
text | string | The text to be displayed on the button. |
callback | () => void | The callback function to be executed when the button is clicked. |
Source
render/SynthesisContainer.ts:163
appendText()
Appends the given text to the editor and ensures the newly added text is visible.
This method wraps the private _appendText
method to insert the text, and then
calls scrollIntoView
on the editor to scroll to the location where the text was added.
Parameters
Parameter | Type | Description |
---|---|---|
text | string | The text to be appended to the editor content. |
Source
render/SynthesisContainer.ts:77
finalize()
Finalizes the editor content by appending a code fence for the ‘enzyme’ language. This function inserts a closing code fence for a ‘enzyme’ code block at the current cursor position within the editor. It then moves the cursor three lines down to position it within the newly created code block, ready for further input. Finally, it focuses the editor to allow for immediate typing.
Source
render/SynthesisContainer.ts:179
getMessagesToHere()
Retrieves all messages up to the specified cursor position.= This function parses the content of the editor up to the specified cursor position and extracts chat messages with metadata. It identifies the role of each message (user or assistant) and extracts the content and metadata for each message. The messages are then returned as an array of ChatMessageWithMetadata objects.
Parameters
Parameter | Type | Description |
---|---|---|
curLine | number | The current line position of the cursor in the editor (defaults to the current line). |
curCh | number | The current character position of the cursor in the editor (defaults to the current character). |
Returns
An array of chat messages with metadata up to the specified cursor position.
Source
render/SynthesisContainer.ts:202
renderMetadata()
Appends the provided metadata as a hidden div element to the editor. This function takes an array of AssistantMessageMetadata objects and converts it into a JSON string. The JSON string is then wrapped in a div element with a style set to display
, which is appended to the editor content. This allows the metadata to be included in the document without being visible to the user.Parameters
Parameter | Type | Description |
---|---|---|
metadata | AssistantMessageMetadata [] | An array of metadata objects to be appended. |
Source
render/SynthesisContainer.ts:147
resetText()
Resets the text in the editor starting from the line after the end of the code fence. It replaces the range of text from the specified starting point to the current cursor position with a new line, a prompt indicator, and a space. This is typically used to clear the editor content and prepare it for new input or messages.
Source
render/SynthesisContainer.ts:124
waitPlaceholder()
Displays a placeholder in the editor and returns a function to remove it. This method inserts a temporary placeholder string into the editor at the current cursor position. The placeholder is styled to pulsate, indicating an ongoing process. The method returns a cleanup function that, when called, removes the placeholder from the editor.
Parameters
Parameter | Type | Description |
---|---|---|
placeholder | string | The text to be displayed as a placeholder. |
Returns
A function that removes the placeholder from the editor when called.
Source
Source
render/SynthesisContainer.ts:97
Generated using typedoc-plugin-markdown and TypeDoc