diff --git a/main.ts b/main.ts index e568cc8..4878d9e 100644 --- a/main.ts +++ b/main.ts @@ -199,20 +199,27 @@ export default class SmartMemosPlugin extends Plugin { let LnToWrite = this.getNextNewLine(editor, currentLn); let lastLine = LnToWrite; + const mock_env = { chunk_handler: (chunk: string) => { - editor.setLine(LnToWrite, editor.getLine(LnToWrite) + chunk); - if(chunk.includes('\n')){ - LnToWrite = this.getNextNewLine(editor, LnToWrite); - } + // Split the chunk by new line character + const lines = chunk.split('\n'); + lines.forEach((line, index) => { + if (index > 0) { + LnToWrite = this.getNextNewLine(editor, LnToWrite); + LnToWrite++; // We want to add an extra break for each new line + } + editor.setLine(LnToWrite, editor.getLine(LnToWrite) + line); + }); }, done_handler: (final_resp: string) => { - LnToWrite = this.getNextNewLine(editor, lastLine); - if(this.settings.includeTranscript) { - editor.setLine(LnToWrite, editor.getLine(LnToWrite) + '\n# Transcript\n' + this.transcript); + if (this.settings.includeTranscript) { + LnToWrite = this.getNextNewLine(editor, LnToWrite); + editor.setLine(LnToWrite++, '# Transcript\n\n' + this.transcript); } } }; + const smart_chat_model = new SmartChatModel( mock_env, "openai", diff --git a/styles.css b/styles.css index 54be996..4248c4f 100644 --- a/styles.css +++ b/styles.css @@ -6,6 +6,10 @@ available in the app when your plugin is enabled. If your plugin does not need CSS, delete this file. */ +.mermaid svg { + width: 100%; + height: auto; +} .text-box { width: 350px;