Refresh the editors if necessary and when switching tab to ensure visibility of its content

This commit is contained in:
Djamil Legato
2016-03-16 19:14:02 -07:00
parent 265ad69edc
commit 914a331cad
2 changed files with 11 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import $ from 'jquery';
import Cookies from 'cookies-js';
import { Instance as Editors } from '../forms/fields/editor';
let Data = JSON.parse(Cookies.get('grav-tabs-state') || '{}');
@@ -9,4 +10,12 @@ $('body').on('touchstart click', '[name^="tab-"]', (event) => {
Data[target.attr('name')] = target.val();
Cookies.set('grav-tabs-state', JSON.stringify(Data), { expires: Infinity });
Editors.editors.each((index, editor) => {
let codemirror = $(editor).data('codemirror');
if (!codemirror) { return; }
if (codemirror.display.lastWrapWidth === 0) {
codemirror.refresh();
}
});
});

File diff suppressed because one or more lines are too long