import { getSelection, getRangeFromSelection, } from '@schlechtenburg/core'; /** * Wrap range with tag */ export const surround = (range: Range) => { range.surroundContents(document.createElement('i')); } /** * Check selection and set activated state to button if there are tag */ export const checkState = (): boolean => { const selection = getSelection(); const range = getRangeFromSelection(selection); console.log(range); const isActive = document.queryCommandState('italic'); return isActive; }