Release v2.6.19
This commit is contained in:
@@ -72,6 +72,18 @@ export function createSlideFormEditorController(options) {
|
||||
return window.tinymce || null;
|
||||
}
|
||||
|
||||
function getEditorContentSafely(editor, fallbackValue) {
|
||||
if (!editor || typeof editor.getContent !== 'function') {
|
||||
return String(fallbackValue || '');
|
||||
}
|
||||
|
||||
try {
|
||||
return String(editor.getContent({ format: 'html' }));
|
||||
} catch (_error) {
|
||||
return String(fallbackValue || '');
|
||||
}
|
||||
}
|
||||
|
||||
function getThemeName() {
|
||||
var theme = String(document.documentElement && document.documentElement.dataset && document.documentElement.dataset.bsTheme || 'light').trim().toLowerCase();
|
||||
if (theme === 'auto') {
|
||||
@@ -95,14 +107,19 @@ export function createSlideFormEditorController(options) {
|
||||
}
|
||||
|
||||
function syncEditorState(regionId, editor, shouldLock, hydrated) {
|
||||
var hidden = getEditorHiddenInput(regionId);
|
||||
var sourceElm = editor && editor.targetElm ? editor.targetElm : null;
|
||||
var fallbackContent = hidden && hidden.value !== undefined ? hidden.value : (sourceElm && sourceElm.value !== undefined ? sourceElm.value : '');
|
||||
|
||||
if (editor && typeof editor.save === 'function') {
|
||||
if (typeof editor.blur === 'function') {
|
||||
editor.blur();
|
||||
}
|
||||
editor.save();
|
||||
}
|
||||
|
||||
var content = editor.getContent({ format: 'html' });
|
||||
var content = sourceElm && sourceElm.value !== undefined ? String(sourceElm.value || '') : getEditorContentSafely(editor, fallbackContent);
|
||||
content = isEmptyRichTextValue(content) ? '' : content;
|
||||
var hidden = getEditorHiddenInput(regionId);
|
||||
var sourceElm = editor && editor.targetElm ? editor.targetElm : null;
|
||||
|
||||
if (hidden) {
|
||||
hidden.value = content;
|
||||
@@ -211,7 +228,7 @@ export function createSlideFormEditorController(options) {
|
||||
}
|
||||
|
||||
editor.on('init', function () {
|
||||
var content = editor.getContent({ format: 'html' });
|
||||
var content = getEditorContentSafely(editor, hidden && hidden.value !== undefined ? hidden.value : (source && source.value !== undefined ? source.value : ''));
|
||||
content = isEmptyRichTextValue(content) ? '' : content;
|
||||
if (hidden) {
|
||||
hidden.value = content;
|
||||
@@ -405,14 +422,12 @@ export function createSlideFormEditorController(options) {
|
||||
var saves = Array.prototype.map.call(templateFields.querySelectorAll('.editor-holder'), function (holder) {
|
||||
var regionId = holder.getAttribute('data-region-id');
|
||||
var editor = editorInstances.get(regionId);
|
||||
var hidden = getEditorHiddenInput(regionId);
|
||||
|
||||
if (!editor || !hidden) {
|
||||
if (!editor) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
hidden.value = editor.getContent({ format: 'html' });
|
||||
syncEditorFontSizeHidden(regionId);
|
||||
syncEditorState(regionId, editor, false, true);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user