This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #392 from ckeditor/t/391
Feature: Introduced the `BlockToolbar` plugin. Closes #391.
- Loading branch information
Showing
10 changed files
with
1,078 additions
and
0 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,60 @@ | ||
/** | ||
* Copyright (c) 2016 - 2017, CKSource - Frederico Knabben. All rights reserved. | ||
*/ | ||
|
||
/** | ||
* @module ui/toolbar/block/blockbuttonview | ||
*/ | ||
|
||
import ButtonView from '../../button/buttonview'; | ||
import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit'; | ||
import '../../../theme/components/toolbar/blocktoolbar.css'; | ||
|
||
const toPx = toUnit( 'px' ); | ||
|
||
/** | ||
* The block button view class. | ||
* | ||
* This view represents a button attached next to block element where the selection is anchored. | ||
* | ||
* See {@link module:ui/toolbar/block/blocktoolbar~BlockToolbar}. | ||
* | ||
* @extends {module:ui/button/buttonview~ButtonView} | ||
*/ | ||
export default class BlockButtonView extends ButtonView { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor( locale ) { | ||
super( locale ); | ||
|
||
const bind = this.bindTemplate; | ||
|
||
// Hide button on init. | ||
this.isVisible = false; | ||
|
||
/** | ||
* Top offset. | ||
* | ||
* @member {Number} #top | ||
*/ | ||
this.set( 'top', 0 ); | ||
|
||
/** | ||
* Left offset. | ||
* | ||
* @member {Number} #left | ||
*/ | ||
this.set( 'left', 0 ); | ||
|
||
this.extendTemplate( { | ||
attributes: { | ||
class: 'ck-block-toolbar-button', | ||
style: { | ||
top: bind.to( 'top', val => toPx( val ) ), | ||
left: bind.to( 'left', val => toPx( val ) ), | ||
} | ||
} | ||
} ); | ||
} | ||
} |
Oops, something went wrong.