mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 04:43:12 +03:00
markdown card given new format
This commit is contained in:
parent
c022938890
commit
b41ff3b22e
@ -173,16 +173,15 @@ textarea.ed_code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dragOver {
|
.dragOver {
|
||||||
background-color: pink;
|
background-color: var(--lightgrey);
|
||||||
border:100px solid red;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tooltip
|
* Tooltip
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@keyframes tooltip-fadein {
|
@keyframes tooltip-fadein {
|
||||||
0% { opacity: 0; }
|
0% { opacity: 0; }
|
||||||
100% { opacity: 1; }
|
100% { opacity: 1; }
|
||||||
|
@ -20,7 +20,6 @@ import {
|
|||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
isEditing: true,
|
|
||||||
accept: 'image/gif,image/jpg,image/jpeg,image/png,image/svg+xml',
|
accept: 'image/gif,image/jpg,image/jpeg,image/png,image/svg+xml',
|
||||||
extensions: ['gif', 'jpg', 'jpeg', 'png', 'svg'],
|
extensions: ['gif', 'jpg', 'jpeg', 'png', 'svg'],
|
||||||
ajax: injectService(),
|
ajax: injectService(),
|
||||||
@ -39,7 +38,6 @@ export default Component.extend({
|
|||||||
this.set('value', this.$('textarea').val());
|
this.set('value', this.$('textarea').val());
|
||||||
this.set('payload', payload);
|
this.set('payload', payload);
|
||||||
this.get('env').save(payload, false);
|
this.get('env').save(payload, false);
|
||||||
this.set('isEditing', false);
|
|
||||||
}),
|
}),
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
@ -73,7 +71,7 @@ export default Component.extend({
|
|||||||
invokeAction(this, 'uploadSuccess', response);
|
invokeAction(this, 'uploadSuccess', response);
|
||||||
let placeholderText = `![uploading:${response.file.name}]()`;
|
let placeholderText = `![uploading:${response.file.name}]()`;
|
||||||
let imageText = `![](${response.url})`;
|
let imageText = `![](${response.url})`;
|
||||||
let [el] = this.$('textarea');
|
let el = this.$('textarea')[0]; // array destructuring on jquery causes ember to throw an error about calling an Object as a Function
|
||||||
|
|
||||||
el.value = el.value.replace(placeholderText, imageText);
|
el.value = el.value.replace(placeholderText, imageText);
|
||||||
this.sendAction('updateValue');
|
this.sendAction('updateValue');
|
||||||
@ -205,23 +203,21 @@ export default Component.extend({
|
|||||||
invokeAction(this, 'selectCard');
|
invokeAction(this, 'selectCard');
|
||||||
},
|
},
|
||||||
didDrop(event) {
|
didDrop(event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
let [el] = this.$('textarea');
|
// eslint-disable-next-line ember-suave/prefer-destructuring
|
||||||
|
let el = this.$('textarea')[0]; // array destructuring here causes ember to throw an error about calling an Object as a Function
|
||||||
|
|
||||||
let start = el.selectionStart;
|
let start = el.selectionStart;
|
||||||
|
|
||||||
let end = el.selectionEnd;
|
let end = el.selectionEnd;
|
||||||
|
|
||||||
let {files} = event.dataTransfer;
|
let {files} = event.dataTransfer;
|
||||||
let combinedLength = 0;
|
let combinedLength = 0;
|
||||||
// for(let i = 0; i < files.length; i++) {
|
|
||||||
// let file = files[i];
|
|
||||||
// let placeholderText = `\r\n![uploading:${file.name}]()\r\n`;
|
|
||||||
// el.value = el.value.substring(0, start) + placeholderText + el.value.substring(end, el.value.length);
|
|
||||||
// combinedLength += placeholderText.length;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// eslint-disable-next-line ember-suave/prefer-destructuring
|
// eslint-disable-next-line ember-suave/prefer-destructuring
|
||||||
let file = files[0];
|
let file = files[0]; // array destructuring here causes ember to throw an error about calling an Object as a Function
|
||||||
let placeholderText = `\r\n![uploading:${file.name}]()\r\n`;
|
let placeholderText = `\r\n![uploading:${file.name}]()\r\n`;
|
||||||
el.value = el.value.substring(0, start) + placeholderText + el.value.substring(end, el.value.length);
|
el.value = el.value.substring(0, start) + placeholderText + el.value.substring(end, el.value.length);
|
||||||
combinedLength += placeholderText.length;
|
combinedLength += placeholderText.length;
|
||||||
@ -237,8 +233,5 @@ export default Component.extend({
|
|||||||
didDragLeave(event) {
|
didDragLeave(event) {
|
||||||
this.$('textarea').removeClass('dragOver');
|
this.$('textarea').removeClass('dragOver');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,7 @@ export default Component.extend({
|
|||||||
classNames: ['editor-holder'],
|
classNames: ['editor-holder'],
|
||||||
emberCards: emberA([]),
|
emberCards: emberA([]),
|
||||||
selectedCard: null,
|
selectedCard: null,
|
||||||
|
editedCard: null,
|
||||||
keyDownHandler: [],
|
keyDownHandler: [],
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
@ -194,10 +195,10 @@ export default Component.extend({
|
|||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
this.send('selectCardHard', id);
|
this.send('selectCardHard', id);
|
||||||
} else {
|
} else {
|
||||||
this.send('deselectCard');
|
this.send('deselectCard');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.send('deselectCard');
|
this.send('deselectCard');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -214,7 +215,9 @@ export default Component.extend({
|
|||||||
selectCard(cardId) {
|
selectCard(cardId) {
|
||||||
let card = this.get('emberCards').find((card) => card.id === cardId);
|
let card = this.get('emberCards').find((card) => card.id === cardId);
|
||||||
let cardHolder = $(`#${cardId}`).parent('.kg-card');
|
let cardHolder = $(`#${cardId}`).parent('.kg-card');
|
||||||
this.send('deselectCard');
|
if(this.get('selectedCard') !== card) {
|
||||||
|
this.send('deselectCard');
|
||||||
|
}
|
||||||
cardHolder.addClass('selected');
|
cardHolder.addClass('selected');
|
||||||
cardHolder.removeClass('selected-hard');
|
cardHolder.removeClass('selected-hard');
|
||||||
this.set('selectedCard', card);
|
this.set('selectedCard', card);
|
||||||
@ -223,7 +226,7 @@ export default Component.extend({
|
|||||||
document.onclick = (event) => {
|
document.onclick = (event) => {
|
||||||
let target = $(event.target);
|
let target = $(event.target);
|
||||||
let parent = target.parents('.kg-card');
|
let parent = target.parents('.kg-card');
|
||||||
if (!target.hasClass('kg-card') && (!parent.length || parent[0] !== cardHolder[0])) {
|
if (!target.hasClass('kg-card') && !target.hasClass('kg-card-button') && !target.hasClass('kg-card-button-text') && (!parent.length || parent[0] !== cardHolder[0])) {
|
||||||
this.send('deselectCard');
|
this.send('deselectCard');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -232,17 +235,20 @@ export default Component.extend({
|
|||||||
// creating blocks under the card and deleting the card.
|
// creating blocks under the card and deleting the card.
|
||||||
// used when selecting the card with the keyboard or clicking on the toolbar.
|
// used when selecting the card with the keyboard or clicking on the toolbar.
|
||||||
selectCardHard(cardId) {
|
selectCardHard(cardId) {
|
||||||
let card = this.get('emberCards').find((card) => card.id === cardId);
|
let card = this.get('emberCards').find((card) => card.id === cardId);
|
||||||
let cardHolder = $(`#${cardId}`).parents('.kg-card');
|
let cardHolder = $(`#${cardId}`).parents('.kg-card');
|
||||||
this.send('deselectCard');
|
if(this.get('selectedCard') !== card) {
|
||||||
cardHolder.addClass('selected');
|
this.send('deselectCard');
|
||||||
cardHolder.addClass('selected-hard');
|
}
|
||||||
this.set('selectedCard', card);
|
cardHolder.addClass('selected');
|
||||||
// cardHolder.focus();
|
cardHolder.addClass('selected-hard');
|
||||||
|
this.set('selectedCard', card);
|
||||||
|
|
||||||
document.onclick = (event) => {
|
document.onclick = (event) => {
|
||||||
let target = $(event.target);
|
let target = $(event.target);
|
||||||
let parent = target.parents('.kg-card');
|
let parent = target.parents('.kg-card');
|
||||||
if (!target.hasClass('kg-card') && (!parent.length || parent[0] !== cardHolder[0])) {
|
|
||||||
|
if (!target.hasClass('kg-card') && !target.hasClass('kg-card-button') && !target.hasClass('kg-card-button-text') && (!parent.length || parent[0] !== cardHolder[0])) {
|
||||||
this.send('deselectCard');
|
this.send('deselectCard');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -324,6 +330,16 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
this.get('keyDownHandler').length = 0;
|
this.get('keyDownHandler').length = 0;
|
||||||
document.onclick = null;
|
document.onclick = null;
|
||||||
|
|
||||||
|
this.set('editedCard', null);
|
||||||
|
},
|
||||||
|
editCard(cardId) {
|
||||||
|
// this.send('selectCard', cardId);
|
||||||
|
let card = this.get('emberCards').find((card) => card.id === cardId);
|
||||||
|
this.set('editedCard', card);
|
||||||
|
},
|
||||||
|
stopEditingCard() {
|
||||||
|
this.set('editedCard', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
import Component from 'ember-component';
|
import Component from 'ember-component';
|
||||||
import layout from '../templates/components/koenig-card';
|
import layout from '../templates/components/koenig-card';
|
||||||
import run from 'ember-runloop';
|
import run from 'ember-runloop';
|
||||||
|
import observer from 'ember-metal/observer';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
|
editing: observer('editedCard', function () {
|
||||||
|
let editing = this.get('editedCard') === this.get('card');
|
||||||
|
if(this.get('isEditing') && !editing) {
|
||||||
|
this.send('stopEdit');
|
||||||
|
}
|
||||||
|
this.set('isEditing', editing);
|
||||||
|
}),
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.set('isEditing', false);
|
|
||||||
},
|
},
|
||||||
didRender() {
|
didRender() {
|
||||||
// add the classname to the wrapping card as generated by mobiledoc.
|
// add the classname to the wrapping card as generated by mobiledoc.
|
||||||
@ -15,36 +22,42 @@ export default Component.extend({
|
|||||||
() => {
|
() => {
|
||||||
let card = this.get('card');
|
let card = this.get('card');
|
||||||
|
|
||||||
if (card.newlyCreated) {
|
|
||||||
this.set('isEditing', true);
|
|
||||||
this.send('selectCard');
|
|
||||||
}
|
|
||||||
let {env: {name}} = card;
|
let {env: {name}} = card;
|
||||||
|
|
||||||
|
// the mobiledoc generated container.
|
||||||
let mobiledocCard = this.$().parents('.__mobiledoc-card');
|
let mobiledocCard = this.$().parents('.__mobiledoc-card');
|
||||||
|
|
||||||
mobiledocCard.removeClass('__mobiledoc-card');
|
mobiledocCard.removeClass('__mobiledoc-card');
|
||||||
mobiledocCard.addClass('kg-card');
|
mobiledocCard.addClass('kg-card');
|
||||||
mobiledocCard.addClass(name ? `kg-${name}` : '');
|
mobiledocCard.addClass(name ? `kg-${name}` : '');
|
||||||
mobiledocCard.attr('tabindex', 3);
|
mobiledocCard.attr('tabindex', 3);
|
||||||
|
mobiledocCard.click(() => {
|
||||||
|
if(!this.get('isEditing')) {
|
||||||
|
this.send('selectCardHard');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
this.set('doSave', Date.now());
|
this.set('doSave', Date.now());
|
||||||
this.send('stopEdit');
|
|
||||||
this.send('selectCardHard');
|
|
||||||
// this.send('on-save');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleState() {
|
toggleState() {
|
||||||
this.set('isEditing', !this.get('isEditing'));
|
if(this.get('isEditing')) {
|
||||||
|
this.send('stopEdit');
|
||||||
|
} else {
|
||||||
|
this.send('startEdit');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selectCard() {
|
selectCard() {
|
||||||
this.sendAction('selectCard', this.card.id);
|
this.sendAction('selectCard', this.card.id);
|
||||||
},
|
},
|
||||||
deselectCard() {
|
deselectCard() {
|
||||||
this.sendAction('deselectCard', this.card.id);
|
this.sendAction('deselectCard', this.card.id);
|
||||||
|
this.send('stopEdit');
|
||||||
},
|
},
|
||||||
selectCardHard() {
|
selectCardHard() {
|
||||||
this.sendAction('selectCardHard', this.card.id);
|
this.sendAction('selectCardHard', this.card.id);
|
||||||
@ -53,10 +66,11 @@ export default Component.extend({
|
|||||||
this.get('card').env.remove();
|
this.get('card').env.remove();
|
||||||
},
|
},
|
||||||
startEdit() {
|
startEdit() {
|
||||||
this.set('isEditing', true);
|
this.sendAction('edit', this.card.id)
|
||||||
},
|
},
|
||||||
stopEdit() {
|
stopEdit() {
|
||||||
this.set('isEditing', false);
|
this.send('save');
|
||||||
|
this.sendAction('stopEdit', this.card.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{#each emberCards as |card|}}
|
{{#each emberCards as |card index|}}
|
||||||
{{#ember-wormhole to=card.id}}
|
{{#ember-wormhole to=card.id}}
|
||||||
{{koenig-card card=card apiRoot=apiRoot assetPath=assetPath selectCard=(action "selectCard") selectCardHard=(action "selectCardHard") deselectCard=(action "deselectCard")}}
|
{{koenig-card tabindex=index card=card apiRoot=apiRoot assetPath=assetPath selectCard=(action "selectCard") selectCardHard=(action "selectCardHard") deselectCard=(action "deselectCard") edit=(action "editCard") stopEdit=(action "stopEditingCard") editedCard=editedCard}}
|
||||||
{{/ember-wormhole}}
|
{{/ember-wormhole}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<div class='gh-koenig'>
|
<div class='gh-koenig'>
|
||||||
|
@ -10,20 +10,21 @@
|
|||||||
selectCard=(action "selectCard")
|
selectCard=(action "selectCard")
|
||||||
selectCardHard=(action "selectCardHard")
|
selectCardHard=(action "selectCardHard")
|
||||||
deselectCard=(action "deselectCard")
|
deselectCard=(action "deselectCard")
|
||||||
|
stopEdit=(action "stopEdit")
|
||||||
}}
|
}}
|
||||||
<div class="kg-card-toolbar">
|
<div class="kg-card-toolbar">
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<label {{action "selectCardHard"}}>{{card.card.label}}:</label>
|
<label {{action "selectCardHard"}}>{{card.card.label}}:</label>
|
||||||
{{#if isEditing}}
|
{{#if isEditing}}
|
||||||
<button {{action "toggleState"}} class='kg-card-button-text'>
|
{{!--<button {{action "stopEdit"}} class='kg-card-button-text'>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>--}}
|
||||||
<button {{action "save"}} class='kg-card-button-save'>
|
<button {{action "stopEdit"}} class='kg-card-button-save'>
|
||||||
Save
|
Done
|
||||||
</button>
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if card.card.buttons.edit}}
|
{{#if card.card.buttons.edit}}
|
||||||
<button {{action "toggleState"}} class='kg-card-button-text'>
|
<button {{action "startEdit"}} class='kg-card-button-text'>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user