Fix HTML editor not showing content initially (#2181)

* Fix HTML editor not showing initially

* Remove line numbers from PlainTextInput
This commit is contained in:
Matthias Metelka 2022-11-05 01:58:04 +01:00 committed by GitHub
parent c60a1c8ebd
commit 03fe2385ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View file

@ -11,7 +11,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let toggleDisplay = false;
export let animated = !document.body.classList.contains("reduced-motion");
let collapsed = false;
let contentHeight = 0;
function dynamicDuration(height: number): number {
@ -56,6 +55,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: height = $size * contentHeight;
$: transitioning = $size > 0 && !(collapsed || expanded);
$: measuring = !(collapsed || transitioning || expanded);
let hidden = collapsed;
$: {
/* await changes dependent on collapsed state */
tick().then(() => (hidden = collapsed));
}
</script>
<div
@ -64,9 +70,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
class:animated
class:expanded
class:full-hide={toggleDisplay}
class:collapsed={!expanded}
class:measuring
class:transitioning
class:hidden
style:--height="{height}px"
>
<slot {collapsed} />
@ -80,7 +86,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<style lang="scss">
.collapsible.animated {
&.measuring {
display: unset;
display: initial;
position: absolute;
opacity: 0;
}
@ -94,7 +100,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
&.full-hide {
&.collapsed {
&.hidden {
display: none;
}
&.transitioning {

View file

@ -34,6 +34,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
const defaultConfiguration = {
rtlMoveVisually: true,
lineNumbers: false,
};
const [editorPromise, resolve] = promiseWithResolver<CodeMirrorLib.Editor>();

View file

@ -164,10 +164,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
:global(.CodeMirror) {
height: 100%;
background: var(--canvas-code);
padding-inline: 4px;
}
:global(.CodeMirror-lines) {
padding: 8px 0;
}
:global(.CodeMirror-gutters) {
background: var(--canvas-code);
}
}
</style>