|
|
@@ -1,65 +0,0 @@
|
|
|
-/**
|
|
|
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
|
|
|
- * For licensing, see LICENSE.md.
|
|
|
- */
|
|
|
-
|
|
|
-import Feature from '../core/feature.js';
|
|
|
-import LinkEngine from './linkengine.js';
|
|
|
-import ButtonController from '../ui/button/button.js';
|
|
|
-import ButtonView from '../ui/button/buttonview.js';
|
|
|
-import Model from '../ui/model.js';
|
|
|
-
|
|
|
-/**
|
|
|
- * The link feature.
|
|
|
- *
|
|
|
- * It uses the {@link basic-styles.LinkEngine link engine feature}.
|
|
|
- *
|
|
|
- * @memberOf link
|
|
|
- * @extends core.Feature
|
|
|
- */
|
|
|
-export default class Link extends Feature {
|
|
|
- /**
|
|
|
- * @inheritDoc
|
|
|
- */
|
|
|
- static get requires() {
|
|
|
- return [ LinkEngine ];
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @inheritDoc
|
|
|
- */
|
|
|
- init() {
|
|
|
- const editor = this.editor;
|
|
|
- const t = editor.t;
|
|
|
- const linkCommand = editor.commands.get( 'link' );
|
|
|
-
|
|
|
- // Create button model.
|
|
|
- const buttonModel = new Model( {
|
|
|
- isEnabled: true,
|
|
|
- isOn: false,
|
|
|
- label: t( 'Link' ),
|
|
|
- icon: 'link'
|
|
|
- } );
|
|
|
-
|
|
|
- const unlinkButtonModel = new Model( {
|
|
|
- isEnabled: true,
|
|
|
- isOn: false,
|
|
|
- label: t( 'Unlink' ),
|
|
|
- icon: 'unlink'
|
|
|
- } );
|
|
|
-
|
|
|
- // Button <-> Command binding.
|
|
|
- buttonModel.bind( 'isOn', 'isEnabled' ).to( linkCommand, 'hasValue', 'isEnabled' );
|
|
|
-
|
|
|
- // Execute linking.
|
|
|
- const hrefValue = 'http://www.cksource.com'; // Temporary href value.
|
|
|
- this.listenTo( buttonModel, 'execute', () => editor.execute( 'link', hrefValue ) );
|
|
|
-
|
|
|
- // Execute unlinking.
|
|
|
- this.listenTo( unlinkButtonModel, 'execute', () => editor.execute( 'unlink' ) );
|
|
|
-
|
|
|
- // Add link button to feature components.
|
|
|
- editor.ui.featureComponents.add( 'link', ButtonController, ButtonView, buttonModel );
|
|
|
- editor.ui.featureComponents.add( 'unlink', ButtonController, ButtonView, unlinkButtonModel );
|
|
|
- }
|
|
|
-}
|