mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
📦 Card-Rename (#603)
no issue - Renames Cards so they comply with the `card-{{name}}` convention rather than `{{name}}-card` - Adds a unkonwnCardHandler to the editor.
This commit is contained in:
parent
482543abed
commit
a8e58bfdf6
|
@ -169,6 +169,6 @@ textarea.ed_code {
|
|||
* HTML Card
|
||||
*/
|
||||
|
||||
.kg-html-card {
|
||||
.kg-card-html {
|
||||
border: #ddd 1px solid;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
name: 'hr-card',
|
||||
name: 'card-hr',
|
||||
label: 'HR Card',
|
||||
icon: '',
|
||||
genus: 'ember',
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
name: 'html-card',
|
||||
name: 'card-html',
|
||||
label: 'HTML Card',
|
||||
icon: '',
|
||||
genus: 'ember',
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
name: 'image-card',
|
||||
name: 'card-image',
|
||||
label: 'Image Card',
|
||||
icon: '',
|
||||
genus: 'ember'
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
name: 'markdown-card',
|
||||
name: 'card-markdown',
|
||||
label: 'Markdown Card',
|
||||
icon: '',
|
||||
genus: 'ember',
|
|
@ -1,7 +1,7 @@
|
|||
import htmlCard from 'gh-koenig/cards/html-card_dom';
|
||||
import imageCard from 'gh-koenig/cards/image-card_dom';
|
||||
import markdownCard from 'gh-koenig/cards/markdown-card_dom';
|
||||
import hrCard from 'gh-koenig/cards/hr-card_dom';
|
||||
import htmlCard from 'gh-koenig/cards/card-html_dom';
|
||||
import imageCard from 'gh-koenig/cards/card-image_dom';
|
||||
import markdownCard from 'gh-koenig/cards/card-markdown_dom';
|
||||
import hrCard from 'gh-koenig/cards/card-hr_dom';
|
||||
|
||||
let cards = [];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Component from 'ember-component';
|
||||
import layout from '../../templates/components/hr-card';
|
||||
import layout from '../../templates/components/card-hr';
|
||||
export default Component.extend({
|
||||
layout
|
||||
});
|
|
@ -1,5 +1,5 @@
|
|||
import Component from 'ember-component';
|
||||
import layout from '../../templates/components/html-card';
|
||||
import layout from '../../templates/components/card-html';
|
||||
import computed from 'ember-computed';
|
||||
import observer from 'ember-metal/observer';
|
||||
|
|
@ -5,7 +5,7 @@ import {htmlSafe} from 'ember-string';
|
|||
import {isBlank} from 'ember-utils';
|
||||
import {isEmberArray} from 'ember-array/utils';
|
||||
import run from 'ember-runloop';
|
||||
import layout from '../../templates/components/image-card';
|
||||
import layout from '../../templates/components/card-image';
|
||||
|
||||
import {invokeAction} from 'ember-invoke-action';
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import Component from 'ember-component';
|
||||
import layout from '../../templates/components/markdown-card';
|
||||
import layout from '../../templates/components/card-markdown';
|
||||
import {formatMarkdown} from '../../lib/format-markdown';
|
||||
import injectService from 'ember-service/inject';
|
||||
import {invokeAction} from 'ember-invoke-action';
|
|
@ -53,7 +53,10 @@ export default Component.extend({
|
|||
}],
|
||||
spellcheck: true,
|
||||
autofocus: this.get('shouldFocusEditor'),
|
||||
placeholder: 'Click here to start ...'
|
||||
placeholder: 'Click here to start ...',
|
||||
unknownCardHandler: () => {
|
||||
// todo
|
||||
}
|
||||
};
|
||||
|
||||
this.editor = new Mobiledoc.Editor(options);
|
||||
|
@ -152,7 +155,7 @@ export default Component.extend({
|
|||
event.preventDefault();
|
||||
for (let i = 0; i < event.dataTransfer.files.length; i++) {
|
||||
let file = [event.dataTransfer.files[i]];
|
||||
this.editor.insertCard('image-card', {pos: 'top', file});
|
||||
this.editor.insertCard('card-image', {pos: 'top', file});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -152,7 +152,7 @@ export default function (editor) {
|
|||
|
||||
range = range.extend(-(matches[0].length));
|
||||
editor.run((postEditor) => {
|
||||
let card = postEditor.builder.createCardSection('image-card', {pos: 'top', img, alt});
|
||||
let card = postEditor.builder.createCardSection('card-image', {pos: 'top', img, alt});
|
||||
postEditor.replaceSection(editor.range.headSection, card);
|
||||
});
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ export default function (editor) {
|
|||
let code = matches[0];
|
||||
range = range.extend(-(matches[0].length));
|
||||
editor.run((postEditor) => {
|
||||
let card = postEditor.builder.createCardSection('markdown-card', {pos: 'top', markdown: code});
|
||||
let card = postEditor.builder.createCardSection('card-markdown', {pos: 'top', markdown: code});
|
||||
postEditor.replaceSection(editor.range.headSection, card);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ export default function (editor, toolbar) {
|
|||
cardMenu: true,
|
||||
onClick: (editor) => {
|
||||
editor.run((postEditor) => {
|
||||
let card = postEditor.builder.createCardSection('image-card', {pos: 'top'});
|
||||
let card = postEditor.builder.createCardSection('card-image', {pos: 'top'});
|
||||
postEditor.insertSection(card);
|
||||
|
||||
});
|
||||
|
@ -219,13 +219,13 @@ export default function (editor, toolbar) {
|
|||
cardMenu: true,
|
||||
onClick: (editor, section) => {
|
||||
editor.run((postEditor) => {
|
||||
let card = postEditor.builder.createCardSection('html-card', {pos: 'top', html: editor.range.headSection.text});
|
||||
let card = postEditor.builder.createCardSection('card-html', {pos: 'top', html: editor.range.headSection.text});
|
||||
// we can't replace a list item so we insert a card after it and then delete it.
|
||||
if (editor.range.headSection.isListItem) {
|
||||
// postEditor.toggleSection('p');
|
||||
// postEditor.insertSection(card);
|
||||
// postEditor.removeSection(editor.range.head.section);
|
||||
editor.insertCard('html-card');
|
||||
editor.insertCard('card-html');
|
||||
} else {
|
||||
postEditor.replaceSection(section || editor.range.headSection, card);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ export default function (editor, toolbar) {
|
|||
cardMenu: true,
|
||||
onClick: (editor) => {
|
||||
editor.run((postEditor) => {
|
||||
let card = postEditor.builder.createCardSection('hr-card', {pos: 'top'});
|
||||
let card = postEditor.builder.createCardSection('card-hr', {pos: 'top'});
|
||||
postEditor.insertSection(card);
|
||||
});
|
||||
},
|
||||
|
@ -264,10 +264,10 @@ export default function (editor, toolbar) {
|
|||
cardMenu: true,
|
||||
onClick: (editor, section) => {
|
||||
editor.run((postEditor) => {
|
||||
let card = postEditor.builder.createCardSection('markdown-card', {pos: 'top', markdown: editor.range.headSection.text});
|
||||
let card = postEditor.builder.createCardSection('card-markdown', {pos: 'top', markdown: editor.range.headSection.text});
|
||||
// we can't replace a list item so we insert a card after it and then delete it.
|
||||
if (editor.range.headSection.isListItem) {
|
||||
editor.insertCard('markdown-card');
|
||||
editor.insertCard('card-markdown');
|
||||
} else {
|
||||
postEditor.replaceSection(section || editor.range.headSection, card);
|
||||
}
|
||||
|
|
1
lib/gh-koenig/app/components/card-hr.js
Normal file
1
lib/gh-koenig/app/components/card-hr.js
Normal file
|
@ -0,0 +1 @@
|
|||
export {default} from 'gh-koenig/components/cards/card-hr';
|
1
lib/gh-koenig/app/components/card-html.js
Normal file
1
lib/gh-koenig/app/components/card-html.js
Normal file
|
@ -0,0 +1 @@
|
|||
export {default} from 'gh-koenig/components/cards/card-html';
|
1
lib/gh-koenig/app/components/card-image.js
Normal file
1
lib/gh-koenig/app/components/card-image.js
Normal file
|
@ -0,0 +1 @@
|
|||
export {default} from 'gh-koenig/components/cards/card-image';
|
1
lib/gh-koenig/app/components/card-markdown.js
Normal file
1
lib/gh-koenig/app/components/card-markdown.js
Normal file
|
@ -0,0 +1 @@
|
|||
export {default} from 'gh-koenig/components/cards/card-markdown';
|
|
@ -1 +0,0 @@
|
|||
export {default} from 'gh-koenig/components/cards/hr-card';
|
|
@ -1 +0,0 @@
|
|||
export {default} from 'gh-koenig/components/cards/html-card';
|
|
@ -1 +0,0 @@
|
|||
export {default} from 'gh-koenig/components/cards/image-card';
|
|
@ -1 +0,0 @@
|
|||
export {default} from 'gh-koenig/components/cards/markdown-card';
|
Loading…
Reference in a new issue