Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.1 KB
Raw Blame
import { post } from './host-bridge'
import type { RichMarkdownKeyboardInsetReader } from './document-host-seams'
import type { RichMarkdownEditorScope } from './document-scope'

/** Posts the covered height, and only when it has actually moved. */
function reportKeyboardInset(
  scope: RichMarkdownEditorScope,
  source: RichMarkdownKeyboardInsetReader
) {
  const rounded = Math.round(source.measure())
  if (rounded === scope.lastInset) {
    return
  }
  scope.lastInset = rounded
  post(scope, { type: 'keyboardInset', bottom: rounded })
}

// Observe/post keyboard cover only when source exists; page omits source because screen measures same viewport and duplicate report would double-lift layout.
export function startKeyboardInset(scope: RichMarkdownEditorScope) {
  const source = scope.keyboardInsetSource()
  if (!source) {
    return
  }
  const report = () => reportKeyboardInset(scope, source)
  scope.removeKeyboardInset = source.observe(report)
  report()
}

export function stopKeyboardInset(scope: RichMarkdownEditorScope) {
  scope.removeKeyboardInset?.()
  scope.removeKeyboardInset = null
}