It currently directly uses postion.offset to calculate word boundary. It needs to also take affinity into calculation.