Skip to content

Commit

Permalink
fix: #267 init html
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Mar 20, 2020
1 parent f992477 commit 94e6d05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
39 changes: 15 additions & 24 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
},

/**
Expand Down
4 changes: 2 additions & 2 deletions test/dev/suneditor_build_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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();
Expand Down

0 comments on commit 94e6d05

Please sign in to comment.