Starting with the canonical quantization procedure for the electromagnetic field inside an effective (linear or nonlinear) medium, we present a direct-space formulation of the theory of quantum optics. This approach does not use the conventional modal decomposition of the field, but relies on the electromagnetic momentum operator defined in terms of local electric- and magnetic-field operators. The momentum operator contains all the information on the spatial characteristics of the field, and can describe the translation of a short light pulse in a nonlinear medium, without a modal analysis of the pulse. Propagation is described through an operatorial wave equation that relates the temporal evolution of an electromagnetic pulse to its spatial progression. Through this equation, the direct-space approach to quantum optics can treat traveling-wave nonlinear-optical phenomena and, at the same time, account for their quantum statistics. The theory is applied to squeezed-light generation by the parametric down-conversion of a short laser pulse, as an illustration.