mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
Fixed mobiledoc-kit automatically upgrading document version
refs 6f5c2a9557
- we previously set a fixed mobiledoc spec version in blank documents but when the editor was serializing to a json string after editing it was bumping the spec version
- makes the specific version a constant to be used when serializing any mobiledoc
This commit is contained in:
parent
4afa33e936
commit
e5acb34a81
@ -5,6 +5,7 @@ import layout from '../templates/components/koenig-basic-html-input';
|
||||
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 {arrayToMap, toggleSpecialFormatEditState} from './koenig-editor';
|
||||
import {assign} from '@ember/polyfills';
|
||||
@ -16,20 +17,6 @@ import {run} from '@ember/runloop';
|
||||
|
||||
const UNDO_DEPTH = 50;
|
||||
|
||||
// blank doc contains a single empty paragraph so that there's some content for
|
||||
// the cursor to start in
|
||||
const BLANK_DOC = {
|
||||
version: '0.3.1',
|
||||
markups: [],
|
||||
atoms: [],
|
||||
cards: [],
|
||||
sections: [
|
||||
[1, 'p', [
|
||||
[0, [], 0, '']
|
||||
]]
|
||||
]
|
||||
};
|
||||
|
||||
// TODO: extract core to share functionality between this and `{{koenig-editor}}`
|
||||
|
||||
export default Component.extend({
|
||||
@ -201,7 +188,7 @@ export default Component.extend({
|
||||
// update mobiledoc reference to match initial editor state from parsed
|
||||
// html. We use this value to compare on re-renders in case we need to
|
||||
// re-parse from html
|
||||
this.mobiledoc = editor.serialize();
|
||||
this.mobiledoc = editor.serialize(MOBILEDOC_VERSION);
|
||||
this._lastMobiledoc = this.mobiledoc;
|
||||
|
||||
this.set('editor', editor);
|
||||
|
@ -43,8 +43,9 @@ export const TESTING_EXPANDO_PROPERTY = '__mobiledoc_kit_editor';
|
||||
|
||||
// blank doc contains a single empty paragraph so that there's some content for
|
||||
// the cursor to start in
|
||||
export const MOBILEDOC_VERSION = '0.3.1';
|
||||
export const BLANK_DOC = {
|
||||
version: '0.3.1',
|
||||
version: MOBILEDOC_VERSION,
|
||||
markups: [],
|
||||
atoms: [],
|
||||
cards: [],
|
||||
@ -683,8 +684,7 @@ export default Component.extend({
|
||||
/* mobiledoc event handlers --------------------------------------------- */
|
||||
|
||||
postDidChange(editor) {
|
||||
let serializeVersion = this.serializeVersion;
|
||||
let updatedMobiledoc = editor.serialize(serializeVersion);
|
||||
let updatedMobiledoc = editor.serialize(MOBILEDOC_VERSION);
|
||||
this._localMobiledoc = updatedMobiledoc;
|
||||
|
||||
// trigger closure action
|
||||
|
@ -5,6 +5,7 @@ import defaultAtoms from '../options/atoms';
|
||||
import layout from '../templates/components/koenig-text-replacement-html-input';
|
||||
import registerKeyCommands, {TEXT_REPLACEMENT_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 {arrayToMap, toggleSpecialFormatEditState} from './koenig-editor';
|
||||
import {assign} from '@ember/polyfills';
|
||||
@ -18,20 +19,6 @@ import {run} from '@ember/runloop';
|
||||
|
||||
const UNDO_DEPTH = 50;
|
||||
|
||||
// blank doc contains a single empty paragraph so that there's some content for
|
||||
// the cursor to start in
|
||||
const BLANK_DOC = {
|
||||
version: '0.3.1',
|
||||
markups: [],
|
||||
atoms: [],
|
||||
cards: [],
|
||||
sections: [
|
||||
[1, 'p', [
|
||||
[0, [], 0, '']
|
||||
]]
|
||||
]
|
||||
};
|
||||
|
||||
// markups that should not be continued when typing and reverted to their
|
||||
// text expansion style when backspacing over final char of markup
|
||||
export const SPECIAL_MARKUPS = {
|
||||
@ -208,7 +195,7 @@ export default Component.extend({
|
||||
// update mobiledoc reference to match initial editor state from parsed
|
||||
// html. We use this value to compare on re-renders in case we need to
|
||||
// re-parse from html
|
||||
this.mobiledoc = editor.serialize();
|
||||
this.mobiledoc = editor.serialize(MOBILEDOC_VERSION);
|
||||
this._lastMobiledoc = this.mobiledoc;
|
||||
|
||||
this.set('editor', editor);
|
||||
|
Loading…
Reference in New Issue
Block a user