Mobile & voice typing
Two ways to get content into noteloom without a physical keyboard and mouse.
Touch-first editing
Typing "/"/"@" still works on a phone keyboard, but it's not a reliable or discoverable primary path there (autocorrect, awkward key access, nothing to discover it by). On a coarse (touch) pointer, mount MobileActionBar alongside your other trigger hooks and it takes over as the touch-first equivalent, pinned above the on-screen keyboard:
import { MobileActionBar } from 'noteloom';
// Next to your other trigger hooks/components, same containerRef:
<MobileActionBar containerRef={containerRef} />It renders nothing on a mouse/trackpad, and nothing until focus is actually inside the editor. Its contents swap based on context:
| Context | Shows |
|---|---|
| Caret/selection inside any block | Duplicate / Move up / Move down / Hide-Show / Delete — the mobile home for the desktop gutter's grip-handle menu. |
| Text selected | Formatting actions (bold/italic/underline/link) — the same surface the desktop FloatingToolbar would show, which disables itself on touch. |
| Collapsed caret, table cell | Insert row/column. |
| Collapsed caret, code block | Language picker. |
| Collapsed caret, callout | Color picker. |
| Collapsed caret, everywhere else | "+" (opens a tap-friendly block picker sheet — the same commands "/" offers), Undo/Redo, dismiss-keyboard. |
The desktop block gutter is hidden entirely on touch input — there's no hover state to reveal it by, and its position sits in a page margin that doesn't exist on a narrow viewport — so both of its actions ("+" and the options menu) live in this bar instead.
How touch is detected
Deliberately not a static matchMedia('(pointer: coarse)') check (see useCoarsePointer, also exported) — a touchscreen laptop reports its trackpad as the "primary" pointer even though the touchscreen sitting right there can be used at any moment, so a pure media-query check would never show touch UI on that class of device.
Instead, the media query only supplies the initial guess (correct pre-interaction, SSR-safe); every real pointerdown afterward overrides it with that event's own pointerType, so a 2-in-1 laptop shows desktop UI while the trackpad is in use and mobile UI the instant the screen is tapped — live, no reload needed. The same signal is mirrored onto <html class="be-touch-input">, so plain CSS (the gutter-hiding rule) reacts to it too, not just MobileActionBar itself.
Trigger-menu and Select popovers reposition above the caret instead of below it when there isn't room before the keyboard, via useVirtualKeyboardInset() (also exported, in case you're positioning your own UI against the keyboard).
Since 0.6.0: typing "/" no longer opens the slash-command menu on a real phone or tablet — MobileActionBar's own "+" picker (above) is the intended, tap-friendly way to insert a block there instead. This is a different signal from the live pointerType-tracking described above: it's backed by useTouchOnlyDevice(), a static, one-time classification (true only when the device has no non-touch pointer at all) rather than "which pointer was used most recently". That distinction matters for a 2-in-1 laptop: its trackpad still opens the slash menu as usual even while the touchscreen is available, since the device genuinely does have a non-touch pointer — only a device that could never show a mouse/trackpad input has this menu suppressed.
Voice typing
useVoiceTyping() wraps the browser's native Web Speech API (SpeechRecognition) for continuous dictation mixed with spoken structural commands — say "heading one", "new paragraph", "bulleted list", "quote", "undo", etc. while dictating, and the current block converts (or a new one is inserted) instead of those words being typed as text.
import { useVoiceTyping } from 'noteloom/voice';
function MicButton() {
const voice = useVoiceTyping();
if (!voice.isSupported) return null; // e.g. Firefox — no bundled fallback, degrades to nothing
return (
<button onClick={() => (voice.isListening ? voice.stop() : voice.start())}>
{voice.isListening ? 'Stop dictation' : 'Start dictation'}
</button>
);
}Returns { isSupported, isListening, status, permissionState, error, start, stop }. No speech-to-text SDK is bundled — real speech recognition needs either a network round-trip to a vendor's servers or a genuinely heavy on-device model, either of which conflicts with staying zero-runtime-dependency — so this is built entirely on SpeechRecognition/webkitSpeechRecognition, and isSupported is false wherever that API doesn't exist (Firefox, most notably).
A command is only recognized when an entire finalized spoken utterance (a natural pause before/after, as reported by the Speech API itself) matches a known phrase exactly — so a command word merely mentioned mid-sentence while dictating prose is never misread as a command.
A mic button in the floating toolbar
Since 0.6.0: rather than building your own mic button, FloatingToolbar (and NoteloomEditor) accept an optional voice prop — pass what useVoiceTyping({ store }) returns and a start/stop dictation toggle appears in the selection toolbar, right next to bold/italic/link:
import { useVoiceTyping } from 'noteloom/voice';
import { FloatingToolbar, useFloatingToolbarTrigger } from 'noteloom';
function EditorSurface({ store }) {
// store option required here — this call sits above/outside the
// EditorProvider that FloatingToolbar itself renders inside of, so
// useVoiceTyping() with no arguments would have no context to read it from.
const voice = useVoiceTyping({ store });
const toolbar = useFloatingToolbarTrigger(containerRef);
return (
<FloatingToolbar
isOpen={toolbar.isOpen}
rect={toolbar.rect}
kind={toolbar.kind}
selection={toolbar.selection}
marks={toolbar.marks}
store={store}
voice={voice} // adds the mic toggle -- omit to leave it out entirely
/>
);
}The explicit store is required here specifically — unlike the MicButton example above, this call site sits outside the EditorProvider that FloatingToolbar itself renders inside of, so the no-argument form would have no context to read the store from. Omitting voice entirely (the default) keeps every bit of SpeechRecognition-related code out of your bundle — neither component imports noteloom/voice itself.
Embedded webviews (Tauri, Electron, ...)
Added in 0.3.3. window.SpeechRecognition is commonly absent or silently broken in an embedded webview — Tauri's WebView2 (Windows) and WKWebView (macOS) most notably: WKWebView has no Web Speech API at all, and WebView2 has the constructor (it's Chromium-based) but every session fails immediately with a 'network' error, since it's missing the private API key real Chrome ships with. Left unhandled, that's a worse experience than no mic button at all — it looks supported and then fails the instant someone clicks it.
Pass engine, a zero-arg factory returning a SpeechRecognition-shaped object, to route dictation through your own bridge instead — a native OS speech API called over Tauri's IPC, or a cloud STT service streamed back into the same shape:
const voice = useVoiceTyping({
engine: () => createMyRecognitionEngine(), // must implement start/stop, continuous/interimResults,
}); // and emit onresult/onstart/onspeechstart/onspeechend/onerror/onend
// in the native SpeechRecognition shape -- see the hook's own doc
// comment (useVoiceTyping.js) for the exact per-event contract.With engine set, isSupported is unconditionally true — you've already decided your engine is usable, so the browser-detection path is skipped entirely. Omit it and existing callers are unaffected.