import { ModelPrivate } from './model-private' ; import { CompositionAtom } from '../core-atoms/composition' ; /**
 * Create, remove or update a composition atom at the current location
 */ export function updateComposition ( model , s ) { const cursor = model . at ( model . position ) ; if ( cursor . type === 'composition' ) { cursor . value = s ; } else { const { caret } = cursor ; cursor . caret = '' ; const atom = new CompositionAtom ( s , { mode : cursor . mode } ) ; atom . caret = caret ; cursor . parent ! . addChildAfter ( atom , cursor ) ; model . position += 1 ; } } /**
 * Remove the composition zone
 */ export function removeComposition ( model ) { const cursor = model . at ( model . position ) ; if ( cursor . type === 'composition' ) { cursor . parent ! . removeChild ( cursor ) ; model . position -= 1 ; } }