mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Allowed custom default tag for html input component
no refs - allows custom html tag to be passed in to basic html input component - updates accordion heading input to use basic html input with h4 tag
This commit is contained in:
parent
697420957c
commit
d3cfa14498
3 changed files with 16 additions and 3 deletions
|
@ -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 '';
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue