mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Changed snippet icon in menus based on snippet contents
no issue - vary the snippet icon based on the snippet contents: text only, text and cards, cards only
This commit is contained in:
parent
0ab0100567
commit
b392313df1
@ -1,5 +1,6 @@
|
||||
import Component from '@ember/component';
|
||||
import mobiledocParsers from 'mobiledoc-kit/parsers/mobiledoc';
|
||||
import snippetIcon from '../utils/snippet-icon';
|
||||
import {CARD_MENU} from '../options/cards';
|
||||
import {computed} from '@ember/object';
|
||||
import {htmlSafe} from '@ember/string';
|
||||
@ -50,7 +51,7 @@ export default Component.extend({
|
||||
snippets.forEach((snippet) => {
|
||||
snippetsSection.items.push({
|
||||
label: snippet.name,
|
||||
icon: 'koenig/kg-card-type-snippet-text',
|
||||
icon: snippetIcon(snippet),
|
||||
type: 'snippet',
|
||||
matches: [snippet.name.toLowerCase()]
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
import Component from '@glimmer/component';
|
||||
import mobiledocParsers from 'mobiledoc-kit/parsers/mobiledoc';
|
||||
import snippetIcon from '../utils/snippet-icon';
|
||||
import {CARD_MENU} from '../options/cards';
|
||||
import {action} from '@ember/object';
|
||||
import {isEmpty} from '@ember/utils';
|
||||
@ -69,7 +70,7 @@ export default class KoenigSlashMenuComponent extends Component {
|
||||
snippets.forEach((snippet) => {
|
||||
snippetsSection.items.push({
|
||||
label: snippet.name,
|
||||
icon: 'koenig/kg-card-type-snippet-text',
|
||||
icon: snippetIcon(snippet),
|
||||
type: 'snippet',
|
||||
matches: [snippet.name.toLowerCase()]
|
||||
});
|
||||
|
17
ghost/admin/lib/koenig-editor/addon/utils/snippet-icon.js
Normal file
17
ghost/admin/lib/koenig-editor/addon/utils/snippet-icon.js
Normal file
@ -0,0 +1,17 @@
|
||||
export default function snippetIcon(snippet) {
|
||||
let {mobiledoc} = snippet;
|
||||
|
||||
if (mobiledoc.cards.length === 0) {
|
||||
return 'koenig/kg-card-type-snippet-text';
|
||||
}
|
||||
|
||||
let hasRichText = mobiledoc.sections.some((section) => {
|
||||
return section[0] !== 10;
|
||||
});
|
||||
|
||||
if (hasRichText) {
|
||||
return 'koenig/kg-card-type-snippet-combination';
|
||||
}
|
||||
|
||||
return 'koenig/kg-card-type-snippet-block';
|
||||
}
|
Loading…
Reference in New Issue
Block a user