src/client/components/PlainMarkdownInput/slate/transforms.js
function unionEmphasis({ change, focusKey, characters, accent, text, startOffset, endOffset, markerLength }) {
  const leftEmphEdge = getLeftEmphEdge(accent, characters, startOffset);
  const rightEmphEdge = getRightEmphEdge(accent, characters, endOffset - 1, text.length);
  const leftMarker = text.substr(leftEmphEdge, markerLength);
  let rightMarkerPos = rightEmphEdge - markerLength;
  const rightMarker = text.substr(rightMarkerPos, markerLength);
  const delCount = delInternalMarkers({
    change,
    focusKey,
    characters,
    accent,
    startPos: leftEmphEdge + markerLength,
    endPos: rightEmphEdge - markerLength
  });
  rightMarkerPos -= delCount * markerLength - 1;
  if (leftMarker !== rightMarker) {
    change.removeTextByKey(focusKey, rightMarkerPos, markerLength).
      insertTextByKey(focusKey, rightMarkerPos, leftMarker);
  }
  return change;
}
function unionEmphasis({ change, focusKey, characters, accent, text, startOffset, endOffset, markerLength }) {
  const leftEmphEdge = getLeftEmphEdge(accent, characters, startOffset);
  const rightEmphEdge = getRightEmphEdge(accent, characters, endOffset - 1, text.length);
  const leftMarker = text.substr(leftEmphEdge, markerLength);
  let rightMarkerPos = rightEmphEdge - markerLength;
  const rightMarker = text.substr(rightMarkerPos, markerLength);
  const delCount = delInternalMarkers({
    change,
    focusKey,
    characters,
    accent,
    startPos: leftEmphEdge + markerLength,
    endPos: rightEmphEdge - markerLength
  });
  rightMarkerPos -= delCount * markerLength - 1;
  if (leftMarker !== rightMarker) {
    change.removeTextByKey(focusKey, rightMarkerPos, markerLength).
      insertTextByKey(focusKey, rightMarkerPos, leftMarker);
  }
  return change;
}
function unionEmphasis ( { change , focusKey , characters , accent , text , startOffset , endOffset , markerLength } ) { const leftEmphEdge = getLeftEmphEdge ( accent , characters , startOffset ) ; const rightEmphEdge = getRightEmphEdge ( accent , characters , endOffset - 1 , text . length ) ; const leftMarker = text . substr ( leftEmphEdge , markerLength ) ; let rightMarkerPos = rightEmphEdge - markerLength ; const rightMarker = text . substr ( rightMarkerPos , markerLength ) ; const delCount = delInternalMarkers ( { change , focusKey , characters , accent , startPos : leftEmphEdge + markerLength , endPos : rightEmphEdge - markerLength } ) ; rightMarkerPos -= delCount * markerLength - 1 ; if ( leftMarker !== rightMarker ) { change . removeTextByKey ( focusKey , rightMarkerPos , markerLength ) . insertTextByKey ( focusKey , rightMarkerPos , leftMarker ) ; } return change ; }
Both selection edges is on emphasis, delete all internal markers

@param change
@param focusKey
@param characters
@param text
@param accent
@param startOffset
@param endOffset
@param markerLength
Both selection edges is on emphasis delete all internal markers