Skip to content

Commit

Permalink
fix: #853
Browse files Browse the repository at this point in the history
fullScreen codeview unscrollable when height auto
  • Loading branch information
JiHong88 committed Dec 18, 2021
1 parent 81509d8 commit 26cf566
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4387,7 +4387,9 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
this._variable._codeOriginCssText = this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/, 'display: block');
this._variable._wysiwygOriginCssText = this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/, 'display: none');

if (options.height === 'auto' && !options.codeMirrorEditor) context.element.code.style.height = context.element.code.scrollHeight > 0 ? (context.element.code.scrollHeight + 'px') : 'auto';
if (this._variable.isFullScreen) context.element.code.style.height = '100%';
else if (options.height === 'auto' && !options.codeMirrorEditor) context.element.code.style.height = context.element.code.scrollHeight > 0 ? (context.element.code.scrollHeight + 'px') : 'auto';

if (options.codeMirrorEditor) options.codeMirrorEditor.refresh();

this._variable.isCodeView = true;
Expand Down Expand Up @@ -4556,6 +4558,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
topArea.style.cssText = _var._originCssText;
_d.body.style.overflow = _var._bodyOverflow;

if (options.height === 'auto' && !options.codeMirrorEditor) event._codeViewAutoHeight();

if (!!options.toolbarContainer) options.toolbarContainer.appendChild(toolbar);

if (options.stickyToolbar > -1) {
Expand Down Expand Up @@ -7248,6 +7252,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
},

_codeViewAutoHeight: function () {
if (core._variable.isFullScreen) return;
context.element.code.style.height = context.element.code.scrollHeight + 'px';
},

Expand Down
10 changes: 8 additions & 2 deletions test/dev/suneditor_build_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,13 @@ let ss = window.ss = suneditor.create(document.getElementById('editor1'), {
// `,
lineAttrReset: '*',
alignItems: ['left', 'right', 'center'],
value: "ss",
value: `<p>ss&nbsp; fdf fdsfa fds</p>
<p>a fdsa fdsa fdas</p>
<p>&nbsp;dsa fdsa fdsa fdsa<br>
</p>
`,
linkTargetNewWindow: true,
imageAlignShow: false,
plugins: {...{custom_container}, ...plugins},
Expand Down Expand Up @@ -491,7 +497,7 @@ let ss = window.ss = suneditor.create(document.getElementById('editor1'), {
// audioAccept: ".mp3",
display: 'block',
width: '100%',
height: '500px',
height: 'auto',
// audioTagAttrs: {
// controlslist: "nodownload",
// },
Expand Down

0 comments on commit 26cf566

Please sign in to comment.