googledocsnormalizer.js 826 B

12345678910111213141516171819202122232425262728293031323334
  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. /**
  6. * @module paste-from-office/normalizer/googledocsnormalizer
  7. */
  8. import removeBoldWrapper from '../filters/removeboldwrapper';
  9. import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter';
  10. /**
  11. * Normalizer for the content pasted from Google Docs.
  12. *
  13. * @implements module:paste-from-office/normalizer~Normalizer
  14. */
  15. export default class GoogleDocsNormalizer {
  16. /**
  17. * @inheritDoc
  18. */
  19. isActive( htmlString ) {
  20. return /id=("|')docs-internal-guid-[-0-9a-f]+("|')/.test( htmlString );
  21. }
  22. /**
  23. * @inheritDoc
  24. */
  25. execute( data ) {
  26. const writer = new UpcastWriter();
  27. removeBoldWrapper( data.content, writer );
  28. }
  29. }