diff --git a/manifest.json b/manifest.json index 241eb0d..ac236e1 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "scribe", "name": "Scribe", - "version": "1.0.4", + "version": "1.0.5", "minAppVersion": "0.15.0", "description": "Record voice notes, Fill in lost thoughts, Transcribe the audio, Summarize & Visualize the text - All in one clip", "author": "Mike Alicea", diff --git a/package.json b/package.json index 5858a3b..b540e1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-scribe-plugin", - "version": "1.0.4", + "version": "1.0.5", "description": "An Obsidian plugin for recording voice notes, transcribing the audio, and summarizing the text - All in one", "main": "build/main.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 114a9fd..3bd2e93 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,6 +46,11 @@ const DEFAULT_STATE: ScribeState = { openAiClient: null, }; +export interface ScribeOptions { + isAppendToActiveFile?: boolean; + isOnlyTranscribeActive?: boolean; +} + export default class ScribePlugin extends Plugin { settings: ScribePluginSettings = DEFAULT_SETTINGS; state: ScribeState = DEFAULT_STATE; @@ -121,7 +126,7 @@ export default class ScribePlugin extends Plugin { } } - async scribe(isAppendToActiveFile?: boolean) { + async scribe(scribeOptions: ScribeOptions = {}) { try { const baseFileName = createBaseFileName(); @@ -132,7 +137,7 @@ export default class ScribePlugin extends Plugin { baseNoteAndAudioFileName: baseFileName, audioRecordingFile: recordingFile, audioRecordingBuffer: recordingBuffer, - isAppendToActiveFile, + scribeOptions: scribeOptions, }); } catch (error) { new Notice(`Scribe: Something went wrong ${error.toString()}`); @@ -225,13 +230,14 @@ export default class ScribePlugin extends Plugin { baseNoteAndAudioFileName, audioRecordingFile, audioRecordingBuffer, - isAppendToActiveFile, + scribeOptions = {}, }: { baseNoteAndAudioFileName: string; audioRecordingFile: TFile; audioRecordingBuffer: ArrayBuffer; - isAppendToActiveFile?: boolean; + scribeOptions?: ScribeOptions; }) { + const { isAppendToActiveFile, isOnlyTranscribeActive } = scribeOptions; const scribeNoteFilename = `scribe-${baseNoteAndAudioFileName}`; let note = isAppendToActiveFile @@ -254,7 +260,11 @@ export default class ScribePlugin extends Plugin { this.app.workspace.openLinkText(note?.path, currentPath, true); const transcript = await this.handleTranscription(audioRecordingBuffer); - await addTranscriptToNote(this, note, transcript); + await addTranscriptToNote(this, note, transcript, isOnlyTranscribeActive); + + if (isOnlyTranscribeActive) { + return; + } const llmSummary = await this.handleTranscriptSummary(transcript); await addSummaryToNote(this, note, llmSummary); diff --git a/src/modal/components/ModalRecordingOptions.tsx b/src/modal/components/ModalRecordingOptions.tsx index f12f88f..87fdb97 100644 --- a/src/modal/components/ModalRecordingOptions.tsx +++ b/src/modal/components/ModalRecordingOptions.tsx @@ -1,24 +1,46 @@ +import type { ScribeOptions } from 'src'; + export function ModalRecordingOptions({ - isAppendToActiveFile, - setIsAppendToActiveFile, + options, + setOptions, }: { - isAppendToActiveFile: boolean; - setIsAppendToActiveFile: (value: boolean) => void; + options: ScribeOptions; + setOptions: React.Dispatch; }) { - const handleCheckboxChange = (event: React.ChangeEvent) => { - setIsAppendToActiveFile(event.target.checked); + const handleChangeIsAppendToActiveFile = ( + event: React.ChangeEvent, + ) => { + // setIsAppendToActiveFile(event.target.checked); + setOptions({ ...options, isAppendToActiveFile: event.target.checked }); + }; + const handleChangeIsOnlyTranscribeActive = ( + event: React.ChangeEvent, + ) => { + setOptions({ ...options, isOnlyTranscribeActive: event.target.checked }); + // setIsOnlyTranscribeActive(event.target.checked); }; + const { isAppendToActiveFile, isOnlyTranscribeActive } = options; + return (
+ +
); } diff --git a/src/modal/scribeControlsModal.tsx b/src/modal/scribeControlsModal.tsx index 7425417..5b2326f 100644 --- a/src/modal/scribeControlsModal.tsx +++ b/src/modal/scribeControlsModal.tsx @@ -1,6 +1,7 @@ import { createRoot, type Root } from 'react-dom/client'; import { Modal } from 'obsidian'; import type ScribePlugin from 'src'; +import type { ScribeOptions } from 'src'; import { useState } from 'react'; import { ModalSettings } from './components/ModalSettings'; import { ModalRecordingTimer } from './components/ModalRecordingTimer'; @@ -53,7 +54,12 @@ const ScribeModal: React.FC<{ plugin: ScribePlugin }> = ({ plugin }) => { const [recordingStartTimeMs, setRecordingStartTimeMs] = useState< number | null >(null); - const [isAppendToActiveFile, setIsAppendToActiveFile] = useState(false); + const [scribeOptions, setScribeOptions] = useState({ + isAppendToActiveFile: false, + isOnlyTranscribeActive: false, + }); + + const { isAppendToActiveFile, isOnlyTranscribeActive } = scribeOptions; const hasOpenAiApiKey = Boolean(plugin.settings.openAiApiKey); @@ -84,7 +90,7 @@ const ScribeModal: React.FC<{ plugin: ScribePlugin }> = ({ plugin }) => { setIsScribing(true); setRecordingStartTimeMs(null); setRecordingState('inactive'); - await plugin.scribe(isAppendToActiveFile); + await plugin.scribe({ isAppendToActiveFile, isOnlyTranscribeActive }); setIsPaused(false); setIsActive(false); setIsScribing(false); @@ -139,8 +145,8 @@ const ScribeModal: React.FC<{ plugin: ScribePlugin }> = ({ plugin }) => { Settings diff --git a/src/styles.css b/src/styles.css index 437ce41..fb56ce3 100644 --- a/src/styles.css +++ b/src/styles.css @@ -144,3 +144,14 @@ If your plugin does not need CSS, delete this file. align-items: center; justify-content: space-between; } + +.scribe-recording-options { + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: space-between; + + label { + margin-bottom: .5em; + } +} diff --git a/src/util/fileUtils.ts b/src/util/fileUtils.ts index 1f0662a..95c5777 100644 --- a/src/util/fileUtils.ts +++ b/src/util/fileUtils.ts @@ -90,9 +90,12 @@ export async function addTranscriptToNote( plugin: ScribePlugin, noteFile: TFile, transcript: string, + isOnlyTranscribeActive?: boolean, ) { try { - const textToAdd = `${transcript} + const textToAdd = isOnlyTranscribeActive + ? `${transcript}` + : `${transcript} ${SUMMARY_IN_PROGRESS_HEADER}`; await plugin.app.vault.process(noteFile, (data) => {