diff --git a/public/scripts/extensions/floating-prompt/index.js b/public/scripts/extensions/floating-prompt/index.js index d37f7bb88..0ebb432c1 100644 --- a/public/scripts/extensions/floating-prompt/index.js +++ b/public/scripts/extensions/floating-prompt/index.js @@ -1,5 +1,6 @@ import { chat_metadata, saveSettingsDebounced } from "../../../script.js"; import { extension_settings, getContext } from "../../extensions.js"; +import { registerSlashCommand } from "../../slash-commands.js"; import { debounce } from "../../utils.js"; export { MODULE_NAME }; @@ -19,6 +20,10 @@ const metadata_keys = { position: 'note_position', } +function setNoteCommand(_, text) { + $('#extension_floating_prompt').val(text).trigger('input'); +} + async function onExtensionFloatingPromptInput() { chat_metadata[metadata_keys.prompt] = $(this).val(); saveMetadataDebounced(); @@ -180,4 +185,5 @@ async function moduleWorker() { addExtensionsSettings(); setInterval(moduleWorkerWrapper, UPDATE_INTERVAL); + registerSlashCommand('note', setNoteCommand, [], " – sets an author's note for the currently selected chat", true, true); })(); \ No newline at end of file diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index c63357074..6ee7600ea 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -97,7 +97,9 @@ function executeSlashCommands(text) { return false; } - const lines = text.split('\n'); + // Hack to allow multi-line slash commands + // All slash command messages should begin with a slash + const lines = [text]; const linesToRemove = []; let interrupt = false;