Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Basic linking feature #19

Merged
merged 55 commits into from
Sep 9, 2016
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
58d139d
Introduced linking engine.
oskarwrobel Aug 12, 2016
ea4ead7
WIP: Introduced link command and link feature.
oskarwrobel Aug 17, 2016
353a2ff
Introduced basic manual test.
oskarwrobel Aug 17, 2016
7cdd8ab
Added binding for active feature. Improved docs.
oskarwrobel Aug 17, 2016
0f93f14
Improved link command.
oskarwrobel Aug 18, 2016
49d61b6
Minor test changes.
oskarwrobel Aug 18, 2016
fae57da
Created mockup of the LinkBalloonPanel.
oleq Aug 19, 2016
cdd90ab
Created basic themes for LinkBalloonPanel.
oleq Aug 19, 2016
d9373c0
Extended Link manual test to include the UI.
oleq Aug 19, 2016
eb414b4
Enabled LinkBalloonPanel in Link feature. Code refactoring.
oleq Aug 19, 2016
6f14c14
Merge remote-tracking branch 'origin/t/1' into t/2
oleq Aug 19, 2016
926f4dc
Use domConverter to obtain native DOM range.
oleq Aug 19, 2016
1b2db40
Added panel elements like button, URL input and label along with the
oleq Aug 19, 2016
fd070c7
Created balloonPanel#url attribute. Basic focus handling when editing…
oleq Aug 19, 2016
eda9c2b
Added Cancel button to LinkBalloonPanel component.
oleq Aug 22, 2016
20cbffc
Massive code refactoring, decoupling and polishing.
oleq Aug 22, 2016
82b170b
Minor refactoring.
oleq Aug 22, 2016
43c1fe6
Added tmp extended version of ck-z helper to linkballoonpanel stylesh…
oleq Aug 22, 2016
eb9223f
Decoupled styles for various components.
oleq Aug 22, 2016
98862a5
Merge branch 't/1' into t/2
oskarwrobel Aug 22, 2016
6821253
Improved data flow between the feature and the UI.
oleq Aug 22, 2016
fc5d6c5
Minor refactoring and docs in Link Feature.
oleq Aug 22, 2016
cd97be6
Added docs for _createBalloonPanel method in Link Feature.
oleq Aug 22, 2016
2cc453c
Very base ui and command integration.
oskarwrobel Aug 23, 2016
b52f48d
Refactored the way of creating panel.
oskarwrobel Aug 23, 2016
f8f9051
Prevent showing panel when editor is not focused.
oskarwrobel Aug 23, 2016
cd2a43c
Moved panel creation to Link Feature init(). Fixed some focus issues.
oleq Aug 23, 2016
762ae4d
Merge branch 't/1' into t/2
oskarwrobel Aug 23, 2016
f9fccc2
Merge branch 'master' into t/2
oskarwrobel Aug 24, 2016
a93540a
Moved Balloon Panel component to ckeditor5-ui-default and ckeditor5-t…
oskarwrobel Aug 29, 2016
932197b
Introduced toolbar unlink button.
oskarwrobel Aug 29, 2016
fc66303
Show panel on Ctrl+l keystroke.
oskarwrobel Aug 29, 2016
ad1d48f
Added missing docs and test for LinkBalloonPanel component.
oskarwrobel Aug 31, 2016
74770f1
Added missing bender tag.
oskarwrobel Aug 31, 2016
c240af5
Added test + minor refactor of Link feature.
oskarwrobel Aug 31, 2016
fb131cd
Moved bender tag at the top of file.
oskarwrobel Aug 31, 2016
7780ed3
Changed the way of getting editable element.
oskarwrobel Sep 4, 2016
25f3806
Removed Balloon Panel test case from link manual test.
oskarwrobel Sep 4, 2016
1b0fb4e
Added use cases to manual test.
oskarwrobel Sep 4, 2016
d3bb9b5
Removed unused editor init.
oskarwrobel Sep 5, 2016
dabe64c
Minor docs refactoring.
oskarwrobel Sep 5, 2016
2cf3f4d
Introduced LinkElement class.
oskarwrobel Sep 5, 2016
6b78bd9
Refactored the way of test which use editable element.
oskarwrobel Sep 5, 2016
a983c1d
Fixed typo in tests.
oskarwrobel Sep 5, 2016
a7ca040
Added unlink button to link balloon panel.
oskarwrobel Sep 5, 2016
f5c07b3
Refactoring after changes in `ckeditor5-ui-default`.
oskarwrobel Sep 8, 2016
10a09de
Changed initialization of LabeledInput component.
oskarwrobel Sep 8, 2016
52fe998
Added keystroke to button title.
oskarwrobel Sep 8, 2016
4840986
Changed CSS class name of LinkForm component region.
oskarwrobel Sep 8, 2016
b940d80
Refactored code style and docs.
oskarwrobel Sep 8, 2016
4b2e4d2
Refactored docs.
oskarwrobel Sep 8, 2016
e49efba
Minor code refactoring and documentation fixes.
oleq Sep 9, 2016
6749e9a
Minor code refactoring and documentation fixes.
oleq Sep 9, 2016
8fdf0f3
Used the new LabeledInput API in the LinkBalloonPanel.
oleq Sep 9, 2016
1091d43
Enhanced visually the link balloon panel with more space.
oleq Sep 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/link.js
Original file line number Diff line number Diff line change
@@ -186,6 +186,13 @@ export default class Link extends Feature {
balloonPanel.view.hide();
} );

// Observe `LinkBalloonPanelMode#execute-unlink` event from within the model of the panel,
// which means that the `Unlink` button has been clicked.
this.listenTo( panelModel, 'execute-unlink', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a strage event name. Why -?

editor.execute( 'unlink' );
balloonPanel.view.hide();
} );

// Always focus editor on panel hide.
this.listenTo( panelModel, 'hide', () => viewDocument.focus() );

51 changes: 45 additions & 6 deletions src/ui/linkballoonpanel.js
Original file line number Diff line number Diff line change
@@ -99,9 +99,12 @@ export default class LinkBalloonPanel extends BalloonPanel {
* @returns {ui.box.Box} Box component.
*/
_createButtons() {
const box = new Box( new Model( {
alignRight: true
const wrapper = new Box( new Model( {
alignContent: 'right'
} ), new BoxView( this.locale ) );
wrapper.view.element.classList.add( 'ck-link-balloon-panel_actions' );

const additionalActions = new Box( new Model(), new BoxView( this.locale ) );

/**
* Button component for submitting form.
@@ -117,11 +120,23 @@ export default class LinkBalloonPanel extends BalloonPanel {
*/
this.cancelButton = this._createCancelButton();

// Add `Cancel` and `Save` buttons as a box content.
box.add( 'content', this.cancelButton );
box.add( 'content', this.saveButton );
/**
* Button component for unlinking.
*
* @member {ui.button.Button} link.ui.LinkBalloonPanel#unlinkButton
*/
this.unlinkButton = this._createUnlinkButton();

// Add `Save`, `Cancel` and `Unlink` buttons as a wrapper content.
wrapper.add( 'content', this.saveButton );
wrapper.add( 'content', this.cancelButton );

// Append Unlink button into additional action box.
additionalActions.add( 'content', this.unlinkButton );

return box;
wrapper.add( 'content', additionalActions );

return wrapper;
}

/**
@@ -166,4 +181,28 @@ export default class LinkBalloonPanel extends BalloonPanel {

return new Button( cancelModel, new ButtonView( this.locale ) );
}

/**
* Initialize {@link ui.button.Button Button} for unlinking command.
*
* @private
* @returns {ui.button.Button} Unlink button component.
*/
_createUnlinkButton() {
const t = this.view.t;
const unlinkModel = new Model( {
isEnabled: true,
isOn: false,
label: t( 'Unlink' ),
withText: true
} );

unlinkModel.on( 'execute', () => this.model.fire( 'execute-unlink' ) );

const button = new Button( unlinkModel, new ButtonView( this.locale ) );

button.view.element.classList.add( 'ck-button-action' );

return button;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing @interface docs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

25 changes: 25 additions & 0 deletions tests/link.js
Original file line number Diff line number Diff line change
@@ -174,6 +174,31 @@ describe( 'Link', () => {
expect( executeSpy.calledWithExactly( 'link', 'http://cksource.com' ) ).to.true;
} );

it( 'should hide balloon panel on balloonPanel#model execute event', () => {
const hideSpy = testUtils.sinon.spy( balloonPanel.view, 'hide' );

balloonPanel.model.fire( 'execute' );

expect( hideSpy.calledOnce ).to.true;
} );

it( 'should execute unlink command on balloonPanel#model execute-unlink event', () => {
const executeSpy = testUtils.sinon.spy( editor, 'execute' );

balloonPanel.model.fire( 'execute-unlink' );

expect( executeSpy.calledOnce ).to.true;
expect( executeSpy.calledWithExactly( 'unlink' ) ).to.true;
} );

it( 'should hide balloon panel on balloonPanel#model execute-unlink event', () => {
const hideSpy = testUtils.sinon.spy( balloonPanel.view, 'hide' );

balloonPanel.model.fire( 'execute-unlink' );

expect( hideSpy.calledOnce ).to.true;
} );

it( 'should append panel element to the body', () => {
expect( document.body.contains( balloonPanel.view.element ) );
} );
18 changes: 17 additions & 1 deletion tests/ui/linkballoonpanel.js
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ describe( 'LinkBalloonPanel', () => {
expect( linkBalloonPanel.saveButton ).to.instanceof( Button );
} );

it( 'should trigger model#execute event after clicking', ( done ) => {
it( 'should fire model#execute event on DOM click event', ( done ) => {
const executeSpy = sinon.spy();

model.on( 'execute', executeSpy );
@@ -109,6 +109,22 @@ describe( 'LinkBalloonPanel', () => {
expect( hideSpy.calledOnce ).to.true;
} );
} );

describe( 'unlinkButton', () => {
it( 'should create Button instance', () => {
expect( linkBalloonPanel.unlinkButton ).to.instanceof( Button );
} );

it( 'should fire model#execute-unlink event on unlinkButton.model#execute event', () => {
const executeUnlinkSpy = sinon.spy();

model.on( 'execute-unlink', executeUnlinkSpy );

linkBalloonPanel.unlinkButton.model.fire( 'execute' );

expect( executeUnlinkSpy.calledOnce ).to.true;
} );
} );
} );
} );
} );
17 changes: 17 additions & 0 deletions theme/components/linkballoonpanel.scss
Original file line number Diff line number Diff line change
@@ -3,4 +3,21 @@

.ck-link-balloon-panel {
padding: ck-spacing();

// Box to accommodate buttons.
&_actions {
display: flex;
flex-direction: row-reverse;
padding-top: ck-spacing();

.ck-button {
& + .ck-button {
margin-right: ck-spacing( 'medium' );
}
}

.ck-box {
flex-grow: 2;
}
}
}