diff --git a/ghost/admin/.lint-todo b/ghost/admin/.lint-todo index ba4717f089..6f5796a5f1 100644 --- a/ghost/admin/.lint-todo +++ b/ghost/admin/.lint-todo @@ -1249,3 +1249,13 @@ remove|ember-template-lint|no-duplicate-landmark-elements|353|28|353|28|38d3be08 remove|ember-template-lint|no-duplicate-landmark-elements|421|28|421|28|345501bb9545198904b82e4c073b11d792ae2ea6|1652054400000|1662422400000|1665014400000|app/components/gh-post-settings-menu.hbs add|ember-template-lint|no-action|6|77|6|77|76726a13a086d82dab219df12e86db1773a9de32|1657756800000|1668128400000|1673312400000|app/components/gh-file-uploader.hbs remove|ember-template-lint|no-action|12|92|12|92|031d04576149d3034549aa3d14bc26da704cd70c|1652054400000|1662422400000|1665014400000|app/components/gh-file-uploader.hbs +remove|ember-template-lint|no-action|9|16|9|16|822c6a91d06436c87443aba1c5316874b4de7e93|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|10|18|10|18|40a9eaaf8ee3a30448bd8f5c51e4f57ad6f637cb|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|11|14|11|14|45b936fe4ae520e86dc577dced7e4de626004fba|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|12|14|12|14|c27072dba50f6e36c62d708160adb2e96b8244e3|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|14|17|14|17|2ecb8ec2db47e693d292cac348977b4c83e5b0a4|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|15|17|15|17|b562d5c8ffc834037fff995329aa4cd49218776b|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|28|20|28|20|b96b7bd3d4b17c4761201d3a44c6876b119611f9|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|34|19|34|19|bb54609cede4c2f20ae22de5cbc2771d396aaaf4|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|no-action|55|20|55|20|ee695277e2f7dac9fbe5570ebfbe9c738280a976|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs +remove|ember-template-lint|require-input-label|31|8|31|8|615e3b52bcc28f911cc3b8e3630bd77324e357a6|1652054400000|1662422400000|1665014400000|lib/koenig-editor/addon/components/koenig-card-code.hbs diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.hbs b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.hbs index 8efba63736..2a83703264 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.hbs +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.hbs @@ -1,36 +1,37 @@ - {{#if this.isEditing}} - {{else}}
-
{{this.escapedCode}}
+
{{this.escapedCode}}
- {{#if this.payload.language}} + {{#if @payload.language}}
- {{this.payload.language}} + {{@payload.language}}
{{/if}}
{{/if}} - {{#if (and (not this.isEditing) (or this.isSelected (clean-basic-html this.payload.caption)))}} + {{#if (and (not @isEditing) (or @isSelected (clean-basic-html @payload.caption)))}} {{/if}} diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.js index 96677af177..f734a47bcc 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-code.js @@ -1,11 +1,11 @@ -import Component from '@ember/component'; +import Component from '@glimmer/component'; import Ember from 'ember'; -import classic from 'ember-classic-decorator'; -import {action, computed, set} from '@ember/object'; +import {action} from '@ember/object'; import {utils as ghostHelperUtils} from '@tryghost/helpers'; import {htmlSafe} from '@ember/template'; import {isBlank} from '@ember/utils'; import {run} from '@ember/runloop'; +import {tracked} from '@glimmer/tracking'; const {Handlebars} = Ember; const {countWords} = ghostHelperUtils; @@ -17,39 +17,19 @@ const CM_MODE_MAP = { js: 'javascript' }; -@classic export default class KoenigCardCode extends Component { - // attrs - payload = null; - isSelected = false; - isEditing = false; - headerOffset = 0; - showLanguageInput = true; + @tracked showLanguageInput = true; - // closure actions - editCard() {} - saveCard() {} - selectCard() {} - deselectCard() {} - deleteCard() {} - registerComponent() {} - moveCursorToNextSection() {} - moveCursorToPrevSection() {} - addParagraphAfterCard() {} - - @computed('payload.code') get isEmpty() { - return isBlank(this.payload.code); + return isBlank(this.args.payload.code); } - @computed('payload.code') get counts() { - return {wordCount: countWords(this.payload.code)}; + return {wordCount: countWords(this.args.payload.code)}; } - @computed('isEditing') get toolbar() { - if (this.isEditing) { + if (this.args.isEditing) { return false; } @@ -60,30 +40,26 @@ export default class KoenigCardCode extends Component { iconClass: 'fill-white', title: 'Edit', text: '', - action: run.bind(this, this.editCard) + action: this.args.editCard }] }; } - @computed('payload.code') get escapedCode() { - let escapedCode = Handlebars.Utils.escapeExpression(this.payload.code); + let escapedCode = Handlebars.Utils.escapeExpression(this.args.payload.code); return htmlSafe(escapedCode); } - @computed('payload.language') get cmMode() { - let {language} = this.payload; + let {language} = this.args.payload; return CM_MODE_MAP[language] || language; } - @computed('isEditing') get cardStyle() { - let style = this.isEditing ? 'background-color: #f4f8fb; border-color: #f4f8fb' : ''; + let style = this.args.isEditing ? 'background-color: #f4f8fb; border-color: #f4f8fb' : ''; return htmlSafe(style); } - @computed('showLanguageInput') get languageInputStyle() { let styles = ['top: 6px', 'right: 6px']; if (!this.showLanguageInput) { @@ -92,18 +68,18 @@ export default class KoenigCardCode extends Component { return htmlSafe(styles.join('; ')); } - init() { - super.init(...arguments); - let payload = this.payload || {}; + constructor() { + super(...arguments); + let payload = this.args.payload || {}; // CodeMirror errors on a `null` or `undefined` value if (!payload.code) { - set(payload, 'code', ''); + payload.code = ''; } - this.set('payload', payload); + this.payload = payload; - this.registerComponent(this); + this.args.registerComponent(this); } @action @@ -134,26 +110,26 @@ export default class KoenigCardCode extends Component { if (this.isEmpty) { // afterRender is required to avoid double modification of `isSelected` // TODO: see if there's a way to avoid afterRender - run.scheduleOnce('afterRender', this, this.deleteCard); + run.scheduleOnce('afterRender', this, this.args.deleteCard); } } _updatePayloadAttr(attr, value) { - let payload = this.payload; - let save = this.saveCard; + let payload = this.args.payload; + let save = this.args.saveCard; - set(payload, attr, value); + payload[attr] = value; // update the mobiledoc and stay in edit mode save(payload, false); } _hideLanguageInput() { - this.set('showLanguageInput', false); + this.showLanguageInput = false; } _showLanguageInput() { - this.set('showLanguageInput', true); + this.showLanguageInput = true; } _addMousemoveHandler() {