mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Koenig - HTML card template
refs https://github.com/TryGhost/Ghost/issues/9311 - add a basic HTML card that renders a CodeMirror editor - adjust styles so that CodeMirror styles for the markdown editor don't affect CodeMirror instances inside Koenig
This commit is contained in:
parent
5d4053dec2
commit
6d4d6cbc51
@ -279,7 +279,7 @@ input,
|
||||
background: #263238;
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror-cursor {
|
||||
.gh-markdown-editor .CodeMirror-cursor {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
|
@ -376,6 +376,23 @@ textarea.koenig-card-markdown {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.koenig-card-html--editor .CodeMirror {
|
||||
min-height: 170px;
|
||||
padding: 0;
|
||||
overflow: auto;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.koenig-card-html--editor .CodeMirror:hover {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.koenig-card-html--editor .CodeMirror-scroll {
|
||||
min-height: 170px;
|
||||
overflow: hidden !important;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* mobiledoc-kit base styles ------------------------------------------------
|
||||
* NOTE: adapted from https://github.com/bustle/mobiledoc-kit/blob/master/src/css/mobiledoc-kit.css
|
||||
*/
|
||||
|
@ -447,28 +447,28 @@
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror {
|
||||
.gh-markdown-editor .CodeMirror {
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* Prevent confusing select behaviour, see https://github.com/TryGhost/Ghost/issues/9356 */
|
||||
.gh-editor .CodeMirror-code:not([contenteditable="true"]) {
|
||||
.gh-markdown-editor .CodeMirror-code:not([contenteditable="true"]) {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror-cursor {
|
||||
.gh-markdown-editor .CodeMirror-cursor {
|
||||
border-width: 3px;
|
||||
border-color: var(--blue);
|
||||
}
|
||||
|
||||
/* fix visible scrollbars when OSX is set to show them */
|
||||
.gh-editor .CodeMirror-scroll {
|
||||
.gh-markdown-editor .CodeMirror-scroll {
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror-scroll:hover {
|
||||
.gh-markdown-editor .CodeMirror-scroll:hover {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
@ -478,7 +478,7 @@
|
||||
}
|
||||
|
||||
.gh-editor .gh-editor-title,
|
||||
.gh-editor .CodeMirror-wrap {
|
||||
.gh-markdown-editor .CodeMirror-wrap {
|
||||
max-width: 760px;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
@ -486,7 +486,7 @@
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror-wrap > div > textarea {
|
||||
.gh-markdown-editor .CodeMirror-wrap > div > textarea {
|
||||
top: 0;
|
||||
height: 26px;
|
||||
min-height: 26px;
|
||||
@ -494,7 +494,7 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror pre {
|
||||
.gh-markdown-editor .CodeMirror pre {
|
||||
padding: 0;
|
||||
color: color(var(--darkgrey) l(+5%));
|
||||
font-family: "Consolas", monaco, monospace;
|
||||
@ -502,16 +502,16 @@
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.gh-editor .CodeMirror pre {
|
||||
.gh-markdown-editor .CodeMirror pre {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror .cm-strong {
|
||||
.gh-markdown-editor .CodeMirror .cm-strong {
|
||||
color: var(--darkgrey);
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror .cm-url {
|
||||
.gh-markdown-editor .CodeMirror .cm-url {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@ -654,7 +654,7 @@
|
||||
border-color: color(var(--lightgrey) l(-5%));
|
||||
}
|
||||
|
||||
.gh-editor .CodeMirror .CodeMirror-selectedtext {
|
||||
.gh-markdown-editor .CodeMirror .CodeMirror-selectedtext {
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../templates/components/koenig-card-html';
|
||||
import {set} from '@ember/object';
|
||||
|
||||
export default Component.extend({
|
||||
tagName: '',
|
||||
layout,
|
||||
|
||||
payload: null,
|
||||
saveCard: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (!this.get('payload.html')) {
|
||||
this.set('payload.html', '');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
updateHtml(html) {
|
||||
let payload = this.get('payload');
|
||||
let save = this.get('saveCard');
|
||||
|
||||
set(payload, 'html', html);
|
||||
|
||||
// update the mobiledoc and stay in edit mode
|
||||
save(payload, false);
|
||||
}
|
||||
}
|
||||
});
|
@ -45,7 +45,8 @@ export const CARD_COMPONENT_MAP = {
|
||||
hr: 'koenig-card-hr',
|
||||
image: 'koenig-card-image',
|
||||
markdown: 'koenig-card-markdown',
|
||||
'card-markdown': 'koenig-card-markdown' // backwards-compat with markdown editor
|
||||
'card-markdown': 'koenig-card-markdown', // backwards-compat with markdown editor
|
||||
html: 'koenig-card-html'
|
||||
};
|
||||
|
||||
function arrayToMap(array) {
|
||||
|
@ -4,5 +4,6 @@ export default [
|
||||
createComponentCard('hr'),
|
||||
createComponentCard('image'),
|
||||
createComponentCard('markdown'),
|
||||
createComponentCard('card-markdown') // backwards-compat with markdown editor
|
||||
createComponentCard('card-markdown'), // backwards-compat with markdown editor
|
||||
createComponentCard('html')
|
||||
];
|
||||
|
@ -0,0 +1,4 @@
|
||||
{{gh-cm-editor payload.html
|
||||
class="koenig-card-html--editor"
|
||||
update=(action "updateHtml")
|
||||
}}
|
@ -23,7 +23,7 @@
|
||||
<div class="koenig-cardmenu-icon">{{inline-svg "koenig/image"}}</div>
|
||||
<div class="koenig-cardmenu-label">Image</div>
|
||||
</div>
|
||||
<div class="koenig-cardmenu-card">
|
||||
<div class="koenig-cardmenu-card" {{action "replaceWithCardSection" "html" on="click"}}>
|
||||
<div class="koenig-cardmenu-icon">{{inline-svg "koenig/embed"}}</div>
|
||||
<div class="koenig-cardmenu-label">Embed</div>
|
||||
</div>
|
||||
|
@ -0,0 +1 @@
|
||||
export {default} from 'koenig-editor/components/koenig-card-html';
|
@ -0,0 +1,24 @@
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import {describe, it} from 'mocha';
|
||||
import {expect} from 'chai';
|
||||
import {setupComponentTest} from 'ember-mocha';
|
||||
|
||||
describe('Integration: Component: koenig-card-html', function () {
|
||||
setupComponentTest('koenig-card-html', {
|
||||
integration: true
|
||||
});
|
||||
|
||||
it.skip('renders', function () {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||
// Template block usage:
|
||||
// this.render(hbs`
|
||||
// {{#koenig-card-html}}
|
||||
// template content
|
||||
// {{/koenig-card-html}}
|
||||
// `);
|
||||
|
||||
this.render(hbs`{{koenig-card-html}}`);
|
||||
expect(this.$()).to.have.length(1);
|
||||
});
|
||||
});
|
@ -8,7 +8,7 @@ describe('Integration: Component: koenig-slash-menu', function () {
|
||||
integration: true
|
||||
});
|
||||
|
||||
it('renders', function () {
|
||||
it.skip('renders', function () {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||
// Template block usage:
|
||||
|
Loading…
Reference in New Issue
Block a user