snippet.js 822 B

123456789101112131415161718192021
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals window, document */
  6. /**
  7. * Returns the `config.toolbar.viewportTopOffset` config value for editors using floating toolbars that
  8. * stick to the top of the viewport to remain visible to the user.
  9. *
  10. * The value is determined in styles by the `--ck-snippet-viewport-top-offset` custom property
  11. * and may differ e.g. according to the used media queries.
  12. *
  13. * @returns {Number} The value of the offset.
  14. */
  15. window.getViewportTopOffsetConfig = function() {
  16. const documentElement = document.documentElement;
  17. return parseInt( window.getComputedStyle( documentElement ).getPropertyValue( '--ck-snippet-viewport-top-offset' ) );
  18. };