src/client/components/PlainMarkdownInput/slate/transforms.js
function(accent, state) {
  if (hasMultiLineSelection(state)) {
    const {
      anchorKey,
      anchorOffset,
      focusKey,
      focusOffset,
      isBackward
    } = state.selection;
    const keys = [];
    let firstBefore, firstAfter, lastBefore, lastAfter;
    for (let i = 0; i < state.texts.size; i++) {
      keys.push(state.texts.get(i).key);
    }

    let change = state.change();
    const keysLength = keys.length;
    const lastNum = keysLength - 1;
    for (let i = 0; i < keysLength; i++) {
      moveSelectionToLine(change, keys[i]);
      if (i === 0) {
        firstBefore = getTextLength(change);
      } else if (i === lastNum) {
        lastBefore = getTextLength(change);
      }
      change = unwrapListCallbacksForChange[accent](change);
      if (i === 0) {
        firstAfter = getTextLength(change);
      } else if (i === lastNum) {
        lastAfter = getTextLength(change);
      }
    }
    const newAnchorOffset = anchorOffset - (isBackward ? lastBefore - lastAfter : firstBefore - firstAfter);
    const newFocusOffset = focusOffset - (isBackward ? firstBefore - firstAfter : lastBefore - lastAfter);
    change.select({
      anchorKey,
      anchorOffset: newAnchorOffset < 0 ? 0 : newAnchorOffset,
      focusKey,
      focusOffset: newFocusOffset < 0 ? 0 : newFocusOffset,
      isFocused: true,
      isBackward
    });
    return change.state;
  } else {
    return unwrapListCallbacks[accent](state);
  }
}
function(accent, state) {
  if (hasMultiLineSelection(state)) {
    const {
      anchorKey,
      anchorOffset,
      focusKey,
      focusOffset,
      isBackward
    } = state.selection;
    const keys = [];
    let firstBefore, firstAfter, lastBefore, lastAfter;
    for (let i = 0; i < state.texts.size; i++) {
      keys.push(state.texts.get(i).key);
    }

    let change = state.change();
    const keysLength = keys.length;
    const lastNum = keysLength - 1;
    for (let i = 0; i < keysLength; i++) {
      moveSelectionToLine(change, keys[i]);
      if (i === 0) {
        firstBefore = getTextLength(change);
      } else if (i === lastNum) {
        lastBefore = getTextLength(change);
      }
      change = unwrapListCallbacksForChange[accent](change);
      if (i === 0) {
        firstAfter = getTextLength(change);
      } else if (i === lastNum) {
        lastAfter = getTextLength(change);
      }
    }
    const newAnchorOffset = anchorOffset - (isBackward ? lastBefore - lastAfter : firstBefore - firstAfter);
    const newFocusOffset = focusOffset - (isBackward ? firstBefore - firstAfter : lastBefore - lastAfter);
    change.select({
      anchorKey,
      anchorOffset: newAnchorOffset < 0 ? 0 : newAnchorOffset,
      focusKey,
      focusOffset: newFocusOffset < 0 ? 0 : newFocusOffset,
      isFocused: true,
      isBackward
    });
    return change.state;
  } else {
    return unwrapListCallbacks[accent](state);
  }
}
function ( accent , state ) { if ( hasMultiLineSelection ( state ) ) { const { anchorKey , anchorOffset , focusKey , focusOffset , isBackward } = state . selection ; const keys = [ ] ; let firstBefore , firstAfter , lastBefore , lastAfter ; for ( let i = 0 ; i < state . texts . size ; i ++ ) { keys . push ( state . texts . get ( i ) . key ) ; } let change = state . change ( ) ; const keysLength = keys . length ; const lastNum = keysLength - 1 ; for ( let i = 0 ; i < keysLength ; i ++ ) { moveSelectionToLine ( change , keys [ i ] ) ; if ( i === 0 ) { firstBefore = getTextLength ( change ) ; } else if ( i === lastNum ) { lastBefore = getTextLength ( change ) ; } change = unwrapListCallbacksForChange [ accent ] ( change ) ; if ( i === 0 ) { firstAfter = getTextLength ( change ) ; } else if ( i === lastNum ) { lastAfter = getTextLength ( change ) ; } } const newAnchorOffset = anchorOffset - ( isBackward ? lastBefore - lastAfter : firstBefore - firstAfter ) ; const newFocusOffset = focusOffset - ( isBackward ? firstBefore - firstAfter : lastBefore - lastAfter ) ; change . select ( { anchorKey , anchorOffset : newAnchorOffset < 0 ? 0 : newAnchorOffset , focusKey , focusOffset : newFocusOffset < 0 ? 0 : newFocusOffset , isFocused : true , isBackward } ) ; return change . state ; } else { return unwrapListCallbacks [ accent ] ( state ) ; } }
Unwrap text with list token

@param {string} accent
@param state - editor state
@returns {Object} - state
Unwrap text with list token