7f059dbd45
Migrate keyboard dictation to continuous Flow sessions with auto-start, tap-to-toggle recording, 60s countdown, five-step onboarding, and App Group IPC. Add docs/ GitHub Pages site with en/zh privacy policy for App Store compliance.
18 lines
645 B
Swift
18 lines
645 B
Swift
// DictationTextComposer.swift
|
|
// OSGKeyboard · Shared
|
|
//
|
|
// Merges pre-dictation anchor text with a live cumulative transcript.
|
|
|
|
import Foundation
|
|
|
|
public enum DictationTextComposer {
|
|
/// Combine text that existed before dictation with the current live transcript.
|
|
public static func compose(anchor: String, live: String) -> String {
|
|
let trimmed = live.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
guard !trimmed.isEmpty else { return anchor }
|
|
if anchor.isEmpty { return trimmed }
|
|
if anchor.last == " " || anchor.last == "\n" { return anchor + trimmed }
|
|
return anchor + " " + trimmed
|
|
}
|
|
}
|