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