1.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @license Copyright (c) 2003-2020, 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, console:false */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. import BalloonPanelView from '../../../../src/panel/balloon/balloonpanelview';
  9. // Set initial scroll for the outer container element.
  10. document.querySelector( '.container-outer' ).scrollTop = 450;
  11. // Init editor with balloon attached to the target element.
  12. ClassicEditor
  13. .create( document.querySelector( '#editor-attach' ), {
  14. plugins: [ ArticlePluginSet ],
  15. toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
  16. } )
  17. .then( editor => {
  18. const panel = new BalloonPanelView();
  19. editor.ui.view.body.add( panel );
  20. panel.element.innerHTML = 'Balloon content.';
  21. editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;
  22. panel.attachTo( {
  23. target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
  24. limiter: editor.ui.getEditableElement()
  25. } );
  26. window.attachEditor = editor;
  27. } )
  28. .catch( err => {
  29. console.error( err.stack );
  30. } );
  31. // Init editor with balloon sticked to the target element.
  32. ClassicEditor
  33. .create( document.querySelector( '#editor-stick' ), {
  34. plugins: [ ArticlePluginSet ],
  35. toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
  36. } )
  37. .then( editor => {
  38. const panel = new BalloonPanelView();
  39. editor.ui.view.body.add( panel );
  40. panel.element.innerHTML = 'Balloon content.';
  41. editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;
  42. panel.pin( {
  43. target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
  44. limiter: editor.ui.getEditableElement()
  45. } );
  46. window.stickEditor = editor;
  47. } )
  48. .catch( err => {
  49. console.error( err.stack );
  50. } );