src/js/wysiwygCommands/code.js
function styleCode(editor, sq) {
  if (!sq.hasFormat('PRE') && sq.hasFormat('code')) {
    sq.changeFormat(null, {tag: 'code'});
    removeUnnecessaryCodeInNextToRange(editor.getSelection().cloneRange());
  } else if (!sq.hasFormat('a') && !sq.hasFormat('PRE')) {
    if (sq.hasFormat('b')) {
      sq.removeBold();
    } else if (sq.hasFormat('i')) {
      sq.removeItalic();
    }

    sq.changeFormat({tag: 'code'});

    const range = sq.getSelection().cloneRange();
    range.setStart(range.endContainer, range.endOffset);
    range.collapse(true);

    sq.setSelection(range);
  }
}
function styleCode(editor, sq) {
  if (!sq.hasFormat('PRE') && sq.hasFormat('code')) {
    sq.changeFormat(null, {tag: 'code'});
    removeUnnecessaryCodeInNextToRange(editor.getSelection().cloneRange());
  } else if (!sq.hasFormat('a') && !sq.hasFormat('PRE')) {
    if (sq.hasFormat('b')) {
      sq.removeBold();
    } else if (sq.hasFormat('i')) {
      sq.removeItalic();
    }

    sq.changeFormat({tag: 'code'});

    const range = sq.getSelection().cloneRange();
    range.setStart(range.endContainer, range.endOffset);
    range.collapse(true);

    sq.setSelection(range);
  }
}
function styleCode ( editor , sq ) { if ( ! sq . hasFormat ( 'PRE' ) && sq . hasFormat ( 'code' ) ) { sq . changeFormat ( null , { tag : 'code' } ) ; removeUnnecessaryCodeInNextToRange ( editor . getSelection ( ) . cloneRange ( ) ) ; } else if ( ! sq . hasFormat ( 'a' ) && ! sq . hasFormat ( 'PRE' ) ) { if ( sq . hasFormat ( 'b' ) ) { sq . removeBold ( ) ; } else if ( sq . hasFormat ( 'i' ) ) { sq . removeItalic ( ) ; } sq . changeFormat ( { tag : 'code' } ) ; const range = sq . getSelection ( ) . cloneRange ( ) ; range . setStart ( range . endContainer , range . endOffset ) ; range . collapse ( true ) ; sq . setSelection ( range ) ; } }
Style code.
@param {object} editor - editor instance
@param {object} sq - squire editor instance
Style code .