This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Added keepAttachedTo() method to the BalloonPanelView. Close…
…s #170.
- Loading branch information
Showing
5 changed files
with
321 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<div class="container-outer"> | ||
<div class="container-inner"> | ||
<div> | ||
<div id="editor-attach"> | ||
<p>Balloon is attached to the <strong>TARGET</strong> element.</p> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<div id="editor-stick"> | ||
<p>Balloon sticks to the <strong>TARGET</strong> element.</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
body { | ||
height: 100%; | ||
} | ||
|
||
.ck-balloon-panel { | ||
padding: 2em; | ||
} | ||
|
||
.ck-editor__editable { | ||
max-height: 300px; | ||
} | ||
|
||
.ck-editor__editable p { | ||
margin: 470px 0; | ||
} | ||
|
||
.container-outer { | ||
height: 500px; | ||
width: 750px; | ||
overflow: scroll; | ||
} | ||
|
||
.container-inner { | ||
padding: 500px 30px 30px; | ||
display: flex; | ||
width: 1000px; | ||
height: 2000px; | ||
background: #e1e1e1; | ||
} | ||
|
||
.container-inner > div { | ||
margin: 0 20px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals window, document, console:false */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic'; | ||
import ArticlePresets from '@ckeditor/ckeditor5-presets/src/article'; | ||
import BalloonPanelView from '@ckeditor/ckeditor5-ui/src/panel/balloon/balloonpanelview'; | ||
|
||
// Set initial scroll for the outer container element. | ||
document.querySelector( '.container-outer' ).scrollTop = 450; | ||
|
||
// Init editor with balloon attached to the target element. | ||
ClassicEditor.create( document.querySelector( '#editor-attach' ), { | ||
plugins: [ ArticlePresets ], | ||
toolbar: [ 'bold', 'italic', 'undo', 'redo' ] | ||
} ) | ||
.then( editor => { | ||
const panel = new BalloonPanelView(); | ||
|
||
panel.element.innerHTML = 'Balloon content.'; | ||
editor.ui.view.body.add( panel ); | ||
|
||
editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360; | ||
|
||
panel.init().then( () => { | ||
panel.attachTo( { | ||
target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ), | ||
limiter: editor.ui.view.editableElement | ||
} ); | ||
} ); | ||
|
||
window.attachEditor = editor; | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
|
||
// Init editor with balloon sticked to the target element. | ||
ClassicEditor.create( document.querySelector( '#editor-stick' ), { | ||
plugins: [ ArticlePresets ], | ||
toolbar: [ 'bold', 'italic', 'undo', 'redo' ] | ||
} ) | ||
.then( editor => { | ||
const panel = new BalloonPanelView(); | ||
|
||
panel.element.innerHTML = 'Balloon content.'; | ||
editor.ui.view.body.add( panel ); | ||
|
||
editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360; | ||
|
||
panel.init().then( () => { | ||
panel.keepAttachedTo( { | ||
target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ), | ||
limiter: editor.ui.view.editableElement | ||
} ); | ||
} ); | ||
|
||
window.stickEditor = editor; | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## BalloonPanelView `attachTo` vs `keepAttachedTo` | ||
|
||
Scroll editable elements and container (horizontally as well). Balloon in the left editor should float but balloon in the | ||
right editor should stick to the target element. |
Oops, something went wrong.