diff --git a/src/components/Editor/Article/FloatingMenu/styles.module.css b/src/components/Editor/Article/FloatingMenu/styles.module.css index 3f5ee52aba..8e9d8c9172 100644 --- a/src/components/Editor/Article/FloatingMenu/styles.module.css +++ b/src/components/Editor/Article/FloatingMenu/styles.module.css @@ -1,6 +1,6 @@ .container { position: absolute; - top: calc(2rem / 2 * -1); + top: calc(2rem / 2 * -1 - 1px); /* 2rem is icon size, 1px for offset */ left: 0; display: flex; align-items: center; diff --git a/src/components/Editor/Article/index.tsx b/src/components/Editor/Article/index.tsx index 4f1373fcb7..781057dc1e 100644 --- a/src/components/Editor/Article/index.tsx +++ b/src/components/Editor/Article/index.tsx @@ -1,6 +1,5 @@ import { useApolloClient } from '@apollo/react-hooks' import { EditorContent, useArticleEdtor } from '@matters/matters-editor' -import classNames from 'classnames' import { useIntl } from 'react-intl' import { useDebouncedCallback } from 'use-debounce' @@ -57,6 +56,13 @@ export const ArticleEditor: React.FC = ({ const content = editor.getHTML() debouncedUpdate({ content }) }, + // toggle body class + onFocus: () => { + document.body.classList.add('editor-focused') + }, + onBlur: () => { + document.body.classList.remove('editor-focused') + }, mentionSuggestion: makeMentionSuggestion({ client }), extensions: [ FigureEmbedLinkInput, @@ -74,9 +80,7 @@ export const ArticleEditor: React.FC = ({ return (
diff --git a/src/components/Editor/Article/styles.module.css b/src/components/Editor/Article/styles.module.css index 8148ade6df..bdf3cf3210 100644 --- a/src/components/Editor/Article/styles.module.css +++ b/src/components/Editor/Article/styles.module.css @@ -1,8 +1,15 @@ .articleEditor { position: relative; - padding-bottom: 4rem; /* bottom bar height */ + height: calc( + 100vh - 3rem -4rem - var(--sp16) * 2 + ); /* 3rem for header, 4rem for bottom bar */ + + height: calc(var(--vvh) * 100 - 3rem -4rem - var(--sp16) * 2); + overflow-x: hidden; + overflow-y: auto; @media (--lg-up) { + height: auto; padding-bottom: 0; } @@ -10,11 +17,6 @@ & :global(.tiptap) { min-height: 50vh; min-height: calc(var(--vvh) * 50); - margin-bottom: var(var(--global-nav-height)); - - @media (--lg-up) { - margin-bottom: 0; - } /* outline */ &:focus { @@ -94,3 +96,14 @@ } } } + +:global(body.editor-focused) { + & .articleEditor { + height: calc(100vh - 3rem - var(--sp16) * 2); /* 3rem for header */ + height: calc(var(--vvh) * 100 - 3rem - var(--sp16) * 2); + + @media (--lg-up) { + height: auto; + } + } +} diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 27c9a86808..6cb6752244 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -84,7 +84,7 @@ const Main: React.FC> & { [styles.hasNavBar]: !isInArticleDetail && !isInDraftDetail, }) - const enbableSticky = !isInArticleDetailHistory && !isInEditor + const enbableSticky = !isInArticleDetailHistory usePullToRefresh.Register('#ptr') usePullToRefresh.Handler(() => window.location.reload()) diff --git a/src/components/Layout/styles.module.css b/src/components/Layout/styles.module.css index 59ee565d89..94c05e7534 100644 --- a/src/components/Layout/styles.module.css +++ b/src/components/Layout/styles.module.css @@ -54,10 +54,15 @@ .article { position: relative; grid-column: content; - min-height: calc(100vh + 1px); + min-height: 100vh; + min-height: calc(var(--vvh) * 100); @media (--sm-up) { grid-column: content; + + /* FIXME: page scrollbar is showed on open dialog */ + min-height: calc(100vh + 1px); + min-height: calc(var(--vvh) * 100 + 1px); padding-bottom: 0; }