From 94e6d05953f5f79a97e4e062ad7e081459ee608e Mon Sep 17 00:00:00 2001 From: JiHong88 <0125ses@hanmail.net> Date: Fri, 20 Mar 2020 18:42:26 +0900 Subject: [PATCH] fix: #267 init html --- src/lib/core.js | 39 ++++++++++++-------------------- test/dev/suneditor_build_test.js | 4 ++-- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/lib/core.js b/src/lib/core.js index 1427426fa..05dd1b031 100755 --- a/src/lib/core.js +++ b/src/lib/core.js @@ -4052,30 +4052,10 @@ export default function (context, pluginCallButtons, plugins, lang, options) { */ _init: function (reload, _initHTML) { this._ww = options.iframe ? context.element.wysiwygFrame.contentWindow : _w; - this._wd = _d; - - _w.setTimeout(function () { - if (options.iframe) { - this._wd = context.element.wysiwygFrame.contentDocument; - context.element.wysiwyg = this._wd.body; - if (options.height === 'auto') { - this._iframeAuto = this._wd.body; - } - } - - this._initWysiwygArea(reload, _initHTML); - - this._checkComponents(); - this._imagesInfoInit = false; - this._imagesInfoReset = false; - - this.history.reset(true); - this._iframeAutoHeight(); - this._checkPlaceholder(); - - if (reload) this.focus(); - if (typeof functions.onload === 'function') return functions.onload(core, reload); - }.bind(this)); + this._wd = options.iframe ? context.element.wysiwygFrame.contentDocument : _d; + if (options.iframe && options.height === 'auto') this._iframeAuto = this._wd.body; + + this._initWysiwygArea(reload, _initHTML); this.editorTagsWhitelistRegExp = util.createTagsWhitelist(options._editorTagsWhitelist); this.pasteTagsWhitelistRegExp = util.createTagsWhitelist(options.pasteTagsWhitelist); @@ -4130,6 +4110,17 @@ export default function (context, pluginCallButtons, plugins, lang, options) { // Excute history function this.history = _history(this, event._onChange_historyStack); + + // Init, validate + this._checkComponents(); + this._imagesInfoInit = false; + this._imagesInfoReset = false; + + this.history.reset(true); + this._iframeAutoHeight(); + this._checkPlaceholder(); + + if (typeof functions.onload === 'function') return functions.onload(core, reload); }, /** diff --git a/test/dev/suneditor_build_test.js b/test/dev/suneditor_build_test.js index 072a5d196..c478bf40c 100644 --- a/test/dev/suneditor_build_test.js +++ b/test/dev/suneditor_build_test.js @@ -165,7 +165,7 @@ let ss = window.ss = suneditor.create(document.getElementById('editor1'), { width: '100%', youtubeQuery :'autoplay=1&mute=1&enablejsapi=1', placeholder: 'SSSFdjskfdsff.f.fdsa.f...', - // fullPage: true, + fullPage: true, addTagsWhitelist: 'mark|canvas|label|select|option|input|nav|button', imageUploadUrl: 'http://localhost:3000/files/upload', attributesWhitelist: { @@ -192,7 +192,7 @@ let ss = window.ss = suneditor.create(document.getElementById('editor1'), { // videoResizing: false, // videoSizeOnlyPercentage: true }); - +// ss.setContents('fsafsa') ss.onload = function (core) { console.log('onload', core); core.focus();