1.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 ArticlePresets from '@ckeditor/ckeditor5-presets/src/article';
  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.create( document.querySelector( '#editor-attach' ), {
  13. plugins: [ ArticlePresets ],
  14. toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
  15. } )
  16. .then( editor => {
  17. const panel = new BalloonPanelView();
  18. panel.element.innerHTML = 'Balloon content.';
  19. editor.ui.view.body.add( panel );
  20. editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;
  21. panel.init();
  22. panel.attachTo( {
  23. target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
  24. limiter: editor.ui.view.editableElement
  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.create( document.querySelector( '#editor-stick' ), {
  33. plugins: [ ArticlePresets ],
  34. toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
  35. } )
  36. .then( editor => {
  37. const panel = new BalloonPanelView();
  38. panel.element.innerHTML = 'Balloon content.';
  39. editor.ui.view.body.add( panel );
  40. editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;
  41. panel.init();
  42. panel.pin( {
  43. target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
  44. limiter: editor.ui.view.editableElement
  45. } );
  46. window.stickEditor = editor;
  47. } )
  48. .catch( err => {
  49. console.error( err.stack );
  50. } );