diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-basic-html-input.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-basic-html-input.js index 1122cca02f..e4f1c5ee2f 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-basic-html-input.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-basic-html-input.js @@ -4,8 +4,8 @@ import cleanBasicHtml from '@tryghost/kg-clean-basic-html'; import parserPlugins from '../options/basic-html-parser-plugins'; import registerKeyCommands, {BASIC_KEY_COMMANDS} from '../options/key-commands'; import validator from 'validator'; -import {BLANK_DOC, MOBILEDOC_VERSION} from './koenig-editor'; import {DRAG_DISABLED_DATA_ATTR} from '../lib/dnd/constants'; +import {MOBILEDOC_VERSION, getBlankMobileDoc} from './koenig-editor'; import {arrayToMap, toggleSpecialFormatEditState} from './koenig-editor'; import {assign} from '@ember/polyfills'; import {computed} from '@ember/object'; @@ -24,6 +24,7 @@ export default Component.extend({ html: null, placeholder: '', spellcheck: true, + defaultTag: 'p', // internal properties activeMarkupTagNames: null, @@ -94,7 +95,7 @@ export default Component.extend({ let mobiledoc = this.mobiledoc; if (!mobiledoc && !this.cleanHTML) { - mobiledoc = BLANK_DOC; + mobiledoc = getBlankMobileDoc(this.defaultTag); } let mobiledocIsSame = @@ -441,7 +442,7 @@ export default Component.extend({ // inline markup that directly maps to HTML elements _getHTML() { if (this.editor && this.editor.element) { - let firstParagraph = this.editor.element.querySelector('p'); + let firstParagraph = this.editor.element.querySelector(this.defaultTag); if (!firstParagraph) { return ''; diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-accordion.hbs b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-accordion.hbs index b7cd86a3da..60c1d3b65f 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-accordion.hbs +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-accordion.hbs @@ -30,6 +30,7 @@ @placeholder="Add your heading here..." @class="w-100 fw4 bn bg-transparent kg-accordion-card-heading" @name="toggle-heading" + @defaultTag="h4" @onChange={{action "setHeadingText"}} @onFocus={{action (mut this.isFocused) true}} @onBlur={{action (mut this.isFocused) false}} diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js index fba4d9393e..4c0e214780 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js @@ -74,6 +74,17 @@ export const SPECIAL_MARKUPS = { SUB: '~' }; +export function getBlankMobileDoc(defaultTag = 'p') { + return { + ...BLANK_DOC, + sections: [ + [1, defaultTag, [ + [0, [], 0, ''] + ]] + ] + }; +} + export function arrayToMap(array) { let map = Object.create(null); array.forEach((key) => {