8
0

1.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  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. panel.element.innerHTML = 'Balloon content.';
  20. editor.ui.view.body.add( panel );
  21. editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;
  22. panel.init();
  23. panel.attachTo( {
  24. target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
  25. limiter: editor.ui.view.editableElement
  26. } );
  27. window.attachEditor = editor;
  28. } )
  29. .catch( err => {
  30. console.error( err.stack );
  31. } );
  32. // Init editor with balloon sticked to the target element.
  33. ClassicEditor
  34. .create( document.querySelector( '#editor-stick' ), {
  35. plugins: [ ArticlePluginSet ],
  36. toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
  37. } )
  38. .then( editor => {
  39. const panel = new BalloonPanelView();
  40. panel.element.innerHTML = 'Balloon content.';
  41. editor.ui.view.body.add( panel );
  42. editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;
  43. panel.init();
  44. panel.pin( {
  45. target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
  46. limiter: editor.ui.view.editableElement
  47. } );
  48. window.stickEditor = editor;
  49. } )
  50. .catch( err => {
  51. console.error( err.stack );
  52. } );