Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
✨ Insert Link styling (#598)
Browse files Browse the repository at this point in the history
closes: TryGhost/Ghost#8109
- adds styling for the insert link toolbar component.
  • Loading branch information
disordinary authored and kevinansfield committed Mar 20, 2017
1 parent 2f56152 commit ab118ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app/styles/addons/gh-koenig/koenig-toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
border-top: color(var(--darkgrey) l(-10%)) 8px solid;
}

.gh-toolbar.is-link {
width: 263px;
height: 40px;
}
.gh-toolbar.is-link input {
width: 100%;
background-color: transparent;
outline: none;
border: none;
padding:5px;
}

.gh-toolbar-btn {
display: flex;
justify-content: center;
Expand Down
10 changes: 7 additions & 3 deletions lib/gh-koenig/addon/components/koenig-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Tools from '../options/default-tools';
export default Component.extend({
layout,
classNames: ['gh-toolbar'],
classNameBindings: ['isVisible'],
classNameBindings: ['isVisible', 'isLink'],
isVisible: false,
tools: [],
hasRendered: false,
Expand Down Expand Up @@ -83,14 +83,14 @@ export default Component.extend({
linkKeyDown(event) {
// if escape close link
if (event.keyCode === 27) {
this.set('isLink', false);
this.send('closeLink');
}
},

linkKeyPress(event) {
// if enter run link
if (event.keyCode === 13) {
this.set('isLink', false);
this.send('closeLink');
this.set('isVisible', false);
this.editor.run((postEditor) => {
let markup = postEditor.builder.createMarkup('a', {href: event.target.value});
Expand All @@ -100,6 +100,10 @@ export default Component.extend({
this.set('linkRange', null);
event.stopPropagation();
}
},

closeLink() {
this.set('isLink', false);
}
},
doLink(range) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{#if isLink}}
{{input keyDown=(action "linkKeyDown") keyPress=(action "linkKeyPress") autofocus=true placeholder="Enter a link"}}
<button class="gh-toolbar-btn" {{action 'closeLink'}}>x</button>
{{else}}
{{#each toolbar as |tool|}}
{{koenig-toolbar-button tool=tool editor=editor iconURL=iconURL assetPath=assetPath}}
Expand Down

0 comments on commit ab118ba

Please sign in to comment.